diff mbox series

[v2,3/3] cpufreq: amd-pstate: Add a module device table

Message ID 20220329015947.565-4-mario.limonciello@amd.com
State New
Headers show
Series Improve usability for amd-pstate | expand

Commit Message

Mario Limonciello March 29, 2022, 1:59 a.m. UTC
`amd-pstate` currently only loads automatically if compiled into the
kernel.  To improve the usability, add a module device table that
will load when AMD CPUs that support CPPC are detected.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v1->v2:
 * Add comment to indicate need of SBIOS support.

 drivers/cpufreq/amd-pstate.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Huang Rui March 29, 2022, 5:56 a.m. UTC | #1
On Tue, Mar 29, 2022 at 09:59:47AM +0800, Limonciello, Mario wrote:
> `amd-pstate` currently only loads automatically if compiled into the
> kernel.  To improve the usability, add a module device table that
> will load when AMD CPUs that support CPPC are detected.
> 
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>

Reviewed-by: Huang Rui <ray.huang@amd.com>

> ---
> v1->v2:
>  * Add comment to indicate need of SBIOS support.
> 
>  drivers/cpufreq/amd-pstate.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 7dc2e344f222..9f78849654e7 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -705,6 +705,17 @@ static void __exit amd_pstate_exit(void)
>  	amd_pstate_enable(false);
>  }
>  
> +/*
> + * This will only match the HW feature, there still needs to be appropriate
> + * SBIOS support, so it's possible that in such cases this causes a module
> + * load with -ENODEV as the result.
> + */
> +static const struct x86_cpu_id __maybe_unused amd_pstate_ids[] = {
> +	X86_MATCH_VENDOR_FEATURE(AMD, X86_FEATURE_CPPC, NULL),
> +	{}
> +};
> +MODULE_DEVICE_TABLE(x86cpu, amd_pstate_ids);
> +
>  module_init(amd_pstate_init);
>  module_exit(amd_pstate_exit);
>  
> -- 
> 2.34.1
>
diff mbox series

Patch

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 7dc2e344f222..9f78849654e7 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -705,6 +705,17 @@  static void __exit amd_pstate_exit(void)
 	amd_pstate_enable(false);
 }
 
+/*
+ * This will only match the HW feature, there still needs to be appropriate
+ * SBIOS support, so it's possible that in such cases this causes a module
+ * load with -ENODEV as the result.
+ */
+static const struct x86_cpu_id __maybe_unused amd_pstate_ids[] = {
+	X86_MATCH_VENDOR_FEATURE(AMD, X86_FEATURE_CPPC, NULL),
+	{}
+};
+MODULE_DEVICE_TABLE(x86cpu, amd_pstate_ids);
+
 module_init(amd_pstate_init);
 module_exit(amd_pstate_exit);