2021-09-26 09:08:29

by Huang Rui

[permalink] [raw]
Subject: [PATCH v2 10/21] cpufreq: amd: add amd-pstate checking support check attribute

The amd-pstate hardware support check will be needed by cpupower to know
whether amd-pstate is enabled and supported.

Signed-off-by: Huang Rui <[email protected]>
---
drivers/cpufreq/amd-pstate.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 847ba00e3351..74f896232d5a 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -517,6 +517,19 @@ static int amd_pstate_cpu_exit(struct cpufreq_policy *policy)
return 0;
}

+static ssize_t show_is_amd_pstate_enabled(struct cpufreq_policy *policy,
+ char *buf)
+{
+ return sprintf(&buf[0], "%d\n", acpi_cpc_valid() ? 1 : 0);
+}
+
+cpufreq_freq_attr_ro(is_amd_pstate_enabled);
+
+static struct freq_attr *amd_pstate_attr[] = {
+ &is_amd_pstate_enabled,
+ NULL,
+};
+
static struct cpufreq_driver amd_pstate_driver = {
.flags = CPUFREQ_CONST_LOOPS | CPUFREQ_NEED_UPDATE_LIMITS,
.verify = amd_pstate_verify,
@@ -525,6 +538,7 @@ static struct cpufreq_driver amd_pstate_driver = {
.exit = amd_pstate_cpu_exit,
.set_boost = amd_pstate_set_boost,
.name = "amd-pstate",
+ .attr = amd_pstate_attr,
};

static int __init amd_pstate_init(void)
--
2.25.1


2021-09-28 21:26:24

by Nathan Fontenot

[permalink] [raw]
Subject: Re: [PATCH v2 10/21] cpufreq: amd: add amd-pstate checking support check attribute

On 9/26/2021 4:05 AM, Huang Rui wrote:
> The amd-pstate hardware support check will be needed by cpupower to know
> whether amd-pstate is enabled and supported.
>

Is this needed?

If acpi_cpc_valid() is false, then the amd_pstate driver would not have been
loaded (see patch 5/21, module init routine will return -ENODEV). If this
driver isn't loaded then this sysfs file won't get created.

Shouldn't the cpupower command just check the scaling_driver in sysfs to see
if it's amd_pstate?

-Nathan

> Signed-off-by: Huang Rui <[email protected]>
> ---
> drivers/cpufreq/amd-pstate.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 847ba00e3351..74f896232d5a 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -517,6 +517,19 @@ static int amd_pstate_cpu_exit(struct cpufreq_policy *policy)
> return 0;
> }
>
> +static ssize_t show_is_amd_pstate_enabled(struct cpufreq_policy *policy,
> + char *buf)
> +{
> + return sprintf(&buf[0], "%d\n", acpi_cpc_valid() ? 1 : 0);
> +}
> +
> +cpufreq_freq_attr_ro(is_amd_pstate_enabled);
> +
> +static struct freq_attr *amd_pstate_attr[] = {
> + &is_amd_pstate_enabled,
> + NULL,
> +};
> +
> static struct cpufreq_driver amd_pstate_driver = {
> .flags = CPUFREQ_CONST_LOOPS | CPUFREQ_NEED_UPDATE_LIMITS,
> .verify = amd_pstate_verify,
> @@ -525,6 +538,7 @@ static struct cpufreq_driver amd_pstate_driver = {
> .exit = amd_pstate_cpu_exit,
> .set_boost = amd_pstate_set_boost,
> .name = "amd-pstate",
> + .attr = amd_pstate_attr,
> };
>
> static int __init amd_pstate_init(void)
> --
> 2.25.1
>

2021-10-14 10:28:14

by Huang Rui

[permalink] [raw]
Subject: RE: [PATCH v2 10/21] cpufreq: amd: add amd-pstate checking support check attribute

[AMD Official Use Only]

> -----Original Message-----
> From: Fontenot, Nathan <[email protected]>
> Sent: Wednesday, September 29, 2021 5:24 AM
> To: Huang, Ray <[email protected]>; Rafael J . Wysocki
> <[email protected]>; Viresh Kumar <[email protected]>;
> Shuah Khan <[email protected]>; Borislav Petkov <[email protected]>;
> Peter Zijlstra <[email protected]>; Ingo Molnar <[email protected]>;
> [email protected]
> Cc: Sharma, Deepak <[email protected]>; Deucher, Alexander
> <[email protected]>; Limonciello, Mario
> <[email protected]>; Su, Jinzhou (Joe) <[email protected]>;
> Du, Xiaojian <[email protected]>; [email protected];
> [email protected]
> Subject: Re: [PATCH v2 10/21] cpufreq: amd: add amd-pstate checking
> support check attribute
>
> On 9/26/2021 4:05 AM, Huang Rui wrote:
> > The amd-pstate hardware support check will be needed by cpupower to
> know
> > whether amd-pstate is enabled and supported.
> >
>
> Is this needed?
>
> If acpi_cpc_valid() is false, then the amd_pstate driver would not have been
> loaded (see patch 5/21, module init routine will return -ENODEV). If this
> driver isn't loaded then this sysfs file won't get created.
>
> Shouldn't the cpupower command just check the scaling_driver in sysfs to
> see
> if it's amd_pstate?
>

Make sense, thanks! Will update it in V3.

Thanks,
Ray