How to use AMD P-State in Linux

It was working here with 5.18.10, but after upgrading to 5.18.11 it stopped working too.
CPU: 5600x

Just curious, can you provide the output of sudo rdmsr 0xc00102b1
You’ll need msr-tools package…

(https://github.com/torvalds/linux/blob/4a57a8400075bc5287c5c877702c68aeae2a033d/arch/x86/include/asm/msr-index.h#L557)

$ sudo rdmsr 0xc00102b1
0

$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver
acpi-cpufreq

$ cat /etc/default/grub | grep amd
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 nowatchdog nvme_load=YES amd_pstate.shared_mem=1"

$ cat /etc/modules-load.d/amd-pstate.conf
# Load amd pstate at boot
amd_pstate
sudo wrmsr 0xc00102b1 1
sudo rmmod acpi-cpufreq
sudo modprobe amd-pstate -v
cpupower frequency-info

same …

$ sudo wrmsr 0xc00102b1 1
$ sudo rmmod acpi-cpufreq
$ sudo modprobe amd-pstate -v
insmod /lib/modules/5.18.11-arch1-1/kernel/drivers/cpufreq/amd_pstate.ko.zst shared_mem=1 
modprobe: ERROR: could not insert 'amd_pstate': No such device

$ LANG=C cpupower frequency-info
analyzing CPU 0:
  no or unknown cpufreq driver is active on this CPU
  CPUs which run at the same hardware frequency: Not Available
  CPUs which need to have their frequency coordinated by software: Not Available
  maximum transition latency:  Cannot determine or is not supported.
Not Available
  available cpufreq governors: Not Available
  Unable to determine current policy
  current CPU frequency: Unable to call hardware
  current CPU frequency:  Unable to call to kernel
  boost state support:
    Supported: yes
    Active: no

:frowning_face: Was worth a try at least.
You might want to load acpi-cpufreq again: sudo modprobe acpi-cpufreq…

1 Like

I’m also getting the same as @anon49550872 on my desktop cpu Ryzen 3800X which was working previously.

this could be it … i mean what has changed so we need another one for desktop cpus…

I’d go bisecting the kernel, but for me it never worked…

what cpu is yours?

Zen2, 4850U. my firmware/BIOS does not have cppc enabled hence it never worked.

zen2 … mine is zen3

i just downgraded kernel and it is working on the old one (only to make sure it is with the kernel)

I think have an idea what the issue is.
Is it correct that you guys (with Zen3 Desktop CPU) had to use the shared_mem flag to be able to load the driver?

https://www.kernel.org/doc/html/latest/admin-guide/pm/amd-pstate.html#kernel-module-options-for-amd-pstate

so now i see … if lscpu | grep cppc gives cppc and what if not:

If the CPU flags have cppc, then this processor supports Full MSR Support. Otherwise, it supports Shared Memory Support.

I would not mind that much… but without this i can not use lower frequencies… and the CPU runs on a minimum of 2.20GHz on all 12 cores… this is not really needed on normal usage… with it enabled i can go down to 500MHz

1 Like

My guess is that the root cause is in some of those CPPC commits (which somehow causes the shared_mem variant not work anymore).

Now there were also a lot of changes due to retbleed. Maybe it’s somehow related to that :man_shrugging: (although for Zen3 it’s probably not relevant/active actually)

If not already, could you try booting with mitigations=off kernel parameter?

If it was working in 5.18.10 and broke with 5.18.11 then it’s very likely to be a regression and therefore fixed in 5.18.12.

It always surprises me when people seem to panic and run around trying to fix something like this by changing configuration settings that worked just fine before.

2 Likes

Can someone check the change between 5.18.10 and 5.18.11 if it has bug?

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/diff/arch/x86/kernel/acpi/cppc.c?id=v5.18.11&id2=v5.18.10

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/diff/drivers/acpi/cppc_acpi.c?id=v5.18.11&id2=v5.18.10

It works on my end with: AMD Ryzen 7 5700U

$ uname -a
Linux arch-gnome 5.18.11-zen1-1-zen #1 ZEN SMP PREEMPT_DYNAMIC Tue, 12 Jul 2022 15:44:35 +0000 x86_64 GNU/Linux
$ cpupower frequency-info 
analyzing CPU 0:
  driver: amd-pstate
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 131 us
  hardware limits: 400 MHz - 4.37 GHz
  available cpufreq governors: conservative ondemand userspace powersave performance schedutil
  current policy: frequency should be within 400 MHz and 4.37 GHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency: Unable to call hardware
  current CPU frequency: 1.10 GHz (asserted by call to kernel)
  boost state support:
    Supported: yes
    Active: yes
    AMD PSTATE Highest Performance: 255. Maximum Frequency: 4.37 GHz.
    AMD PSTATE Nominal Performance: 105. Nominal Frequency: 1.80 GHz.
    AMD PSTATE Lowest Non-linear Performance: 65. Lowest Non-linear Frequency: 1.11 GHz.
    AMD PSTATE Lowest Performance: 24. Lowest Frequency: 400 MHz.
1 Like