Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 350983
b: refs/heads/master
c: 3757b94
h: refs/heads/master
i:
  350981: bd88c41
  350979: 4e4d7a0
  350975: dec9faa
v: v3
  • Loading branch information
Rafael J. Wysocki committed Feb 13, 2013
1 parent ce3f65b commit 11ac5b5
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 56 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 64fd7401c5e4cf7c64452ecd9b700a55a5ebea50
refs/heads/master: 3757b94802fb65d8f696597a74053cf21738da0b
56 changes: 37 additions & 19 deletions trunk/drivers/acpi/acpi_memhotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,16 @@ acpi_memory_get_device_resources(struct acpi_memory_device *mem_device)
return 0;
}

static int
acpi_memory_get_device(acpi_handle handle,
struct acpi_memory_device **mem_device)
static int acpi_memory_get_device(acpi_handle handle,
struct acpi_memory_device **mem_device)
{
struct acpi_device *device = NULL;
int result;
int result = 0;

if (!acpi_bus_get_device(handle, &device) && device)
acpi_scan_lock_acquire();

acpi_bus_get_device(handle, &device);
if (device)
goto end;

/*
Expand All @@ -169,23 +171,28 @@ acpi_memory_get_device(acpi_handle handle,
*/
result = acpi_bus_scan(handle);
if (result) {
acpi_handle_warn(handle, "Cannot add acpi bus\n");
return -EINVAL;
acpi_handle_warn(handle, "ACPI namespace scan failed\n");
result = -EINVAL;
goto out;
}
result = acpi_bus_get_device(handle, &device);
if (result) {
acpi_handle_warn(handle, "Missing device object\n");
return -EINVAL;
result = -EINVAL;
goto out;
}

end:
end:
*mem_device = acpi_driver_data(device);
if (!(*mem_device)) {
dev_err(&device->dev, "driver data not found\n");
return -ENODEV;
result = -ENODEV;
goto out;
}

return 0;
out:
acpi_scan_lock_release();
return result;
}

static int acpi_memory_check_device(struct acpi_memory_device *mem_device)
Expand Down Expand Up @@ -305,6 +312,7 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
struct acpi_device *device;
struct acpi_eject_event *ej_event = NULL;
u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */
acpi_status status;

switch (event) {
case ACPI_NOTIFY_BUS_CHECK:
Expand All @@ -327,29 +335,40 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"\nReceived EJECT REQUEST notification for device\n"));

status = AE_ERROR;
acpi_scan_lock_acquire();

if (acpi_bus_get_device(handle, &device)) {
acpi_handle_err(handle, "Device doesn't exist\n");
break;
goto unlock;
}
mem_device = acpi_driver_data(device);
if (!mem_device) {
acpi_handle_err(handle, "Driver Data is NULL\n");
break;
goto unlock;
}

ej_event = kmalloc(sizeof(*ej_event), GFP_KERNEL);
if (!ej_event) {
pr_err(PREFIX "No memory, dropping EJECT\n");
break;
goto unlock;
}

get_device(&device->dev);
ej_event->device = device;
ej_event->event = ACPI_NOTIFY_EJECT_REQUEST;
acpi_os_hotplug_execute(acpi_bus_hot_remove_device,
(void *)ej_event);
/* The eject is carried out asynchronously. */
status = acpi_os_hotplug_execute(acpi_bus_hot_remove_device,
ej_event);
if (ACPI_FAILURE(status)) {
put_device(&device->dev);
kfree(ej_event);
}

/* eject is performed asynchronously */
return;
unlock:
acpi_scan_lock_release();
if (ACPI_SUCCESS(status))
return;
default:
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Unsupported event [0x%x]\n", event));
Expand All @@ -360,7 +379,6 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)

/* Inform firmware that the hotplug operation has completed */
(void) acpi_evaluate_hotplug_ost(handle, event, ost_code, NULL);
return;
}

