diff mbox series

x86/cstate: Replace vendor check with X86_FEATURE_MWAIT in ffh_cstate_init

Message ID 1656659147-20396-1-git-send-email-TonyWWang-oc@zhaoxin.com
State New
Headers show
Series x86/cstate: Replace vendor check with X86_FEATURE_MWAIT in ffh_cstate_init | expand

Commit Message

Tony W Wang-oc July 1, 2022, 7:05 a.m. UTC
The original commit 991528d73486 ("ACPI: Processor native C-states using
MWAIT") has a vendor check for Intel in the function of ffh_cstate_init().

Commit 5209654a46ee ("x86/ACPI/cstate: Allow ACPI C1 FFH MWAIT use on AMD
systems") and commit 280b68a3b3b9 ("x86/cstate: Allow ACPI C1 FFH MWAIT
use on Hygon systems") add vendor check for AMD and HYGON in the function
of ffh_cstate_init().

Recent Zhaoxin and Centaur CPUs support MONITOR/MWAIT instructions that
can be used for ACPI Cx state in the same way as Intel. So expected to
add the support of these CPUs in the function of ffh_cstate_init() too.

The CPU feature X86_FEATURE_MWAIT indicates processor supports MONITOR/
MWAIT instructions. So the check for many CPU vendors in ffh_cstate_init()
is unnecessary, use X86_FEATURE_MWAIT to replace the CPU vendor check.

Signed-off-by: Tony W Wang-oc <TonyWWang-oc@zhaoxin.com>
---
 arch/x86/kernel/acpi/cstate.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

Comments

Rafael J. Wysocki July 5, 2022, 6:45 p.m. UTC | #1
On Fri, Jul 1, 2022 at 9:05 AM Tony W Wang-oc <TonyWWang-oc@zhaoxin.com> wrote:
>
> The original commit 991528d73486 ("ACPI: Processor native C-states using
> MWAIT") has a vendor check for Intel in the function of ffh_cstate_init().
>
> Commit 5209654a46ee ("x86/ACPI/cstate: Allow ACPI C1 FFH MWAIT use on AMD
> systems") and commit 280b68a3b3b9 ("x86/cstate: Allow ACPI C1 FFH MWAIT
> use on Hygon systems") add vendor check for AMD and HYGON in the function
> of ffh_cstate_init().
>
> Recent Zhaoxin and Centaur CPUs support MONITOR/MWAIT instructions that
> can be used for ACPI Cx state in the same way as Intel. So expected to
> add the support of these CPUs in the function of ffh_cstate_init() too.
>
> The CPU feature X86_FEATURE_MWAIT indicates processor supports MONITOR/
> MWAIT instructions. So the check for many CPU vendors in ffh_cstate_init()
> is unnecessary, use X86_FEATURE_MWAIT to replace the CPU vendor check.
>
> Signed-off-by: Tony W Wang-oc <TonyWWang-oc@zhaoxin.com>

Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

or please let me know if I'm expected to pick up this one.  Thanks!


> ---
>  arch/x86/kernel/acpi/cstate.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/arch/x86/kernel/acpi/cstate.c b/arch/x86/kernel/acpi/cstate.c
> index 7945eae..a64c38f 100644
> --- a/arch/x86/kernel/acpi/cstate.c
> +++ b/arch/x86/kernel/acpi/cstate.c
> @@ -209,11 +209,7 @@ EXPORT_SYMBOL_GPL(acpi_processor_ffh_cstate_enter);
>
>  static int __init ffh_cstate_init(void)
>  {
> -       struct cpuinfo_x86 *c = &boot_cpu_data;
> -
> -       if (c->x86_vendor != X86_VENDOR_INTEL &&
> -           c->x86_vendor != X86_VENDOR_AMD &&
> -           c->x86_vendor != X86_VENDOR_HYGON)
> +       if (!boot_cpu_has(X86_FEATURE_MWAIT))
>                 return -1;
>
>         cpu_cstate_entry = alloc_percpu(struct cstate_entry);
> --
> 2.7.4
>
Tony W Wang-oc July 19, 2022, 3:36 a.m. UTC | #2
On 2022/7/6 上午2:45, Rafael J. Wysocki wrote:
> On Fri, Jul 1, 2022 at 9:05 AM Tony W Wang-oc <TonyWWang-oc@zhaoxin.com> wrote:
>>
>> The original commit 991528d73486 ("ACPI: Processor native C-states using
>> MWAIT") has a vendor check for Intel in the function of ffh_cstate_init().
>>
>> Commit 5209654a46ee ("x86/ACPI/cstate: Allow ACPI C1 FFH MWAIT use on AMD
>> systems") and commit 280b68a3b3b9 ("x86/cstate: Allow ACPI C1 FFH MWAIT
>> use on Hygon systems") add vendor check for AMD and HYGON in the function
>> of ffh_cstate_init().
>>
>> Recent Zhaoxin and Centaur CPUs support MONITOR/MWAIT instructions that
>> can be used for ACPI Cx state in the same way as Intel. So expected to
>> add the support of these CPUs in the function of ffh_cstate_init() too.
>>
>> The CPU feature X86_FEATURE_MWAIT indicates processor supports MONITOR/
>> MWAIT instructions. So the check for many CPU vendors in ffh_cstate_init()
>> is unnecessary, use X86_FEATURE_MWAIT to replace the CPU vendor check.
>>
>> Signed-off-by: Tony W Wang-oc <TonyWWang-oc@zhaoxin.com>
> 
> Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 

Thanks a lot.
Add some original commit authors this patch related to.

> or please let me know if I'm expected to pick up this one.  Thanks!
> 

Yes for me. Thanks a lot.

> 
>> ---
>>   arch/x86/kernel/acpi/cstate.c | 6 +-----
>>   1 file changed, 1 insertion(+), 5 deletions(-)
>>
>> diff --git a/arch/x86/kernel/acpi/cstate.c b/arch/x86/kernel/acpi/cstate.c
>> index 7945eae..a64c38f 100644
>> --- a/arch/x86/kernel/acpi/cstate.c
>> +++ b/arch/x86/kernel/acpi/cstate.c
>> @@ -209,11 +209,7 @@ EXPORT_SYMBOL_GPL(acpi_processor_ffh_cstate_enter);
>>
>>   static int __init ffh_cstate_init(void)
>>   {
>> -       struct cpuinfo_x86 *c = &boot_cpu_data;
>> -
>> -       if (c->x86_vendor != X86_VENDOR_INTEL &&
>> -           c->x86_vendor != X86_VENDOR_AMD &&
>> -           c->x86_vendor != X86_VENDOR_HYGON)
>> +       if (!boot_cpu_has(X86_FEATURE_MWAIT))
>>                  return -1;
>>
>>          cpu_cstate_entry = alloc_percpu(struct cstate_entry);
>> --
>> 2.7.4
>>
> .
>
diff mbox series

Patch

diff --git a/arch/x86/kernel/acpi/cstate.c b/arch/x86/kernel/acpi/cstate.c
index 7945eae..a64c38f 100644
--- a/arch/x86/kernel/acpi/cstate.c
+++ b/arch/x86/kernel/acpi/cstate.c
@@ -209,11 +209,7 @@  EXPORT_SYMBOL_GPL(acpi_processor_ffh_cstate_enter);
 
 static int __init ffh_cstate_init(void)
 {
-	struct cpuinfo_x86 *c = &boot_cpu_data;
-
-	if (c->x86_vendor != X86_VENDOR_INTEL &&
-	    c->x86_vendor != X86_VENDOR_AMD &&
-	    c->x86_vendor != X86_VENDOR_HYGON)
+	if (!boot_cpu_has(X86_FEATURE_MWAIT))
 		return -1;
 
 	cpu_cstate_entry = alloc_percpu(struct cstate_entry);