From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.111 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796092222; b=havdPaBiyc37GTThWckKolEFz5xV0+yViPVJjSXh/DBEq8estJk9vBaFfhdBpuAWmLC0 ruvjtSVc93aclq4u+V/Vb0nx2QDhG4388H+ll13LMhIxnT0NQK859mPadRgB+dXZoORNs yMSuv+VGrurvb8ZTH0sG9Twk6C3Y/3snum8u63MVvcfVVPZQt2IAy7gK/6p41FHrHKGYJ HayEE9OURdTnpMGzjQGKuH+aPyYyGWJIaQaa70mtDc4msPb9EzK/8p2B3IpFu9OaRkb46 HscmXREZxJ/JTn5Gr8sdkRlfp95aozgtOSOpMxPcN/RVzSEO0jE4eOnO1ArEbh5rD2Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796092222; h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:From:To:Cc: Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=SmPL+9ZKU0E9XxdNJ1c5aC8ori/+cfulCkK5fYGTyaU=; b=Axci+mFiEl/30rprKft/5YNr/hVHuYj3xZZanp1Wfn54/NnIRTqhg8HBBrzmEFIJxI+4 wg8c1F+6D40qZwJBzVWhwn1NQPGtcx+eR3kgcNVnoOAWvoZRvAISVIONoDfddb2NTk4xK l5njqgQQtnfe0Ol3oT2M1wJI7naRvVFfZcgI84Qdn5s3wtu8EEFnbi9jEI58RJBK8s9IH uG/wRa8k0vqMYa1NYJOzP8L3+U/Jxd4OPK0D9LZXcQU0Rl5nYm9fa0MBQz4ALyGcfS3Tx diRVWnONJcWnOhCW9cLEdXocqzYnnlvlpiRs9nL4KthxLcUvdPAantbOncDar8AkjQQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b="t3JDF/rn"; arc=none smtp.remote-ip=115.124.30.111 Received: from out30-111.freemail.mail.aliyun.com (out30-111.freemail.mail.aliyun.com [115.124.30.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA743606A31A; Tue, 1 Dec 2026 02:30:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DA743606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=t3JDF/rn DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796092218; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=SmPL+9ZKU0E9XxdNJ1c5aC8ori/+cfulCkK5fYGTyaU=; b=t3JDF/rnqZPtrxOT3K3tve8k8ps61FvG/RF3uenjwnz9Ihb3hsQPrY9380YNAhQL7z3B+yoKnjSuUu33OdYZ/p2lEOCpg3ZUsbyyP8PHi8F/tc9XUrYY/GWRwh+AuAozUp+/pGgCYXjHKXIpPcrv7n+WMIq5T0BSoVEmk8kOMU0= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033045144198;MF=jiangtianfeng@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0XFrUtiP_1796092214; Received: from h68d07384.sqa.eu95.tbsite.net(mailfrom:jiangtianfeng@linux.alibaba.com fp:SMTPD_---0XFrUtiP_1796092214 cluster:ay36) by smtp.aliyun-inc.com; Tue, 01 Dec 2026 10:30:16 +0800 From: Jiangtian Feng To: rafael@kernel.org, viresh.kumar@linaro.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, zhongqiu.han@oss.qualcomm.com, christian.loehle@arm.com, ananthu.cv@oss.qualcomm.com, pierre.gondois@arm.com, zhangpengjie2@huawei.com, zhenglifeng1@huawei.com, zhanjie9@hisilicon.com, Jiangtian Feng Subject: [PATCH 2/2] cpufreq: Keep global boost enabled after partial enable Date: Tue, 1 Dec 2026 10:30:01 +0800 Message-ID: <20261201023001.1131130-3-jiangtianfeng@linux.alibaba.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261201023001.1131130-1-jiangtianfeng@linux.alibaba.com> References: <20261201023001.1131130-1-jiangtianfeng@linux.alibaba.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When global boost is enabled from the disabled state, a failure after one or more policies have been updated successfully currently restores the global flag to 0 without rolling back those policies. This leaves them locally enabled, with their boost-related driver/QoS updates retained, while the global flag rejects per-policy sysfs writes. Keep the global flag enabled if at least one policy_set_boost() call succeeded, while preserving the existing error return path. Global boost = 1 grants permission to boost; it does not require every policy to have boost enabled. The mixed per-policy state is therefore valid and individual policies remain accessible through per-policy sysfs. Restore the previous global state on disable and when no policy was enabled successfully. After a partial enable, keep global boost enabled so users can repair individual policies through sysfs. Do not roll back earlier policy updates. Qoder, an AI coding assistant, helped analyze the issue, develop the fix and state matrix, and draft this description. Fixes: 218a06a79d9a ("cpufreq: Support per-policy performance boost") Reviewed-by: Zhongqiu Han Reviewed-by: Pengjie Zhang Signed-off-by: Jiangtian Feng --- drivers/cpufreq/cpufreq.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index e97838e40a54..d998ea0ed43c 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2887,6 +2887,7 @@ static int cpufreq_boost_trigger_state(int state) struct cpufreq_policy *policy; unsigned long flags; bool boost_enabled; + bool policy_success = false; int ret = 0; guard(mutex)(&cpufreq_boost_mutex); @@ -2911,6 +2912,8 @@ static int cpufreq_boost_trigger_state(int state) ret = policy_set_boost(policy, state); if (unlikely(ret)) break; + + policy_success = true; } cpus_read_unlock(); @@ -2918,9 +2921,12 @@ static int cpufreq_boost_trigger_state(int state) if (likely(!ret)) return 0; - write_lock_irqsave(&cpufreq_driver_lock, flags); - cpufreq_driver->boost_enabled = boost_enabled; - write_unlock_irqrestore(&cpufreq_driver_lock, flags); + /* On failure, restore old state unless partial enable needs local repair. */ + if (!state || !policy_success) { + write_lock_irqsave(&cpufreq_driver_lock, flags); + cpufreq_driver->boost_enabled = boost_enabled; + write_unlock_irqrestore(&cpufreq_driver_lock, flags); + } pr_err("%s: Cannot %s BOOST\n", __func__, str_enable_disable(state)); -- 2.47.3