Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH V1] x86/cstate: Add Zhaoxin/Centaur ACPI Cx FFH MWAIT support
@ 2022-06-23  1:26 Tony W Wang-oc
  2022-06-23 15:55 ` Dave Hansen
  0 siblings, 1 reply; 3+ messages in thread
From: Tony W Wang-oc @ 2022-06-23  1:26 UTC (permalink / raw)
  To: Rafael J. Wysocki, Len Brown, Pavel Machek, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen,
	the arch/x86 maintainers, H. Peter Anvin, Linux PM,
	Linux Kernel Mailing List
  Cc: CobeChen, TimGuo, LindaChai, LeoLiu, ACPI Devel Maling List

Recent Zhaoxin/Centaur CPUs support X86_FEATURE_MWAIT that implies
the MONITOR/MWAIT instructions can be used for ACPI Cx state.
The BIOS declares Cx state in _CST object to use FFH on Zhaoxin/Centaur
systems. So let function ffh_cstate_init() support These CPUs too.

Signed-off-by: Tony W Wang-oc <TonyWWang-oc@zhaoxin.com>
---
  arch/x86/kernel/acpi/cstate.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/acpi/cstate.c b/arch/x86/kernel/acpi/cstate.c
index 7945eae..d4185e1 100644
--- a/arch/x86/kernel/acpi/cstate.c
+++ b/arch/x86/kernel/acpi/cstate.c
@@ -213,7 +213,9 @@ static int __init ffh_cstate_init(void)

  	if (c->x86_vendor != X86_VENDOR_INTEL &&
  	    c->x86_vendor != X86_VENDOR_AMD &&
-	    c->x86_vendor != X86_VENDOR_HYGON)
+	    c->x86_vendor != X86_VENDOR_HYGON &&
+	    c->x86_vendor != X86_VENDOR_CENTAUR &&
+	    c->x86_vendor != X86_VENDOR_ZHAOXIN)
  		return -1;

  	cpu_cstate_entry = alloc_percpu(struct cstate_entry);
-- 
2.7.4


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

* Re: [PATCH V1] x86/cstate: Add Zhaoxin/Centaur ACPI Cx FFH MWAIT support
  2022-06-23  1:26 [PATCH V1] x86/cstate: Add Zhaoxin/Centaur ACPI Cx FFH MWAIT support Tony W Wang-oc
@ 2022-06-23 15:55 ` Dave Hansen
  2022-06-24  3:05   ` Tony W Wang-oc
  0 siblings, 1 reply; 3+ messages in thread
From: Dave Hansen @ 2022-06-23 15:55 UTC (permalink / raw)
  To: Tony W Wang-oc, Rafael J. Wysocki, Len Brown, Pavel Machek,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
	the arch/x86 maintainers, H. Peter Anvin, Linux PM,
	Linux Kernel Mailing List
  Cc: CobeChen, TimGuo, LindaChai, LeoLiu, ACPI Devel Maling List

On 6/22/22 18:26, Tony W Wang-oc wrote:
> Recent Zhaoxin/Centaur CPUs support X86_FEATURE_MWAIT that implies
> the MONITOR/MWAIT instructions can be used for ACPI Cx state.
> The BIOS declares Cx state in _CST object to use FFH on Zhaoxin/Centaur
> systems. So let function ffh_cstate_init() support These CPUs too.
> 
> Signed-off-by: Tony W Wang-oc <TonyWWang-oc@zhaoxin.com>
> ---
>  arch/x86/kernel/acpi/cstate.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kernel/acpi/cstate.c b/arch/x86/kernel/acpi/cstate.c
> index 7945eae..d4185e1 100644
> --- a/arch/x86/kernel/acpi/cstate.c
> +++ b/arch/x86/kernel/acpi/cstate.c
> @@ -213,7 +213,9 @@ static int __init ffh_cstate_init(void)
> 
>      if (c->x86_vendor != X86_VENDOR_INTEL &&
>          c->x86_vendor != X86_VENDOR_AMD &&
> -        c->x86_vendor != X86_VENDOR_HYGON)
> +        c->x86_vendor != X86_VENDOR_HYGON &&
> +        c->x86_vendor != X86_VENDOR_CENTAUR &&
> +        c->x86_vendor != X86_VENDOR_ZHAOXIN)
>          return -1;

Many of the changelogs that add new vendors here go on about particular
C states declared in the _CST object and contents of CPUID leaf 5.

Why do we even _have_ a vendor check here?  Shouldn't the code just be
going and doing the validation of the _CST object and CPUID that the
changelogs blather on about?

Intel certainly made the original sin on this one (see 991528d7348), but
I hope _something_ changed in the 16 years since that patch went in.

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

* Re: [PATCH V1] x86/cstate: Add Zhaoxin/Centaur ACPI Cx FFH MWAIT support
  2022-06-23 15:55 ` Dave Hansen
