Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1477967lql; Tue, 12 Mar 2024 20:58:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXGKY0TWS2V5bbEh0td53L9JbsA+Wi1IaZGHB6XIqXG68z4ngHwE2iH1I1aoSnjv0qWr/MbwSg8JVqWZpc3ElUu+Vj+x+IHgM9BdhjxIw== X-Google-Smtp-Source: AGHT+IFOxLUOmHWlzCm6ToVmxSGaXy4623IuI0em0DnhnDIrUzQgwPMQaxxLmzWzWkFP71DliKvf X-Received: by 2002:ac8:59c4:0:b0:42e:e050:a9d1 with SMTP id f4-20020ac859c4000000b0042ee050a9d1mr4227853qtf.11.1710302307531; Tue, 12 Mar 2024 20:58:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710302307; cv=pass; d=google.com; s=arc-20160816; b=t+uB/YGiSogXPgWd/5Xm+hlZAHH50VdMh46N7hRQnBe0hv5m/xjXme2GRcETM8VAdQ spaSyLddykEIIGtO79aWT1XDuzUCqlgYD6o2CKO4fSw1w7g7uxntnjTD5AigokiLyhlK EJuvGKVpfqo5XzYU897UeGMIoENG85VcFQDM85+WW+WFn/j4FlyfcBe2oQUaNXzZYlLw LNrACuoi3Ituq+/ot/Hi+OAwr1iHiCkey54/ApfkRwlljDH/xSMqRs1e27x4p7JRP8LQ MPwAmpVmVqwxEBNWOvs17kCtq+XROWSYgbL0ax9e35kRPxWgpBT7Hj7xAciF/gb/eu/N FUMA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=2zEJnb+X2P9JoC16UeFaOr89hdYpBdPufqM92BzndE4=; fh=1iyYAo1PQGLbATaxmDuQgJgMkLznaLIuQclczVORv2I=; b=yGaIGku2r2a8BvwHcC4mUIyX9liHnbzYYxDGKWlnjCF2k7TQiJypPlhRtW6SZZHVWw dtTNeVTFtcHAR4ps6O9QFdm+yVtTB00gLS7ajgOO4qHQUHeDXzbrPS7yw2K58O4Vp80j vTtE2VEn8681M7YeQTmI1T6oDuy5CVQiiaA2pXusS3kTv54qw+iop0E+DTuVlxSYCxDM 2RTa9/1KLQoYal89IBs6gT/7PjJvFt6XusBvo/dujN0m+HL+9JZON3YHkQquG77r2Eck c7WQJ7fsU31dr5LeYirLlPba1ozgsi1TVZam6kDH0buwBYeXemHphXTQvxKE4u1HhhMl Ok4Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-101088-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101088-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 8-20020ac85908000000b0042e58d7b15fsi9312952qty.26.2024.03.12.20.58.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 20:58:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101088-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-101088-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101088-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 469561C21A3E for ; Wed, 13 Mar 2024 03:58:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4C49812E6C; Wed, 13 Mar 2024 03:57:50 +0000 (UTC) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 030E711193; Wed, 13 Mar 2024 03:57:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710302269; cv=none; b=DH4QVK2mh+f60C+Z+L6b2a6JKByRNR2ZXhWV6JQqkWMstd+dm5NbZEa789pB2qyR2gCef3TRFPEDoscOX4Q0BrkOdp2kt9sdC4rMuuTRxMd1JHdSEmKptA4JlafzY+XN8S9E2AOpM0ZBE3yh0YwcI+ZpZLXhz8Epx2gJmJaOByg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710302269; c=relaxed/simple; bh=xn9BaF+vY4E9A1GdYxDTCZbaTQ/pZd2l44gxSKuHeGE=; h=Message-ID:Date:MIME-Version:From:Subject:To:CC:References: In-Reply-To:Content-Type; b=eAIbWN2VZ7HgmKvyZ+uoXO6uMtVTmeU+it+KgUo79ZWv023Er8bAukkOlwbosLYsPoVIbW1lqDhRXWfH4DYgIWNp8rXx6eZD3/ZgPIXlk1Vd5ej8GRV+V0mKij0PgYT5yc8SIqfrcCNcOUnTeJKyLN/mnQZAl7DcJbckt2tbXDE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4TvcB70xxZz1xqfx; Wed, 13 Mar 2024 11:55:59 +0800 (CST) Received: from canpemm500008.china.huawei.com (unknown [7.192.105.151]) by mail.maildlp.com (Postfix) with ESMTPS id 2010B1400FD; Wed, 13 Mar 2024 11:57:44 +0800 (CST) Received: from [10.67.111.115] (10.67.111.115) by canpemm500008.china.huawei.com (7.192.105.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 13 Mar 2024 11:57:43 +0800 Message-ID: <8bfcacb1-b97a-8c54-7e41-f66df8ac32fd@huawei.com> Date: Wed, 13 Mar 2024 11:57:43 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.7.0 From: Yipeng Zou Subject: Re: [PATCH V3] cpufreq: Fix per-policy boost behavior on SoCs using cpufreq_boost_set_sw To: Sibi Sankar , , , , , CC: , , , , , , , References: <20240312103723.3469762-1-quic_sibis@quicinc.com> Content-Language: en-US In-Reply-To: <20240312103723.3469762-1-quic_sibis@quicinc.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500008.china.huawei.com (7.192.105.151) Hi, Oh, I just catch this issue too recently. Also test this patch on my board and it's works fine to me. Tested-by:Yipeng Zou Reviewed-by: Yipeng Zou 在 2024/3/12 18:37, Sibi Sankar 写道: > In the existing code, per-policy flags doesn't have any impact i.e. > if cpufreq_driver boost is enabled and one or more of the per-policy > boost is disabled, the cpufreq driver will behave as if boost is > enabled. Fix this by incorporating per-policy boost flag in the policy->max > calculus used in cpufreq_frequency_table_cpuinfo and setting the default > per-policy boost to mirror the cpufreq_driver boost flag. > > Fixes: 218a06a79d9a ("cpufreq: Support per-policy performance boost") > Reported-by: Dietmar Eggemann > Reviewed-by: Viresh Kumar > Reviewed-by: Dhruva Gole > Signed-off-by: Sibi Sankar > --- > > v3: > * Pickup Rbs. > * Simplify per-policy boost setting. [Viresh] > > v2: > * Enable per-policy boost flag in the core instead. [Viresh] > * Add more details regarding the bug. [Viresh] > * Drop cover-letter and patch 2. > > Logs reported-by Dietmar Eggemann: > https://lore.kernel.org/lkml/265e5f2c-9b45-420f-89b1-44369aeb8418@arm.com/ > > drivers/cpufreq/cpufreq.c | 18 ++++++++++++------ > drivers/cpufreq/freq_table.c | 2 +- > 2 files changed, 13 insertions(+), 7 deletions(-) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index f6f8d7f450e7..66e10a19d76a 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -653,14 +653,16 @@ static ssize_t store_local_boost(struct cpufreq_policy *policy, > if (policy->boost_enabled == enable) > return count; > > + policy->boost_enabled = enable; > + > cpus_read_lock(); > ret = cpufreq_driver->set_boost(policy, enable); > cpus_read_unlock(); > > - if (ret) > + if (ret) { > + policy->boost_enabled = !policy->boost_enabled; > return ret; > - > - policy->boost_enabled = enable; > + } > > return count; > } > @@ -1428,6 +1430,9 @@ static int cpufreq_online(unsigned int cpu) > goto out_free_policy; > } > > + /* Let the per-policy boost flag mirror the cpufreq_driver boost during init */ > + policy->boost_enabled = cpufreq_boost_enabled() && policy_has_boost_freq(policy); > + > /* > * The initialization has succeeded and the policy is online. > * If there is a problem with its frequency table, take it > @@ -2769,11 +2774,12 @@ int cpufreq_boost_trigger_state(int state) > > cpus_read_lock(); > for_each_active_policy(policy) { > + policy->boost_enabled = state; > ret = cpufreq_driver->set_boost(policy, state); > - if (ret) > + if (ret) { > + policy->boost_enabled = !policy->boost_enabled; > goto err_reset_state; > - > - policy->boost_enabled = state; > + } > } > cpus_read_unlock(); > > diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c > index c4d4643b6ca6..c17dc51a5a02 100644 > --- a/drivers/cpufreq/freq_table.c > +++ b/drivers/cpufreq/freq_table.c > @@ -40,7 +40,7 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, > cpufreq_for_each_valid_entry(pos, table) { > freq = pos->frequency; > > - if (!cpufreq_boost_enabled() > + if ((!cpufreq_boost_enabled() || !policy->boost_enabled) > && (pos->flags & CPUFREQ_BOOST_FREQ)) > continue; > -- Regards, Yipeng Zou