Skip to content

Commit 32ece31

Browse files
committed
ACPI: PM: s2idle: Only retrieve constraints when needed
The evaluation of LPS0 _DSM Function 1 in lps0_device_attach() may be useless if pm_debug_messages_on is never set. For this reason, instead of evaluating it in lps0_device_attach(), do that in a new .begin() callback for s2idle, acpi_s2idle_begin_lps0(), only when pm_debug_messages_on is set at that point. However, never attempt to evaluate LPS0 _DSM Function 1 more than once to avoid recurring failures. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org> Link: https://patch.msgid.link/3027060.e9J7NaK4W3@rafael.j.wysocki
1 parent bfc0990 commit 32ece31

1 file changed

Lines changed: 23 additions & 6 deletions

File tree

drivers/acpi/x86/s2idle.c

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ static void lpi_check_constraints(void)
303303
{
304304
struct lpi_constraints *entry;
305305

306+
if (IS_ERR_OR_NULL(lpi_constraints_table))
307+
return;
308+
306309
for_each_lpi_constraint(entry) {
307310
struct acpi_device *adev = acpi_fetch_acpi_dev(entry->handle);
308311

@@ -484,11 +487,6 @@ static int lps0_device_attach(struct acpi_device *adev,
484487

485488
lps0_device_handle = adev->handle;
486489

487-
if (acpi_s2idle_vendor_amd())
488-
lpi_device_get_constraints_amd();
489-
else
490-
lpi_device_get_constraints();
491-
492490
/*
493491
* Use suspend-to-idle by default if ACPI_FADT_LOW_POWER_S0 is set in
494492
* the FADT and the default suspend mode was not set from the command
@@ -515,6 +513,25 @@ static struct acpi_scan_handler lps0_handler = {
515513
.attach = lps0_device_attach,
516514
};
517515

516+
static int acpi_s2idle_begin_lps0(void)
517+
{
518+
if (pm_debug_messages_on && !lpi_constraints_table) {
519+
if (acpi_s2idle_vendor_amd())
520+
lpi_device_get_constraints_amd();
521+
else
522+
lpi_device_get_constraints();
523+
524+
/*
525+
* Try to retrieve the constraints only once because failures
526+
* to do so usually are sticky.
527+
*/
528+
if (!lpi_constraints_table)
529+
lpi_constraints_table = ERR_PTR(-ENODATA);
530+
}
531+
532+
return acpi_s2idle_begin();
533+
}
534+
518535
static int acpi_s2idle_prepare_late_lps0(void)
519536
{
520537
struct acpi_s2idle_dev_ops *handler;
@@ -612,7 +629,7 @@ static void acpi_s2idle_restore_early_lps0(void)
612629
}
613630

614631
static const struct platform_s2idle_ops acpi_s2idle_ops_lps0 = {
615-
.begin = acpi_s2idle_begin,
632+
.begin = acpi_s2idle_begin_lps0,
616633
.prepare = acpi_s2idle_prepare,
617634
.prepare_late = acpi_s2idle_prepare_late_lps0,
618635
.check = acpi_s2idle_check_lps0,

0 commit comments

Comments
 (0)