From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.130 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796037248; b=hH5k3Ukdq5pEOgvyVBZq1JKsoiVyccRcnCv0PIeYTwefs0UmybY2nh+/zzHZYly3HhPw X2Zp5M3+/albwVUaXVq196nO8M5GDlj8SMXTIIdn16/YhyOPwDrs+cRhlsxl0TSm7dOuS jXg8u8tJsO3GHx2mT9oEZ7dcwvtIFTtTmx3neHs0I50FFBTf+2z3GvMt9pLuaGxOJyvlh xQ3hJg1ftOrJ9ayx0GHC7RSdmCRLQnxSqU+xieSe8RoQJBedqOdLFxAj1yhpazMThcQqi GCwSAjAfOi7kAuUoEEaYYOvtEls60bZkNsP7iWXljaETbXmsygGniWziq1MK6cl44FA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796037248; 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=oRTxAxtNz4SXYhWPBXz5wphaxlXmy6/Oz7Qr08goKTo=; b=313F67gVsIj9MnExvwtaxrDzYAGH3Ib3UdvtnYrjzirE1y+ctbFGiJ6EQ4vhhvB8btnO DnrJzDBuOsaKwienwqBE0IQaiEgDlm1ee0OeYSeVGjFAUcnLNLqwlvVroYCTnE2KoliD2 uL2VUJw0eifqrn7o4RpS6wHalMe+CGDP8RNPBG0niowP05GHgujKVK9pHuSRxtGi0zTMR Qy8KzvC4S43bX1Q+Ux2Fpul6SQLcV0/kql5WlZ8PRSlDHaq1LGLzt6ueo5/33y0rjFKKw Jkfqk6LEoj4HMyw7/bmbahoeUe1sI131s6p7H0RGnSNJqV9NjxD8I8qJzdUZ9t/af+g== 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=P1KFWafk; arc=none smtp.remote-ip=115.124.30.130 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) (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 7A796606A334; Mon, 30 Nov 2026 11:14:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7A796606A334 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=P1KFWafk DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796037245; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=oRTxAxtNz4SXYhWPBXz5wphaxlXmy6/Oz7Qr08goKTo=; b=P1KFWafk3nT3CKuUK/2cj/pxwAAAXsLujW/BhdkxiXi5iRHQLfyASw8O+kBDOsCsK2Wi2/aKF2WRMUijTwoTx+axu4HtjLqKi6iiOB8ZTKGTy3ra7GFpdfMr71TzqXRn3iaZe0LWwrziNVbCc/gD4KGFAdqFJW4gTaxgE7x92bM= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033040069076;MF=jiangtianfeng@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0XFk0Sm4_1796037242; Received: from h68d07384.sqa.eu95.tbsite.net(mailfrom:jiangtianfeng@linux.alibaba.com fp:SMTPD_---0XFk0Sm4_1796037242 cluster:ay36) by smtp.aliyun-inc.com; Mon, 30 Nov 2026 19:14:04 +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: Mon, 30 Nov 2026 19:13:48 +0800 Message-ID: <20261130111348.363810-3-jiangtianfeng@linux.alibaba.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261130111348.363810-1-jiangtianfeng@linux.alibaba.com> References: <20261130111348.363810-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 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 f83fc6e40fbe..3d8927cc9787 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2888,6 +2888,7 @@ static int cpufreq_boost_trigger_state(int state) unsigned long flags; bool boost_enabled; bool any_boost_supported = false; + bool policy_success = false; int ret = 0; guard(mutex)(&cpufreq_boost_mutex); @@ -2915,6 +2916,8 @@ static int cpufreq_boost_trigger_state(int state) ret = policy_set_boost(policy, state); if (unlikely(ret)) break; + + policy_success = true; } if (!any_boost_supported) @@ -2925,9 +2928,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