static void acpi_memory_device_free(struct acpi_memory_device *mem_device)
Expand Down
12 changes: 8 additions & 4 deletions trunk/drivers/acpi/container.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
acpi_status status;
u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */

acpi_scan_lock_acquire();

switch (type) {
case ACPI_NOTIFY_BUS_CHECK:
/* Fall through */
Expand All @@ -103,7 +105,7 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
/* device exist and this is a remove request */
device->flags.eject_pending = 1;
kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE);
return;
goto out;
}
break;
}
Expand All @@ -130,18 +132,20 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
if (!acpi_bus_get_device(handle, &device) && device) {
device->flags.eject_pending = 1;
kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE);
return;
goto out;
}
break;

default:
/* non-hotplug event; possibly handled by other handler */
return;
goto out;
}

/* Inform firmware that the hotplug operation has completed */
(void) acpi_evaluate_hotplug_ost(handle, type, ost_code, NULL);
return;

out:
acpi_scan_lock_release();
}

static bool is_container(acpi_handle handle)
Expand Down
19 changes: 16 additions & 3 deletions trunk/drivers/acpi/dock.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,9 @@ static void acpi_dock_deferred_cb(void *context)
{
struct dock_data *data = context;

acpi_scan_lock_acquire();
dock_notify(data->handle, data->event, data->ds);
acpi_scan_lock_release();
kfree(data);
}

Expand All @@ -757,20 +759,31 @@ static int acpi_dock_notifier_call(struct notifier_block *this,
if (event != ACPI_NOTIFY_BUS_CHECK && event != ACPI_NOTIFY_DEVICE_CHECK
&& event != ACPI_NOTIFY_EJECT_REQUEST)
return 0;

acpi_scan_lock_acquire();

list_for_each_entry(dock_station, &dock_stations, sibling) {
if (dock_station->handle == handle) {
struct dock_data *dd;
acpi_status status;

dd = kmalloc(sizeof(*dd), GFP_KERNEL);
if (!dd)
return 0;
break;

dd->handle = handle;
dd->event = event;
dd->ds = dock_station;
acpi_os_hotplug_execute(acpi_dock_deferred_cb, dd);
return 0 ;
status = acpi_os_hotplug_execute(acpi_dock_deferred_cb,
dd);
if (ACPI_FAILURE(status))
kfree(dd);

break;
}
}

acpi_scan_lock_release();
return 0;
}

Expand Down
24 changes: 17 additions & 7 deletions trunk/drivers/acpi/processor_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,8 +683,11 @@ static void acpi_processor_hotplug_notify(acpi_handle handle,
struct acpi_device *device = NULL;
struct acpi_eject_event *ej_event = NULL;
u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */
acpi_status status;
int result;

acpi_scan_lock_acquire();

switch (event) {
case ACPI_NOTIFY_BUS_CHECK:
case ACPI_NOTIFY_DEVICE_CHECK:
Expand Down Expand Up @@ -733,25 +736,32 @@ static void acpi_processor_hotplug_notify(acpi_handle handle,
break;
}

get_device(&device->dev);
ej_event->device = device;
ej_event->event = ACPI_NOTIFY_EJECT_REQUEST;
acpi_os_hotplug_execute(acpi_bus_hot_remove_device,
(void *)ej_event);

/* eject is performed asynchronously */
return;
/* The eject is carried out asynchronously. */
status = acpi_os_hotplug_execute(acpi_bus_hot_remove_device,
ej_event);
if (ACPI_FAILURE(status)) {
put_device(&device->dev);
kfree(ej_event);
break;
}
goto out;

default:
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Unsupported event [0x%x]\n", event));

/* non-hotplug event; possibly handled by other handler */
return;
goto out;
}

/* Inform firmware that the hotplug operation has completed */
(void) acpi_evaluate_hotplug_ost(handle, event, ost_code, NULL);
return;

out:
acpi_scan_lock_release();
}

static acpi_status is_processor_device(acpi_handle handle)
Expand Down
Loading

0 comments on commit 11ac5b5

Please sign in to comment.