Commit 9bc67590 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'pm-for-3.6-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull power management fixes from Rafael J. Wysocki:
 "Three ACPI device power management fixes related to checking and
  setting device power states."

* tag 'pm-for-3.6-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  ACPI / PM: Use KERN_DEBUG when no power resources are found
  ACPI / PM: Fix resource_lock dead lock in acpi_power_on_device
  ACPI / PM: Infer parent power state from child if unknown, v2
parents 6167f81f f25b7061
...@@ -237,6 +237,16 @@ static int __acpi_bus_get_power(struct acpi_device *device, int *state) ...@@ -237,6 +237,16 @@ static int __acpi_bus_get_power(struct acpi_device *device, int *state)
} else if (result == ACPI_STATE_D3_HOT) { } else if (result == ACPI_STATE_D3_HOT) {
result = ACPI_STATE_D3; result = ACPI_STATE_D3;
} }
/*
* If we were unsure about the device parent's power state up to this
* point, the fact that the device is in D0 implies that the parent has
* to be in D0 too.
*/
if (device->parent && device->parent->power.state == ACPI_STATE_UNKNOWN
&& result == ACPI_STATE_D0)
device->parent->power.state = ACPI_STATE_D0;
*state = result; *state = result;
out: out:
......
...@@ -107,6 +107,7 @@ struct acpi_power_resource { ...@@ -107,6 +107,7 @@ struct acpi_power_resource {
/* List of devices relying on this power resource */ /* List of devices relying on this power resource */
struct acpi_power_resource_device *devices; struct acpi_power_resource_device *devices;
struct mutex devices_lock;
}; };
static struct list_head acpi_power_resource_list; static struct list_head acpi_power_resource_list;
...@@ -225,7 +226,6 @@ static void acpi_power_on_device(struct acpi_power_managed_device *device) ...@@ -225,7 +226,6 @@ static void acpi_power_on_device(struct acpi_power_managed_device *device)
static int __acpi_power_on(struct acpi_power_resource *resource) static int __acpi_power_on(struct acpi_power_resource *resource)
{ {
struct acpi_power_resource_device *device_list = resource->devices;
acpi_status status = AE_OK; acpi_status status = AE_OK;
status = acpi_evaluate_object(resource->device->handle, "_ON", NULL, NULL); status = acpi_evaluate_object(resource->device->handle, "_ON", NULL, NULL);
...@@ -238,19 +238,15 @@ static int __acpi_power_on(struct acpi_power_resource *resource) ...@@ -238,19 +238,15 @@ static int __acpi_power_on(struct acpi_power_resource *resource)
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Power resource [%s] turned on\n", ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Power resource [%s] turned on\n",
resource->name)); resource->name));
while (device_list) {
acpi_power_on_device(device_list->device);
device_list = device_list->next;
}
return 0; return 0;
} }
static int acpi_power_on(acpi_handle handle) static int acpi_power_on(acpi_handle handle)
{ {
int result = 0; int result = 0;
bool resume_device = false;
struct acpi_power_resource *resource = NULL; struct acpi_power_resource *resource = NULL;
struct acpi_power_resource_device *device_list;
result = acpi_power_get_context(handle, &resource); result = acpi_power_get_context(handle, &resource);
if (result) if (result)
...@@ -266,10 +262,25 @@ static int acpi_power_on(acpi_handle handle) ...@@ -266,10 +262,25 @@ static int acpi_power_on(acpi_handle handle)
result = __acpi_power_on(resource); result = __acpi_power_on(resource);
if (result) if (result)
resource->ref_count--; resource->ref_count--;
else
resume_device = true;
} }
mutex_unlock(&resource->resource_lock); mutex_unlock(&resource->resource_lock);
if (!resume_device)
return result;
mutex_lock(&resource->devices_lock);
device_list = resource->devices;
while (device_list) {
acpi_power_on_device(device_list->device);
device_list = device_list->next;
}
mutex_unlock(&resource->devices_lock);
return result; return result;
} }
...@@ -355,7 +366,7 @@ static void __acpi_power_resource_unregister_device(struct device *dev, ...@@ -355,7 +366,7 @@ static void __acpi_power_resource_unregister_device(struct device *dev,
if (acpi_power_get_context(res_handle, &resource)) if (acpi_power_get_context(res_handle, &resource))
return; return;
mutex_lock(&resource->resource_lock); mutex_lock(&resource->devices_lock);
prev = NULL; prev = NULL;
curr = resource->devices; curr = resource->devices;
while (curr) { while (curr) {
...@@ -372,7 +383,7 @@ static void __acpi_power_resource_unregister_device(struct device *dev, ...@@ -372,7 +383,7 @@ static void __acpi_power_resource_unregister_device(struct device *dev,
prev = curr; prev = curr;
curr = curr->next; curr = curr->next;
} }
mutex_unlock(&resource->resource_lock); mutex_unlock(&resource->devices_lock);
} }
/* Unlink dev from all power resources in _PR0 */ /* Unlink dev from all power resources in _PR0 */
...@@ -414,10 +425,10 @@ static int __acpi_power_resource_register_device( ...@@ -414,10 +425,10 @@ static int __acpi_power_resource_register_device(
power_resource_device->device = powered_device; power_resource_device->device = powered_device;
mutex_lock(&resource->resource_lock); mutex_lock(&resource->devices_lock);
power_resource_device->next = resource->devices; power_resource_device->next = resource->devices;
resource->devices = power_resource_device; resource->devices = power_resource_device;
mutex_unlock(&resource->resource_lock); mutex_unlock(&resource->devices_lock);
return 0; return 0;
} }
...@@ -462,7 +473,7 @@ int acpi_power_resource_register_device(struct device *dev, acpi_handle handle) ...@@ -462,7 +473,7 @@ int acpi_power_resource_register_device(struct device *dev, acpi_handle handle)
return ret; return ret;
no_power_resource: no_power_resource:
printk(KERN_WARNING PREFIX "Invalid Power Resource to register!"); printk(KERN_DEBUG PREFIX "Invalid Power Resource to register!");
return -ENODEV; return -ENODEV;
} }
EXPORT_SYMBOL_GPL(acpi_power_resource_register_device); EXPORT_SYMBOL_GPL(acpi_power_resource_register_device);
...@@ -721,6 +732,7 @@ static int acpi_power_add(struct acpi_device *device) ...@@ -721,6 +732,7 @@ static int acpi_power_add(struct acpi_device *device)
resource->device = device; resource->device = device;
mutex_init(&resource->resource_lock); mutex_init(&resource->resource_lock);
mutex_init(&resource->devices_lock);
strcpy(resource->name, device->pnp.bus_id); strcpy(resource->name, device->pnp.bus_id);
strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME); strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME);
strcpy(acpi_device_class(device), ACPI_POWER_CLASS); strcpy(acpi_device_class(device), ACPI_POWER_CLASS);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment