linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] Improve usability for amd-pstate
@ 2022-03-29  1:59 Mario Limonciello
  2022-03-29  1:59 ` [PATCH v2 1/3] cpufreq: Export acpu_cpufreq_exit for other drivers to call Mario Limonciello
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Mario Limonciello @ 2022-03-29  1:59 UTC (permalink / raw)
  To: Huang Rui, Rafael J . Wysocki, Viresh Kumar
  Cc: open list:AMD PSTATE DRIVER, open list, Mario Limonciello

There has recently been some news coverage about `amd-pstate` being in
5.17, but this news also mentioned that it's a bit difficult to use.

You need to either block init calls, or compile the module into the kernel
to force it to take precedence over acpi-cpufreq.

This series aims to improve the usability of amd-pstate so that distros
can compile as a module, but users can still use it (relatively) easily.

A new module parameter is included that will force amd-pstate to take
precedence and a module table to let it load automatically on such systems.

With the patches in this series a user can make a file
/etc/modprobe.d/amd-pstate.conf:

options amd-pstate replace=1

Then upon the next reboot amd-pstate should load automatically even if
acpi-cpufreq was included on the system.

Mario Limonciello (3):
  cpufreq: Export acpu_cpufreq_exit for other drivers to call
  cpufreq: amd-pstate: Allow replacing acpi-cpufreq when loaded
  cpufreq: amd-pstate: Add a module device table

 drivers/cpufreq/acpi-cpufreq.c |  3 ++-
 drivers/cpufreq/amd-pstate.c   | 30 +++++++++++++++++++++++++++---
 2 files changed, 29 insertions(+), 4 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2 1/3] cpufreq: Export acpu_cpufreq_exit for other drivers to call
  2022-03-29  1:59 [PATCH v2 0/3] Improve usability for amd-pstate Mario Limonciello
@ 2022-03-29  1:59 ` Mario Limonciello
  2022-03-29  5:47   ` Huang Rui
                     ` (2 more replies)
  2022-03-29  1:59 ` [PATCH v2 2/3] cpufreq: amd-pstate: Allow replacing acpi-cpufreq when loaded Mario Limonciello
                   ` (2 subsequent siblings)
  3 siblings, 3 replies; 12+ messages in thread
From: Mario Limonciello @ 2022-03-29  1:59 UTC (permalink / raw)
  To: Huang Rui, Rafael J . Wysocki, Viresh Kumar
  Cc: open list:AMD PSTATE DRIVER, open list, Mario Limonciello

Currently, the only way to load an alternative cpufreq driver is to unload
acpi-cpufreq first.

Loosen that restriction to allow other kernel modules to unregister a
registered driver.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v1->v2:
 * Export symbol instead of changing internals

 drivers/cpufreq/acpi-cpufreq.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index 3d514b82d055..92ac978c1c53 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -1033,7 +1033,7 @@ static int __init acpi_cpufreq_init(void)
 	return ret;
 }
 
-static void __exit acpi_cpufreq_exit(void)
+void __exit acpi_cpufreq_exit(void)
 {
 	pr_debug("%s\n", __func__);
 
@@ -1043,6 +1043,7 @@ static void __exit acpi_cpufreq_exit(void)
 
 	free_acpi_perf_data();
 }
