How To Use The New AMD P-State Driver With Linux 5.17
![AMD](/assets/categories/amd.webp)
First up, the easiest way to check to verify your CPU frequency scaling driver is by reading /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver to see if you are on acpi-cpufreq or amd-pstate. As a reminder, AMD P-State is only supported with AMD Zen 2 processors and newer. AMD P-State depends upon ACPI Collaborative Processor Performance Contols (CPPC) and that is only with Zen 2 and newer -- Zen 1 / Zen 1+ will not be seeing any support. You also need to ensure CPPC is enabled in your BIOS in case it happened to be disabled. Many motherboard vendors do have a "ACPI CPPC" option in the BIOS that can be set to enabled or auto on Zen 2 and newer processors.
This guide was written making use of Ubuntu with their Ubuntu Mainline Kernel PPA kernel builds. ACPI CPUFreq is the default still with their Linux 5.17+ kernel builds but the AMD P-State module is included as part of the kernel builds. Most other distro kernel builds will at least likely have the CONFIG_X86_AMD_PSTATE=m option enabled so it's at least built. If you don't see CONFIG_X86_AMD_PSTATE and it's commented out or "n", you would need to first rebuild your kernel so that driver is included.
On most (all?) distribution kernels the ACPI CPUFreq driver is built into the kernel and not a module, so simply blacklisting it will not work. To avoid loading ACPI CPUFreq even if it's built-in, the "initcall_blacklist=acpi_cpufreq_init" option can be set in your /boot/grub/grub.cfg or respective place for editing your kernel command line options at boot (e.g. "/etc/default/grub" for a more permanent solution). This initcall_blacklist is needed to prevent the ACPI CPUFreq initialization function from being called and thus then allowing AMD P-State to successfully initialize. For Ubuntu/initramfs users wanting to have AMD P-State loaded by default, you can also add "amd_pstate" to the "/etc/initramfs-tools/modules " file followed by running update-initramfs -u.
After a reboot with those changes made to blacklist the ACPI CPUFreq driver and to load the AMD P-State driver, you should then be on that new AMD CPU frequency scaling driver code path. Again, you can check /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver to verify. If you are on the new driver, it should print amd-pstate. If that file isn't present you may have successfully black-listed ACPI CPUFreq but AMD P-State didn't load yet in which case you can try modprobe amd-pstate.
If AMD P-State still isn't working, you may need to add amd_pstate.shared_mem=1 as part of your kernel command line configuration. With Linux 5.17 some systems require using the "shared_mem" module option for AMD P-State to correctly function with some hardware. Hopefully soon that limitation will be addressed to not require setting that extra option.
That's the quick overview if left wondering how to enable AMD P-State on Linux 5.17. If any questions or issues stop by our forums / commenting on this article. I'll have up some new AMD P-State benchmarks off Linux 5.17 final shortly. Keep in mind though this driver is initially focused on Ryzen mobile APUs like the Steam Deck while moving forward expect to see more desktop (and perhaps AMD EPYC server) tuning.
35 Comments