From patchwork Wed Jan 6 08:30:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 7965351 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4E4E59F38D for ; Wed, 6 Jan 2016 08:31:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7B39020165 for ; Wed, 6 Jan 2016 08:31:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8E6DB20160 for ; Wed, 6 Jan 2016 08:31:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752375AbcAFIao (ORCPT ); Wed, 6 Jan 2016 03:30:44 -0500 Received: from mail-pa0-f41.google.com ([209.85.220.41]:35822 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752289AbcAFIaj (ORCPT ); Wed, 6 Jan 2016 03:30:39 -0500 Received: by mail-pa0-f41.google.com with SMTP id do7so2002407pab.2 for ; Wed, 06 Jan 2016 00:30:39 -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=R6DjzPZpgW5PvpiiuPYLMApPCNjCfmoxuQi2tvZ/pwU8wYtV3o8E3VmC8iWlTeHuL9 YqGkyKJZTQNaBati3kC2Nk8JBCZmhkNHOUHlKs8V+1+ZNKSstqKmEqGTAy4wIShXzD8D N8gZewoQBXMG+WMDS1eXEJU4krIsPydp/wFmQ= 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=OmGi2nqjgLIwZNBjVqHIWh3x45BADbY3GUUmWcBww6CBnupZkQwPnvsFACxCbkOV0T y4z3tV7oNVKeysiiRMWzmpr/QN9o2T3XyaEcWov5l+u4lcsy1G6mMcDz3lh8IFWOIUC6 c/p1InFXK+8cHg6gr4AtJaYOmlQbCPOFd2tP2SITVGfIC3cEwY2DqqWGefDRohFSlRX7 dgfsf8OF8tf7e87XDOCRbLWDOpGMOgChdXwx14t9h0YiO77cAx8pka41RXS6WSDlw0lF kj5S6vEd2w7k4AzDn1RhAClV03yxyR9rVYPVC6yvRIQzLN67/348B+DBKwt4PPA4T6/z YI3w== X-Gm-Message-State: ALoCoQnDifX5Aq7fRlxH8V06rc87hn4GWZQM5d4m5CLpL2EHWPHLPHATtwTsfQ4bd8T55o9jXDgA9+FpoZa8j1evDR3vvjMbeA== X-Received: by 10.67.6.195 with SMTP id cw3mr140749219pad.88.1452069039447; Wed, 06 Jan 2016 00:30:39 -0800 (PST) Received: from localhost.localdomain (v17.blockcn.net. [192.241.236.26]) by smtp.gmail.com with ESMTPSA id f24sm133416478pff.68.2016.01.06.00.30.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Jan 2016 00:30:38 -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 v2 1/4] thermal: power_allocator: rework proportional parameter Date: Wed, 6 Jan 2016 16:30:20 +0800 Message-Id: <1452069023-32149-2-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1452069023-32149-1-git-send-email-leo.yan@linaro.org> References: <1452069023-32149-1-git-send-email-leo.yan@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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;