+EXPORT_SYMBOL_GPL(acpi_cpufreq_exit);
 
 module_param(acpi_pstate_strict, uint, 0644);
 MODULE_PARM_DESC(acpi_pstate_strict,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 2/3] cpufreq: amd-pstate: Allow replacing acpi-cpufreq when loaded
  2022-03-29  1:59 [PATCH v2 0/3] Improve usability for amd-pstate Mario Limonciello
  2022-03-29  1:59 ` [PATCH v2 1/3] cpufreq: Export acpu_cpufreq_exit for other drivers to call Mario Limonciello
@ 2022-03-29  1:59 ` Mario Limonciello
  2022-03-29  5:56   ` Huang Rui
  2022-03-29  1:59 ` [PATCH v2 3/3] cpufreq: amd-pstate: Add a module device table Mario Limonciello
  2022-03-29  6:02 ` [PATCH v2 0/3] Improve usability for amd-pstate Huang Rui
  3 siblings, 1 reply; 12+ messages in thread
From: Mario Limonciello @ 2022-03-29  1:59 UTC (permalink / raw)
  To: Huang Rui, Rafael J . Wysocki, Viresh Kumar
  Cc: open list:AMD PSTATE DRIVER, open list, Mario Limonciello

`amd-pstate` can be compiled as a module.  This however can be a
deficiency because `acpi-cpufreq` will be loaded earlier when compiled
into the kernel meaning `amd-pstate` doesn't get a chance.
`acpi-cpufreq` is also unable to be unloaded in this circumstance.

To better improve the usability of `amd-pstate` when compiled as a module,
add an optional module parameter that will force it to replace other
cpufreq drivers at startup.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v1->v2:
 * Update to changes from v1.
 * Verify the driver being matched is acpi-cpufreq.
 * Show a message letting users know they can use amd-pstate.

 drivers/cpufreq/amd-pstate.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 7be38bc6a673..7dc2e344f222 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -63,6 +63,12 @@ module_param(shared_mem, bool, 0444);
 MODULE_PARM_DESC(shared_mem,
 		 "enable amd-pstate on processors with shared memory solution (false = disabled (default), true = enabled)");
 
+static bool replace = false;
+module_param(replace, bool, 0444);
+MODULE_PARM_DESC(replace,
+		  "replace acpi-cpufreq driver upon init if necessary");
+extern void acpi_cpufreq_exit(void);
+
 static struct cpufreq_driver amd_pstate_driver;
 
 /**
@@ -643,6 +649,7 @@ static struct cpufreq_driver amd_pstate_driver = {
 
 static int __init amd_pstate_init(void)
 {
+	const char *current_driver;
 	int ret;
 
 	if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
@@ -653,9 +660,15 @@ static int __init amd_pstate_init(void)
 		return -ENODEV;
 	}
 
-	/* don't keep reloading if cpufreq_driver exists */
-	if (cpufreq_get_current_driver())
-		return -EEXIST;
+	current_driver = cpufreq_get_current_driver();
+	if (current_driver) {
+		if (replace && strcmp(current_driver, "acpi-cpufreq") == 0) {
+			acpi_cpufreq_exit();
+		} else {
+			pr_info("This processor supports amd-pstate, you can enable it with amd_pstate.replace=1\n");
+			return -EEXIST;
+		}
+	}
 
 	/* capability check */
 	if (boot_cpu_has(X86_FEATURE_CPPC)) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 3/3] cpufreq: amd-pstate: Add a module device table
  2022-03-29  1:59 [PATCH v2 0/3] Improve usability for amd-pstate Mario Limonciello
  2022-03-29  1:59 ` [PATCH v2 1/3] cpufreq: Export acpu_cpufreq_exit for other drivers to call Mario Limonciello
  2022-03-29  1:59 ` [PATCH v2 2/3] cpufreq: amd-pstate: Allow replacing acpi-cpufreq when loaded Mario Limonciello
@ 2022-03-29  1:59 ` Mario Limonciello
  2022-03-29  5:56   ` Huang Rui
  2022-03-29  6:02 ` [PATCH v2 0/3] Improve usability for amd-pstate Huang Rui
  3 siblings, 1 reply; 12+ messages in thread
From: Mario Limonciello @ 2022-03-29  1:59 UTC (permalink / raw)
  To: Huang Rui, Rafael J . Wysocki, Viresh Kumar
  Cc: open list:AMD PSTATE DRIVER, open list, Mario Limonciello

`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(+)

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


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/3] cpufreq: Export acpu_cpufreq_exit for other drivers to call
  2022-03-29  1:59 ` [PATCH v2 1/3] cpufreq: Export acpu_cpufreq_exit for other drivers to call Mario Limonciello
@ 2022-03-29  5:47   ` Huang Rui
  2022-03-29  6:22   ` kernel test robot
  2022-03-29  6:32   ` kernel test robot
  2 siblings, 0 replies; 12+ messages in thread
From: Huang Rui @ 2022-03-29  5:47 UTC (permalink / raw)
  To: Limonciello, Mario
  Cc: Rafael J . Wysocki, Viresh Kumar, open list:AMD PSTATE DRIVER, open list

On Tue, Mar 29, 2022 at 09:59:45AM +0800, Limonciello, Mario wrote:
> Currently, the only way to load an alternative cpufreq driver is to unload
> acpi-cpufreq first.
> 
> Loosen that restriction to allow other kernel modules to unregister a
> registered driver.
> 
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>

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

> ---
> v1->v2:
>  * Export symbol instead of changing internals
> 
>  drivers/cpufreq/acpi-cpufreq.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
> index 3d514b82d055..92ac978c1c53 100644
> --- a/drivers/cpufreq/acpi-cpufreq.c
> +++ b/drivers/cpufreq/acpi-cpufreq.c
> @@ -1033,7 +1033,7 @@ static int __init acpi_cpufreq_init(void)
>  	return ret;
>  }
>  
> -static void __exit acpi_cpufreq_exit(void)
> +void __exit acpi_cpufreq_exit(void)
>  {
>  	pr_debug("%s\n", __func__);
>  
> @@ -1043,6 +1043,7 @@ static void __exit acpi_cpufreq_exit(void)
>  
>  	free_acpi_perf_data();
>  }
> +EXPORT_SYMBOL_GPL(acpi_cpufreq_exit);
>  
>  module_param(acpi_pstate_strict, uint, 0644);
>  MODULE_PARM_DESC(acpi_pstate_strict,
> -- 
> 2.34.1
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 2/3] cpufreq: amd-pstate: Allow replacing acpi-cpufreq when loaded
  2022-03-29  1:59 ` [PATCH v2 2/3] cpufreq: amd-pstate: Allow replacing acpi-cpufreq when loaded Mario Limonciello
