From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 0B5CE3A3825 for ; Thu, 26 Mar 2026 08:18:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774513124; cv=none; b=KQbPRbgbIfal/FGF7+6cnJm9RRu7xvFrydcz4t1wcMpL/RjRxDY0Uodlt7qwn2lfZ6ajvRdxg3wQH1qk/r1H25DFGp4lDrQiscRkbrKqKRkZj7RULHMpo2tP1SDLYb6pD3dh2pJh1kwueNtYJaUhBteWapBeo+YuoDnEsOPR9h8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774513124; c=relaxed/simple; bh=u2Y6KKbgbbKhS8i10gQhgt/wQsfDs6c9xOr5mXVXsMk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=NKWh/0J39oxQlf751VXIDRHSCxOZVAXZ55ZnmsHiX8u13YwSBOukb4xJwdYGOoBB9SxfwIs1pXaGkJRNBtsCkGhyOCG/ehPY/jCSSIDXrZ5xK9OZZT2zOJyYEIew1KevIVWl9LttRXUhcEcRqmWPimefF3La0XrzuO5wMhYnJQQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=PsONPIjJ; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Qu3dPAjN; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="PsONPIjJ"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Qu3dPAjN" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62Q6NCi5141354 for ; Thu, 26 Mar 2026 08:18:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= SxnhaBklzFLc8eoTq471oYVEanoFKpaP1wRuMYtQWrU=; b=PsONPIjJVg0375h+ slJJhdx2WirToaHrkVwvnIqFOrsips0f3DSFogB3KUat5RCMd8UwAzEE6Jp6c9jA xQOKXFNs/VbCC/JqJxSDb9cpH9Ef+08A1pFBv1uXVVp3Al5SalYI2x+C7zoaXDXE sikm2S78+VLSyu8gGRbiPnKkNTq1+HdLFgk8FcLNZrge/nfccidrikpcLnZMlC2b /AVRU5QGaSFv9NdG/7An/XikKV698Bw+VIGwLhIgIerJnLo1ofXWF0b6LU5GnP+1 4LMnD0GuDL5GPnXURsA2fzr9bvF5AAHqhGIbmks7UaX5WqOUudWdBKBweLVOXmoI yi88FA== Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4d4q091x64-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 26 Mar 2026 08:18:41 +0000 (GMT) Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-2b05370ec01so28806775ad.1 for ; Thu, 26 Mar 2026 01:18:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1774513121; x=1775117921; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=SxnhaBklzFLc8eoTq471oYVEanoFKpaP1wRuMYtQWrU=; b=Qu3dPAjNAmRXNFLvGyGSRToEWvnkVEKXt8oUNTXjXaU7rmJS+muaKyGTlb2YgPJS1a 8L+kWYi8+ubNZL72tMaFXOloAsadP/+ey3meSCVDQUpp0CTTy8S2yg5C53bmCIwIfJX7 SREsGOkJ8P96Ttujpf/2eR8pwnKloSrAZwH+61WyHqIPN79g0+2p2Vdarir0luPDMEk0 9/TiZcUxqwFniLwzZvSe0pA9eGXKluiA8viKph3QNanPQ+B2gEID7/xUnh0XFZGNrSwB qKS0A2C2/LAJoBYeGH61qK5nRr3KCWw4cEOaNL98mH+zSu9d4e5kyPpKRG3krBnhw/TV JJjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774513121; x=1775117921; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=SxnhaBklzFLc8eoTq471oYVEanoFKpaP1wRuMYtQWrU=; b=ISvam8AN1uk4va5QEbogiGoH+NqVz6KAK6NTpg91SlYWnOOW9Ul3jBrPquVip3z+Dl HprpL8N70EZANm25CGsRh1hx4rK7P/uLSy/y7XpeC6Eypf2WMnf5YfN9BUQ0p56i/Ue9 RZpKNJhObYsnVD7TSOKA6RQm3Uvp8C3rR02fqZFReKFLvH37i4Oaa79Zi0rcELhGeyeo EgqkA5+NBcf0afWoDTOTYYzbjAmMD6A85TpfQIyG8HJKjuktuzwsomqWRV1Kqtqne06a kB8WvnsEIGmHclash97OyksnPVEPsYyI9Gn3mQzCPC2XhWe265yR7C3ywLgM/RIgRqNX Govg== X-Forwarded-Encrypted: i=1; AJvYcCVGeb9UvJu0FnuaFZxhNpt7tInlSGg5KyKrNg4MXOoeMaejifGkNPVIouq76RU8z3f54k3Msxi8rKrhgeY=@vger.kernel.org X-Gm-Message-State: AOJu0Yy5HFA3uLdsCFocoeAqa46DnUeI1wfQB3uLbo+H3LR8l+hll9ra rbtr7egQi951W+iN0DJ5O4iVsHyeekNxk2KjUg2kZck4pkC7zsi/IhNIY+ezntDJbC8nnpqM4iz Rut3n/R5r0+EhjZUPz6ueM6SYYgxmcYBVm40yBJe1lwzOgfpuXe/vA5pzN7YAbysv9gg= X-Gm-Gg: ATEYQzxTJAlXCGeUE+DPOBKcY/EgLgly731s/7ZZQAB/bUIj8gsEM7PXkTolQj7r43Y 8QbNLRWWOSbae8ult0l+Q1eOcKEbhwkBPW9IN9BU+UYDt2MTl7v+hp5FdnCAQsKsM4jiBxTOrbg +9tTnJGx/Id+PSQhSOyIb7CLYFjad7ibu0zwoozsfRDYN77CN2Mqtj+hYzL75G9pX/cQj24tbkf K0Z1J2/be4mRkLm6of2pq26mO6otUkGQ2AZazUNrRw6CG5xvA2bAmFOa66j8eo0S4oMb+KX9u6o K22aXv23A8NaSIoHL2NYe2jcGoqOL25kKn3wRWprqmblKX+4Jz3tOA7aV3MQ8OwXLOgitlvQmQD iLXHmD5xsozWgTGaJxyj10yUK4oclg6oi+4AeiV5zq8m4XvTJt0Q7ljKbsRjZgELXf9iUT6OmMm ERmM0YSoutz7SrUsfd X-Received: by 2002:a17:903:240c:b0:2ae:80bc:9bfb with SMTP id d9443c01a7336-2b0b0b0e2f7mr80094525ad.40.1774513121262; Thu, 26 Mar 2026 01:18:41 -0700 (PDT) X-Received: by 2002:a17:903:240c:b0:2ae:80bc:9bfb with SMTP id d9443c01a7336-2b0b0b0e2f7mr80094085ad.40.1774513120719; Thu, 26 Mar 2026 01:18:40 -0700 (PDT) Received: from [10.133.33.234] (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b0bc7b233fsm22925735ad.32.2026.03.26.01.18.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Mar 2026 01:18:40 -0700 (PDT) Message-ID: Date: Thu, 26 Mar 2026 16:18:35 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v7 2/2] cpufreq: Add boost_freq_req QoS request To: Pierre Gondois , linux-kernel@vger.kernel.org Cc: Lifeng Zheng , Huang Rui , "Gautham R. Shenoy" , Mario Limonciello , Perry Yuan , "Rafael J. Wysocki" , Viresh Kumar , linux-pm@vger.kernel.org, zhongqiu.han@oss.qualcomm.com References: <20260325165255.386576-1-pierre.gondois@arm.com> <20260325165255.386576-3-pierre.gondois@arm.com> Content-Language: en-US From: Zhongqiu Han In-Reply-To: <20260325165255.386576-3-pierre.gondois@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Authority-Analysis: v=2.4 cv=fufRpV4f c=1 sm=1 tr=0 ts=69c4ebe2 cx=c_pps a=MTSHoo12Qbhz2p7MsH1ifg==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=7CQSdrXTAAAA:8 a=OTLpJuPVDTOuwz7AMcsA:9 a=QEXdDO2ut3YA:10 a=GvdueXVYPmCkWapjIL-Q:22 a=a-qgeE7W1pNrGK8U0ZQC:22 X-Proofpoint-GUID: aGukpjyANz5HWEDBn2plc1mJH82XNQ8v X-Proofpoint-ORIG-GUID: aGukpjyANz5HWEDBn2plc1mJH82XNQ8v X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI2MDA1OSBTYWx0ZWRfX+dOvml0W6j7J /LdnafGnFRKuMAKemrfxZ41v+lMYmppsVOajfMuGC5Q+IkkZ7Axi4NJk8AvpoJkUPg6WjFwKS4S YYZILjmnfrYBq9DGdUEIGTwnQSVRLUA2Zc/jFpYdCU+rhL8x2cpHnM8zfgemXP2EakPOcV53DN0 AP/WtXR/o83hA+TmAxGYqq4zQcZLS1BO2yylC9YKzeRm6OOJFzcvP23YakmBBh2RZkXO0O1kbWp g8mzHoPsdTskqYuxyQpQgNaheWcCU0nikOh09qvz1PFO2m7AVdrBC/KT2z7BZaHWGZtiRl0YXOn aNmxsQmyO/iMtSo/Sranf/6YYq3asNr3xvppQ633Mkmml+1dug2pIXHN6qCK8jCOAkzve29dJwF ONHVkwIyQ0q1um1rk6BPqFDv6xb02ogcd0U5o6XFlLg4Trosp9CWXDs5qDtAtdnZiYK6cr0nL4U Ql3UMhevuUzoyr/8MHg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-26_02,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 adultscore=0 priorityscore=1501 malwarescore=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 phishscore=0 impostorscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603260059 On 3/26/2026 12:52 AM, Pierre Gondois wrote: > The Power Management Quality of Service (PM QoS) allows to > aggregate constraints from multiple entities. It is currently > used to manage the min/max frequency of a given policy. > > Frequency constraints can come for instance from: > - Thermal framework: acpi_thermal_cpufreq_init() > - Firmware: _PPC objects: acpi_processor_ppc_init() > - User: by setting policyX/scaling_[min|max]_freq > The minimum of the max frequency constraints is used to compute > the resulting maximum allowed frequency. > > When enabling boost frequencies, the same frequency request object > (policy->max_freq_req) as to handle requests from users is used. > As a result, when setting: > - scaling_max_freq > - boost > The last sysfs file used overwrites the request from the other > sysfs file. > > To avoid this, create a per-policy boost_freq_req to save the boost > constraints instead of overwriting the last scaling_max_freq > constraint. > > policy_set_boost() calls the cpufreq set_boost callback. > Update the newly added boost_freq_req request from there: > - whenever boost is toggled > - to cover all possible paths > > In the existing .set_boost() callbacks: > - Don't update policy->max as this is done through the qos notifier > cpufreq_notifier_max() which calls cpufreq_set_policy(). > - Remove freq_qos_update_request() calls as the qos request is now > done in policy_set_boost() and updates the new boost_freq_req > > $ ## Init state > scaling_max_freq:1000000 > cpuinfo_max_freq:1000000 > > $ echo 700000 > scaling_max_freq > scaling_max_freq:700000 > cpuinfo_max_freq:1000000 > > $ echo 1 > ../boost > scaling_max_freq:1200000 > cpuinfo_max_freq:1200000 > > $ echo 800000 > scaling_max_freq > scaling_max_freq:800000 > cpuinfo_max_freq:1200000 > > $ ## Final step: > $ ## Without the patches: > $ echo 0 > ../boost > scaling_max_freq:1000000 > cpuinfo_max_freq:1000000 > > $ ## With the patches: > $ echo 0 > ../boost > scaling_max_freq:800000 > cpuinfo_max_freq:1000000 > > Note: > cpufreq_frequency_table_cpuinfo() updates policy->min > and max from: > A. > cpufreq_boost_set_sw() > \-cpufreq_frequency_table_cpuinfo() > B. > cpufreq_policy_online() > \-cpufreq_table_validate_and_sort() > \-cpufreq_frequency_table_cpuinfo() > Keep these updates as some drivers expect policy->min and > max to be set through B. > > Signed-off-by: Pierre Gondois > --- > drivers/cpufreq/amd-pstate.c | 2 -- > drivers/cpufreq/cppc_cpufreq.c | 10 ++----- > drivers/cpufreq/cpufreq.c | 51 ++++++++++++++++++++++++++-------- > include/linux/cpufreq.h | 1 + > 4 files changed, 43 insertions(+), 21 deletions(-) > > diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c > index 5aa9fcd80cf51..d0675d6a19fe1 100644 > --- a/drivers/cpufreq/amd-pstate.c > +++ b/drivers/cpufreq/amd-pstate.c > @@ -769,8 +769,6 @@ static int amd_pstate_cpu_boost_update(struct cpufreq_policy *policy, bool on) > else if (policy->cpuinfo.max_freq > nominal_freq) > policy->cpuinfo.max_freq = nominal_freq; > > - policy->max = policy->cpuinfo.max_freq; > - > if (cppc_state == AMD_PSTATE_PASSIVE) { > ret = freq_qos_update_request(&cpudata->req[1], policy->cpuinfo.max_freq); > if (ret < 0) > diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c > index 011f35cb47b94..f4f574fbe547b 100644 > --- a/drivers/cpufreq/cppc_cpufreq.c > +++ b/drivers/cpufreq/cppc_cpufreq.c > @@ -807,17 +807,11 @@ static int cppc_cpufreq_set_boost(struct cpufreq_policy *policy, int state) > { > struct cppc_cpudata *cpu_data = policy->driver_data; > struct cppc_perf_caps *caps = &cpu_data->perf_caps; > - int ret; > > if (state) > - policy->max = cppc_perf_to_khz(caps, caps->highest_perf); > + policy->cpuinfo.max_freq = cppc_perf_to_khz(caps, caps->highest_perf); > else > - policy->max = cppc_perf_to_khz(caps, caps->nominal_perf); > - policy->cpuinfo.max_freq = policy->max; > - > - ret = freq_qos_update_request(policy->max_freq_req, policy->max); > - if (ret < 0) > - return ret; > + policy->cpuinfo.max_freq = cppc_perf_to_khz(caps, caps->nominal_perf); > > return 0; > } > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index 5757f12633d16..947ed87cf8d76 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -609,10 +609,19 @@ static int policy_set_boost(struct cpufreq_policy *policy, bool enable) > policy->boost_enabled = enable; > > ret = cpufreq_driver->set_boost(policy, enable); > - if (ret) > + if (ret) { > policy->boost_enabled = !policy->boost_enabled; > + return ret; > + } > > - return ret; > + ret = freq_qos_update_request(policy->boost_freq_req, policy->cpuinfo.max_freq); Hello Pierre, Would it be reasonable to add a NULL check for policy->boost_freq_req in policy_set_boost() before calling freq_qos_update_request(), even though callers already check policy->boost_supported? Thanks > + if (ret < 0) { > + policy->boost_enabled = !policy->boost_enabled; > + cpufreq_driver->set_boost(policy, policy->boost_enabled); > + return ret; > + } > + > + return 0; > } > > static ssize_t store_local_boost(struct cpufreq_policy *policy, > @@ -1377,6 +1386,8 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy) > } > > freq_qos_remove_request(policy->min_freq_req); > + if (policy->boost_freq_req) > + freq_qos_remove_request(policy->boost_freq_req); > kfree(policy->min_freq_req); > > cpufreq_policy_put_kobj(policy); > @@ -1445,18 +1456,42 @@ static int cpufreq_policy_online(struct cpufreq_policy *policy, > cpumask_and(policy->cpus, policy->cpus, cpu_online_mask); > > if (new_policy) { > + unsigned int req_nr; > + > for_each_cpu(j, policy->related_cpus) { > per_cpu(cpufreq_cpu_data, j) = policy; > add_cpu_dev_symlink(policy, j, get_cpu_device(j)); > } > > - policy->min_freq_req = kzalloc(2 * sizeof(*policy->min_freq_req), > + req_nr = policy->boost_supported ? 3 : 2; > + policy->min_freq_req = kzalloc(req_nr * sizeof(*policy->min_freq_req), > GFP_KERNEL); > if (!policy->min_freq_req) { > ret = -ENOMEM; > goto out_destroy_policy; > } > > + if (policy->boost_supported) { > + policy->boost_freq_req = policy->min_freq_req + 2; > + > + /* > + * If boost is supported, > + * init the constraint with cpuinfo.max_freq. > + */ > + ret = freq_qos_add_request(&policy->constraints, > + policy->boost_freq_req, > + FREQ_QOS_MAX, > + policy->cpuinfo.max_freq); > + if (ret < 0) { > + /* > + * So we don't call freq_qos_remove_request() for an > + * uninitialized request. > + */ > + policy->boost_freq_req = NULL; > + goto out_destroy_policy; > + } > + } > + > ret = freq_qos_add_request(&policy->constraints, > policy->min_freq_req, FREQ_QOS_MIN, > FREQ_QOS_MIN_DEFAULT_VALUE); > @@ -2788,16 +2823,10 @@ int cpufreq_boost_set_sw(struct cpufreq_policy *policy, int state) > return -ENXIO; > > ret = cpufreq_frequency_table_cpuinfo(policy); > - if (ret) { > + if (ret) > pr_err("%s: Policy frequency update failed\n", __func__); > - return ret; > - } > - > - ret = freq_qos_update_request(policy->max_freq_req, policy->max); > - if (ret < 0) > - return ret; > > - return 0; > + return ret; > } > EXPORT_SYMBOL_GPL(cpufreq_boost_set_sw); > > diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h > index cc894fc389710..89157e367eefa 100644 > --- a/include/linux/cpufreq.h > +++ b/include/linux/cpufreq.h > @@ -81,6 +81,7 @@ struct cpufreq_policy { > struct freq_constraints constraints; > struct freq_qos_request *min_freq_req; > struct freq_qos_request *max_freq_req; > + struct freq_qos_request *boost_freq_req; > > struct cpufreq_frequency_table *freq_table; > enum cpufreq_table_sorting freq_table_sorted; -- Thx and BRs, Zhongqiu Han