From nobody Mon Jun 8 15:38:17 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CD7853B47D7; Thu, 28 May 2026 09:09:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779959400; cv=none; b=BDq9POak8UyG7BePOew9/ySz1FMrMjiGqm+FmD18wK3Om/fE4vRoFrwn0Ylp17M8MvdF6K2Vg8TpG21q9BEMUbzxkrg9vF0I8eM7mIx+ojbkvn+pibJuSRu9rC3m/12liu7YK0gqomGHkxA8XMGAssW3qxwT0eJWS4Pr3WEZv6U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779959400; c=relaxed/simple; bh=OrIbLK4EvKzZg2CobVMv3AVJGKbR0lNlgy5pTXO+xRI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XHXxSR5CND3R0sttWQZbAbv2pW6gLFB4jtTpgkNLJZU1z1H59WKVr6OHnBYYHQ8LLcgnVaX7IGiXZ4HWKPQFhLPWVt8ztAiTaoaRdpt5PL7d3vCZ4uFXixE7W8dUHip3ufNFthpAvmSzMnSbXEOKrT1xipQGPkrkJLGa5j/ITeU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=VZNjgRY7; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="VZNjgRY7" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1D3404402; Thu, 28 May 2026 02:09:52 -0700 (PDT) Received: from e135073.arm.com (unknown [10.57.24.196]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B96FD3F632; Thu, 28 May 2026 02:09:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1779959397; bh=OrIbLK4EvKzZg2CobVMv3AVJGKbR0lNlgy5pTXO+xRI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VZNjgRY7SGSkq95nHN0iz9nMQV05DAXBGFJDq5LRKX3YYHo9jWlpekB02ia5aDiqM g3FjKoFSHCOAFrhD7oAXX5kCpkk0wEqKTF196M+iCbaMvsLJFIXOdTUJNhgkyHT+Yh gO1PBQDdz4VkyLi3i0ZbdTpADPCdtv5UqI6Lgn38= From: Pierre Gondois To: linux-kernel@vger.kernel.org Cc: Jie Zhan , Lifeng Zheng , Ionela Voinescu , Sumit Gupta , Zhongqiu Han , Pierre Gondois , "Rafael J. Wysocki" , Viresh Kumar , Jonathan Corbet , Shuah Khan , Huang Rui , Mario Limonciello , Perry Yuan , K Prateek Nayak , Srinivas Pandruvada , Len Brown , Saravana Kannan , linux-pm@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v3 1/4] cpufreq: Extract cpufreq_policy_init_qos() function Date: Thu, 28 May 2026 11:09:03 +0200 Message-ID: <20260528090913.2759118-2-pierre.gondois@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260528090913.2759118-1-pierre.gondois@arm.com> References: <20260528090913.2759118-1-pierre.gondois@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Extract the QoS related logic from cpufreq_policy_online() to make the function shorter/simpler. The logic is placed in cpufreq_policy_init_qos() and is now executed right after the following calls: - cpufreq_driver->init() - cpufreq_table_validate_and_sort() This helps preparing following patches that will, in cpufreq_policy_init_qos(): - treat the policy->min/max values set by drivers as QoS requests. - set a default policy->min/max value to all policies. No functional change. Signed-off-by: Pierre Gondois Reviewed-by: Zhongqiu Han Reviewed-by: Jie Zhan Acked-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 53 +++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 44eb1b7e7fc1b..50616cfebc617 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1397,6 +1397,32 @@ static void cpufreq_policy_free(struct cpufreq_polic= y *policy) kfree(policy); } =20 +static int cpufreq_policy_init_qos(struct cpufreq_policy *policy) +{ + int ret; + + if (policy->boost_supported) { + ret =3D freq_qos_add_request(&policy->constraints, + &policy->boost_freq_req, + FREQ_QOS_MAX, + policy->cpuinfo.max_freq); + if (ret < 0) + return ret; + } + + ret =3D freq_qos_add_request(&policy->constraints, &policy->min_freq_req, + FREQ_QOS_MIN, FREQ_QOS_MIN_DEFAULT_VALUE); + if (ret < 0) + return ret; + + ret =3D freq_qos_add_request(&policy->constraints, &policy->max_freq_req, + FREQ_QOS_MAX, FREQ_QOS_MAX_DEFAULT_VALUE); + if (ret < 0) + return ret; + + return 0; +} + static int cpufreq_policy_online(struct cpufreq_policy *policy, unsigned int cpu, bool new_policy) { @@ -1442,6 +1468,12 @@ static int cpufreq_policy_online(struct cpufreq_poli= cy *policy, if (ret) goto out_offline_policy; =20 + if (new_policy) { + ret =3D cpufreq_policy_init_qos(policy); + if (ret < 0) + goto out_offline_policy; + } + /* related_cpus should at least include policy->cpus. */ cpumask_copy(policy->related_cpus, policy->cpus); } @@ -1458,27 +1490,6 @@ static int cpufreq_policy_online(struct cpufreq_poli= cy *policy, add_cpu_dev_symlink(policy, j, get_cpu_device(j)); } =20 - if (policy->boost_supported) { - ret =3D freq_qos_add_request(&policy->constraints, - &policy->boost_freq_req, - FREQ_QOS_MAX, - policy->cpuinfo.max_freq); - if (ret < 0) - goto out_destroy_policy; - } - - ret =3D freq_qos_add_request(&policy->constraints, - &policy->min_freq_req, FREQ_QOS_MIN, - FREQ_QOS_MIN_DEFAULT_VALUE); - if (ret < 0) - goto out_destroy_policy; - - ret =3D freq_qos_add_request(&policy->constraints, - &policy->max_freq_req, FREQ_QOS_MAX, - FREQ_QOS_MAX_DEFAULT_VALUE); - if (ret < 0) - goto out_destroy_policy; - blocking_notifier_call_chain(&cpufreq_policy_notifier_list, CPUFREQ_CREATE_POLICY, policy); } --=20 2.43.0 From nobody Mon Jun 8 15:38:17 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5A6CA3B9DAD; Thu, 28 May 2026 09:10:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779959405; cv=none; b=Dh5Ss9tcidp9FBAVv0UWl99rzGgfdHQP0pCxw3CWrb0MkGX7qgwIZcauzNjwpB12R9j6jR8JAYXuxomuwpwhKS5uCJC1UtrGZZs3jlAfz5WVhOWnlfsFhdNeXf7FVWblim/9yA5ICWTx/gsO3su7J+HxQR6mI9KLeGK1ydPQXCY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779959405; c=relaxed/simple; bh=vgB+WvFX2P24NmpAuw+DDNfAp8EJaXmIPGpOeG6sTnE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f5gqDa1BcsTPm62sRqfzySLfM3mQpMHEl/j6d22Uq/Yrr/NfRhKHxX20weMF8RoPY/UtKuAGCyW/ynuqtxP6Yd0DY2+jvO++oQ+WDuha3pq1lZewMiHVQFWDpgSQaZApHeXLxUq1Ebsps+4duX9G3hn0jTBvQEMnh5ZQxS215NU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=ngtq21Fz; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="ngtq21Fz" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6A7ED4403; Thu, 28 May 2026 02:09:57 -0700 (PDT) Received: from e135073.arm.com (unknown [10.57.24.196]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 829813F632; Thu, 28 May 2026 02:09:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1779959402; bh=vgB+WvFX2P24NmpAuw+DDNfAp8EJaXmIPGpOeG6sTnE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ngtq21Fz36O5E0qtdyzxOk3+3HreR0rb+CwjClnPd2cuy51iqYM72w227vZkJehLw o5jT9QvWVxzyoGy+CFNIOiVFRPR5ImT4+tFOMShRO7kTCoWT+vYIX5xa50P0uqW+aM 7ZZa5BHV039/MdprVXOmxhg5UaZQwjCdkK19rcMc= From: Pierre Gondois To: linux-kernel@vger.kernel.org Cc: Jie Zhan , Lifeng Zheng , Ionela Voinescu , Sumit Gupta , Zhongqiu Han , Pierre Gondois , "Rafael J. Wysocki" , Viresh Kumar , Jonathan Corbet , Shuah Khan , Huang Rui , Mario Limonciello , Perry Yuan , K Prateek Nayak , Srinivas Pandruvada , Len Brown , Saravana Kannan , linux-pm@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v3 2/4] cpufreq: Set default policy->min/max values for all drivers Date: Thu, 28 May 2026 11:09:04 +0200 Message-ID: <20260528090913.2759118-3-pierre.gondois@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260528090913.2759118-1-pierre.gondois@arm.com> References: <20260528090913.2759118-1-pierre.gondois@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Some drivers set policy->min/max in their .init() callback. cpufreq_set_policy() will ultimately override them through: cpufreq_policy_online() \-cpufreq_init_policy() \-cpufreq_set_policy() \-/* Set policy->min/max */ Thus the policy min/max values provided are only temporary. There is an exception if CPUFREQ_NEED_INITIAL_FREQ_CHECK is set and: cpufreq_policy_online() \-__cpufreq_driver_target() \-cpufreq_driver->target() To prepare for a following patch that will remove all policy->min/max initialization in the driver .init() callback if the min/max value is equal to the cpuinfo.min/max_freq, set a default policy->min/max value for all drivers. Signed-off-by: Pierre Gondois Reviewed-by: Jie Zhan Acked-by: Viresh Kumar Reviewed-by: Zhongqiu Han --- drivers/cpufreq/cpufreq.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 50616cfebc617..d75c6739aa780 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1474,6 +1474,13 @@ static int cpufreq_policy_online(struct cpufreq_poli= cy *policy, goto out_offline_policy; } =20 + /* + * If the driver didn't set policy->min/max, set them as + * they are used to clamp frequency requests. + */ + policy->min =3D policy->min ? policy->min : policy->cpuinfo.min_freq; + policy->max =3D policy->max ? policy->max : policy->cpuinfo.max_freq; + /* related_cpus should at least include policy->cpus. */ cpumask_copy(policy->related_cpus, policy->cpus); } --=20 2.43.0 From nobody Mon Jun 8 15:38:17 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0937D3AA1B8; Thu, 28 May 2026 09:10:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779959410; cv=none; b=XuZGV4qUIwjwrSXE9Z052mfPWywE1W9aBM9egy28XOljL6fmPuEwNJ0VmPSd0aHaMfcXD9SrPwmwLmr1TzoU5T6jBczxNJffPMTGQCNrhQoUeIbdQD8+xCtvJ6dwIqm0Xks6BMp2twt8zwt38pQ2JpHOhYHXamBC0faQzOzAChY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779959410; c=relaxed/simple; bh=K3NSarPzrjjV70TzFS7POKTnzVvo0TcvGwH8BUzBKUI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YQ4svQ/XwoA/Hsyu95drWsHoXuMsqbmnzAGIUpVwirCjyhY12tEYR71nhM/2Gpx/3mG2Gl2FLAFAfv6dL8LQEYfC+UuWFAN1Lx8uFItIQPnXpZXLGmyQUR5E7oCk/KpP7eDakusYthwr11B97IiNNTlzWBEcZbCjOOAVWg2H1yo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=XN1DsYaF; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="XN1DsYaF" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E92AE4419; Thu, 28 May 2026 02:10:02 -0700 (PDT) Received: from e135073.arm.com (unknown [10.57.24.196]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E13CC3F632; Thu, 28 May 2026 02:10:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1779959407; bh=K3NSarPzrjjV70TzFS7POKTnzVvo0TcvGwH8BUzBKUI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XN1DsYaFIuFgtaW0yc7Af+zlk86bKucCYZw4sFTdZwQuHJqUPh/OISlJOo4Rj5QJD TLYu0p3jCZFPD4AY9cm8fZUO0t+xxR1p4UK4FS3hwRkJyTG7EQEvZREt6rs5mly2i9 juZN22wbf93G7aHHBZZZCU7t3mQ1ZsCZGNYiwC7s= From: Pierre Gondois To: linux-kernel@vger.kernel.org Cc: Jie Zhan , Lifeng Zheng , Ionela Voinescu , Sumit Gupta , Zhongqiu Han , Pierre Gondois , "Rafael J. Wysocki" , Viresh Kumar , Jonathan Corbet , Shuah Khan , Huang Rui , Mario Limonciello , Perry Yuan , K Prateek Nayak , Srinivas Pandruvada , Len Brown , Saravana Kannan , linux-pm@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v3 3/4] cpufreq: Remove driver default policy->min/max init Date: Thu, 28 May 2026 11:09:05 +0200 Message-ID: <20260528090913.2759118-4-pierre.gondois@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260528090913.2759118-1-pierre.gondois@arm.com> References: <20260528090913.2759118-1-pierre.gondois@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Prior to [1], drivers were setting policy->min/max and the value was used as a QoS constraint. After that change, the values were only temporarily used: cpufreq_set_policy() ultimately overriding them through: cpufreq_policy_online() \-cpufreq_init_policy() \-cpufreq_set_policy() \-/* Set policy->min/max */ This patch reinstate the initial behaviour. This will allow drivers to request min/max QoS frequencies if desired. For instance, the cppc driver advertises a lowest non-linear frequency, which should be used as a min QoS value. To avoid having drivers setting policy->min/max to default values which are considered as QoS values (i.e. the reason why [1] was introduced), remove the initialization of policy->min/max in .init() callbacks wherever the policy->min/max values are identical to the policy->cpuinfo.min/max_freq. Indeed, the previous patch ("cpufreq: Set default policy->min/max values for all drivers") makes this initialization redundant. The only drivers where these values are different are: - gx-suspmod.c (min) - cppc-cpufreq.c (min) - longrun.c [1] commit 521223d8b3ec ("cpufreq: Fix initialization of min and max frequency QoS requests") Signed-off-by: Pierre Gondois Acked-by: Jie Zhan Acked-by: Viresh Kumar Reviewed-by: Zhongqiu Han --- drivers/cpufreq/amd-pstate.c | 14 ++++++-------- drivers/cpufreq/cppc_cpufreq.c | 5 ++--- drivers/cpufreq/cpufreq-nforce2.c | 4 ++-- drivers/cpufreq/freq_table.c | 7 +++---- drivers/cpufreq/gx-suspmod.c | 2 +- drivers/cpufreq/intel_pstate.c | 3 --- drivers/cpufreq/pcc-cpufreq.c | 10 ++++------ drivers/cpufreq/pxa3xx-cpufreq.c | 5 ++--- drivers/cpufreq/sh-cpufreq.c | 6 ++---- drivers/cpufreq/virtual-cpufreq.c | 5 +---- 10 files changed, 23 insertions(+), 38 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 62b5d995281d2..2f0bb732ea173 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -1086,10 +1086,9 @@ static int amd_pstate_cpu_init(struct cpufreq_policy= *policy) =20 perf =3D READ_ONCE(cpudata->perf); =20 - policy->cpuinfo.min_freq =3D policy->min =3D perf_to_freq(perf, - cpudata->nominal_freq, - perf.lowest_perf); - policy->cpuinfo.max_freq =3D policy->max =3D cpudata->max_freq; + policy->cpuinfo.min_freq =3D perf_to_freq(perf, cpudata->nominal_freq, + perf.lowest_perf); + policy->cpuinfo.max_freq =3D cpudata->max_freq; =20 policy->driver_data =3D cpudata; ret =3D amd_pstate_cppc_enable(policy); @@ -1915,10 +1914,9 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_po= licy *policy) =20 perf =3D READ_ONCE(cpudata->perf); =20 - policy->cpuinfo.min_freq =3D policy->min =3D perf_to_freq(perf, - cpudata->nominal_freq, - perf.lowest_perf); - policy->cpuinfo.max_freq =3D policy->max =3D cpudata->max_freq; + policy->cpuinfo.min_freq =3D perf_to_freq(perf, cpudata->nominal_freq, + perf.lowest_perf); + policy->cpuinfo.max_freq =3D cpudata->max_freq; policy->driver_data =3D cpudata; =20 ret =3D amd_pstate_cppc_enable(policy); diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c index 7e7f9dfb7a24c..5abac50df7508 100644 --- a/drivers/cpufreq/cppc_cpufreq.c +++ b/drivers/cpufreq/cppc_cpufreq.c @@ -660,8 +660,6 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy = *policy) * Section 8.4.7.1.1.5 of ACPI 6.1 spec) */ policy->min =3D cppc_perf_to_khz(caps, caps->lowest_nonlinear_perf); - policy->max =3D cppc_perf_to_khz(caps, policy->boost_enabled ? - caps->highest_perf : caps->nominal_perf); =20 /* * Set cpuinfo.min_freq to Lowest to make the full range of performance @@ -669,7 +667,8 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy = *policy) * nonlinear perf */ policy->cpuinfo.min_freq =3D cppc_perf_to_khz(caps, caps->lowest_perf); - policy->cpuinfo.max_freq =3D policy->max; + policy->cpuinfo.max_freq =3D cppc_perf_to_khz(caps, policy->boost_enabled= ? + caps->highest_perf : caps->nominal_perf); =20 policy->transition_delay_us =3D cppc_cpufreq_get_transition_delay_us(cpu); policy->shared_type =3D cpu_data->shared_type; diff --git a/drivers/cpufreq/cpufreq-nforce2.c b/drivers/cpufreq/cpufreq-nf= orce2.c index fbbbe501cf2dc..831102522ad64 100644 --- a/drivers/cpufreq/cpufreq-nforce2.c +++ b/drivers/cpufreq/cpufreq-nforce2.c @@ -355,8 +355,8 @@ static int nforce2_cpu_init(struct cpufreq_policy *poli= cy) min_fsb =3D NFORCE2_MIN_FSB; =20 /* cpuinfo and default policy values */ - policy->min =3D policy->cpuinfo.min_freq =3D min_fsb * fid * 100; - policy->max =3D policy->cpuinfo.max_freq =3D max_fsb * fid * 100; + policy->cpuinfo.min_freq =3D min_fsb * fid * 100; + policy->cpuinfo.max_freq =3D max_fsb * fid * 100; =20 return 0; } diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c index 5b364d8da4f92..ea994647abc88 100644 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c @@ -49,16 +49,15 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_poli= cy *policy) max_freq =3D freq; } =20 - policy->min =3D policy->cpuinfo.min_freq =3D min_freq; - policy->max =3D max_freq; + policy->cpuinfo.min_freq =3D min_freq; /* * If the driver has set its own cpuinfo.max_freq above max_freq, leave * it as is. */ if (policy->cpuinfo.max_freq < max_freq) - policy->max =3D policy->cpuinfo.max_freq =3D max_freq; + policy->cpuinfo.max_freq =3D max_freq; =20 - if (policy->min =3D=3D ~0) + if (min_freq =3D=3D ~0) return -EINVAL; else return 0; diff --git a/drivers/cpufreq/gx-suspmod.c b/drivers/cpufreq/gx-suspmod.c index d269a4f26f98e..d40c9e0bbb740 100644 --- a/drivers/cpufreq/gx-suspmod.c +++ b/drivers/cpufreq/gx-suspmod.c @@ -421,7 +421,7 @@ static int cpufreq_gx_cpu_init(struct cpufreq_policy *p= olicy) policy->min =3D maxfreq / max_duration; else policy->min =3D maxfreq / POLICY_MIN_DIV; - policy->max =3D maxfreq; + policy->cpuinfo.min_freq =3D maxfreq / max_duration; policy->cpuinfo.max_freq =3D maxfreq; =20 diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 1f093e3464301..dfc1e321f9e02 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -3049,9 +3049,6 @@ static int __intel_pstate_cpu_init(struct cpufreq_pol= icy *policy) policy->cpuinfo.max_freq =3D READ_ONCE(global.no_turbo) ? cpu->pstate.max_freq : cpu->pstate.turbo_freq; =20 - policy->min =3D policy->cpuinfo.min_freq; - policy->max =3D policy->cpuinfo.max_freq; - intel_pstate_init_acpi_perf_limits(policy); =20 policy->fast_switch_possible =3D true; diff --git a/drivers/cpufreq/pcc-cpufreq.c b/drivers/cpufreq/pcc-cpufreq.c index ac2e90a65f0c4..0f185a13577f8 100644 --- a/drivers/cpufreq/pcc-cpufreq.c +++ b/drivers/cpufreq/pcc-cpufreq.c @@ -551,13 +551,11 @@ static int pcc_cpufreq_cpu_init(struct cpufreq_policy= *policy) goto out; } =20 - policy->max =3D policy->cpuinfo.max_freq =3D - ioread32(&pcch_hdr->nominal) * 1000; - policy->min =3D policy->cpuinfo.min_freq =3D - ioread32(&pcch_hdr->minimum_frequency) * 1000; + policy->cpuinfo.max_freq =3D ioread32(&pcch_hdr->nominal) * 1000; + policy->cpuinfo.min_freq =3D ioread32(&pcch_hdr->minimum_frequency) * 100= 0; =20 - pr_debug("init: policy->max is %d, policy->min is %d\n", - policy->max, policy->min); + pr_debug("init: max_freq is %d, min_freq is %d\n", + policy->cpuinfo.max_freq, policy->cpuinfo.min_freq); out: return result; } diff --git a/drivers/cpufreq/pxa3xx-cpufreq.c b/drivers/cpufreq/pxa3xx-cpuf= req.c index 50ff3b6a69000..06b27cbc59d6a 100644 --- a/drivers/cpufreq/pxa3xx-cpufreq.c +++ b/drivers/cpufreq/pxa3xx-cpufreq.c @@ -185,9 +185,8 @@ static int pxa3xx_cpufreq_init(struct cpufreq_policy *p= olicy) int ret =3D -EINVAL; =20 /* set default policy and cpuinfo */ - policy->min =3D policy->cpuinfo.min_freq =3D 104000; - policy->max =3D policy->cpuinfo.max_freq =3D - (cpu_is_pxa320()) ? 806000 : 624000; + policy->cpuinfo.min_freq =3D 104000; + policy->cpuinfo.max_freq =3D (cpu_is_pxa320()) ? 806000 : 624000; policy->cpuinfo.transition_latency =3D 1000; /* FIXME: 1 ms, assumed */ =20 if (cpu_is_pxa300() || cpu_is_pxa310()) diff --git a/drivers/cpufreq/sh-cpufreq.c b/drivers/cpufreq/sh-cpufreq.c index 642ddb9ea217e..3c99d7009cbe2 100644 --- a/drivers/cpufreq/sh-cpufreq.c +++ b/drivers/cpufreq/sh-cpufreq.c @@ -124,10 +124,8 @@ static int sh_cpufreq_cpu_init(struct cpufreq_policy *= policy) dev_notice(dev, "no frequency table found, falling back " "to rate rounding.\n"); =20 - policy->min =3D policy->cpuinfo.min_freq =3D - (clk_round_rate(cpuclk, 1) + 500) / 1000; - policy->max =3D policy->cpuinfo.max_freq =3D - (clk_round_rate(cpuclk, ~0UL) + 500) / 1000; + policy->cpuinfo.min_freq =3D (clk_round_rate(cpuclk, 1) + 500) / 1000; + policy->cpuinfo.max_freq =3D (clk_round_rate(cpuclk, ~0UL) + 500) / 1000; } =20 return 0; diff --git a/drivers/cpufreq/virtual-cpufreq.c b/drivers/cpufreq/virtual-cp= ufreq.c index 4159f31349b16..dc78b74409af4 100644 --- a/drivers/cpufreq/virtual-cpufreq.c +++ b/drivers/cpufreq/virtual-cpufreq.c @@ -164,10 +164,7 @@ static int virt_cpufreq_get_freq_info(struct cpufreq_p= olicy *policy) policy->cpuinfo.min_freq =3D 1; policy->cpuinfo.max_freq =3D virt_cpufreq_get_perftbl_entry(policy->cpu,= 0); =20 - policy->min =3D policy->cpuinfo.min_freq; - policy->max =3D policy->cpuinfo.max_freq; - - policy->cur =3D policy->max; + policy->cur =3D policy->cpuinfo.max_freq; return 0; } =20 --=20 2.43.0 From nobody Mon Jun 8 15:38:17 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 33C903AB274; Thu, 28 May 2026 09:10:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779959415; cv=none; b=oAkPRFR9i8Jdk8ihle7v7kbvFWjKWAFcz1VsPVdWrM+7X3dJWhVRD2RD5yLsUy7W9Ab8tP9qxtkNk1nSJaRYhvxmApwJxgWnm+wFTnfmOX2GPeLBsUSdeQahGTK7M+pRM/NL1YX+cbfENNTxGhTgka4P3kQcyP6wGYtU9l8eld4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779959415; c=relaxed/simple; bh=r3/vjATgWEGj2o9tOCXkkVyPIqLlGthQcOjtR8FaSiM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lVoOX9nQb5W3+L0pt76kYOVFhYth3gMUXS4SNSO9iqfo5mCzO64oP163TcXXTkZNnL0c0JEpj/vT6KbWs9cUAClW0qqdAkBuXM+iD6t74IxfnLFsbDpiYCPxnmfld9qj644Q8Hw5RtSkL936SHLsdx73K8631wDyIenEC/cOyRQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=hgazRG0H; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="hgazRG0H" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 841394403; Thu, 28 May 2026 02:10:08 -0700 (PDT) Received: from e135073.arm.com (unknown [10.57.24.196]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 860523F632; Thu, 28 May 2026 02:10:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1779959413; bh=r3/vjATgWEGj2o9tOCXkkVyPIqLlGthQcOjtR8FaSiM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hgazRG0HyEBEPtlFjrSSpaMRCWY/ECmc7Stsh41Yg9FCvFoxQbJQ1CkNZIaTrx+cz ohA2zVRzyNo8lZ0CP2kSF1bUtjwopFUBSZ3wD/AO4g2nacElQRRgkEfSvmtupuw6nH XMIg28sQPVwJOCdCoaOD22vAk0aZgpWxg/LaWSOw= From: Pierre Gondois To: linux-kernel@vger.kernel.org Cc: Jie Zhan , Lifeng Zheng , Ionela Voinescu , Sumit Gupta , Zhongqiu Han , Pierre Gondois , "Rafael J. Wysocki" , Viresh Kumar , Jonathan Corbet , Shuah Khan , Huang Rui , Mario Limonciello , Perry Yuan , K Prateek Nayak , Srinivas Pandruvada , Len Brown , Saravana Kannan , linux-pm@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v3 4/4] cpufreq: Use policy->min/max init as QoS request Date: Thu, 28 May 2026 11:09:06 +0200 Message-ID: <20260528090913.2759118-5-pierre.gondois@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260528090913.2759118-1-pierre.gondois@arm.com> References: <20260528090913.2759118-1-pierre.gondois@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Consider policy->min/max being set in the driver .init() callback as a QoS request. Impacted driver are: - gx-suspmod.c (min) - cppc-cpufreq.c (min) - longrun.c (min/max) Update the documentation accordingly. Signed-off-by: Pierre Gondois Acked-by: Viresh Kumar Reviewed-by: Zhongqiu Han --- Documentation/cpu-freq/cpu-drivers.rst | 9 +++++++-- drivers/cpufreq/cpufreq.c | 12 ++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Documentation/cpu-freq/cpu-drivers.rst b/Documentation/cpu-fre= q/cpu-drivers.rst index c5635ac3de547..95e4c513c4533 100644 --- a/Documentation/cpu-freq/cpu-drivers.rst +++ b/Documentation/cpu-freq/cpu-drivers.rst @@ -114,8 +114,13 @@ Then, the driver must fill in the following values: |policy->cur | The current operating frequency of | | | this CPU (if appropriate) | +-----------------------------------+-------------------------------------= -+ -|policy->min, | | -|policy->max, | | +|policy->min, | The min/max scaling frequency. | +|policy->max | If set by the driver in ->init(), | +| | used as initial min/max frequency | +| | QoS request; otherwise, follow | +| | the min/max allowed frequency | +| | the cpufreq driver can set. | ++-----------------------------------+-------------------------------------= -+ |policy->policy and, if necessary, | | |policy->governor | must contain the "default policy" for| | | this CPU. A few moments later, | diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index d75c6739aa780..759e85bf4ba17 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1399,8 +1399,16 @@ static void cpufreq_policy_free(struct cpufreq_polic= y *policy) =20 static int cpufreq_policy_init_qos(struct cpufreq_policy *policy) { + unsigned int min_freq, max_freq; int ret; =20 + /* Use policy->min/max set by the driver as QoS requests. */ + min_freq =3D max(FREQ_QOS_MIN_DEFAULT_VALUE, policy->min); + if (policy->max) + max_freq =3D min(FREQ_QOS_MAX_DEFAULT_VALUE, policy->max); + else + max_freq =3D FREQ_QOS_MAX_DEFAULT_VALUE; + if (policy->boost_supported) { ret =3D freq_qos_add_request(&policy->constraints, &policy->boost_freq_req, @@ -1411,12 +1419,12 @@ static int cpufreq_policy_init_qos(struct cpufreq_p= olicy *policy) } =20 ret =3D freq_qos_add_request(&policy->constraints, &policy->min_freq_req, - FREQ_QOS_MIN, FREQ_QOS_MIN_DEFAULT_VALUE); + FREQ_QOS_MIN, min_freq); if (ret < 0) return ret; =20 ret =3D freq_qos_add_request(&policy->constraints, &policy->max_freq_req, - FREQ_QOS_MAX, FREQ_QOS_MAX_DEFAULT_VALUE); + FREQ_QOS_MAX, max_freq); if (ret < 0) return ret; =20 --=20 2.43.0