From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796354385; b=XFD82li16MWbGk6q+pMLwxIpYlamnX/bWo+FvBNoJLAD7V1Wz+UuRPmKmkBRwdh0NePH dlP/tS+MlWXpaAjX2ubDJNWkcU9kbytka0sbJp6VD6XkaoX1yyHpj9F8wvlzHB/xuegXV 2CMbm20+7yiGRnLMYqFOGUg4e7v1d/UDmBUMcHKI9OhMEmByPjpooRoaN4jmSHARNrmdY 4Wg5i0HV5liUOgAcmV4Uj0pasS4aPovKjV7FviYQieKh5R1LHL/UuTUPVnFPJA1saV8vr 5bz7ZUyHN1QzE1VqOuMmB1ta8tRDwmpvQJdav2QbMG+hdpQpDFHRqEtCYwxthQPadFA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796354385; 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=Fu+XVRfKR7t2rgAAmeu6Vglk2qycIdfejLrp3QgxkBU=; b=Bxshj5Z4hcr0FKadYxKOgeNNqL1eHraqjBbF2OgCDisUJoBNLCtcIv9oTEEipSkRMbEj 8o8fvf4NSLswAjQfSXy9624JlLJmeMwmK1Olchi+UqlQ42s6l+w6tNvAwtYooYK9YxSse 74uSMbR8bNHMPM5/qnlz0mIo9AWa/YGb9OS2OEDWPo6x6m4MPeSg4qnbxdnbLF4APOU5r wbTsO1kG8ZPk4e34vadLAuZPlhHrLigGt5+Kyzl9d4ZnDi+uAmjvCx89xmiFutk+Bu/MW cM3AdtnbRVFToxbcRCWbebO+d4KEJFtg7HjBYaWl9IB6ZZdOP6hOgWZSq+R1s9dijJQ== 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=WkwNtWZx; arc=none smtp.remote-ip=115.124.30.131 Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) (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 D1EC0606A32C; Fri, 4 Dec 2026 03:19:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D1EC0606A32C 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=WkwNtWZx DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796354381; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=Fu+XVRfKR7t2rgAAmeu6Vglk2qycIdfejLrp3QgxkBU=; b=WkwNtWZxGRRVrRClQAfBnjiZ7Uo2FIpEyF/Js2S1xfX1gOdwh66k5D8OmFw3iJPTGSC4eGIoMdgZFiHvhEtYZSslI9SN3TocblzdmE5MRuoTgqkF2PTvi3lBawh0pHyHvz2uQHQBh6QGi9H09zxbeXfeB0z2jDQL61OUNKVZrl8= 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-contentspam033037033178;MF=jiangtianfeng@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0XGFrZsX_1796354379; Received: from h68d07384.sqa.eu95.tbsite.net(mailfrom:jiangtianfeng@linux.alibaba.com fp:SMTPD_---0XGFrZsX_1796354379 cluster:ay36) by smtp.aliyun-inc.com; Fri, 04 Dec 2026 11:19:40 +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 v7 2/2] cpufreq: Keep global boost enabled after partial enable Date: Fri, 4 Dec 2026 11:19:26 +0800 Message-ID: <20261204031926.278915-3-jiangtianfeng@linux.alibaba.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261204031926.278915-1-jiangtianfeng@linux.alibaba.com> References: <20261204031926.278915-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 Reviewed-by: Christian Loehle Signed-off-by: Jiangtian Feng --- drivers/cpufreq/cpufreq.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index e97838e40a54..48b2ccaa8c0b 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 restore = true; int ret = 0; guard(mutex)(&cpufreq_boost_mutex); @@ -2911,6 +2912,9 @@ static int cpufreq_boost_trigger_state(int state) ret = policy_set_boost(policy, state); if (unlikely(ret)) break; + + if (state) + restore = false; } cpus_read_unlock(); @@ -2918,9 +2922,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 (restore) { + 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