@ 2022-03-29  5:56   ` Huang Rui
  0 siblings, 0 replies; 12+ messages in thread
From: Huang Rui @ 2022-03-29  5:56 UTC (permalink / raw)
  To: Limonciello, Mario
  Cc: Rafael J . Wysocki, Viresh Kumar, open list:AMD PSTATE DRIVER, open list

On Tue, Mar 29, 2022 at 09:59:46AM +0800, Limonciello, Mario wrote:
> `amd-pstate` can be compiled as a module.  This however can be a
> deficiency because `acpi-cpufreq` will be loaded earlier when compiled
> into the kernel meaning `amd-pstate` doesn't get a chance.
> `acpi-cpufreq` is also unable to be unloaded in this circumstance.
> 
> To better improve the usability of `amd-pstate` when compiled as a module,
> add an optional module parameter that will force it to replace other
> cpufreq drivers at startup.
> 
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> v1->v2:
>  * Update to changes from v1.
>  * Verify the driver being matched is acpi-cpufreq.
>  * Show a message letting users know they can use amd-pstate.
> 
>  drivers/cpufreq/amd-pstate.c | 19 ++++++++++++++++---
>  1 file changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 7be38bc6a673..7dc2e344f222 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -63,6 +63,12 @@ module_param(shared_mem, bool, 0444);
>  MODULE_PARM_DESC(shared_mem,
>  		 "enable amd-pstate on processors with shared memory solution (false = disabled (default), true = enabled)");
>  
> +static bool replace = false;
> +module_param(replace, bool, 0444);
> +MODULE_PARM_DESC(replace,
> +		  "replace acpi-cpufreq driver upon init if necessary");
> +extern void acpi_cpufreq_exit(void);
> +
>  static struct cpufreq_driver amd_pstate_driver;
>  
>  /**
> @@ -643,6 +649,7 @@ static struct cpufreq_driver amd_pstate_driver = {
>  
>  static int __init amd_pstate_init(void)
>  {
> +	const char *current_driver;
>  	int ret;
>  
>  	if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
> @@ -653,9 +660,15 @@ static int __init amd_pstate_init(void)
>  		return -ENODEV;
>  	}
>  
> -	/* don't keep reloading if cpufreq_driver exists */
> -	if (cpufreq_get_current_driver())
> -		return -EEXIST;
> +	current_driver = cpufreq_get_current_driver();
> +	if (current_driver) {
> +		if (replace && strcmp(current_driver, "acpi-cpufreq") == 0) {

#ifdef CONFIG_X86_ACPI_CPUFREQ
> +			acpi_cpufreq_exit();
#endif

We need a kernel config checking here, otherwise, it will be built failed
once the acpi-cpufreq not set but amd_pstate is set.

Thanks,
Ray

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 3/3] cpufreq: amd-pstate: Add a module device table
  2022-03-29  1:59 ` [PATCH v2 3/3] cpufreq: amd-pstate: Add a module device table Mario Limonciello
