Bug 216248

Summary: [Regression] amd-pstate stops working after [ACPI: CPPC: Check _OSC for flexible address space]
Product: Power Management Reporter: Arek Ruśniak (arek.rusi)
Component: cpufreqAssignee: linux-pm (linux-pm)
Status: RESOLVED CODE_FIX    
Severity: normal CC: manualinux, mario.limonciello, pandre0x59, Perry.Yuan, perry_yuan, pierre.gondois, tasksynctest
Priority: P1    
Hardware: AMD   
OS: Linux   
Kernel Version: 5.18.11 Subsystem:
Regression: Yes Bisected commit-id:
Attachments: lscpu
dmesg
acpidump
dmesg with more debug stuff
dmesg 5.18.10 - with working amd_pstate
possible patch to avoid the error

Description Arek Ruśniak 2022-07-14 20:40:31 UTC
Created attachment 301428 [details]
lscpu

Model name: AMD Ryzen 7 5800HS with Radeon Graphics
CPU family: 25
Model: 80
Flags: ... cppc ...

amd-pstate won't load:
modprobe: ERROR: could not insert 'amd_pstate': No such device

first bad commit is: 13bb696dd2f3bd5f23a6be2d97063ee3bdb6b690
[ACPI: CPPC: Check _OSC for flexible address space]

it cannot be simlpy reverted unfortunaltelly 

Issue is quite simmilar to: 
https://lore.kernel.org/lkml/3559249.JlDtxWtqDm@natalenko.name/

To be sure i've tweaked that patch to fit to my cpu, but it didn't work.
Comment 1 Mario Limonciello (AMD) 2022-07-15 03:12:51 UTC
I believe your CPU should support the MSR approach.  It should have been fixed by "ACPI: CPPC: Don't require _OSC if X86_FEATURE_CPPC is supported".  You can see in your lscpu output the "cppc" flag is present.

That other patch won't matter.  That patch was specifically to fix "ACPI: bus: Set CPPC _OSC bits for all and when CPPC_LIB is supported".

A few asks:
1) Does acpi-cpufreq work?  Or that's broken too from this commit?
2) Can you please share your full dmesg and an acpidump?
3) If you turn on dynamic debugging for drivers/acpi/cppc_acpi.c do you see "Flexible address space capability not supported"?  I would expect yes from that bisect.
Comment 2 perry_yuan 2022-07-15 03:20:05 UTC
Hi Arek:

Could try the latest kernel from linux-pm tree ?
https://kernel.googlesource.com/pub/scm/linux/kernel/git/rafael/linux-pm.git

I tried this tree, the pstate driver can be loaded.

[  250.010934] cpufreq: setting new policy for CPU 15: 400000 - 4673000 kHz
[  250.010935] cpufreq: new min and max freqs are 400000 - 4673000 kHz
[  250.010935] cpufreq: governor limits update
[  250.010935] cpufreq: cpufreq_governor_limits: for CPU 15
[  250.010936] cpufreq: initialization complete
[  250.010937] cpufreq: driver amd-pstate up and running


 5.19.0-rc6+ #13 SMP PREEMPT_DYNAMIC Fri Jul 15 11:07:12 CST 2022 x86_64 x86_64 x86_64 GNU/Linux

My system has the same model id like yours. 

Vendor ID:                       AuthenticAMD
CPU family:                      25
Model:                           80

with cppc flag in cpuid

Perry.
Comment 3 Arek Ruśniak 2022-07-15 08:09:30 UTC
I've built ...git/rafael/linux-pm.git #branch=bleeding-edge (as far I can see it's match linux-next) amd-pstate not working.

I've done any dumps on this build (hope it's not a problem)

1)it's loaded but not detect boost (but according to turbostats boost works)
2)will be uploaded
3)yes, you have right:
 [    0.494379] ACPI CPPC: CPPC v2 _OSC not acked
 [    0.494388] ACPI CPPC: Flexible address space capability not supported
Comment 4 Arek Ruśniak 2022-07-15 08:11:04 UTC
Created attachment 301431 [details]
dmesg
Comment 5 Arek Ruśniak 2022-07-15 08:12:17 UTC
Created attachment 301432 [details]
acpidump
Comment 6 Perry Yuan(AMD) 2022-07-15 08:56:44 UTC
(In reply to Arek Ruśniak from comment #3)
> I've built ...git/rafael/linux-pm.git #branch=bleeding-edge (as far I can
> see it's match linux-next) amd-pstate not working.
> 
> I've done any dumps on this build (hope it's not a problem)
> 
> 1)it's loaded but not detect boost (but according to turbostats boost works)
> 2)will be uploaded
> 3)yes, you have right:
>  [    0.494379] ACPI CPPC: CPPC v2 _OSC not acked
>  [    0.494388] ACPI CPPC: Flexible address space capability not supported


