Message ID | 20230912060957.2516790-1-liaochang1@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp742111vqx; Tue, 12 Sep 2023 16:30:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHK4p1ArrsotSi/hZBHvYeWBfPQCrBNGwWKpNY7OlLuywWIFwbKSkszYm4+O3JzsAFWPw+D X-Received: by 2002:a17:90a:f60b:b0:268:ac99:4bb4 with SMTP id bw11-20020a17090af60b00b00268ac994bb4mr791639pjb.46.1694561416091; Tue, 12 Sep 2023 16:30:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694561416; cv=none; d=google.com; s=arc-20160816; b=g0FfFqPo4EXdD8Zwxn3UaCyJIoPAQ4GIT53eKlbTw4//Q7EkTUbRsKV5xX08ekKFji ZSNGPhU3ilxgbdknxk8E3SS0JilOgp/M+ybv5YWXcS16KsBsoKsO2hkBhXLCAzjIuVAM Pa0ggYyE6a3DhO73m4B62mSUQrao4g0+CwwKirekzf0MO0zZF83Y0D4uGJQe06VLQ6nb Tq0G1VQtCIppzqResfkyn55Z8KaQNKCrWZzIhw+4qpOl0B0LkRJ//vqa3Q1wSKexT4K0 wW3DZ2X8Vraw0uxwFojXSU+lb/nYgAfSyAA1phRPSc+tgIwH/h7uTHoyJkDN3++P/XQj uP3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=XVXxQd/6zqFCy3IonIVym14lEBk7s3rUaO7xDKZVRJ0=; fh=0vaYOzzn3Z5SQEjgoqvxffIotvjIeDSv5QGTvx6cK/U=; b=ukWkgvmpcoBgTjvaddfyBMs1QZ78/vOkQrDoMLeN5xubLobDUkLlh4627kwSq7CTKh ZfHEEX+A1Cj9AWZ+/u1HL8r76mMeN1l0lzRPP/hEieaT8cktKzlqYIvBl+S5KojkxmOS sW7Y+DBpsbyDkZEXuGzqjNhuO+2MY9gzoWbp4m4Y/k6ycfMU4vY85KMGUfNuvxdc9qcz Kk9qz3jxVa30Ar3/LhN90z1qKjzKGDsO2mnLSk4s8gRtE8TBGtS40kNFmYYyXLg6Hnqz tT9mVaJwdmuu3kJeGUe+WkWq4sXMSUmj8MExBJNwQPi90ANM1d0tYF/6DrEzBvFhsqNP Rq6g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id x13-20020a17090abc8d00b0026d40e6a819si285924pjr.157.2023.09.12.16.30.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 16:30:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 0495882C92E0; Mon, 11 Sep 2023 23:12:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229461AbjILGMX (ORCPT <rfc822;ruipengqi7@gmail.com> + 39 others); Tue, 12 Sep 2023 02:12:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229625AbjILGMV (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 12 Sep 2023 02:12:21 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E432DE78; Mon, 11 Sep 2023 23:12:17 -0700 (PDT) Received: from kwepemd200002.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RlCn518WPztQSC; Tue, 12 Sep 2023 14:08:09 +0800 (CST) Received: from huawei.com (10.67.174.28) by kwepemd200002.china.huawei.com (7.221.188.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1258.23; Tue, 12 Sep 2023 14:12:14 +0800 From: Liao Chang <liaochang1@huawei.com> To: <rafael@kernel.org>, <viresh.kumar@linaro.org> CC: <linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH] cpufreq: conservative: Ensure requested_freq is greater than min frequency Date: Tue, 12 Sep 2023 06:09:57 +0000 Message-ID: <20230912060957.2516790-1-liaochang1@huawei.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.174.28] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemd200002.china.huawei.com (7.221.188.186) X-CFilter-Loop: Reflected Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 11 Sep 2023 23:12:27 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776876431354058874 X-GMAIL-MSGID: 1776876431354058874 |
Series |
cpufreq: conservative: Ensure requested_freq is greater than min frequency
|
|
Commit Message
Liao Chang
Sept. 12, 2023, 6:09 a.m. UTC
The governor ensures that the requested frequency is greater than the
minimum frequency when the condition for decreasing frequency is
satisfied. This is done by either reducing the frequency step from the
current frequency if the current frequency is greater than the sum of
the frequency step and the minimum frequency, or setting the frequency
to the minimum one otherwise.
Signed-off-by: Liao Chang <liaochang1@huawei.com>
---
drivers/cpufreq/cpufreq_conservative.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 12-09-23, 06:09, Liao Chang wrote: > The governor ensures that the requested frequency is greater than the > minimum frequency when the condition for decreasing frequency is > satisfied. This is done by either reducing the frequency step from the > current frequency if the current frequency is greater than the sum of > the frequency step and the minimum frequency, or setting the frequency > to the minimum one otherwise. > > Signed-off-by: Liao Chang <liaochang1@huawei.com> > --- > drivers/cpufreq/cpufreq_conservative.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c > index 56500b25d77c..54e09242b2e2 100644 > --- a/drivers/cpufreq/cpufreq_conservative.c > +++ b/drivers/cpufreq/cpufreq_conservative.c > @@ -130,7 +130,7 @@ static unsigned int cs_dbs_update(struct cpufreq_policy *policy) > if (requested_freq == policy->min) > goto out; > > - if (requested_freq > freq_step) > + if (requested_freq > policy->min + freq_step) > requested_freq -= freq_step; > else > requested_freq = policy->min; I think all we want to ensure here is that we don't end up getting a negative number (since requested_freq is unsigned int, it will end up being a very large freq). __cpufreq_driver_target() will eventually set the freq to policy->min only as we are using CPUFREQ_RELATION_LE here.
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c index 56500b25d77c..54e09242b2e2 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c @@ -130,7 +130,7 @@ static unsigned int cs_dbs_update(struct cpufreq_policy *policy) if (requested_freq == policy->min) goto out; - if (requested_freq > freq_step) + if (requested_freq > policy->min + freq_step) requested_freq -= freq_step; else requested_freq = policy->min;