@ 2022-03-29  5:56   ` Huang Rui
  0 siblings, 0 replies; 12+ messages in thread
From: Huang Rui @ 2022-03-29  5:56 UTC (permalink / raw)
  To: Limonciello, Mario
  Cc: Rafael J . Wysocki, Viresh Kumar, open list:AMD PSTATE DRIVER, open list

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
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 0/3] Improve usability for amd-pstate
  2022-03-29  1:59 [PATCH v2 0/3] Improve usability for amd-pstate Mario Limonciello
                   ` (2 preceding siblings ...)
  2022-03-29  1:59 ` [PATCH v2 3/3] cpufreq: amd-pstate: Add a module device table Mario Limonciello
@ 2022-03-29  6:02 ` Huang Rui
  2022-03-29 20:47   ` Limonciello, Mario
  3 siblings, 1 reply; 12+ messages in thread
From: Huang Rui @ 2022-03-29  6:02 UTC (permalink / raw)
  To: Limonciello, Mario
  Cc: Rafael J . Wysocki, Viresh Kumar, open list:AMD PSTATE DRIVER, open list

On Tue, Mar 29, 2022 at 09:59:44AM +0800, Limonciello, Mario wrote:
> There has recently been some news coverage about `amd-pstate` being in
> 5.17, but this news also mentioned that it's a bit difficult to use.
> 
> You need to either block init calls, or compile the module into the kernel
> to force it to take precedence over acpi-cpufreq.
> 
> This series aims to improve the usability of amd-pstate so that distros
> can compile as a module, but users can still use it (relatively) easily.
> 
> A new module parameter is included that will force amd-pstate to take
> precedence and a module table to let it load automatically on such systems.
> 
> With the patches in this series a user can make a file
> /etc/modprobe.d/amd-pstate.conf:
> 
> options amd-pstate replace=1
> 
> Then upon the next reboot amd-pstate should load automatically even if
> acpi-cpufreq was included on the system.
> 
> Mario Limonciello (3):
>   cpufreq: Export acpu_cpufreq_exit for other drivers to call
>   cpufreq: amd-pstate: Allow replacing acpi-cpufreq when loaded
>   cpufreq: amd-pstate: Add a module device table
> 
>  drivers/cpufreq/acpi-cpufreq.c |  3 ++-
>  drivers/cpufreq/amd-pstate.c   | 30 +++++++++++++++++++++++++++---
>  2 files changed, 29 insertions(+), 4 deletions(-)
> 

Mario, just applied your patch set in my platform, but it get the page fault
panic below:

[    4.195078] BUG: unable to handle page fault for address: ffffffff8aa2db87
[    4.196838] #PF: supervisor instruction fetch in kernel mode
[    4.197035] #PF: error_code(0x0011) - permissions violation
[    4.197035] PGD 1f980e067 P4D 1f980e067 PUD 1f980f063 PMD 100800063 PTE 80000001fa42d163
[    4.197035] Oops: 0011 [#1] PREEMPT SMP NOPTI
[    4.197035] CPU: 2 PID: 464 Comm: systemd-udevd Not tainted 5.17.0-custom+ #1
[    4.197035] Hardware name: AMD Artic/Artic-CZN, BIOS WA21407N 04/06/2021
[    4.197035] RIP: 0010:acpi_cpufreq_exit+0x0/0x46
[    4.197035] Code: 7f 00 00 a0 56 95 d2 4f 7f 00 00 80 f9 e7 d1 4f 7f 00 00 00 40 90 d2 4f 7f 00 00 10 36 93 d2 4f 7f 00 00 10 a4 87 d2 4f 7f 00 <00> d0 b6 57 d2 4f 7f 00 00 40 bf 1b d2 4f 7f 00 00 00 a4 85 d2 4f
[    4.197035] RSP: 0018:ffffaee0c156fc78 EFLAGS: 00010246
[    4.197035] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000040
[    4.197035] RDX: 0000000000000000 RSI: ffffffffc04ee5c5 RDI: ffffffff8a706100
[    4.197035] RBP: ffffaee0c156fc88 R08: 0000000000000000 R09: 0000000000000000
[    4.197035] R10: 0000000000000000 R11: 0000000000000001 R12: 00000000ffffffed
[    4.197035] R13: ffff9286ceead7e0 R14: ffffaee0c156fd90 R15: ffffffffc04f0740
[    4.197035] FS:  00007fe0ab0c3880(0000) GS:ffff9289ee280000(0000) knlGS:0000000000000000
[    4.197035] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[    4.197035] CR2: ffffffff8aa2db87 CR3: 0000000105a40000 CR4: 0000000000750ee0
[    4.197035] PKRU: 55555554
[    4.197035] Call Trace:
[    4.197035]  <TASK>
[    4.197035]  ? amd_pstate_init+0x7d/0x1000 [amd_pstate]
[    4.197035]  ? 0xffffffffc0477000
[    4.197035]  do_one_initcall+0x48/0x200
[    4.197035]  ? __x64_sys_delete_module+0x251/0x260
[    4.197035]  ? kmem_cache_alloc_trace+0x34c/0x450
[    4.197035]  do_init_module+0x52/0x240
[    4.197035]  load_module+0x2471/0x2790
[    4.197035]  __do_sys_finit_module+0xc5/0x130
[    4.197035]  ? __do_sys_finit_module+0xc5/0x130
[    4.197035]  __x64_sys_finit_module+0x1a/0x20
[    4.197035]  do_syscall_64+0x3b/0xc0
[    4.197035]  entry_SYSCALL_64_after_hwframe+0x44/0xae
[    4.197035] RIP: 0033:0x7fe0ab64589d

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/3] cpufreq: Export acpu_cpufreq_exit for other drivers to call
  2022-03-29  1:59 ` [PATCH v2 1/3] cpufreq: Export acpu_cpufreq_exit for other drivers to call Mario Limonciello
  2022-03-29  5:47   ` Huang Rui
@ 2022-03-29  6:22   ` kernel test robot
  2022-03-29  6:32   ` kernel test robot
  2 siblings, 0 replies; 12+ messages in thread
From: kernel test robot @ 2022-03-29  6:22 UTC (permalink / raw)
  To: Mario Limonciello, Huang Rui, Rafael J . Wysocki, Viresh Kumar
  Cc: kbuild-all, open list:AMD PSTATE DRIVER, open list, Mario Limonciello

Hi Mario,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on rafael-pm/linux-next]
[also build test WARNING on v5.17 next-20220329]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Mario-Limonciello/Improve-usability-for-amd-pstate/20220329-100211
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20220329/202203291412.G3zBxLNx-lkp@intel.com/config)
compiler: gcc-9 (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/86835efc7d91d9fc921d7d425b1fdab9c13feafb
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Mario-Limonciello/Improve-usability-for-amd-pstate/20220329-100211
        git checkout 86835efc7d91d9fc921d7d425b1fdab9c13feafb
        # save the config file to linux build tree
        mkdir build_dir
        make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/cpufreq/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/cpufreq/acpi-cpufreq.c:1036:13: warning: no previous prototype for 'acpi_cpufreq_exit' [-Wmissing-prototypes]
    1036 | void __exit acpi_cpufreq_exit(void)
         |             ^~~~~~~~~~~~~~~~~


vim +/acpi_cpufreq_exit +1036 drivers/cpufreq/acpi-cpufreq.c

  1035	
> 1036	void __exit acpi_cpufreq_exit(void)
  1037	{
  1038		pr_debug("%s\n", __func__);
  1039	
  1040		acpi_cpufreq_boost_exit();
  1041	
  1042		cpufreq_unregister_driver(&acpi_cpufreq_driver);
  1043	
  1044		free_acpi_perf_data();
  1045	}
  1046	EXPORT_SYMBOL_GPL(acpi_cpufreq_exit);
  1047	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/3] cpufreq: Export acpu_cpufreq_exit for other drivers to call
  2022-03-29  1:59 ` [PATCH v2 1/3] cpufreq: Export acpu_cpufreq_exit for other drivers to call Mario Limonciello
  2022-03-29  5:47   ` Huang Rui
  2022-03-29  6:22   ` kernel test robot
