Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751249AbdFBHGm (ORCPT ); Fri, 2 Jun 2017 03:06:42 -0400 Received: from goliath.siemens.de ([192.35.17.28]:49086 "EHLO goliath.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750918AbdFBHGj (ORCPT ); Fri, 2 Jun 2017 03:06:39 -0400 From: Jan Kiszka Subject: [PATCH v2] acpi: configfs: Unload SSDT on configfs entry removal To: "Rafael J. Wysocki" , Len Brown Cc: Lv Zheng , linux-acpi@vger.kernel.org, Linux Kernel Mailing List , devel@acpica.org, "Moore, Robert" Message-ID: <3e2e6c99-a833-5c98-a5d0-ae5eddfbefe5@siemens.com> Date: Fri, 2 Jun 2017 09:06:20 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2247 Lines: 72 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 --- Changes in v2: - do not touch acpica drivers/acpi/acpi_configfs.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/acpi_configfs.c b/drivers/acpi/acpi_configfs.c index 146a77fb762d..853bc7fc673f 100644 --- a/drivers/acpi/acpi_configfs.c +++ b/drivers/acpi/acpi_configfs.c @@ -15,11 +15,15 @@ #include #include +#include "acpica/accommon.h" +#include "acpica/actables.h" + static struct config_group *acpi_table_group; struct acpi_table { struct config_item cfg; struct acpi_table_header *header; + u32 index; }; static ssize_t acpi_table_aml_write(struct config_item *cfg, @@ -52,7 +56,11 @@ static ssize_t acpi_table_aml_write(struct config_item *cfg, if (!table->header) return -ENOMEM; - ret = acpi_load_table(table->header); + ACPI_INFO(("Host-directed Dynamic ACPI Table Load:")); + ret = acpi_tb_install_and_load_table( + ACPI_PTR_TO_PHYSADDR(table->header), + ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL, FALSE, + &table->index); if (ret) { kfree(table->header); table->header = NULL; @@ -215,8 +223,18 @@ static struct config_item *acpi_table_make_item(struct config_group *group, return &table->cfg; } +static void acpi_table_drop_item(struct config_group *group, + struct config_item *cfg) +{ + struct acpi_table *table = container_of(cfg, struct acpi_table, cfg); + + ACPI_INFO(("Host-directed Dynamic ACPI Table Unload")); + acpi_tb_unload_table(table->index); +} + struct configfs_group_operations acpi_table_group_ops = { .make_item = acpi_table_make_item, + .drop_item = acpi_table_drop_item, }; static struct config_item_type acpi_tables_type = {