Skip to content

Commit 6cba603

Browse files
committed
ACPI: thermal: Rework system suspend and resume handling
In the process of handling system resume, acpi_thermal_resume() attempts to power up active cooling devices to guarantee that they will be operational when the ACPI thermal check queued by it runs. However, the only kind of cooling devices that can be bound to ACPI thermal zones is fans and they are already powered up by the ACPI fan driver resume, which additionally takes "ACPI 4" fans that don't need to be powered up into account. For this reason, remove the part of acpi_thermal_resume() related to fans and in order to ensure that it will run after powering up all fans, rename it to acpi_thermal_complete() and point the .complete() driver callback to it. Analogously, rename acpi_thermal_suspend() to acpi_thermal_prepare() and point the .prepare() driver callback to it. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: lihuisong@huawei.com Link: https://patch.msgid.link/3024049.e9J7NaK4W3@rafael.j.wysocki
1 parent d1db160 commit 6cba603

1 file changed

Lines changed: 13 additions & 24 deletions

File tree

drivers/acpi/thermal.c

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -911,37 +911,26 @@ static void acpi_thermal_remove(struct platform_device *pdev)
911911
}
912912

913913
#ifdef CONFIG_PM_SLEEP
914-
static int acpi_thermal_suspend(struct device *dev)
914+
static int acpi_thermal_prepare(struct device *dev)
915915
{
916916
/* Make sure the previously queued thermal check work has been done */
917917
flush_workqueue(acpi_thermal_pm_queue);
918918
return 0;
919919
}
920920

921-
static int acpi_thermal_resume(struct device *dev)
921+
static void acpi_thermal_complete(struct device *dev)
922922
{
923-
struct acpi_thermal *tz = dev_get_drvdata(dev);
924-
int i, j;
925-
926-
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
927-
struct acpi_thermal_trip *acpi_trip = &tz->trips.active[i].trip;
928-
929-
if (!acpi_thermal_trip_valid(acpi_trip))
930-
break;
931-
932-
for (j = 0; j < acpi_trip->devices.count; j++)
933-
acpi_bus_update_power(acpi_trip->devices.handles[j], NULL);
934-
}
935-
936-
acpi_queue_thermal_check(tz);
937-
938-
return AE_OK;
923+
acpi_queue_thermal_check(dev_get_drvdata(dev));
939924
}
940-
#else
941-
#define acpi_thermal_suspend NULL
942-
#define acpi_thermal_resume NULL
943-
#endif
944-
static SIMPLE_DEV_PM_OPS(acpi_thermal_pm, acpi_thermal_suspend, acpi_thermal_resume);
925+
926+
static const struct dev_pm_ops acpi_thermal_pm_ops = {
927+
.prepare = acpi_thermal_prepare,
928+
.complete = acpi_thermal_complete,
929+
};
930+
#define ACPI_THERMAL_PM &acpi_thermal_pm_ops
931+
#else /* !CONFIG_PM_SLEEP */
932+
#define ACPI_THERMAL_PM NULL
933+
#endif /* CONFIG_PM_SLEEP */
945934

946935
static const struct acpi_device_id thermal_device_ids[] = {
947936
{ACPI_THERMAL_HID, 0},
@@ -955,7 +944,7 @@ static struct platform_driver acpi_thermal_driver = {
955944
.driver = {
956945
.name = "acpi-thermal",
957946
.acpi_match_table = thermal_device_ids,
958-
.pm = &acpi_thermal_pm,
947+
.pm = ACPI_THERMAL_PM,
959948
},
960949
};
961950

0 commit comments

Comments
 (0)