@ 2022-03-29  6:32   ` kernel test robot
  2 siblings, 0 replies; 12+ messages in thread
From: kernel test robot @ 2022-03-29  6:32 UTC (permalink / raw)
  To: Mario Limonciello, Huang Rui, Rafael J . Wysocki, Viresh Kumar
  Cc: llvm, kbuild-all, open list:AMD PSTATE DRIVER, open list,
	Mario Limonciello

Hi Mario,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on rafael-pm/linux-next]
[also build test WARNING on v5.17 next-20220329]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Mario-Limonciello/Improve-usability-for-amd-pstate/20220329-100211
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
config: x86_64-randconfig-a001 (https://download.01.org/0day-ci/archive/20220329/202203291402.XRbJXAas-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 0f6d9501cf49ce02937099350d08f20c4af86f3d)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/86835efc7d91d9fc921d7d425b1fdab9c13feafb
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Mario-Limonciello/Improve-usability-for-amd-pstate/20220329-100211
        git checkout 86835efc7d91d9fc921d7d425b1fdab9c13feafb
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/cpufreq/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/cpufreq/acpi-cpufreq.c:1036:13: warning: no previous prototype for function 'acpi_cpufreq_exit' [-Wmissing-prototypes]
   void __exit acpi_cpufreq_exit(void)
               ^
   drivers/cpufreq/acpi-cpufreq.c:1036:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void __exit acpi_cpufreq_exit(void)
   ^
   static 
   1 warning generated.


vim +/acpi_cpufreq_exit +1036 drivers/cpufreq/acpi-cpufreq.c

  1035	
> 1036	void __exit acpi_cpufreq_exit(void)
  1037	{
  1038		pr_debug("%s\n", __func__);
  1039	
  1040		acpi_cpufreq_boost_exit();
  1041	
  1042		cpufreq_unregister_driver(&acpi_cpufreq_driver);
  1043	
  1044		free_acpi_perf_data();
  1045	}
  1046	EXPORT_SYMBOL_GPL(acpi_cpufreq_exit);
  1047	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH v2 0/3] Improve usability for amd-pstate
  2022-03-29  6:02 ` [PATCH v2 0/3] Improve usability for amd-pstate Huang Rui
