提交 c02256be 编写于 作者: Z Zhang Rui 提交者: Len Brown

ACPI: fix a deadlock in hotplug case

we used to run the hotplug code in keventd_wq.
But when hot removing the ACPI battery device,
power_supply_unregister invokes flush_scheduled_work.
This causes a deadlock. i.e
1. When dock is unplugged, all the hotplug code is run on kevent_wq.
2. the hotplug code removes all the child devices of dock device.
3. removing the child device may invoke flush_scheduled_work
4. flush_scheduled_work waits until all the work on kevent_wq to be
   finished, while this will never be true because the hotplug code
   is running on keventd_wq...

Introduce a new workqueue for hotplug in this patch.
http://bugzilla.kernel.org/show_bug.cgi?id=13533Tested-by: NPaul Martin <pm@debian.org>
Tested-by: NVojtech Gondzala <vojtech.gondzala@gmail.com>
Signed-off-by: NZhang Rui <rui.zhang@intel.com>
Reviewed-by: NBjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: NLen Brown <len.brown@intel.com>
上级 07a2039b
...@@ -79,6 +79,7 @@ static acpi_osd_handler acpi_irq_handler; ...@@ -79,6 +79,7 @@ static acpi_osd_handler acpi_irq_handler;
static void *acpi_irq_context; static void *acpi_irq_context;
static struct workqueue_struct *kacpid_wq; static struct workqueue_struct *kacpid_wq;
static struct workqueue_struct *kacpi_notify_wq; static struct workqueue_struct *kacpi_notify_wq;
static struct workqueue_struct *kacpi_hotplug_wq;
struct acpi_res_list { struct acpi_res_list {
resource_size_t start; resource_size_t start;
...@@ -192,8 +193,10 @@ acpi_status acpi_os_initialize1(void) ...@@ -192,8 +193,10 @@ acpi_status acpi_os_initialize1(void)
{ {
kacpid_wq = create_singlethread_workqueue("kacpid"); kacpid_wq = create_singlethread_workqueue("kacpid");
kacpi_notify_wq = create_singlethread_workqueue("kacpi_notify"); kacpi_notify_wq = create_singlethread_workqueue("kacpi_notify");
kacpi_hotplug_wq = create_singlethread_workqueue("kacpi_hotplug");
BUG_ON(!kacpid_wq); BUG_ON(!kacpid_wq);
BUG_ON(!kacpi_notify_wq); BUG_ON(!kacpi_notify_wq);
BUG_ON(!kacpi_hotplug_wq);
return AE_OK; return AE_OK;
} }
...@@ -206,6 +209,7 @@ acpi_status acpi_os_terminate(void) ...@@ -206,6 +209,7 @@ acpi_status acpi_os_terminate(void)
destroy_workqueue(kacpid_wq); destroy_workqueue(kacpid_wq);
destroy_workqueue(kacpi_notify_wq); destroy_workqueue(kacpi_notify_wq);
destroy_workqueue(kacpi_hotplug_wq);
return AE_OK; return AE_OK;
} }
...@@ -716,6 +720,7 @@ static acpi_status __acpi_os_execute(acpi_execute_type type, ...@@ -716,6 +720,7 @@ static acpi_status __acpi_os_execute(acpi_execute_type type,
acpi_status status = AE_OK; acpi_status status = AE_OK;
struct acpi_os_dpc *dpc; struct acpi_os_dpc *dpc;
struct workqueue_struct *queue; struct workqueue_struct *queue;
work_func_t func;
int ret; int ret;
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"Scheduling function [%p(%p)] for deferred execution.\n", "Scheduling function [%p(%p)] for deferred execution.\n",
...@@ -740,15 +745,17 @@ static acpi_status __acpi_os_execute(acpi_execute_type type, ...@@ -740,15 +745,17 @@ static acpi_status __acpi_os_execute(acpi_execute_type type,
dpc->function = function; dpc->function = function;
dpc->context = context; dpc->context = context;
if (!hp) { /*
INIT_WORK(&dpc->work, acpi_os_execute_deferred); * We can't run hotplug code in keventd_wq/kacpid_wq/kacpid_notify_wq
queue = (type == OSL_NOTIFY_HANDLER) ? * because the hotplug code may call driver .remove() functions,
kacpi_notify_wq : kacpid_wq; * which invoke flush_scheduled_work/acpi_os_wait_events_complete
ret = queue_work(queue, &dpc->work); * to flush these workqueues.
} else { */
INIT_WORK(&dpc->work, acpi_os_execute_hp_deferred); queue = hp ? kacpi_hotplug_wq :
ret = schedule_work(&dpc->work); (type == OSL_NOTIFY_HANDLER ? kacpi_notify_wq : kacpid_wq);
} func = hp ? acpi_os_execute_hp_deferred : acpi_os_execute_deferred;
INIT_WORK(&dpc->work, func);
ret = queue_work(queue, &dpc->work);
if (!ret) { if (!ret) {
printk(KERN_ERR PREFIX printk(KERN_ERR PREFIX
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册