* [PATCH] cpufreq: amd-pstate: Allow users to write 'default' EPP string
@ 2024-06-12 14:57 Mario Limonciello
2024-06-12 15:03 ` Artem S. Tashkinov
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Mario Limonciello @ 2024-06-12 14:57 UTC (permalink / raw)
To: Gautham R . Shenoy
Cc: Perry Yuan, linux-pm, Mario Limonciello, Artem S . Tashkinov
The EPP string for 'default' represents what the firmware had configured
as the default EPP value but once a user changes EPP to another string
they can't reset it back to 'default'.
Cache the firmware EPP value and allow the user to write 'default' using
this value.
Reported-by: Artem S. Tashkinov <aros@gmx.com>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217931#c61
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/cpufreq/amd-pstate.c | 8 +++-----
drivers/cpufreq/amd-pstate.h | 1 +
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index fda8f86c90e0..5bdcdd3ea163 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -282,10 +282,8 @@ static int amd_pstate_set_energy_pref_index(struct amd_cpudata *cpudata,
int epp = -EINVAL;
int ret;
- if (!pref_index) {
- pr_debug("EPP pref_index is invalid\n");
- return -EINVAL;
- }
+ if (!pref_index)
+ epp = cpudata->epp_default;
if (epp == -EINVAL)
epp = epp_values[pref_index];
@@ -1441,7 +1439,7 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
policy->driver_data = cpudata;
- cpudata->epp_cached = amd_pstate_get_epp(cpudata, 0);
+ cpudata->epp_cached = cpudata->epp_default = amd_pstate_get_epp(cpudata, 0);
policy->min = policy->cpuinfo.min_freq;
policy->max = policy->cpuinfo.max_freq;
diff --git a/drivers/cpufreq/amd-pstate.h b/drivers/cpufreq/amd-pstate.h
index e6a28e7f4dbf..f80b33fa5d43 100644
--- a/drivers/cpufreq/amd-pstate.h
+++ b/drivers/cpufreq/amd-pstate.h
@@ -99,6 +99,7 @@ struct amd_cpudata {
u32 policy;
u64 cppc_cap1_cached;
bool suspended;
+ s16 epp_default;
};
#endif /* _LINUX_AMD_PSTATE_H */
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] cpufreq: amd-pstate: Allow users to write 'default' EPP string
2024-06-12 14:57 [PATCH] cpufreq: amd-pstate: Allow users to write 'default' EPP string Mario Limonciello
@ 2024-06-12 15:03 ` Artem S. Tashkinov
2024-06-13 9:21 ` Yuan, Perry
2024-06-21 8:43 ` Gautham R.Shenoy
2 siblings, 0 replies; 4+ messages in thread
From: Artem S. Tashkinov @ 2024-06-12 15:03 UTC (permalink / raw)
To: linux-pm
That was blazing fast.
Thanks a ton!
On 6/12/24 2:57 PM, Mario Limonciello wrote:
> The EPP string for 'default' represents what the firmware had configured
> as the default EPP value but once a user changes EPP to another string
> they can't reset it back to 'default'.
>
> Cache the firmware EPP value and allow the user to write 'default' using
> this value.
>
> Reported-by: Artem S. Tashkinov <aros@gmx.com>
> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217931#c61
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> drivers/cpufreq/amd-pstate.c | 8 +++-----
> drivers/cpufreq/amd-pstate.h | 1 +
> 2 files changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index fda8f86c90e0..5bdcdd3ea163 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -282,10 +282,8 @@ static int amd_pstate_set_energy_pref_index(struct amd_cpudata *cpudata,
> int epp = -EINVAL;
> int ret;
>
> - if (!pref_index) {
> - pr_debug("EPP pref_index is invalid\n");
> - return -EINVAL;
> - }
> + if (!pref_index)
> + epp = cpudata->epp_default;
>
> if (epp == -EINVAL)
> epp = epp_values[pref_index];
> @@ -1441,7 +1439,7 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
>
> policy->driver_data = cpudata;
>
> - cpudata->epp_cached = amd_pstate_get_epp(cpudata, 0);
> + cpudata->epp_cached = cpudata->epp_default = amd_pstate_get_epp(cpudata, 0);
>
> policy->min = policy->cpuinfo.min_freq;
> policy->max = policy->cpuinfo.max_freq;
> diff --git a/drivers/cpufreq/amd-pstate.h b/drivers/cpufreq/amd-pstate.h
> index e6a28e7f4dbf..f80b33fa5d43 100644
> --- a/drivers/cpufreq/amd-pstate.h
> +++ b/drivers/cpufreq/amd-pstate.h
> @@ -99,6 +99,7 @@ struct amd_cpudata {
> u32 policy;
> u64 cppc_cap1_cached;
> bool suspended;
> + s16 epp_default;
> };
>
> #endif /* _LINUX_AMD_PSTATE_H */
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH] cpufreq: amd-pstate: Allow users to write 'default' EPP string
2024-06-12 14:57 [PATCH] cpufreq: amd-pstate: Allow users to write 'default' EPP string Mario Limonciello
2024-06-12 15:03 ` Artem S. Tashkinov
@ 2024-06-13 9:21 ` Yuan, Perry
2024-06-21 8:43 ` Gautham R.Shenoy
2 siblings, 0 replies; 4+ messages in thread
From: Yuan, Perry @ 2024-06-13 9:21 UTC (permalink / raw)
To: Limonciello, Mario, Shenoy, Gautham Ranjal
Cc: linux-pm@vger.kernel.org, Artem S . Tashkinov
[AMD Official Use Only - AMD Internal Distribution Only]
> -----Original Message-----
> From: Limonciello, Mario <Mario.Limonciello@amd.com>
> Sent: Wednesday, June 12, 2024 10:58 PM
> To: Shenoy, Gautham Ranjal <gautham.shenoy@amd.com>
> Cc: Yuan, Perry <Perry.Yuan@amd.com>; linux-pm@vger.kernel.org;
> Limonciello, Mario <Mario.Limonciello@amd.com>; Artem S . Tashkinov
> <aros@gmx.com>
> Subject: [PATCH] cpufreq: amd-pstate: Allow users to write 'default' EPP
> string
>
> The EPP string for 'default' represents what the firmware had configured as
> the default EPP value but once a user changes EPP to another string they
> can't reset it back to 'default'.
>
> Cache the firmware EPP value and allow the user to write 'default' using this
> value.
>
> Reported-by: Artem S. Tashkinov <aros@gmx.com>
> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217931#c61
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> drivers/cpufreq/amd-pstate.c | 8 +++----- drivers/cpufreq/amd-pstate.h | 1
> +
> 2 files changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index fda8f86c90e0..5bdcdd3ea163 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -282,10 +282,8 @@ static int amd_pstate_set_energy_pref_index(struct
> amd_cpudata *cpudata,
> int epp = -EINVAL;
> int ret;
>
> - if (!pref_index) {
> - pr_debug("EPP pref_index is invalid\n");
> - return -EINVAL;
> - }
> + if (!pref_index)
> + epp = cpudata->epp_default;
>
> if (epp == -EINVAL)
> epp = epp_values[pref_index];
> @@ -1441,7 +1439,7 @@ static int amd_pstate_epp_cpu_init(struct
> cpufreq_policy *policy)
>
> policy->driver_data = cpudata;
>
> - cpudata->epp_cached = amd_pstate_get_epp(cpudata, 0);
> + cpudata->epp_cached = cpudata->epp_default =
> +amd_pstate_get_epp(cpudata, 0);
>
> policy->min = policy->cpuinfo.min_freq;
> policy->max = policy->cpuinfo.max_freq; diff --git
> a/drivers/cpufreq/amd-pstate.h b/drivers/cpufreq/amd-pstate.h index
> e6a28e7f4dbf..f80b33fa5d43 100644
> --- a/drivers/cpufreq/amd-pstate.h
> +++ b/drivers/cpufreq/amd-pstate.h
> @@ -99,6 +99,7 @@ struct amd_cpudata {
> u32 policy;
> u64 cppc_cap1_cached;
> bool suspended;
> + s16 epp_default;
> };
>
> #endif /* _LINUX_AMD_PSTATE_H */
> --
> 2.43.0
LGTM,thanks.
Reviewed-by: Perry Yuan <perry.yuan@amd.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] cpufreq: amd-pstate: Allow users to write 'default' EPP string
2024-06-12 14:57 [PATCH] cpufreq: amd-pstate: Allow users to write 'default' EPP string Mario Limonciello
2024-06-12 15:03 ` Artem S. Tashkinov
2024-06-13 9:21 ` Yuan, Perry
@ 2024-06-21 8:43 ` Gautham R.Shenoy
2 siblings, 0 replies; 4+ messages in thread
From: Gautham R.Shenoy @ 2024-06-21 8:43 UTC (permalink / raw)
To: Mario Limonciello
Cc: Perry Yuan, linux-pm, Mario Limonciello, Artem S . Tashkinov
Mario Limonciello <mario.limonciello@amd.com> writes:
> The EPP string for 'default' represents what the firmware had configured
> as the default EPP value but once a user changes EPP to another string
> they can't reset it back to 'default'.
>
> Cache the firmware EPP value and allow the user to write 'default' using
> this value.
>
> Reported-by: Artem S. Tashkinov <aros@gmx.com>
> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217931#c61
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
> ---
> drivers/cpufreq/amd-pstate.c | 8 +++-----
> drivers/cpufreq/amd-pstate.h | 1 +
> 2 files changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index fda8f86c90e0..5bdcdd3ea163 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -282,10 +282,8 @@ static int amd_pstate_set_energy_pref_index(struct amd_cpudata *cpudata,
> int epp = -EINVAL;
> int ret;
>
> - if (!pref_index) {
> - pr_debug("EPP pref_index is invalid\n");
> - return -EINVAL;
> - }
> + if (!pref_index)
> + epp = cpudata->epp_default;
>
> if (epp == -EINVAL)
> epp = epp_values[pref_index];
> @@ -1441,7 +1439,7 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
>
> policy->driver_data = cpudata;
>
> - cpudata->epp_cached = amd_pstate_get_epp(cpudata, 0);
> + cpudata->epp_cached = cpudata->epp_default = amd_pstate_get_epp(cpudata, 0);
>
> policy->min = policy->cpuinfo.min_freq;
> policy->max = policy->cpuinfo.max_freq;
> diff --git a/drivers/cpufreq/amd-pstate.h b/drivers/cpufreq/amd-pstate.h
> index e6a28e7f4dbf..f80b33fa5d43 100644
> --- a/drivers/cpufreq/amd-pstate.h
> +++ b/drivers/cpufreq/amd-pstate.h
> @@ -99,6 +99,7 @@ struct amd_cpudata {
> u32 policy;
> u64 cppc_cap1_cached;
> bool suspended;
> + s16 epp_default;
> };
>
> #endif /* _LINUX_AMD_PSTATE_H */
> --
> 2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-06-21 8:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-12 14:57 [PATCH] cpufreq: amd-pstate: Allow users to write 'default' EPP string Mario Limonciello
2024-06-12 15:03 ` Artem S. Tashkinov
2024-06-13 9:21 ` Yuan, Perry
2024-06-21 8:43 ` Gautham R.Shenoy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).