@ 2022-03-29 20:47   ` Limonciello, Mario
  2022-03-30  9:54     ` Huang Rui
  0 siblings, 1 reply; 12+ messages in thread
From: Limonciello, Mario @ 2022-03-29 20:47 UTC (permalink / raw)
  To: Huang, Ray
  Cc: Rafael J . Wysocki, Viresh Kumar, open list:AMD PSTATE DRIVER, open list

[AMD Official Use Only]



> -----Original Message-----
> From: Huang, Ray <Ray.Huang@amd.com>
> Sent: Tuesday, March 29, 2022 01:03
> To: Limonciello, Mario <Mario.Limonciello@amd.com>
> Cc: Rafael J . Wysocki <rafael@kernel.org>; Viresh Kumar
> <viresh.kumar@linaro.org>; open list:AMD PSTATE DRIVER <linux-
> pm@vger.kernel.org>; open list <linux-kernel@vger.kernel.org>
> Subject: Re: [PATCH v2 0/3] Improve usability for amd-pstate
> 
> On Tue, Mar 29, 2022 at 09:59:44AM +0800, Limonciello, Mario wrote:
> > There has recently been some news coverage about `amd-pstate` being in
> > 5.17, but this news also mentioned that it's a bit difficult to use.
> >
> > You need to either block init calls, or compile the module into the kernel
> > to force it to take precedence over acpi-cpufreq.
> >
> > This series aims to improve the usability of amd-pstate so that distros
> > can compile as a module, but users can still use it (relatively) easily.
> >
> > A new module parameter is included that will force amd-pstate to take
> > precedence and a module table to let it load automatically on such systems.
> >
> > With the patches in this series a user can make a file
> > /etc/modprobe.d/amd-pstate.conf:
> >
> > options amd-pstate replace=1
> >
> > Then upon the next reboot amd-pstate should load automatically even if
> > acpi-cpufreq was included on the system.
> >
> > Mario Limonciello (3):
> >   cpufreq: Export acpu_cpufreq_exit for other drivers to call
> >   cpufreq: amd-pstate: Allow replacing acpi-cpufreq when loaded
> >   cpufreq: amd-pstate: Add a module device table
> >
> >  drivers/cpufreq/acpi-cpufreq.c |  3 ++-
> >  drivers/cpufreq/amd-pstate.c   | 30 +++++++++++++++++++++++++++---
> >  2 files changed, 29 insertions(+), 4 deletions(-)
> >
> 
> Mario, just applied your patch set in my platform, but it get the page fault
> panic below:
> 
> [    4.195078] BUG: unable to handle page fault for address: ffffffff8aa2db87
> [    4.196838] #PF: supervisor instruction fetch in kernel mode
> [    4.197035] #PF: error_code(0x0011) - permissions violation
> [    4.197035] PGD 1f980e067 P4D 1f980e067 PUD 1f980f063 PMD 100800063
> PTE 80000001fa42d163
> [    4.197035] Oops: 0011 [#1] PREEMPT SMP NOPTI
> [    4.197035] CPU: 2 PID: 464 Comm: systemd-udevd Not tainted 5.17.0-
> custom+ #1
> [    4.197035] Hardware name: AMD Artic/Artic-CZN, BIOS WA21407N
> 04/06/2021
> [    4.197035] RIP: 0010:acpi_cpufreq_exit+0x0/0x46
> [    4.197035] Code: 7f 00 00 a0 56 95 d2 4f 7f 00 00 80 f9 e7 d1 4f 7f 00 00 00 40
> 90 d2 4f 7f 00 00 10 36 93 d2 4f 7f 00 00 10 a4 87 d2 4f 7f 00 <00> d0 b6 57 d2 4f
> 7f 00 00 40 bf 1b d2 4f 7f 00 00 00 a4 85 d2 4f
> [    4.197035] RSP: 0018:ffffaee0c156fc78 EFLAGS: 00010246
> [    4.197035] RAX: 0000000000000000 RBX: 0000000000000000 RCX:
> 0000000000000040
> [    4.197035] RDX: 0000000000000000 RSI: ffffffffc04ee5c5 RDI:
> ffffffff8a706100
> [    4.197035] RBP: ffffaee0c156fc88 R08: 0000000000000000 R09:
> 0000000000000000
> [    4.197035] R10: 0000000000000000 R11: 0000000000000001 R12:
> 00000000ffffffed
> [    4.197035] R13: ffff9286ceead7e0 R14: ffffaee0c156fd90 R15:
> ffffffffc04f0740
> [    4.197035] FS:  00007fe0ab0c3880(0000) GS:ffff9289ee280000(0000)
> knlGS:0000000000000000
> [    4.197035] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [    4.197035] CR2: ffffffff8aa2db87 CR3: 0000000105a40000 CR4:
> 0000000000750ee0
> [    4.197035] PKRU: 55555554
> [    4.197035] Call Trace:
> [    4.197035]  <TASK>
> [    4.197035]  ? amd_pstate_init+0x7d/0x1000 [amd_pstate]
> [    4.197035]  ? 0xffffffffc0477000
> [    4.197035]  do_one_initcall+0x48/0x200
> [    4.197035]  ? __x64_sys_delete_module+0x251/0x260
> [    4.197035]  ? kmem_cache_alloc_trace+0x34c/0x450
> [    4.197035]  do_init_module+0x52/0x240
> [    4.197035]  load_module+0x2471/0x2790
> [    4.197035]  __do_sys_finit_module+0xc5/0x130
> [    4.197035]  ? __do_sys_finit_module+0xc5/0x130
> [    4.197035]  __x64_sys_finit_module+0x1a/0x20
> [    4.197035]  do_syscall_64+0x3b/0xc0
> [    4.197035]  entry_SYSCALL_64_after_hwframe+0x44/0xae
> [    4.197035] RIP: 0033:0x7fe0ab64589d

Presumably you didn't have acpi-cpufreq compiled in or loaded at this time
right?  I think I'll need to use IS_REACHABLE().

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 0/3] Improve usability for amd-pstate
  2022-03-29 20:47   ` Limonciello, Mario
@ 2022-03-30  9:54     ` Huang Rui
  0 siblings, 0 replies; 12+ messages in thread
