Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 31 additions & 31 deletions drivers/acpi/osl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1063,10 +1063,9 @@ int __init acpi_debugger_init(void)
acpi_status acpi_os_execute(acpi_execute_type type,
acpi_osd_exec_callback function, void *context)
{
acpi_status status = AE_OK;
struct acpi_os_dpc *dpc;
struct workqueue_struct *queue;
int ret;

ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"Scheduling function [%p(%p)] for deferred execution.\n",
function, context));
Expand All @@ -1075,9 +1074,9 @@ acpi_status acpi_os_execute(acpi_execute_type type,
ret = acpi_debugger_create_thread(function, context);
if (ret) {
pr_err("Kernel thread creation failed\n");
status = AE_ERROR;
return AE_ERROR;
}
goto out_thread;
return AE_OK;
}

/*
Expand All @@ -1095,43 +1094,41 @@ acpi_status acpi_os_execute(acpi_execute_type type,

dpc->function = function;
dpc->context = context;
INIT_WORK(&dpc->work, acpi_os_execute_deferred);

/*
* To prevent lockdep from complaining unnecessarily, make sure that
* there is a different static lockdep key for each workqueue by using
* INIT_WORK() for each of them separately.
*/
if (type == OSL_NOTIFY_HANDLER) {
queue = kacpi_notify_wq;
INIT_WORK(&dpc->work, acpi_os_execute_deferred);
} else if (type == OSL_GPE_HANDLER) {
queue = kacpid_wq;
INIT_WORK(&dpc->work, acpi_os_execute_deferred);
} else {
switch (type) {
case OSL_NOTIFY_HANDLER:
ret = queue_work(kacpi_notify_wq, &dpc->work);
break;
case OSL_GPE_HANDLER:
/*
* On some machines, a software-initiated SMI causes corruption
* unless the SMI runs on CPU 0. An SMI can be initiated by
* any AML, but typically it's done in GPE-related methods that
* are run via workqueues, so we can avoid the known corruption
* cases by always queueing on CPU 0.
*/
ret = queue_work_on(0, kacpid_wq, &dpc->work);
break;
default:
pr_err("Unsupported os_execute type %d.\n", type);
status = AE_ERROR;
goto err;
}

if (ACPI_FAILURE(status))
goto err_workqueue;

/*
* On some machines, a software-initiated SMI causes corruption unless
* the SMI runs on CPU 0. An SMI can be initiated by any AML, but
* typically it's done in GPE-related methods that are run via
* workqueues, so we can avoid the known corruption cases by always
* queueing on CPU 0.
*/
ret = queue_work_on(0, queue, &dpc->work);
if (!ret) {
pr_err("Unable to queue work\n");
status = AE_ERROR;
goto err;
}
err_workqueue:
if (ACPI_FAILURE(status))
kfree(dpc);
out_thread:
return status;

return AE_OK;

err:
kfree(dpc);
return AE_ERROR;
}
EXPORT_SYMBOL(acpi_os_execute);

Expand Down Expand Up @@ -1522,6 +1519,7 @@ acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock lockp)
__acquires(lockp)
{
acpi_cpu_flags flags;

spin_lock_irqsave(lockp, flags);
return flags;
}
Expand Down Expand Up @@ -1670,7 +1668,7 @@ acpi_status __init acpi_os_initialize(void)
acpi_status __init acpi_os_initialize1(void)
{
kacpid_wq = alloc_workqueue("kacpid", 0, 1);
kacpi_notify_wq = alloc_workqueue("kacpi_notify", 0, 1);
kacpi_notify_wq = alloc_workqueue("kacpi_notify", 0, 0);
kacpi_hotplug_wq = alloc_ordered_workqueue("kacpi_hotplug", 0);
BUG_ON(!kacpid_wq);
BUG_ON(!kacpi_notify_wq);
Expand Down Expand Up @@ -1708,6 +1706,7 @@ acpi_status acpi_os_prepare_sleep(u8 sleep_state, u32 pm1a_control,
u32 pm1b_control)
{
int rc = 0;

if (__acpi_os_prepare_sleep)
rc = __acpi_os_prepare_sleep(sleep_state,
pm1a_control, pm1b_control);
Expand All @@ -1730,6 +1729,7 @@ acpi_status acpi_os_prepare_extended_sleep(u8 sleep_state, u32 val_a,
u32 val_b)
{
int rc = 0;

if (__acpi_os_prepare_extended_sleep)
rc = __acpi_os_prepare_extended_sleep(sleep_state,
val_a, val_b);
Expand Down
Loading