Fixing a set of bugs for ioapic hotplug
v4 cover Fixing a set of bugs for ioapic hotplug
A set of patches fixing bugs found while testing IOAPIC hotplug.
Regards,
Rui
Changelog:
Changes from v3 to v4:
* Rebased on top of 4.8-rc2 and re-tested it.
* Added the missing 'Acked-by: Bjorn Helgaas <[email protected]>' in 0002.
* Sent to [email protected] for review as suggested by Rafael.
Changes from v2 to v3:
* Rebased on top of 4.8-rc1 per Bjorn & Rafael.
* Improved the commit message of 0003, w/ clearer explanation.
Changes from v1 to v2:
* Split the first patch into two as advised by Bjorn: "would be nicer if the interface change and header file munging were in a separate patch so they wouldn't obscure the meat of the change, i.e., the addition of calls to acpi_ioapic_add()."
* Removed acpi_ioapic_add() as an exported symbol.
* Fixed some typos, and s/acpi/ACPI/, s/ioapic/IOAPIC/ throughout.
* Fixed a warning from 0-day testing.
Rui Wang (5):
x86/ioapic: Change prototype of acpi_ioapic_add() x86/ioapic: Support hot-removal of IOAPICs present during boot x86/ioapic: Fix setup_res() failing to get resource x86/ioapic: Fix lost IOAPIC resource after hot-removal and hotadd x86/ioapic: Fix ioapic failing to request resource
drivers/acpi/internal.h | 2 -- drivers/acpi/ioapic.c | 46 ++++++++++++++++++++++++++-------------------- drivers/acpi/pci_root.c | 12 +++++++++++- drivers/pci/setup-bus.c | 5 ++++- include/linux/acpi.h | 6 ++++++ 5 files changed, 47 insertions(+), 24 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v4 1/5 x86/ioapic: Change prototype of acpi_ioapic_add()
Change the argument of acpi_ioapic_add() to a generic ACPI handle, and move its prototype from drivers/acpi/internal.h to include/linux/acpi.h so that it can be called from outside the pci_root driver.
--- drivers/acpi/internal.h | 2 -- drivers/acpi/ioapic.c | 6 +++--- drivers/acpi/pci_root.c | 2 +- include/linux/acpi.h | 6 ++++++ 4 files changed, 10 insertions(+), 6 deletions(-)
drivers/acpi/internal.h +0 -2
@@ -40,10 +40,8 @@ int acpi_sysfs_init(void);void acpi_container_init (void );void acpi_memory_hotplug_init (void );#ifdef CONFIG_ACPI_HOTPLUG_IOAPIC -int acpi_ioapic_add (struct acpi_pci_root *root);int acpi_ioapic_remove (struct acpi_pci_root *root);#else -static inline int acpi_ioapic_add (struct acpi_pci_root *root) {return 0 ; }static inline int acpi_ioapic_remove (struct acpi_pci_root *root) {return 0 ; }#endif #ifdef CONFIG_ACPI_DOCK
drivers/acpi/ioapic.c +3 -3
@@ -189,13 +189,13 @@ exit:return AE_OK ; } -int acpi_ioapic_add (struct acpi_pci_root *root) +int acpi_ioapic_add (acpi_handle root_handle) {acpi_status status, retval =AE_OK ; - status =acpi_walk_namespace (ACPI_TYPE_DEVICE , root->device->handle, + status =acpi_walk_namespace (ACPI_TYPE_DEVICE , root_handle,UINT_MAX , handle_ioapic_add,NULL , - root->device->handle, (void **)&retval); + root_handle, (void **)&retval);return ACPI_SUCCESS (status) &&ACPI_SUCCESS (retval) ?0 : -ENODEV ; }
drivers/acpi/pci_root.c +1 -1
@@ -614,7 +614,7 @@ static int acpi_pci_root_add(struct acpi_device *device,if (hotadd) {pcibios_resource_survey_bus (root->bus);pci_assign_unassigned_root_bus_resources (root->bus); -acpi_ioapic_add (root); +acpi_ioapic_add (root->device->handle); }pci_lock_rescan_remove ();
include/linux/acpi.h +6 -0
@@ -751,6 +751,12 @@ static inline int acpi_reconfig_notifier_unregister(struct notifier_block *nb)#endif /* !CONFIG_ACPI */ +#ifdef CONFIG_ACPI_HOTPLUG_IOAPIC +int acpi_ioapic_add (acpi_handle root); +#else +static inline int acpi_ioapic_add (acpi_handle root) {return 0 ; } +#endif +#ifdef CONFIG_ACPI void acpi_os_set_prepare_sleep (int (*func)(u8 sleep_state,u32 pm1a_ctrl,u32 pm1b_ctrl));
Signature · 1 line
1.8.3.1
PATCH v4 2/5 x86/ioapic: Support hot-removal of IOAPICs present during boot
In reply to Rui WangIOAPICs present during system boot aren't added to ioapic_list, thus are unable to be hot-removed. Fix it by calling acpi_ioapic_add() during root bus enumeration.
--- drivers/acpi/pci_root.c | 10 ++++++++++ drivers/pci/setup-bus.c | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-)
drivers/acpi/pci_root.c +10 -0
@@ -614,6 +614,16 @@ static int acpi_pci_root_add(struct acpi_device *device,if (hotadd) {pcibios_resource_survey_bus (root->bus);pci_assign_unassigned_root_bus_resources (root->bus); +/* +* This is only called for the hotadd case. For the boot-time +* case, we need to wait until after PCI initialization in +* order to deal with IOAPICs mapped in on a PCI BAR. +* +* This is currently x86-specific, because acpi_ioapic_add() +* is an empty function without CONFIG_ACPI_HOTPLUG_IOAPIC. +* And CONFIG_ACPI_HOTPLUG_IOAPIC depends on CONFIG_X86_IO_APIC +* (see drivers/acpi/Kconfig). +*/ acpi_ioapic_add (root->device->handle); }
drivers/pci/setup-bus.c +4 -1
@@ -25,6 +25,7 @@#include <linux/ioport.h> #include <linux/cache.h> #include <linux/slab.h> +#include <linux/acpi.h> #include "pci.h" unsigned int pci_flags;
@@ -1852,8 +1853,10 @@ void __init pci_assign_unassigned_resources(void) {struct pci_bus *root_bus; -list_for_each_entry (root_bus, &pci_root_buses, node) +list_for_each_entry (root_bus, &pci_root_buses, node) {pci_assign_unassigned_root_bus_resources (root_bus); +acpi_ioapic_add (ACPI_HANDLE (root_bus->bridge)); + } }void pci_assign_unassigned_bridge_resources (struct pci_dev *bridge)
Signature · 1 line
1.8.3.1
PATCH v4 3/5 x86/ioapic: Fix setup_res() failing to get resource
In reply to Rui Wangacpi_dev_filter_resource_type() returns 0 on success, and 1 on failure. A return value of zero means there's a matching resource, so we should continue within setup_res() to get the resource.
--- drivers/acpi/ioapic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/ioapic.c +1 -1
@@ -46,7 +46,7 @@ static acpi_status setup_res(struct acpi_resource *acpi_res, void *data)struct resource_win win; res->flags =0 ; -if (acpi_dev_filter_resource_type (acpi_res,IORESOURCE_MEM ) ==0 ) +if (acpi_dev_filter_resource_type (acpi_res,IORESOURCE_MEM ))return AE_OK ;if (!acpi_dev_resource_memory (acpi_res, res)) {
Signature · 1 line
1.8.3.1
PATCH v4 4/5 x86/ioapic: Fix lost IOAPIC resource after hot-removal and hotadd
In reply to Rui WangIOAPIC resource at 0xfecxxxxx gets lost from /proc/iomem after hot-removing and then hot-adding the IOAPIC device.
After system boot, in /proc/iomem:
fec00000-fecfffff : PNP0003:00
fec00000-fec003ff : IOAPIC 0
fec01000-fec013ff : IOAPIC 1
fec40000-fec403ff : IOAPIC 2
fec80000-fec803ff : IOAPIC 3
fecc0000-fecc03ff : IOAPIC 4
Then hot-remove IOAPIC 2 and hot-add it again:
fec00000-fecfffff : PNP0003:00
fec00000-fec003ff : IOAPIC 0
fec01000-fec013ff : IOAPIC 1
fec80000-fec803ff : IOAPIC 3
fecc0000-fecc03ff : IOAPIC 4
The range at 0xfec40000 is lost from /proc/iomem. It is because handle_ioapic_add() requests resource from either PCI config BAR or ACPI "_CRS", not both. But Intel platforms map the IOxAPIC registers both at the PCI config BAR (called MBAR, dynamic), and at the ACPI "_CRS" (called ABAR, static). The 0xfecX_YZ00 to 0xfecX_YZFF range appears in "_CRS" of each IOAPIC device. Both ranges should be claimed from /proc/iomem for exclusive use.
--- drivers/acpi/ioapic.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-)
drivers/acpi/ioapic.c +20 -16
@@ -97,7 +97,7 @@ static acpi_status handle_ioapic_add(acpi_handle handle, u32 lvl,unsigned long long gsi_base;struct acpi_pci_ioapic *ioapic;struct pci_dev *dev =NULL ; -struct resource *res =NULL ; +struct resource *res =NULL , *pci_res =NULL , *crs_res;char *type =NULL ;if (!acpi_is_ioapic (handle, &type))
@@ -137,23 +137,28 @@ static acpi_status handle_ioapic_add(acpi_handle handle, u32 lvl,pci_set_master (dev);if (pci_request_region (dev,0 , type)) goto exit_disable; - res = &dev->resource[0 ]; + pci_res = &dev->resource[0 ]; ioapic->pdev = dev; }else {pci_dev_put (dev); dev =NULL ; + } - res = &ioapic->res; -acpi_walk_resources (handle,METHOD_NAME__CRS , setup_res, res); -if (res->flags ==0 ) { -acpi_handle_warn (handle,"failed to get resource\n" ); - goto exit_free; - }else if (request_resource (&iomem_resource, res)) { -acpi_handle_warn (handle,"failed to insert resource\n" ); - goto exit_free; - } + crs_res = &ioapic->res; +acpi_walk_resources (handle,METHOD_NAME__CRS , setup_res, crs_res); +if (crs_res->flags ==0 ) { +acpi_handle_warn (handle,"failed to get resource\n" ); + goto exit_release; + }else if (request_resource (&iomem_resource, crs_res)) { +acpi_handle_warn (handle,"failed to insert resource\n" ); + goto exit_release; } +/* try pci resource first, then "_CRS" resource */ + res = pci_res; +if (!res || !res->flags) + res = crs_res; +if (acpi_register_ioapic (handle, res->start, (u32 )gsi_base)) {acpi_handle_warn (handle,"failed to register IOAPIC\n" ); goto exit_release;
@@ -174,14 +179,13 @@ done: exit_release:if (dev)pci_release_region (dev,0 ); -else -release_resource (res); +if (ioapic->res.flags && ioapic->res.parent) +release_resource (&ioapic->res); exit_disable:if (dev)pci_disable_device (dev); exit_put:pci_dev_put (dev); -exit_free:kfree (ioapic); exit:mutex_unlock (&ioapic_list_lock);
@@ -217,9 +221,9 @@ int acpi_ioapic_remove(struct acpi_pci_root *root)pci_release_region (ioapic->pdev,0 );pci_disable_device (ioapic->pdev);pci_dev_put (ioapic->pdev); - }else if (ioapic->res.flags && ioapic->res.parent) { -release_resource (&ioapic->res); } +if (ioapic->res.flags && ioapic->res.parent) +release_resource (&ioapic->res);list_del (&ioapic->list);kfree (ioapic); }
Signature · 1 line
1.8.3.1
PATCH v4 5/5 x86/ioapic: Fix ioapic failing to request resource
In reply to Rui Wanghandle_ioapic_add() uses request_resource() to request ACPI "_CRS" resources. This can fail with the following error message:
[ 247.325693] ACPI: \_SB_.IIO1.AID1: failed to insert resource
This happens when there are multiple IOAPICs and DSDT groups their "_CRS" resources as the children of a parent resource, as seen from /proc/iomem:
fec00000-fecfffff : PNP0003:00
fec00000-fec003ff : IOAPIC 0
fec01000-fec013ff : IOAPIC 1
fec40000-fec403ff : IOAPIC 2
In this case request_resource() fails because there's a conflicting resource which is the parent (fec0000-fecfffff). Fix it by using insert_resource() which can request resources by taking the conflicting resource as the parent.
--- drivers/acpi/ioapic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/acpi/ioapic.c +3 -1
@@ -146,10 +146,12 @@ static acpi_status handle_ioapic_add(acpi_handle handle, u32 lvl, crs_res = &ioapic->res;acpi_walk_resources (handle,METHOD_NAME__CRS , setup_res, crs_res); + crs_res->name = type; + crs_res->flags |=IORESOURCE_BUSY ;if (crs_res->flags ==0 ) {acpi_handle_warn (handle,"failed to get resource\n" ); goto exit_release; - }else if (request_resource (&iomem_resource, crs_res)) { + }else if (insert_resource (&iomem_resource, crs_res)) {acpi_handle_warn (handle,"failed to insert resource\n" ); goto exit_release; }
Signature · 1 line
1.8.3.1
tip-bot for Rui Wang
merge bot[tip:x86/apic] x86/ioapic: Change prototype of acpi_ioapic_add()
In reply to Rui Wangx86/ioapic: Change prototype of acpi_ioapic_add()
Commit-ID: fe7bd58f5d25d5d655b1da4a084cc4ef6f085fee Gitweb: http://git.kernel.org/tip/fe7bd58f5d25d5d655b1da4a084cc4ef6f085fee Author: Rui Wang <[email protected]> AuthorDate: Wed, 17 Aug 2016 16:00:33 +0800 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 18 Aug 2016 11:45:18 +0200
x86/ioapic: Change prototype of acpi_ioapic_add()
Change the argument of acpi_ioapic_add() to a generic ACPI handle, and move its prototype from drivers/acpi/internal.h to include/linux/acpi.h so that it can be called from outside the pci_root driver.
--- drivers/acpi/internal.h | 2 -- drivers/acpi/ioapic.c | 6 +++--- drivers/acpi/pci_root.c | 2 +- include/linux/acpi.h | 6 ++++++ 4 files changed, 10 insertions(+), 6 deletions(-)
drivers/acpi/internal.h +0 -2
@@ -40,10 +40,8 @@ int acpi_sysfs_init(void);void acpi_container_init (void );void acpi_memory_hotplug_init (void );#ifdef CONFIG_ACPI_HOTPLUG_IOAPIC -int acpi_ioapic_add (struct acpi_pci_root *root);int acpi_ioapic_remove (struct acpi_pci_root *root);#else -static inline int acpi_ioapic_add (struct acpi_pci_root *root) {return 0 ; }static inline int acpi_ioapic_remove (struct acpi_pci_root *root) {return 0 ; }#endif #ifdef CONFIG_ACPI_DOCK
drivers/acpi/ioapic.c +3 -3
@@ -189,13 +189,13 @@ exit:return AE_OK ; } -int acpi_ioapic_add (struct acpi_pci_root *root) +int acpi_ioapic_add (acpi_handle root_handle) {acpi_status status, retval =AE_OK ; - status =acpi_walk_namespace (ACPI_TYPE_DEVICE , root->device->handle, + status =acpi_walk_namespace (ACPI_TYPE_DEVICE , root_handle,UINT_MAX , handle_ioapic_add,NULL , - root->device->handle, (void **)&retval); + root_handle, (void **)&retval);return ACPI_SUCCESS (status) &&ACPI_SUCCESS (retval) ?0 : -ENODEV ; }
drivers/acpi/pci_root.c +1 -1
@@ -614,7 +614,7 @@ static int acpi_pci_root_add(struct acpi_device *device,if (hotadd) {pcibios_resource_survey_bus (root->bus);pci_assign_unassigned_root_bus_resources (root->bus); -acpi_ioapic_add (root); +acpi_ioapic_add (root->device->handle); }pci_lock_rescan_remove ();
include/linux/acpi.h +6 -0
@@ -751,6 +751,12 @@ static inline int acpi_reconfig_notifier_unregister(struct notifier_block *nb)#endif /* !CONFIG_ACPI */ +#ifdef CONFIG_ACPI_HOTPLUG_IOAPIC +int acpi_ioapic_add (acpi_handle root); +#else +static inline int acpi_ioapic_add (acpi_handle root) {return 0 ; } +#endif +#ifdef CONFIG_ACPI void acpi_os_set_prepare_sleep (int (*func)(u8 sleep_state,u32 pm1a_ctrl,u32 pm1b_ctrl));
tip-bot for Rui Wang
merge bot[tip:x86/apic] x86/ioapic: Support hot-removal of IOAPICs present during boot
In reply to Rui Wangx86/ioapic: Support hot-removal of IOAPICs present during boot
Commit-ID: 584c5c422f6c749ced1e0bc3c6837f650f64e1e1 Gitweb: http://git.kernel.org/tip/584c5c422f6c749ced1e0bc3c6837f650f64e1e1 Author: Rui Wang <[email protected]> AuthorDate: Wed, 17 Aug 2016 16:00:34 +0800 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 18 Aug 2016 11:45:18 +0200
x86/ioapic: Support hot-removal of IOAPICs present during boot
IOAPICs present during system boot aren't added to ioapic_list, thus are unable to be hot-removed. Fix it by calling acpi_ioapic_add() during root bus enumeration.
--- drivers/acpi/pci_root.c | 10 ++++++++++ drivers/pci/setup-bus.c | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-)
drivers/acpi/pci_root.c +10 -0
@@ -614,6 +614,16 @@ static int acpi_pci_root_add(struct acpi_device *device,if (hotadd) {pcibios_resource_survey_bus (root->bus);pci_assign_unassigned_root_bus_resources (root->bus); +/* +* This is only called for the hotadd case. For the boot-time +* case, we need to wait until after PCI initialization in +* order to deal with IOAPICs mapped in on a PCI BAR. +* +* This is currently x86-specific, because acpi_ioapic_add() +* is an empty function without CONFIG_ACPI_HOTPLUG_IOAPIC. +* And CONFIG_ACPI_HOTPLUG_IOAPIC depends on CONFIG_X86_IO_APIC +* (see drivers/acpi/Kconfig). +*/ acpi_ioapic_add (root->device->handle); }
drivers/pci/setup-bus.c +4 -1
@@ -25,6 +25,7 @@#include <linux/ioport.h> #include <linux/cache.h> #include <linux/slab.h> +#include <linux/acpi.h> #include "pci.h" unsigned int pci_flags;
@@ -1852,8 +1853,10 @@ void __init pci_assign_unassigned_resources(void) {struct pci_bus *root_bus; -list_for_each_entry (root_bus, &pci_root_buses, node) +list_for_each_entry (root_bus, &pci_root_buses, node) {pci_assign_unassigned_root_bus_resources (root_bus); +acpi_ioapic_add (ACPI_HANDLE (root_bus->bridge)); + } }void pci_assign_unassigned_bridge_resources (struct pci_dev *bridge)
tip-bot for Rui Wang
merge bot[tip:x86/apic] x86/ioapic: Fix setup_res() failing to get resource
In reply to Rui Wangx86/ioapic: Fix setup_res() failing to get resource
Commit-ID: 6ab7eba5db93c11d61f6f7fbe21edbc875b26c1a Gitweb: http://git.kernel.org/tip/6ab7eba5db93c11d61f6f7fbe21edbc875b26c1a Author: Rui Wang <[email protected]> AuthorDate: Wed, 17 Aug 2016 16:00:35 +0800 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 18 Aug 2016 11:45:18 +0200
x86/ioapic: Fix setup_res() failing to get resource
acpi_dev_filter_resource_type() returns 0 on success, and 1 on failure. A return value of zero means there's a matching resource, so we should continue within setup_res() to get the resource.
--- drivers/acpi/ioapic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/ioapic.c +1 -1
@@ -46,7 +46,7 @@ static acpi_status setup_res(struct acpi_resource *acpi_res, void *data)struct resource_win win; res->flags =0 ; -if (acpi_dev_filter_resource_type (acpi_res,IORESOURCE_MEM ) ==0 ) +if (acpi_dev_filter_resource_type (acpi_res,IORESOURCE_MEM ))return AE_OK ;if (!acpi_dev_resource_memory (acpi_res, res)) {
tip-bot for Rui Wang
merge bot[tip:x86/apic] x86/ioapic: Fix lost IOAPIC resource after hot-removal and hotadd
In reply to Rui Wangx86/ioapic: Fix lost IOAPIC resource after hot-removal and hotadd
Commit-ID: 162b83bd5f1d7124e21da78bcf2685b9824d9ef0 Gitweb: http://git.kernel.org/tip/162b83bd5f1d7124e21da78bcf2685b9824d9ef0 Author: Rui Wang <[email protected]> AuthorDate: Wed, 17 Aug 2016 16:00:36 +0800 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 18 Aug 2016 11:45:18 +0200
x86/ioapic: Fix lost IOAPIC resource after hot-removal and hotadd
IOAPIC resource at 0xfecxxxxx gets lost from /proc/iomem after hot-removing and then hot-adding the IOAPIC device.
After system boot, in /proc/iomem:
fec00000-fecfffff : PNP0003:00
fec00000-fec003ff : IOAPIC 0
fec01000-fec013ff : IOAPIC 1
fec40000-fec403ff : IOAPIC 2
fec80000-fec803ff : IOAPIC 3
fecc0000-fecc03ff : IOAPIC 4
Then hot-remove IOAPIC 2 and hot-add it again:
fec00000-fecfffff : PNP0003:00
fec00000-fec003ff : IOAPIC 0
fec01000-fec013ff : IOAPIC 1
fec80000-fec803ff : IOAPIC 3
fecc0000-fecc03ff : IOAPIC 4
The range at 0xfec40000 is lost from /proc/iomem - which is a bug.
This bug happens because handle_ioapic_add() requests resources from either PCI config BAR or ACPI "_CRS", not both. But Intel platforms map the IOxAPIC registers both at the PCI config BAR (called MBAR, dynamic), and at the ACPI "_CRS" (called ABAR, static). The 0xfecX_YZ00 to 0xfecX_YZFF range appears in "_CRS" of each IOAPIC device.
Both ranges should be claimed from /proc/iomem for exclusive use.
--- drivers/acpi/ioapic.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-)
drivers/acpi/ioapic.c +20 -16
@@ -97,7 +97,7 @@ static acpi_status handle_ioapic_add(acpi_handle handle, u32 lvl,unsigned long long gsi_base;struct acpi_pci_ioapic *ioapic;struct pci_dev *dev =NULL ; -struct resource *res =NULL ; +struct resource *res =NULL , *pci_res =NULL , *crs_res;char *type =NULL ;if (!acpi_is_ioapic (handle, &type))
@@ -137,23 +137,28 @@ static acpi_status handle_ioapic_add(acpi_handle handle, u32 lvl,pci_set_master (dev);if (pci_request_region (dev,0 , type)) goto exit_disable; - res = &dev->resource[0 ]; + pci_res = &dev->resource[0 ]; ioapic->pdev = dev; }else {pci_dev_put (dev); dev =NULL ; + } - res = &ioapic->res; -acpi_walk_resources (handle,METHOD_NAME__CRS , setup_res, res); -if (res->flags ==0 ) { -acpi_handle_warn (handle,"failed to get resource\n" ); - goto exit_free; - }else if (request_resource (&iomem_resource, res)) { -acpi_handle_warn (handle,"failed to insert resource\n" ); - goto exit_free; - } + crs_res = &ioapic->res; +acpi_walk_resources (handle,METHOD_NAME__CRS , setup_res, crs_res); +if (crs_res->flags ==0 ) { +acpi_handle_warn (handle,"failed to get resource\n" ); + goto exit_release; + }else if (request_resource (&iomem_resource, crs_res)) { +acpi_handle_warn (handle,"failed to insert resource\n" ); + goto exit_release; } +/* try pci resource first, then "_CRS" resource */ + res = pci_res; +if (!res || !res->flags) + res = crs_res; +if (acpi_register_ioapic (handle, res->start, (u32 )gsi_base)) {acpi_handle_warn (handle,"failed to register IOAPIC\n" ); goto exit_release;
@@ -174,14 +179,13 @@ done: exit_release:if (dev)pci_release_region (dev,0 ); -else -release_resource (res); +if (ioapic->res.flags && ioapic->res.parent) +release_resource (&ioapic->res); exit_disable:if (dev)pci_disable_device (dev); exit_put:pci_dev_put (dev); -exit_free:kfree (ioapic); exit:mutex_unlock (&ioapic_list_lock);
@@ -217,9 +221,9 @@ int acpi_ioapic_remove(struct acpi_pci_root *root)pci_release_region (ioapic->pdev,0 );pci_disable_device (ioapic->pdev);pci_dev_put (ioapic->pdev); - }else if (ioapic->res.flags && ioapic->res.parent) { -release_resource (&ioapic->res); } +if (ioapic->res.flags && ioapic->res.parent) +release_resource (&ioapic->res);list_del (&ioapic->list);kfree (ioapic); }
tip-bot for Rui Wang
merge bot[tip:x86/apic] x86/ioapic: Fix IOAPIC failing to request resource
In reply to Rui Wangx86/ioapic: Fix IOAPIC failing to request resource
Commit-ID: 624cad9d2907a0788b56e3ca664c5d7d02645ed4 Gitweb: http://git.kernel.org/tip/624cad9d2907a0788b56e3ca664c5d7d02645ed4 Author: Rui Wang <[email protected]> AuthorDate: Wed, 17 Aug 2016 16:00:37 +0800 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 18 Aug 2016 11:45:19 +0200
x86/ioapic: Fix IOAPIC failing to request resource
handle_ioapic_add() uses request_resource() to request ACPI "_CRS" resources. This can fail with the following error message:
[ 247.325693] ACPI: \_SB_.IIO1.AID1: failed to insert resource
This happens when there are multiple IOAPICs and DSDT groups their "_CRS" resources as the children of a parent resource, as seen from /proc/iomem:
fec00000-fecfffff : PNP0003:00
fec00000-fec003ff : IOAPIC 0
fec01000-fec013ff : IOAPIC 1
fec40000-fec403ff : IOAPIC 2In this case request_resource() fails because there's a conflicting resource which is the parent (fec0000-fecfffff). Fix it by using insert_resource() which can request resources by taking the conflicting resource as the parent.
--- drivers/acpi/ioapic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/acpi/ioapic.c +3 -1
@@ -146,10 +146,12 @@ static acpi_status handle_ioapic_add(acpi_handle handle, u32 lvl, crs_res = &ioapic->res;acpi_walk_resources (handle,METHOD_NAME__CRS , setup_res, crs_res); + crs_res->name = type; + crs_res->flags |=IORESOURCE_BUSY ;if (crs_res->flags ==0 ) {acpi_handle_warn (handle,"failed to get resource\n" ); goto exit_release; - }else if (request_resource (&iomem_resource, crs_res)) { + }else if (insert_resource (&iomem_resource, crs_res)) {acpi_handle_warn (handle,"failed to insert resource\n" ); goto exit_release; }
[oops] [tip:x86/apic] x86/ioapic: Support hot-removal of IOAPICs present during boot
In reply to tip-bot for Rui WangQuoted 8 lines · tip-bot for Rui Wang
Commit-ID:
584c5c422f6c749ced1e0bc3c6837f650f64e1e1Gitweb:
http://git.kernel.org/tip/584c5c422f6c749ced1e0bc3c6837f650f64e1e1Author: Rui Wang <[email protected]> AuthorDate: Wed, 17 Aug 2016 16:00:34 +0800 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 18 Aug 2016 11:45:18 +0200
Quoted 5 lines
x86/ioapic: Support hot-removal of IOAPICs present during boot
IOAPICs present during system boot aren't added to
ioapic_list, thus are unable to be hot-removed. Fix it by callingacpi_ioapic_add()during root bus enumeration.
This commit makes tip on my x3550 M3 go boom during boot. Revert the series, all is well, start re-applying them, box goes boom at this commit as below. Tree is tip v4.8-rc4-312-g5e7dd767889c.
[ 2.018042] pci 0000:01:00.0: can't claim BAR 6 [mem 0xfffc0000-0xffffffff pref]: no compatible bridge window [ 2.028010] pci 0000:00:1c.0: BAR 15: assigned [mem 0x90000000-0x901fffff 64bit pref] [ 2.035837] pci 0000:00:01.0: PCI bridge to [bus 0b-0f] [ 2.041063] pci 0000:00:01.0: bridge window [mem 0x92000000-0x95ffffff] [ 2.047852] pci 0000:00:02.0: PCI bridge to [bus 10-14] [ 2.053082] pci 0000:00:03.0: PCI bridge to [bus 15-19] [ 2.058312] pci 0000:00:07.0: PCI bridge to [bus 1a-1e] [ 2.063544] pci 0000:01:00.0: BAR 6: assigned [mem 0x97980000-0x979bffff pref] [ 2.070766] pci 0000:00:1c.0: PCI bridge to [bus 01-05] [ 2.075991] pci 0000:00:1c.0: bridge window [io 0x1000-0x1fff] [ 2.082085] pci 0000:00:1c.0: bridge window [mem 0x97900000-0x979fffff] [ 2.088871] pci 0000:00:1c.0: bridge window [mem 0x90000000-0x901fffff 64bit pref] [ 2.096615] pci 0000:06:00.0: PCI bridge to [bus 07] [ 2.101586] pci 0000:06:00.0: bridge window [mem 0x97000000-0x978fffff] [ 2.108372] pci 0000:06:00.0: bridge window [mem 0x96000000-0x96ffffff pref] [ 2.115597] pci 0000:00:1c.4: PCI bridge to [bus 06-0a] [ 2.120823] pci 0000:00:1c.4: bridge window [mem 0x97000000-0x978fffff] [ 2.127610] pci 0000:00:1c.4: bridge window [mem 0x96000000-0x96ffffff 64bit pref] [ 2.135353] pci 0000:00:1e.0: PCI bridge to [bus 1f-23] [ 2.140655] BUG: unable to handle kernel NULL pointer dereference at 0000000000000018 [ 2.148511] IP: [<ffffffff813e70e7>] acpi_ns_walk_namespace+0x70/0x249 [ 2.155055] PGD 0 [ 2.157087] Oops: 0000 [#1] PREEMPT SMP [ 2.160920] Dumping ftrace buffer: [ 2.164322] (ftrace buffer empty) [ 2.167897] Modules linked in: [ 2.170970] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.8.0-tip+ #27 [ 2.177317] Hardware name: IBM System x3550 M3 -[7944K3G]-/69Y5698 , BIOS -[D6E150AUS-1.10]- 12/15/2010 [ 2.187044] task: ffff88016ab58000 task.stack: ffffc90000638000 [ 2.192955] RIP: 0010:[<ffffffff813e70e7>] [<ffffffff813e70e7>] acpi_ns_walk_namespace+0x70/0x249 [ 2.201923] RSP: 0000:ffffc9000063bd00 EFLAGS: 00010202 [ 2.207230] RAX: 0000000000000001 RBX: 0000000000000001 RCX: 0000000000000010 [ 2.214356] RDX: 000000100000000f RSI: ffffffff81882810 RDI: 00000000000000c8 [ 2.221482] RBP: ffffc9000063bd50 R08: ffffffff813fcd89 R09: 0000000000000000 [ 2.228606] R10: 0000000000000000 R11: 0000000000000006 R12: 0000000000000000 [ 2.235732] R13: 0000000000000000 R14: 0000000000000001 R15: 0000000000000000 [ 2.242858] FS: 0000000000000000(0000) GS:ffff88017fc00000(0000) knlGS:0000000000000000 [ 2.250939] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 2.256678] CR2: 0000000000000018 CR3: 0000000001c06000 CR4: 00000000000006f0 [ 2.263804] Stack: [ 2.265818] 0000000000000000 ffffffff813fcd89 00000001813f5396 ffffffffffffffff [ 2.273283] 0000000000000006 0000000000000000 00000000ffffffff ffffffff813fcd89 [ 2.280747] 0000000000000000 0000000000000000 ffffc9000063bda8 ffffffff813e7a7d [ 2.288211] Call Trace: [ 2.290660] [<ffffffff813fcd89>] ? setup_res+0x94/0x94 [ 2.295879] [<ffffffff813fcd89>] ? setup_res+0x94/0x94 [ 2.301100] [<ffffffff813e7a7d>] acpi_walk_namespace+0xfc/0x14c [ 2.307103] [<ffffffff81d97356>] ? ras_debugfs_init+0x1b/0x1b [ 2.312931] [<ffffffff813fd12f>] acpi_ioapic_add+0x39/0x51 [ 2.318498] [<ffffffff81d82b35>] pci_assign_unassigned_resources+0x65/0x6d [ 2.325452] [<ffffffff81d9736d>] pcibios_assign_resources+0x17/0xb4 [ 2.331800] [<ffffffff81d97356>] ? ras_debugfs_init+0x1b/0x1b [ 2.337629] [<ffffffff81000450>] do_one_initcall+0x50/0x190 [ 2.343284] [<ffffffff8108e2cb>] ? parse_args+0x27b/0x460 [ 2.348768] [<ffffffff81d43291>] kernel_init_freeable+0x194/0x224 [ 2.354943] [<ffffffff81d429aa>] ? set_debug_rodata+0x12/0x12 [ 2.360774] [<ffffffff81610660>] ? rest_init+0x90/0x90 [ 2.365994] [<ffffffff8161066e>] kernel_init+0xe/0x110 [ 2.371215] [<ffffffff8161c6c5>] ret_from_fork+0x25/0x30 [ 2.376607] Code: b8 4c 89 4d b0 e8 af b5 00 00 49 83 fc ff 4c 0f 44 25 fe a2 c8 00 45 31 ed e8 67 b5 00 00 44 89 f0 c7 45 d4 00 00 00 00 83 e0 01 <4d> 8b 7c 24 18 89 45 cc 4d 85 ff 0f 84 97 01 00 00 85 db 0f 84 [ 2.396735] RIP [<ffffffff813e70e7>] acpi_ns_walk_namespace+0x70/0x249 [ 2.403364] RSP <ffffc9000063bd00> [ 2.406849] CR2: 0000000000000018 [ 2.410164] ---[ end trace 6cc1410993da3e1d ]---
(gdb) list *acpi_ns_walk_namespace+0x700xffffffff813e70e7 is in acpi_ns_walk_namespace (drivers/acpi/acpica/nswalk.c:79). 74
75 if (!child_node) {
76
77 /* It's really the parent's _scope_ that we want */
78
79 return (parent_node->child);
80 }
81
82 /* Otherwise just return the next peer */
83
00:00.0 Host bridge: Intel Corporation 5520 I/O Hub to ESI Port (rev 22)
00:01.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 1 (rev 22)
00:02.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 2 (rev 22)
00:03.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 3 (rev 22)
00:07.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 7 (rev 22)
00:10.0 PIC: Intel Corporation 7500/5520/5500/X58 Physical and Link Layer Registers Port 0 (rev 22) 00:10.1 PIC: Intel Corporation 7500/5520/5500/X58 Routing and Protocol Layer Registers Port 0 (rev 22) 00:11.0 PIC: Intel Corporation 7500/5520/5500 Physical and Link Layer Registers Port 1 (rev 22) 00:11.1 PIC: Intel Corporation 7500/5520/5500 Routing & Protocol Layer Register Port 1 (rev 22) 00:14.0 PIC: Intel Corporation 7500/5520/5500/X58 I/O Hub System Management Registers (rev 22) 00:14.1 PIC: Intel Corporation 7500/5520/5500/X58 I/O Hub GPIO and Scratch Pad Registers (rev 22) 00:14.2 PIC: Intel Corporation 7500/5520/5500/X58 I/O Hub Control Status and RAS Registers (rev 22) 00:14.3 PIC: Intel Corporation 7500/5520/5500/X58 I/O Hub Throttle Registers (rev 22)
00:15.0 PIC: Intel Corporation 7500/5520/5500/X58 Trusted Execution Technology Registers (rev 22) 00:16.0 System peripheral: Intel Corporation 5520/5500/X58 Chipset QuickData Technology Device (rev 22) 00:16.1 System peripheral: Intel Corporation 5520/5500/X58 Chipset QuickData Technology Device (rev 22) 00:16.2 System peripheral: Intel Corporation 5520/5500/X58 Chipset QuickData Technology Device (rev 22) 00:16.3 System peripheral: Intel Corporation 5520/5500/X58 Chipset QuickData Technology Device (rev 22) 00:16.4 System peripheral: Intel Corporation 5520/5500/X58 Chipset QuickData Technology Device (rev 22) 00:16.5 System peripheral: Intel Corporation 5520/5500/X58 Chipset QuickData Technology Device (rev 22) 00:16.6 System peripheral: Intel Corporation 5520/5500/X58 Chipset QuickData Technology Device (rev 22) 00:16.7 System peripheral: Intel Corporation 5520/5500/X58 Chipset QuickData Technology Device (rev 22) 00:1a.0 USB controller: Intel Corporation 82801JI (ICH10 Family) USB UHCI Controller #4
00:1a.1 USB controller: Intel Corporation 82801JI (ICH10 Family) USB UHCI Controller #5
00:1a.7 USB controller: Intel Corporation 82801JI (ICH10 Family) USB2 EHCI Controller #2
00:1c.0 PCI bridge: Intel Corporation 82801JI (ICH10 Family) PCI Express Root Port 1
00:1c.4 PCI bridge: Intel Corporation 82801JI (ICH10 Family) PCI Express Root Port 5
00:1d.0 USB controller: Intel Corporation 82801JI (ICH10 Family) USB UHCI Controller #1
00:1d.1 USB controller: Intel Corporation 82801JI (ICH10 Family) USB UHCI Controller #2
00:1d.2 USB controller: Intel Corporation 82801JI (ICH10 Family) USB UHCI Controller #3
00:1d.7 USB controller: Intel Corporation 82801JI (ICH10 Family) USB2 EHCI Controller #1
00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev 90)
00:1f.0 ISA bridge: Intel Corporation 82801JIB (ICH10) LPC Interface Controller
00:1f.2 IDE interface: Intel Corporation 82801JI (ICH10 Family) 4 port SATA IDE Controller #1 00:1f.3 SMBus: Intel Corporation 82801JI (ICH10 Family) SMBus Controller
00:1f.5 IDE interface: Intel Corporation 82801JI (ICH10 Family) 2 port SATA IDE Controller #2 01:00.0 RAID bus controller: LSI Logic / Symbios Logic MegaRAID SAS 2108 [Liberator] (rev 03) 06:00.0 PCI bridge: Vitesse Semiconductor VSC452 [SuperBMC] (rev 01)
07:00.0 VGA compatible controller: Matrox Electronics Systems Ltd. MGA G200EV
0b:00.0 Ethernet controller: Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet (rev 20) 0b:00.1 Ethernet controller: Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet (rev 20) ff:00.0 Host bridge: Intel Corporation Xeon 5600 Series QuickPath Architecture Generic Non-core Registers (rev 02) ff:00.1 Host bridge: Intel Corporation Xeon 5600 Series QuickPath Architecture System Address Decoder (rev 02) ff:02.0 Host bridge: Intel Corporation Xeon 5600 Series QPI Link 0 (rev 02)
ff:02.1 Host bridge: Intel Corporation Xeon 5600 Series QPI Physical 0 (rev 02)
ff:02.2 Host bridge: Intel Corporation Xeon 5600 Series Mirror Port Link 0 (rev 02)
ff:02.3 Host bridge: Intel Corporation Xeon 5600 Series Mirror Port Link 1 (rev 02)
ff:02.4 Host bridge: Intel Corporation Xeon 5600 Series QPI Link 1 (rev 02)
ff:02.5 Host bridge: Intel Corporation Xeon 5600 Series QPI Physical 1 (rev 02)
ff:03.0 Host bridge: Intel Corporation Xeon 5600 Series Integrated Memory Controller Registers (rev 02) ff:03.1 Host bridge: Intel Corporation Xeon 5600 Series Integrated Memory Controller Target Address Decoder (rev 02) ff:03.2 Host bridge: Intel Corporation Xeon 5600 Series Integrated Memory Controller RAS Registers (rev 02) ff:03.4 Host bridge: Intel Corporation Xeon 5600 Series Integrated Memory Controller Test Registers (rev 02) ff:04.0 Host bridge: Intel Corporation Xeon 5600 Series Integrated Memory Controller Channel 0 Control (rev 02) ff:04.1 Host bridge: Intel Corporation Xeon 5600 Series Integrated Memory Controller Channel 0 Address (rev 02) ff:04.2 Host bridge: Intel Corporation Xeon 5600 Series Integrated Memory Controller Channel 0 Rank (rev 02) ff:04.3 Host bridge: Intel Corporation Xeon 5600 Series Integrated Memory Controller Channel 0 Thermal Control (rev 02) ff:05.0 Host bridge: Intel Corporation Xeon 5600 Series Integrated Memory Controller Channel 1 Control (rev 02) ff:05.1 Host bridge: Intel Corporation Xeon 5600 Series Integrated Memory Controller Channel 1 Address (rev 02) ff:05.2 Host bridge: Intel Corporation Xeon 5600 Series Integrated Memory Controller Channel 1 Rank (rev 02) ff:05.3 Host bridge: Intel Corporation Xeon 5600 Series Integrated Memory Controller Channel 1 Thermal Control (rev 02) ff:06.0 Host bridge: Intel Corporation Xeon 5600 Series Integrated Memory Controller Channel 2 Control (rev 02) ff:06.1 Host bridge: Intel Corporation Xeon 5600 Series Integrated Memory Controller Channel 2 Address (rev 02) ff:06.2 Host bridge: Intel Corporation Xeon 5600 Series Integrated Memory Controller Channel 2 Rank (rev 02) ff:06.3 Host bridge: Intel Corporation Xeon 5600 Series Integrated Memory Controller Channel 2 Thermal Control (rev 02)