From: Huang Rui @ 2022-03-30  9:54 UTC (permalink / raw)
  To: Limonciello, Mario
  Cc: Rafael J . Wysocki, Viresh Kumar, open list:AMD PSTATE DRIVER, open list

On Wed, Mar 30, 2022 at 04:47:02AM +0800, Limonciello, Mario wrote:
> [AMD Official Use Only]
> 
> 
> 
> > -----Original Message-----
> > From: Huang, Ray <Ray.Huang@amd.com>
> > Sent: Tuesday, March 29, 2022 01:03
> > To: Limonciello, Mario <Mario.Limonciello@amd.com>
> > Cc: Rafael J . Wysocki <rafael@kernel.org>; Viresh Kumar
> > <viresh.kumar@linaro.org>; open list:AMD PSTATE DRIVER <linux-
> > pm@vger.kernel.org>; open list <linux-kernel@vger.kernel.org>
> > Subject: Re: [PATCH v2 0/3] Improve usability for amd-pstate
> > 
> > On Tue, Mar 29, 2022 at 09:59:44AM +0800, Limonciello, Mario wrote:
> > > There has recently been some news coverage about `amd-pstate` being in
> > > 5.17, but this news also mentioned that it's a bit difficult to use.
> > >
> > > You need to either block init calls, or compile the module into the kernel
> > > to force it to take precedence over acpi-cpufreq.
> > >
> > > This series aims to improve the usability of amd-pstate so that distros
> > > can compile as a module, but users can still use it (relatively) easily.
> > >
> > > A new module parameter is included that will force amd-pstate to take
> > > precedence and a module table to let it load automatically on such systems.
> > >
> > > With the patches in this series a user can make a file
> > > /etc/modprobe.d/amd-pstate.conf:
> > >
> > > options amd-pstate replace=1
> > >
> > > Then upon the next reboot amd-pstate should load automatically even if
> > > acpi-cpufreq was included on the system.
> > >
> > > Mario Limonciello (3):
> > >   cpufreq: Export acpu_cpufreq_exit for other drivers to call
> > >   cpufreq: amd-pstate: Allow replacing acpi-cpufreq when loaded
> > >   cpufreq: amd-pstate: Add a module device table
> > >
> > >  drivers/cpufreq/acpi-cpufreq.c |  3 ++-
> > >  drivers/cpufreq/amd-pstate.c   | 30 +++++++++++++++++++++++++++---
> > >  2 files changed, 29 insertions(+), 4 deletions(-)
> > >
> > 
> > Mario, just applied your patch set in my platform, but it get the page fault
> > panic below:
> > 
> > [    4.195078] BUG: unable to handle page fault for address: ffffffff8aa2db87
> > [    4.196838] #PF: supervisor instruction fetch in kernel mode
> > [    4.197035] #PF: error_code(0x0011) - permissions violation
> > [    4.197035] PGD 1f980e067 P4D 1f980e067 PUD 1f980f063 PMD 100800063
> > PTE 80000001fa42d163
> > [    4.197035] Oops: 0011 [#1] PREEMPT SMP NOPTI
> > [    4.197035] CPU: 2 PID: 464 Comm: systemd-udevd Not tainted 5.17.0-
> > custom+ #1
> > [    4.197035] Hardware name: AMD Artic/Artic-CZN, BIOS WA21407N
> > 04/06/2021
> > [    4.197035] RIP: 0010:acpi_cpufreq_exit+0x0/0x46
> > [    4.197035] Code: 7f 00 00 a0 56 95 d2 4f 7f 00 00 80 f9 e7 d1 4f 7f 00 00 00 40
> > 90 d2 4f 7f 00 00 10 36 93 d2 4f 7f 00 00 10 a4 87 d2 4f 7f 00 <00> d0 b6 57 d2 4f
> > 7f 00 00 40 bf 1b d2 4f 7f 00 00 00 a4 85 d2 4f
> > [    4.197035] RSP: 0018:ffffaee0c156fc78 EFLAGS: 00010246
> > [    4.197035] RAX: 0000000000000000 RBX: 0000000000000000 RCX:
> > 0000000000000040
> > [    4.197035] RDX: 0000000000000000 RSI: ffffffffc04ee5c5 RDI:
> > ffffffff8a706100
> > [    4.197035] RBP: ffffaee0c156fc88 R08: 0000000000000000 R09:
> > 0000000000000000
> > [    4.197035] R10: 0000000000000000 R11: 0000000000000001 R12:
> > 00000000ffffffed
> > [    4.197035] R13: ffff9286ceead7e0 R14: ffffaee0c156fd90 R15:
> > ffffffffc04f0740
> > [    4.197035] FS:  00007fe0ab0c3880(0000) GS:ffff9289ee280000(0000)
> > knlGS:0000000000000000
> > [    4.197035] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> > [    4.197035] CR2: ffffffff8aa2db87 CR3: 0000000105a40000 CR4:
> > 0000000000750ee0
> > [    4.197035] PKRU: 55555554
> > [    4.197035] Call Trace:
> > [    4.197035]  <TASK>
> > [    4.197035]  ? amd_pstate_init+0x7d/0x1000 [amd_pstate]
> > [    4.197035]  ? 0xffffffffc0477000
> > [    4.197035]  do_one_initcall+0x48/0x200
> > [    4.197035]  ? __x64_sys_delete_module+0x251/0x260
> > [    4.197035]  ? kmem_cache_alloc_trace+0x34c/0x450
> > [    4.197035]  do_init_module+0x52/0x240
> > [    4.197035]  load_module+0x2471/0x2790
> > [    4.197035]  __do_sys_finit_module+0xc5/0x130
> > [    4.197035]  ? __do_sys_finit_module+0xc5/0x130
> > [    4.197035]  __x64_sys_finit_module+0x1a/0x20
> > [    4.197035]  do_syscall_64+0x3b/0xc0
> > [    4.197035]  entry_SYSCALL_64_after_hwframe+0x44/0xae
> > [    4.197035] RIP: 0033:0x7fe0ab64589d
> 
> Presumably you didn't have acpi-cpufreq compiled in or loaded at this time
> right?  I think I'll need to use IS_REACHABLE().

In fact, I have compiled and loaded acpi-cpufreq at first, otherwise, we
cannot get "acpi-cpufreq" driver instance with
cpufreq_get_current_driver().

Thanks,
Ray

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-03-30  9:55 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-29  1:59 [PATCH v2 0/3] Improve usability for amd-pstate Mario Limonciello
2022-03-29  1:59 ` [PATCH v2 1/3] cpufreq: Export acpu_cpufreq_exit for other drivers to call Mario Limonciello
2022-03-29  5:47   ` Huang Rui
2022-03-29  6:22   ` kernel test robot
2022-03-29  6:32   ` kernel test robot
2022-03-29  1:59 ` [PATCH v2 2/3] cpufreq: amd-pstate: Allow replacing acpi-cpufreq when loaded Mario Limonciello
2022-03-29  5:56   ` Huang Rui
2022-03-29  1:59 ` [PATCH v2 3/3] cpufreq: amd-pstate: Add a module device table Mario Limonciello
2022-03-29  5:56   ` Huang Rui
2022-03-29  6:02 ` [PATCH v2 0/3] Improve usability for amd-pstate Huang Rui
2022-03-29 20:47   ` Limonciello, Mario
2022-03-30  9:54     ` Huang Rui

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).