@ 2022-06-24  3:05   ` Tony W Wang-oc
  0 siblings, 0 replies; 3+ messages in thread
From: Tony W Wang-oc @ 2022-06-24  3:05 UTC (permalink / raw)
  To: Dave Hansen, Rafael J. Wysocki, Len Brown, Pavel Machek,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
	the arch/x86 maintainers, H. Peter Anvin, Linux PM,
	Linux Kernel Mailing List
  Cc: CobeChen, TimGuo, LindaChai, LeoLiu, ACPI Devel Maling List

On 23/6/2022 23:55, Dave Hansen wrote:
> On 6/22/22 18:26, Tony W Wang-oc wrote:
>> Recent Zhaoxin/Centaur CPUs support X86_FEATURE_MWAIT that implies
>> the MONITOR/MWAIT instructions can be used for ACPI Cx state.
>> The BIOS declares Cx state in _CST object to use FFH on Zhaoxin/Centaur
>> systems. So let function ffh_cstate_init() support These CPUs too.
>>
>> Signed-off-by: Tony W Wang-oc <TonyWWang-oc@zhaoxin.com>
>> ---
>>   arch/x86/kernel/acpi/cstate.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/kernel/acpi/cstate.c b/arch/x86/kernel/acpi/cstate.c
>> index 7945eae..d4185e1 100644
>> --- a/arch/x86/kernel/acpi/cstate.c
>> +++ b/arch/x86/kernel/acpi/cstate.c
>> @@ -213,7 +213,9 @@ static int __init ffh_cstate_init(void)
>>
>>       if (c->x86_vendor != X86_VENDOR_INTEL &&
>>           c->x86_vendor != X86_VENDOR_AMD &&
>> -        c->x86_vendor != X86_VENDOR_HYGON)
>> +        c->x86_vendor != X86_VENDOR_HYGON &&
>> +        c->x86_vendor != X86_VENDOR_CENTAUR &&
>> +        c->x86_vendor != X86_VENDOR_ZHAOXIN)
>>           return -1;
> 
> Many of the changelogs that add new vendors here go on about particular
> C states declared in the _CST object and contents of CPUID leaf 5.
> 
> Why do we even _have_ a vendor check here?  Shouldn't the code just be
> going and doing the validation of the _CST object and CPUID that the
> changelogs blather on about?
> 

Yes, agree!

Will change as below. Please help to check if it is OK. Thanks a lot.
  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;

> Intel certainly made the original sin on this one (see 991528d7348), but
> I hope _something_ changed in the 16 years since that patch went in.
> .
> 

-- 
Sincerely
TonyWWang-oc

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

end of thread, other threads:[~2022-06-24  3:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-23  1:26 [PATCH V1] x86/cstate: Add Zhaoxin/Centaur ACPI Cx FFH MWAIT support Tony W Wang-oc
2022-06-23 15:55 ` Dave Hansen
2022-06-24  3:05   ` Tony W Wang-oc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox