From patchwork Wed Jan 6 08:53:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 59225 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp6449650lbb; Wed, 6 Jan 2016 00:54:20 -0800 (PST) X-Received: by 10.98.19.82 with SMTP id b79mr97053727pfj.28.1452070460203; Wed, 06 Jan 2016 00:54:20 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u75si32425577pfa.108.2016.01.06.00.54.19; Wed, 06 Jan 2016 00:54:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752420AbcAFIyR (ORCPT + 29 others); Wed, 6 Jan 2016 03:54:17 -0500 Received: from mail-pf0-f180.google.com ([209.85.192.180]:35938 "EHLO mail-pf0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752365AbcAFIyL (ORCPT ); Wed, 6 Jan 2016 03:54:11 -0500 Received: by mail-pf0-f180.google.com with SMTP id 65so190446206pff.3 for ; Wed, 06 Jan 2016 00:54:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=q0D8XFRH8BA5s5lmmujTMP3Z6o3Smq+mtmDC75QSvkw=; b=OGlmCm6CQnR4Z5rL1D7U+DzVQO5z1Rke9+zLvPWnel8KcvwSb5npj+sX3T07uLpZ9E CyFxuLwdVFtkTR0Sg6WEv0xG71sH+jVyTVHK7sCK4Hn7J0nnnJnaXssfx6rdxQC+hOQk emQmhKCeDvxJwsDwqNYv8sK/vE9acIU9cR5/0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=q0D8XFRH8BA5s5lmmujTMP3Z6o3Smq+mtmDC75QSvkw=; b=VKHe0lCdATPK1ALKhfIKGQVHJh8GQSjRZQPpDxn+2LG6rQ/bdMRk/60hqgKvOoXJd5 tl64a3Ecys9ZEsw9Z5Iw/LFsrOrBeVtl9RHXdrM3J9Qg9GNGqqGlZ4swM8UWK6DcxdnZ QzH8w0dL/owDM02ai+detoSqiFIqrFpvvBOdlipeLJ8tTauOpk6X/Z7oymh+oX04aF1b gK2j822MBp7aO4puOqPNKM+NwKFdj2FsnBHj1ZfGCqSROkFcyhFadAXB9gZwRMaI+QSu 24uCoxP1ZqU62JFT4frWoigS3dMA0ME9R8a+atYiaWkH4EUPl2irX6zv1XByO4BUS/WJ ydsw== X-Gm-Message-State: ALoCoQnGniJ4A+H3fxjzdOwlqIIvYJtXcRDgSfg/cvOKoHZLHSCgNw1ZY1LEFJ3gNryx/HzZ6LHHyOotN3BtNQcJK5eMSmrK4w== X-Received: by 10.98.18.1 with SMTP id a1mr14667273pfj.7.1452070451115; Wed, 06 Jan 2016 00:54:11 -0800 (PST) Received: from localhost.localdomain (v17.blockcn.net. [192.241.236.26]) by smtp.gmail.com with ESMTPSA id ux2sm138843233pac.46.2016.01.06.00.54.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Jan 2016 00:54:09 -0800 (PST) From: Leo Yan To: Jonathan Corbet , Zhang Rui , Eduardo Valentin , Javi Merino , Punit Agrawal , Daniel Kurtz , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Daniel Thompson Cc: Leo Yan Subject: [PATCH v3 1/4] thermal: power_allocator: rework proportional parameter Date: Wed, 6 Jan 2016 16:53:45 +0800 Message-Id: <1452070428-2567-2-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1452070428-2567-1-git-send-email-leo.yan@linaro.org> References: <1452070428-2567-1-git-send-email-leo.yan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org k_po/k_pu are two proportional term constants and essentially they have fixed ratio compared with sustainable power. In current implementation, k_po and k_pu are absolute value after calculation and cannot represent the ratio relationship with sustainable power; as a result, when change sustainable power we cannot smoothly change proportional term constant. So this patch introduces variants k_po_ratio and k_pu_ratio, which represent the ratio value compared against sustainable power, so smaller ratio will result in thermal slower ramp. The formulas finally are as below: k_pu = k_pu_ratio * sustainable_power / (desired_temperature - switch_on_temp) k_po = k_po_ratio * sustainable_power / (desired_temperature - switch_on_temp) Signed-off-by: Leo Yan --- drivers/thermal/power_allocator.c | 18 ++++++++++++------ include/linux/thermal.h | 4 ++-- 2 files changed, 14 insertions(+), 8 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/drivers/thermal/power_allocator.c b/drivers/thermal/power_allocator.c index 1246aa6..76d2b47 100644 --- a/drivers/thermal/power_allocator.c +++ b/drivers/thermal/power_allocator.c @@ -155,13 +155,11 @@ static void estimate_pid_constants(struct thermal_zone_device *tz, if (!temperature_threshold) return; - if (!tz->tzp->k_po || force) - tz->tzp->k_po = int_to_frac(sustainable_power) / - temperature_threshold; + if (!tz->tzp->k_po_ratio || force) + tz->tzp->k_po_ratio = 1; - if (!tz->tzp->k_pu || force) - tz->tzp->k_pu = int_to_frac(2 * sustainable_power) / - temperature_threshold; + if (!tz->tzp->k_pu_ratio || force) + tz->tzp->k_pu_ratio = 2; if (!tz->tzp->k_i || force) tz->tzp->k_i = int_to_frac(10) / 1000; @@ -169,6 +167,11 @@ static void estimate_pid_constants(struct thermal_zone_device *tz, * The default for k_d and integral_cutoff is 0, so we can * leave them as they are. */ + + tz->tzp->k_po = int_to_frac(tz->tzp->k_po_ratio * sustainable_power) / + temperature_threshold; + tz->tzp->k_pu = int_to_frac(tz->tzp->k_pu_ratio * sustainable_power) / + temperature_threshold; } /** @@ -202,6 +205,9 @@ static u32 pid_controller(struct thermal_zone_device *tz, if (tz->tzp->sustainable_power) { sustainable_power = tz->tzp->sustainable_power; + estimate_pid_constants(tz, sustainable_power, + params->trip_switch_on, control_temp, + false); } else { sustainable_power = estimate_sustainable_power(tz); estimate_pid_constants(tz, sustainable_power, diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 613c29b..2638f0b 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -284,13 +284,13 @@ struct thermal_zone_params { * Proportional parameter of the PID controller when * overshooting (i.e., when temperature is below the target) */ - s32 k_po; + s32 k_po, k_po_ratio; /* * Proportional parameter of the PID controller when * undershooting */ - s32 k_pu; + s32 k_pu, k_pu_ratio; /* Integral parameter of the PID controller */ s32 k_i;