Hi Arek:


Could you upload the dmesg log with below parameter in grub?

cpufreq.dyndbg=+p amd_pstate.dyndbg=+p cppc_acpi.dyndbg=+p debug loglevel=8 log_buf_len=100M

If the driver was loaded, I would like to see if there is any loading error.

also need you help to post cpupower output .

# sudo cpupower frequency-info 

Perry.
Comment 7 Arek Ruśniak 2022-07-15 09:20:08 UTC
Created attachment 301434 [details]
dmesg with more debug stuff

[    3.964861] amd_pstate: the _CPC object is not present in SBIOS
is this what we are looking for?
Comment 8 Arek Ruśniak 2022-07-15 09:21:42 UTC
# cpupower frequency-info 
analyzing CPU 0:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency:  Cannot determine or is not supported.
  hardware limits: 1.20 GHz - 3.20 GHz
  available frequency steps:  3.20 GHz, 1.30 GHz, 1.20 GHz
  available cpufreq governors: conservative ondemand userspace powersave performance schedutil
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "schedutil" may decide which speed to use
                  within this range.
  current CPU frequency: 1.20 GHz (asserted by call to hardware)
  boost state support:
    Supported: yes
    Active: yes
    Boost States: 0
    Total States: 3
    Pstate-P0:  3200MHz
    Pstate-P1:  1300MHz
    Pstate-P2:  1200MHz
Comment 9 Arek Ruśniak 2022-07-15 09:37:57 UTC
Created attachment 301435 [details]
dmesg 5.18.10 - with working amd_pstate
Comment 10 José Luis Lara Carrascal 2022-07-15 10:36:30 UTC
Hello,

I have the same problem with kernel 5.18.11, which is still in kernel 5.18.12, released today.

I have an AMD Ryzen 3 3100, and I use the kernel boot option: amd_pstate.shared_mem=1. With kernel 5.18.10 and earlier, no problem.

Regards.
Comment 11 Arek Ruśniak 2022-07-15 10:43:44 UTC
Hi Jose, did you try:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?h=next-20220714&id=fbd74d16890b9f5d08ea69b5282b123c894f8860

It's fixing issue I've mentioned in #1
Comment 12 José Luis Lara Carrascal 2022-07-15 10:52:04 UTC
(In reply to Arek Ruśniak from comment #11)
> Hi Jose, did you try:
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/
> ?h=next-20220714&id=fbd74d16890b9f5d08ea69b5282b123c894f8860
> 
> It's fixing issue I've mentioned in #1

Thank you, I will try it.
Comment 13 José Luis Lara Carrascal 2022-07-15 11:00:28 UTC
Problem solved. Thanks to all.
Comment 14 Mario Limonciello (AMD) 2022-07-15 15:20:16 UTC
> [    0.688308] ACPI CPPC: CPPC v2 _OSC not acked

OK good, this confirms that your system had _OSC not advertising.
> [    0.688392] ACPI CPPC: Flexible address space capability not supported

That does confirm that your assertion of the bisect was the cause.

I'm attaching a patch that I think can help the problem.
Comment 15 Mario Limonciello (AMD) 2022-07-15 15:20:41 UTC
Created attachment 301440 [details]
possible patch to avoid the error
Comment 16 Arek Ruśniak 2022-07-15 17:30:44 UTC
Mario, Perry thanks a lot for help.
I've testing patch onto 5.18.2 and it works as before. 

[    3.337866] amd_pstate: AMD CPPC MSR based functionality is supported
Comment 17 Arek Ruśniak 2022-07-15 17:32:48 UTC
*I mean 5.18.12*
Comment 18 phandrix 2022-07-17 13:55:40 UTC
Hi Mario, the patch don’t solve the issue on Zen2 CPU on Arch Linux or Based Systems. I saw some reports on the Manjaro forum.: https://forum.manjaro.org/t/testing-update-2022-07-17-kernel-5-18-octopi-haskell-python/116789

Patch is applied.
Comment 20 Arek Ruśniak 2022-07-17 14:06:41 UTC
Hi, phandrix did you read issue i've mention in #1
https://lore.kernel.org/lkml/3559249.JlDtxWtqDm@natalenko.name/
an patch for that issue:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?h=next-20220715&id=fbd74d16890b9f5d08ea69b5282b123c894f8860
if it still not helps, and you don't have 'cppc' flag in lscpu output please file a new bug,
Comment 21 pierre.gondois 2022-07-17 17:53:24 UTC
Hi,
Sorry for the mess I created and thanks Mario for fixing it. It s a bit late but please let me know if I can be of any help,
Pierre
Comment 22 phandrix 2022-07-17 21:13:35 UTC
Hi,

I will just say that amd_pstate work again on Manjaro. Both patches applied there. 

Hope it will be upstream later. :)