From ca499fc87ed945094d952da0eb7eea7dbeb1feec Mon Sep 17 00:00:00 2001 From: Toshi Kani Date: Wed, 20 Nov 2013 14:25:34 +0100 Subject: [PATCH 1/4] ACPI / hotplug: Fix conflicted PCI bridge notify handlers The PCI host bridge scan handler installs its own notify handler, handle_hotplug_event_root(), by itself. Nevertheless, the ACPI hotplug framework also installs the common notify handler, acpi_hotplug_notify_cb(), for PCI root bridges. This causes acpi_hotplug_notify_cb() to call _OST method with unsupported error as hotplug.enabled is not set. To address this issue, introduce hotplug.ignore flag, which indicates that the scan handler installs its own notify handler by itself. The ACPI hotplug framework does not install the common notify handler when this flag is set. Signed-off-by: Toshi Kani [rjw: Changed the name of the new flag] Cc: 3.9+ # 3.9+ Signed-off-by: Rafael J. Wysocki --- drivers/acpi/pci_root.c | 3 +++ drivers/acpi/scan.c | 2 +- include/acpi/acpi_bus.h | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index b5cb729328a4..a84ea1b51a89 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -65,6 +65,9 @@ static struct acpi_scan_handler pci_root_handler = { .ids = root_device_ids, .attach = acpi_pci_root_add, .detach = acpi_pci_root_remove, + .hotplug = { + .ignore = true, + }, }; static DEFINE_MUTEX(osc_lock); diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index ce518867a18a..e76b5230f476 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1773,7 +1773,7 @@ static void acpi_scan_init_hotplug(acpi_handle handle, int type) */ list_for_each_entry(hwid, &pnp.ids, list) { handler = acpi_scan_match_handler(hwid->id, NULL); - if (handler) { + if (handler && !handler->hotplug.ignore) { acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, acpi_hotplug_notify_cb, handler); break; diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index d64a3010332f..5f4bb4501305 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -100,6 +100,7 @@ enum acpi_hotplug_mode { struct acpi_hotplug_profile { struct kobject kobj; bool enabled:1; + bool ignore:1; enum acpi_hotplug_mode mode; }; From 51468a9d3a80249a218a854100c6d5d0eb8b781e Mon Sep 17 00:00:00 2001 From: Al Stone Date: Wed, 20 Nov 2013 15:45:51 -0700 Subject: [PATCH 2/4] ACPI / sleep: clean up compiler warning about uninitialized field Initialize pwr_btn_status as disabled which (a) makes sure it is in a proper state to start, and (b) cleans up a compiler warning about an uninitialized variable. Signed-off-by: Al Stone Signed-off-by: Rafael J. Wysocki --- drivers/acpi/sleep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index 14df30580e15..721e949e606e 100644 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c @@ -525,7 +525,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state) * generate wakeup events. */ if (ACPI_SUCCESS(status) && (acpi_state == ACPI_STATE_S3)) { - acpi_event_status pwr_btn_status; + acpi_event_status pwr_btn_status = ACPI_EVENT_FLAG_DISABLED; acpi_get_event_status(ACPI_EVENT_POWER_BUTTON, &pwr_btn_status); From 083ca8c4172585409170dac9955a1da8137fef49 Mon Sep 17 00:00:00 2001 From: Daisuke HATAYAMA Date: Tue, 19 Nov 2013 17:54:47 +0900 Subject: [PATCH 3/4] ACPI / sysfs: Set file size for each exposed ACPI table Currently, each of the ACPI tables exported from /sys/firmware/acpi/tables is of zero size: $ LANG=C ls -ld /sys/firmware/acpi/tables/* -r-------- 1 root root 0 Nov 19 09:48 /sys/firmware/acpi/tables/APIC -r-------- 1 root root 0 Nov 19 09:48 /sys/firmware/acpi/tables/BOOT -r-------- 1 root root 0 Nov 19 14:25 /sys/firmware/acpi/tables/DSDT -r-------- 1 root root 0 Nov 19 14:25 /sys/firmware/acpi/tables/FACP -r-------- 1 root root 0 Nov 19 14:25 /sys/firmware/acpi/tables/FACS -r-------- 1 root root 0 Nov 19 14:25 /sys/firmware/acpi/tables/MCFG -r-------- 1 root root 0 Nov 19 14:25 /sys/firmware/acpi/tables/SRAT drwxr-xr-x 2 root root 0 Nov 19 09:48 /sys/firmware/acpi/tables/dynamic/ due to which, user-land tools fail reading each table. For example: $ acpidump -f /sys/firmware/acpi/tables/SRAT Could not get input file size: /sys/firmware/acpi/tables/SRAT To deal with the issue, this patch assigns size of each ACPI table to the corresponding sysfs file. $ LANG=C ls -hld /sys/firmware/acpi/tables/* -r-------- 1 root root 94 Nov 19 16:45 /sys/firmware/acpi/tables/APIC -r-------- 1 root root 40 Nov 19 16:45 /sys/firmware/acpi/tables/BOOT -r-------- 1 root root 58K Nov 19 16:55 /sys/firmware/acpi/tables/DSDT -r-------- 1 root root 244 Nov 19 16:55 /sys/firmware/acpi/tables/FACP -r-------- 1 root root 64 Nov 19 16:55 /sys/firmware/acpi/tables/FACS -r-------- 1 root root 60 Nov 19 16:55 /sys/firmware/acpi/tables/MCFG -r-------- 1 root root 168 Nov 19 16:45 /sys/firmware/acpi/tables/SRAT drwxr-xr-x 2 root root 0 Nov 19 16:55 /sys/firmware/acpi/tables/dynamic/ Then, user-land tools work well like: $ acpidump -f /sys/firmware/acpi/tables/SRAT SRAT @ 0x0000000000000000 0000: 53 52 41 54 A8 00 00 00 02 65 56 4D 57 41 52 45 SRAT.....eVMWARE 0010: 4D 45 4D 50 4C 55 47 20 00 00 04 06 56 4D 57 20 MEMPLUG ....VMW 0020: 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 ................ 0030: 01 28 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .(.............. 0040: 00 00 0A 00 00 00 00 00 00 00 00 00 01 00 00 00 ................ 0050: 00 00 00 00 00 00 00 00 01 28 00 00 00 00 00 00 .........(...... 0060: 00 00 10 00 00 00 00 00 00 00 F0 BF 00 00 00 00 ................ 0070: 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 ................ 0080: 01 28 00 00 00 00 00 00 00 00 00 00 01 00 00 00 .(.............. 0090: 00 00 00 40 00 00 00 00 00 00 00 00 01 00 00 00 ...@............ 00A0: 00 00 00 00 00 00 00 00 ........ Signed-off-by: HATAYAMA Daisuke Acked-by: Toshi Kani Acked-by: Zhang Rui Signed-off-by: Rafael J. Wysocki --- drivers/acpi/sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c index db5293650f62..45f82c751225 100644 --- a/drivers/acpi/sysfs.c +++ b/drivers/acpi/sysfs.c @@ -309,7 +309,7 @@ static void acpi_table_attr_init(struct acpi_table_attr *table_attr, sprintf(table_attr->name + ACPI_NAME_SIZE, "%d", table_attr->instance); - table_attr->attr.size = 0; + table_attr->attr.size = table_header->length; table_attr->attr.read = acpi_table_show; table_attr->attr.attr.name = table_attr->name; table_attr->attr.attr.mode = 0400; From de03beedb43fa1fd26792a4e502eeacbf5a6bade Mon Sep 17 00:00:00 2001 From: Jeremy Compostella Date: Thu, 21 Nov 2013 11:20:23 +0100 Subject: [PATCH 4/4] ACPI / sysfs: Fix incorrect ACPI tables walk in acpi_tables_sysfs_init() When executing on an ACPI Hardware Reduced hardware, all the ACPI tables are not exposed in sysfs due to the fact that FACS is silently ignored by the kernel in the ACPI hardware reduced mode and, moreover, the acpi_tables_sysfs_init() ACPI table walk is buggy and stops too soon. The acpi_tables_sysfs_init() function should rely on the acpi_status return value from acpi_get_table_by_index() to decide whether or not to stop the iteration (the walk should only be terminated when that value is AE_BAD_PARAMETER). This way, when running in an ACPI Harware Reduced environment (where the FACS table is silently ignored by the kernel) or if some ACPI tables are not correctly memory mapped or have bad checksums, it will still walk through the remaining tables that may be correct. [rjw: Changelog] Signed-off-by: Jeremy Compostella Signed-off-by: Rafael J. Wysocki --- drivers/acpi/sysfs.c | 50 +++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c index 45f82c751225..6dbc3ca45223 100644 --- a/drivers/acpi/sysfs.c +++ b/drivers/acpi/sysfs.c @@ -354,8 +354,9 @@ static int acpi_tables_sysfs_init(void) { struct acpi_table_attr *table_attr; struct acpi_table_header *table_header = NULL; - int table_index = 0; - int result; + int table_index; + acpi_status status; + int ret; tables_kobj = kobject_create_and_add("tables", acpi_kobj); if (!tables_kobj) @@ -365,33 +366,34 @@ static int acpi_tables_sysfs_init(void) if (!dynamic_tables_kobj) goto err_dynamic_tables; - do { - result = acpi_get_table_by_index(table_index, &table_header); - if (!result) { - table_index++; - table_attr = NULL; - table_attr = - kzalloc(sizeof(struct acpi_table_attr), GFP_KERNEL); - if (!table_attr) - return -ENOMEM; + for (table_index = 0;; table_index++) { + status = acpi_get_table_by_index(table_index, &table_header); - acpi_table_attr_init(table_attr, table_header); - result = - sysfs_create_bin_file(tables_kobj, - &table_attr->attr); - if (result) { - kfree(table_attr); - return result; - } else - list_add_tail(&table_attr->node, - &acpi_table_attr_list); + if (status == AE_BAD_PARAMETER) + break; + + if (ACPI_FAILURE(status)) + continue; + + table_attr = NULL; + table_attr = kzalloc(sizeof(*table_attr), GFP_KERNEL); + if (!table_attr) + return -ENOMEM; + + acpi_table_attr_init(table_attr, table_header); + ret = sysfs_create_bin_file(tables_kobj, &table_attr->attr); + if (ret) { + kfree(table_attr); + return ret; } - } while (!result); + list_add_tail(&table_attr->node, &acpi_table_attr_list); + } + kobject_uevent(tables_kobj, KOBJ_ADD); kobject_uevent(dynamic_tables_kobj, KOBJ_ADD); - result = acpi_install_table_handler(acpi_sysfs_table_handler, NULL); + status = acpi_install_table_handler(acpi_sysfs_table_handler, NULL); - return result == AE_OK ? 0 : -EINVAL; + return ACPI_FAILURE(status) ? -EINVAL : 0; err_dynamic_tables: kobject_put(tables_kobj); err: