summaryrefslogtreecommitdiff
path: root/drivers/acpi/power.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2021-10-15 19:14:10 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2021-10-19 19:34:06 +0200
commita1224f34d72a103829d6953935d6c6621f135b83 (patch)
tree1e11169cf4b14794b0e383344132bd11fe689ed5 /drivers/acpi/power.c
parentbc28368596436e6e81ffc48c815b8225d96121c0 (diff)
ACPI: PM: Check states of power resources during initialization
To avoid situations in which the actual states of certain ACPI power resources are not known just because they have never been referenced by any device configuration objects, check the initial states of all power resources as soon as they are found in the ACPI namespace (and fall back to turning them on if the state check fails). Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Tested-by: Andreas K. Huettel <andreas.huettel@ur.de>
Diffstat (limited to 'drivers/acpi/power.c')
-rw-r--r--drivers/acpi/power.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index f0ed4414edb1..bb03fb0eaa0e 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -943,6 +943,7 @@ struct acpi_device *acpi_add_power_resource(acpi_handle handle)
union acpi_object acpi_object;
struct acpi_buffer buffer = { sizeof(acpi_object), &acpi_object };
acpi_status status;
+ u8 state_dummy;
int result;
acpi_bus_get_device(handle, &device);
@@ -971,6 +972,10 @@ struct acpi_device *acpi_add_power_resource(acpi_handle handle)
resource->order = acpi_object.power_resource.resource_order;
resource->state = ACPI_POWER_RESOURCE_STATE_UNKNOWN;
+ /* Get the initial state or just flip it on if that fails. */
+ if (acpi_power_get_state(resource, &state_dummy))
+ __acpi_power_on(resource);
+
pr_info("%s [%s]\n", acpi_device_name(device), acpi_device_bid(device));
device->flags.match_driver = true;