Skip to content

Latest commit

 

History

21 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

amd_pmc Kernel Module fixed for some IdeaPads and backported

This kernel module is a driver for the AMD SoC Power Management Controller and usually part of the Linux kernel, under drivers/platform/x86/amd/pmc/

Taken from v7.0 and patched to work around a bug on some Lenovo laptops, mostly IdeaPad Slim 3 models with either Zen3 or Zen3+ CPU. That bug manifests as broken keyboard and lid switch after suspend+resume.

See also my blogpost about it and the issue in the kernel bugzilla and the pull request to get my fix upstream.


Note: This fix will be in upstream kernel 7.2 (already is in current RC) and is in the latest stable and longterm update releases (7.1.5, 6.18.41, 6.12.100, 6.6.147).

I haven't checked if any distros have merged this yet into their kernels yet, I hope they will. If yours hasn't, just keep on using the module provided here :-)


I modified the source so it compiles with Linux Kernel 6.5 and newer.
Note: I made sure it compiles with various kernel versions, but only tested the functionality with 6.18 and 7.0. Please let me know if it doesn't build or work on other versions (>= 6.5).

Possibly remaining problems (with wakealarm)

Unfortunately, this does not completely fix the issues on all devices.

Normal suspend and resume (with keyboard or lid switch or touchpad, ...) works fine, but timer-base suspend+resume ("wakealarm", used by the amd-s2idle testprogram or rtcwake, for example) still has the old problems on some machines (like my 16ABR8), but apparently works fine on others (like 14ARP10).

I think this shouldn't be a big problem in practice, but you should probably be aware of this.

At least on 16ABR8 you can still use the i8042.nopnp kernel commandline parameter to keep most of the keyboard functional after a timed suspend - that will allow you to unlock your screensaver after resume, save your open files and then reboot to restore full keyboard and lid switch functionality.

Building and installing

First you need to get this project on your computer, either by cloning it with git or by downloading and extracting a source ZIP.

You'll need the headers for your currently running kernel installed and also a compiler and GNU make.

... with DKMS

Add it to dkms (will copy the source to /usr/src/amd_pmc-0.0.4/, among other things):
$ sudo dkms add path/to/amd_pmc-ideapad/
(replace path/to/amd_pmc-ideapad/ with the path to the directory with the source)

If you have installed an older version version like 0.0.3, remove it now (if not, skip this command):
$ sudo dkms remove amd_pmc/0.0.3 --all
and/or the same with amd_pmc/0.0.2 or amd_pmc/0.0.1

Build a module for your currently running kernel:
$ sudo dkms build amd_pmc/0.0.4

Install the freshly built module:
$ sudo dkms install amd_pmc/0.0.4

Now you could either just reboot or unload the old module and load the new one, like:
$ sudo rmmod amd-pmc
$ sudo modprobe amd-pmc

See below for how to make sure all this actually worked.

... manually

Build it:

$ make -C /lib/modules/`uname -r`/build M=$PWD

To test it without installing, you can do
$ sudo rmmod amd-pmc
to unload the currently loaded (old) amd_pmc module, then
$ sudo insmod ./amd-pmc.ko
to load the freshly built module.
(See below for how to make sure it works)

To actually install this module for the current kernel, run

$ sudo make -C /lib/modules/`uname -r`/build M=$PWD modules_install

Note: I recommend using DKMS once you've successfully tested this, so the fixed module gets built and used automatically when the kernel is updated.

Making sure it works

The easiest check to see if the new module has been loaded is
ls /sys/module/amd_pmc/parameters/delay_suspend

If that file actually exists, the patched module is loaded.

If you have a Lenovo laptop and run
sudo dmidecode -s system-product-name
and it shows a name that is "83MM" or either starts with "82X" (like "82XR") or "83K" (like "83K6"), the workaround will be used automatically.

If you have another laptop and want to try if this workaround helps there as well, you can enforce its usage with
$ echo 1 | sudo tee /sys/module/amd_pmc/parameters/delay_suspend

Now to test, just suspend the laptop. Wait 10 seconds or so until it's really asleep, then wake it up again. Try if the keyboard, incl. the Fn keys/multimedia keys still work.

You can check in dmesg if this workaround was used.
There will be a line like
[ 65.812742] amd_pmc AMDI0005:00: Delaying suspend by 2.5s to avoid platform bug
if your laptop was automatically detected as affected, or
[ 65.812742] amd_pmc AMDI0005:00: Delaying suspend by 2.5s because delay_suspend=1. If this solves problems on your machine, please report this whole line (...)
if you enforced using it by setting the module parameter.

If your laptop is affected and not automatically detected, please report that to me so I can add it. Please post the whole Delaying suspend for 2.5s because delay_suspend=1. If (...) line from dmesg, it contains information needed to identify your device in the quirks list.

To permanently enforce using it (on laptops not automatically detected as affected), add a file /etc/modprobe.d/my_amd_pmc.conf with the following content:

# always enable the delay_suspend workaround when amd_pmc is loaded
options amd_pmc delay_suspend=1

License

The original source is:

Copyright (c) 2020-2026, Advanced Micro Devices, Inc.

Licensed under GPLv2, most files GPLv2 or later. See LICENSE for the GPLv2 text.

About

Linux amd_pmc kernelmodule patched to work around IdeaPad firmware bugs

Resources

Stars

32 stars

Watchers

5 watching

Forks

Releases

Packages

Contributors

Languages