acpiphp: Prevent deadlock on PCI-to-PCI bridge remove
Subsystems (3)
PATCH 1/1 acpiphp: Prevent deadlock on PCI-to-PCI bridge remove
I originally submitted a patch to workaround this by pushing all Ejection Requests and Device Checks onto the kacpi_hotplug queue.
http://marc.info/?l=linux-acpi&m=131678270930105&w=2
The patch is still insufficient in that Bus Checks also need to be added.
Rather than add all events, including non-PCI-hotplug events, to the hotplug queue, mjg suggested that a better approach would be to modify the acpiphp driver so only acpiphp events would be added to the kacpi_hotplug queue.
It's a longer patch, but at least we maintain the benefit of having separate queues in ACPI. This, of course, is still only a workaround the problem. As Bjorn and mjg pointed out, we have to refactor a lot of this code to do the right thing but at this point it is a better to have this code working.
Jesse -- Unless there are any objections from the ACPI guys, I think this patch should be pushed through linux-pci now since 95% of the changes are contained within drivers/pci/hotplug.
P.
---8<---
The acpi core places all events on the kacpi_notify queue. When the acpiphp driver is loaded and a PCI card with a PCI-to-PCI bridge is removed the following call sequence occurs:
cleanup_p2p_bridge()
-> cleanup_bridge() -> acpi_remove_notify_handler() -> acpi_os_wait_events_complete() -> flush_workqueue(kacpi_notify_wq)
which is the queue we are currently executing on and the process will hang.
Move all hotplug acpiphp events onto the kacpi_hotplug workqueue. In handle_hotplug_event_bridge() and handle_hotplug_event_func() we can simply push the rest of the work onto the kacpi_hotplug queue and then avoid the deadlock.
--- drivers/acpi/osl.c | 3 +- drivers/pci/hotplug/acpiphp_glue.c | 109 +++++++++++++++++++++++++++++++----- include/acpi/acpiosxf.h | 2 + 3 files changed, 98 insertions(+), 16 deletions(-)
drivers/acpi/osl.c +2 -1
@@ -80,7 +80,8 @@ static acpi_osd_handler acpi_irq_handler;static void *acpi_irq_context;static struct workqueue_struct *kacpid_wq;static struct workqueue_struct *kacpi_notify_wq; -static struct workqueue_struct *kacpi_hotplug_wq; +struct workqueue_struct *kacpi_hotplug_wq; +EXPORT_SYMBOL (kacpi_hotplug_wq);struct acpi_res_list {resource_size_t start;
drivers/pci/hotplug/acpiphp_glue.c +94 -15
163 lines not on this page · raw message
include/acpi/acpiosxf.h +2 -0
@@ -189,6 +189,8 @@ void acpi_os_fixed_event_count(u32 fixed_event_number);/* * Threads and Scheduling */ +extern struct workqueue_struct *kacpi_hotplug_wq; +acpi_thread_id acpi_os_get_thread_id (void ); acpi_status
Signature · 1 line
1.7.1
Jesse Barnes
AppliedQuoted 12 lines · On Wed, 28 Sep 2011 19:40:53 -0400 Prarit Bhargava <[email protected]> wrote:
I originally submitted a patch to workaround this by pushing all Ejection Requests and Device Checks onto the
kacpi_hotplugqueue.http://marc.info/?l=linux-acpi&m=131678270930105&w=2
The patch is still insufficient in that Bus Checks also need to be added.
Rather than add all events, including non-PCI-hotplug events, to the hotplug queue, mjg suggested that a better approach would be to modify the acpiphp driver so only acpiphp events would be added to the
kacpi_hotplugqueue.
Quoted 8 lines
It's a longer patch, but at least we maintain the benefit of having separate queues in ACPI. This, of course, is still only a workaround the problem. As Bjorn and mjg pointed out, we have to refactor a lot of this code to do the right thing but at this point it is a better to have this code working.
Jesse -- Unless there are any objections from the ACPI guys, I think this patch should be pushed through linux-pci now since 95% of the changes are contained within
drivers/pci/hotplug.
Applied to linux-next, thanks.
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center