Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ACPI: configfs: Unload SSDT on configfs entry removal

Call directly into acpica to load a table to obtain its index on return.
We choose the direct call of acpica internal functions to avoid having
to modify its API which is used outside of Linux as well.

Use that index to unload the table again when the corresponding
directory in configfs gets removed. This allows to change SSDTs without
rebooting the system. It also allows to destroy devices again that a
dynamically loaded SSDT created.

This is widely similar to the DT overlay behavior.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Jan Kiszka and committed by
Rafael J. Wysocki
772bf1e2 41f1830f

+23 -1
+19 -1
drivers/acpi/acpi_configfs.c
··· 15 15 #include <linux/configfs.h> 16 16 #include <linux/acpi.h> 17 17 18 + #include "acpica/accommon.h" 19 + #include "acpica/actables.h" 20 + 18 21 static struct config_group *acpi_table_group; 19 22 20 23 struct acpi_table { 21 24 struct config_item cfg; 22 25 struct acpi_table_header *header; 26 + u32 index; 23 27 }; 24 28 25 29 static ssize_t acpi_table_aml_write(struct config_item *cfg, ··· 56 52 if (!table->header) 57 53 return -ENOMEM; 58 54 59 - ret = acpi_load_table(table->header); 55 + ACPI_INFO(("Host-directed Dynamic ACPI Table Load:")); 56 + ret = acpi_tb_install_and_load_table( 57 + ACPI_PTR_TO_PHYSADDR(table->header), 58 + ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL, FALSE, 59 + &table->index); 60 60 if (ret) { 61 61 kfree(table->header); 62 62 table->header = NULL; ··· 223 215 return &table->cfg; 224 216 } 225 217 218 + static void acpi_table_drop_item(struct config_group *group, 219 + struct config_item *cfg) 220 + { 221 + struct acpi_table *table = container_of(cfg, struct acpi_table, cfg); 222 + 223 + ACPI_INFO(("Host-directed Dynamic ACPI Table Unload")); 224 + acpi_tb_unload_table(table->index); 225 + } 226 + 226 227 struct configfs_group_operations acpi_table_group_ops = { 227 228 .make_item = acpi_table_make_item, 229 + .drop_item = acpi_table_drop_item, 228 230 }; 229 231 230 232 static struct config_item_type acpi_tables_type = {
+4
drivers/acpi/acpica/tbdata.c
··· 867 867 return_ACPI_STATUS(status); 868 868 } 869 869 870 + ACPI_EXPORT_SYMBOL(acpi_tb_install_and_load_table) 871 + 870 872 /******************************************************************************* 871 873 * 872 874 * FUNCTION: acpi_tb_unload_table ··· 916 914 acpi_tb_set_table_loaded_flag(table_index, FALSE); 917 915 return_ACPI_STATUS(status); 918 916 } 917 + 918 + ACPI_EXPORT_SYMBOL(acpi_tb_unload_table)