From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=113.46.200.216 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796046670; b=lhhGlnZIpZrj8lNiX235MBbnj5s/pGIcdpV4xFQoB43zm9glpjBy2ZGqL9a1sOLDTqIz SKLerduk5XyMZ4jO1FrrWY62yKcUBsVJSkdliojuEv9Z5ZfAVOFP3WK83oB92Pqxqji0w +zcly3Tjng5T6JKbUQCtCmH3RKdLIc3UjghQUv8IrO4tKAwiQVVqjcEXn/4X8+ov75Wic 5LH3+cQfRpDg1TKCa6i7RGCkeTXEyisZiebruDCaHr4vY4vPCK95DtDfRSNC0ZBcANs0z eN5csi9GqqMnjODSumhqxlNBq+SmGK3fZWj+Nb72bxOKUP4GptChmEzfdNjvLMepI4w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796046670; h=DMARC-Filter:dkim-signature:Received:Received:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:CC:References:From: In-Reply-To:Content-Type:Content-Transfer-Encoding:X-Originating-IP: X-ClientProxiedBy; bh=U+JgnWD2bUphR0qyJdWpCt4JZMyYW2KuSe7rx4D5Zcc=; b=o8YzZRGFDUYK35eGCBHRShrMqahkxmURNpg4b1sG1cENhDQkle8kma0+7wBBxKSQ/doH vWlUGO9mcODieOczc40RuVTd/me17LlLoa0ISqorjFwieMTtnUnxTqtJF7BJSE1U4Dtz4 3vs+7Gd31HUMiBPb9bjRFUWsgmc/SOKKy6uWXVUCyDXXNdj1s9LQWjT1yE1Z8xCy4gmMt uf8ZwgmJ5nPDfTDbjlvfCttyQAm0+q7bW0SOhbmXNsLBT1y7X63u+9J3fxc7T67mRM6+g fvrTbgDOm8CfbdujHdvvw98ps+/OaTvn1hD3dxX7cZWvBtUMVf+YANSBKgRzoQCWfDA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=vFvuIZIs; arc=none smtp.remote-ip=113.46.200.216 Received: from canpmsgout01.his.huawei.com (canpmsgout01.his.huawei.com [113.46.200.216]) (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 7254C606A320; Mon, 30 Nov 2026 13:51:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7254C606A320 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=vFvuIZIs dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=U+JgnWD2bUphR0qyJdWpCt4JZMyYW2KuSe7rx4D5Zcc=; b=vFvuIZIsnty3MnJDOd+RaZM0srTaPOiNJNskw+gF1Xvew+5m9wEo66IxO7Wr6CIlKsSg6kxSS REhpC45+9V8Z8dK8Sg4Nng1BqZHU8duQt/L45T56OM0nanj2pSDXevx7zR4kRFfKbaD6v3KHgFw 9sORF0IMZf6HFUaaDQD52IQ= Received: from mail.maildlp.com (unknown [172.19.163.0]) by canpmsgout01.his.huawei.com (SkyGuard) with ESMTPS id 4jdQPn3MFWz1T4hM; Mon, 30 Nov 2026 21:50:05 +0800 (CST) Received: from kwepemr200004.china.huawei.com (unknown [7.202.195.241]) by mail.maildlp.com (Postfix) with ESMTPS id 98E0040537; Mon, 30 Nov 2026 21:51:02 +0800 (CST) Received: from [10.67.121.62] (10.67.121.62) by kwepemr200004.china.huawei.com (7.202.195.241) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Mon, 30 Nov 2026 21:51:01 +0800 Message-ID: Date: Mon, 30 Nov 2026 21:51:00 +0800 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 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] cpufreq: Keep global boost enabled after partial enable To: Jiangtian Feng , , CC: , , , , , , , References: <20261130111348.363810-1-jiangtianfeng@linux.alibaba.com> <20261130111348.363810-3-jiangtianfeng@linux.alibaba.com> From: Pengjie Zhang In-Reply-To: <20261130111348.363810-3-jiangtianfeng@linux.alibaba.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To kwepemr200004.china.huawei.com (7.202.195.241) On 11/30/2026 7:13 PM, Jiangtian Feng wrote: > 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)); Reviewed-by: Pengjie Zhang