Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp402071ybz; Fri, 24 Apr 2020 02:24:09 -0700 (PDT) X-Google-Smtp-Source: APiQypJPbrZ1vKlqhMfOCAa+JAWwyvj1fwciRhyiN8N/vDMhLLGDrwqAuQkgDAC2FfTlr+KyVOnp X-Received: by 2002:a17:906:3709:: with SMTP id d9mr6589406ejc.94.1587720249405; Fri, 24 Apr 2020 02:24:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587720249; cv=none; d=google.com; s=arc-20160816; b=DkBHfk5bs+rkTwXXynVhBC5BV7aWIwL+GUfMM7hJtV9T/L5MpJD8ZxfbncP8eTQJQq BACrLPx9MTI2Mwvw7Yrln9R+F67r9PBGqleahfVVKFaSUguOk//727cq9dMf/WxC6BIF WT2yu7kX/d2JntILjdeY0HFi/xnjKRZpWJrYxzlEPATeV+vY1PXXD+q4hFv/IpkZEwYg 46KTLEvx7dmttTL4nOzfyhXWj/nEe2sGrHS5LgAt10zAaYw6ZmPW1+QMEX+zomv/b2FI gK429Y5+cTt0wxUz07bX9ESbGaToog0g2GUobnQHxJ39qq+Ax4liayPp1+W1oU8tS7ah QipA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=6EPUynoDVjviFUWr/H8GhwUL28bqssqpwyOhZizgIMo=; b=bwhSLj9ReIXGJZUU7nGKExhe+8el8MmYjqczNlvcEZ1YEX5AvfWMWOb3iVcaztYBi+ aLZFkmOgVB/bxrKU8Hfm6QN+a09l9qymxXwbA3K151cxZ20qrmylSycQIkvAekDfxv5C 5vlO7HE84u2/upDbB186otHzJhti7Sjd84evLST61baygBQFnMkRBSfi6ilTpH9RMs1f /AZtOe8wNuXfUsU4theGVA1Vk8Ltp1cGIPBe1WQoFCQqBQ6quS5nWhKQ4iiLQJ7I5sDq QRQZ2j9LgXV65221SwSwosbzsIbMbcbl9klzO89PcQvt78PIsDdpNbImUlLDEKklV2on srVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w21si2835874ejz.276.2020.04.24.02.23.45; Fri, 24 Apr 2020 02:24:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726806AbgDXJWN (ORCPT + 99 others); Fri, 24 Apr 2020 05:22:13 -0400 Received: from foss.arm.com ([217.140.110.172]:58060 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726726AbgDXJWM (ORCPT ); Fri, 24 Apr 2020 05:22:12 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CEBB81FB; Fri, 24 Apr 2020 02:22:11 -0700 (PDT) Received: from [10.37.12.92] (unknown [10.37.12.92]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1A5703F73D; Fri, 24 Apr 2020 02:22:06 -0700 (PDT) Subject: Re: [PATCH] thermal: power_allocate: add upper and lower limits To: Michael Kao , Zhang Rui , Eduardo Valentin , Daniel Lezcano , Rob Herring , Mark Rutland , Matthias Brugger , hsinyi@chromium.org, linux-pm@vger.kernel.org, srv_heupstream@mediatek.com Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org References: <20200424071601.2636-1-michael.kao@mediatek.com> From: Lukasz Luba Message-ID: Date: Fri, 24 Apr 2020 10:22:03 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20200424071601.2636-1-michael.kao@mediatek.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Michael, On 4/24/20 8:16 AM, Michael Kao wrote: > The upper and lower limits of thermal throttle state in the > device tree do not apply to the power_allocate governor. > Add the upper and lower limits to the power_allocate governor. > > Signed-off-by: Michael Kao > --- > drivers/thermal/thermal_core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c > index 9a321dc548c8..f6feed2265bd 100644 > --- a/drivers/thermal/thermal_core.c > +++ b/drivers/thermal/thermal_core.c > @@ -598,7 +598,7 @@ int power_actor_set_power(struct thermal_cooling_device *cdev, > if (ret) > return ret; > > - instance->target = state; > + instance->target = clamp_val(state, instance->lower, instance->upper); > mutex_lock(&cdev->lock); > cdev->updated = false; > mutex_unlock(&cdev->lock); > Thank you for the patch and having to look at it. I have some concerns with this approach. Let's analyze it further. In default the cooling devices in the thermal zone which is used by IPA do not have this 'lower' and 'upper' limits. They are set to THERMAL_NO_LIMIT in DT to give full control to IPA over the states. This the function 'power_actor_set_power' actually translates granted power to the state that device will run for the next period. The IPA algorithm has already split the power budget. Now what happen when the 'lower' value will change the state to a state which consumes more power than was calculated in the IPA alg... It will became unstable. I would rather see a change which uses these 'lower' and 'upper' limits before the IPA do the calculation of the power budget. But this wasn't a requirement and we assumed that IPA has full control over the cooling device (which I described above with this DT THERMAL_NO_LIMIT). Is there a problem with your platform that it has to provide some minimal performance, so you tried to introduce this clamping? Regards, Lukasz