Search code examples
linux-kernellinux-device-driveracpi

How to unload an overlay loaded using ACPI_CONFIG_SYSFS


https://www.kernel.org/doc/html/latest/admin-guide/acpi/ssdt-overlays.html gives the following method to load an overlay

cd /config/acpi/table
mkdir my_ssdt
cat ~/ssdt.aml > my_ssdt/aml

This method only works once. Once I have loaded the aml file, I can't reload it.

[ 1901.153829] ACPI configfs: table already loaded

Is there a way to unload the aml file? At the moment, I am trying to load a enumerate the device using ACPI. Being new to ACPI and Overlays, am updating the asl file to fix issues, and recompiling and attempting to load.

But once the module is loaded, the kernel does not seem to apply the overlay again forcing me to reload the and then re-check.

So is there a way to reload the re-genrated aml file?


Solution

  • The kernel documentation indeed doesn't describe this moment. However, if you look into the source code of ACPI ConfigFS support you may see that it supports dropping items. It is a basic stuff by ConfigFS API, namely reaction to rmdir() system call. So, it means that simple removing the folder is what you need in order to unload the table:

    rm -rf /sys/kernel/config/acpi/table/my_ssdt
    

    Note, this is a debug feature and not guaranteed to work properly on all possible type of tables. In kernel only SPI, I2C and platform devices can be unbound.

    Also note, that unloading tables wasn't in the kernel till the commit Unload SSDT on configfs entry removal appears.