Skip to content

Commit ac6f87a

Browse files
committed
PM: sleep: stats: Log errors right after running suspend callbacks
The error logging and failure statistics updates are carried out in two places in each system-wide device suspend phase, which is unnecessary code duplication, so do that in one place in each phase, right after invoking device suspend callbacks. While at it, add "noirq" or "late" to the "async" string printed when the failing device callback in the "noirq" or "late" suspend phase, respectively, was run asynchronously. Signed-off-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]> Reviewed-by: Ulf Hansson <[email protected]>
1 parent a6d38e9 commit ac6f87a

File tree

1 file changed

+13
-36
lines changed

1 file changed

+13
-36
lines changed

drivers/base/power/main.c

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,8 @@ static int __device_suspend_noirq(struct device *dev, pm_message_t state, bool a
12441244
error = dpm_run_callback(callback, dev, state, info);
12451245
if (error) {
12461246
async_error = error;
1247+
dpm_save_failed_dev(dev_name(dev));
1248+
pm_dev_err(dev, state, async ? " async noirq" : " noirq", error);
12471249
goto Complete;
12481250
}
12491251

@@ -1273,14 +1275,8 @@ static int __device_suspend_noirq(struct device *dev, pm_message_t state, bool a
12731275
static void async_suspend_noirq(void *data, async_cookie_t cookie)
12741276
{
12751277
struct device *dev = data;
1276-
int error;
1277-
1278-
error = __device_suspend_noirq(dev, pm_transition, true);
1279-
if (error) {
1280-
dpm_save_failed_dev(dev_name(dev));
1281-
pm_dev_err(dev, pm_transition, " async", error);
1282-
}
12831278

1279+
__device_suspend_noirq(dev, pm_transition, true);
12841280
put_device(dev);
12851281
}
12861282

@@ -1312,12 +1308,8 @@ static int dpm_noirq_suspend_devices(pm_message_t state)
13121308

13131309
mutex_lock(&dpm_list_mtx);
13141310

1315-
if (error) {
1316-
pm_dev_err(dev, state, " noirq", error);
1317-
dpm_save_failed_dev(dev_name(dev));
1318-
} else if (!list_empty(&dev->power.entry)) {
1311+
if (!error && !list_empty(&dev->power.entry))
13191312
list_move(&dev->power.entry, &dpm_noirq_list);
1320-
}
13211313

13221314
mutex_unlock(&dpm_list_mtx);
13231315

@@ -1437,6 +1429,8 @@ static int __device_suspend_late(struct device *dev, pm_message_t state, bool as
14371429
error = dpm_run_callback(callback, dev, state, info);
14381430
if (error) {
14391431
async_error = error;
1432+
dpm_save_failed_dev(dev_name(dev));
1433+
pm_dev_err(dev, state, async ? " async late" : " late", error);
14401434
goto Complete;
14411435
}
14421436
dpm_propagate_wakeup_to_parent(dev);
@@ -1453,13 +1447,8 @@ static int __device_suspend_late(struct device *dev, pm_message_t state, bool as
14531447
static void async_suspend_late(void *data, async_cookie_t cookie)
14541448
{
14551449
struct device *dev = data;
1456-
int error;
14571450

1458-
error = __device_suspend_late(dev, pm_transition, true);
1459-
if (error) {
1460-
dpm_save_failed_dev(dev_name(dev));
1461-
pm_dev_err(dev, pm_transition, " async", error);
1462-
}
1451+
__device_suspend_late(dev, pm_transition, true);
14631452
put_device(dev);
14641453
}
14651454

@@ -1500,11 +1489,6 @@ int dpm_suspend_late(pm_message_t state)
15001489
if (!list_empty(&dev->power.entry))
15011490
list_move(&dev->power.entry, &dpm_late_early_list);
15021491

1503-
if (error) {
1504-
pm_dev_err(dev, state, " late", error);
1505-
dpm_save_failed_dev(dev_name(dev));
1506-
}
1507-
15081492
mutex_unlock(&dpm_list_mtx);
15091493

15101494
put_device(dev);
@@ -1719,8 +1703,11 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
17191703
dpm_watchdog_clear(&wd);
17201704

17211705
Complete:
1722-
if (error)
1706+
if (error) {
17231707
async_error = error;
1708+
dpm_save_failed_dev(dev_name(dev));
1709+
pm_dev_err(dev, state, async ? " async" : "", error);
1710+
}
17241711

17251712
complete_all(&dev->power.completion);
17261713
TRACE_SUSPEND(error);
@@ -1730,14 +1717,8 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
17301717
static void async_suspend(void *data, async_cookie_t cookie)
17311718
{
17321719
struct device *dev = data;
1733-
int error;
1734-
1735-
error = __device_suspend(dev, pm_transition, true);
1736-
if (error) {
1737-
dpm_save_failed_dev(dev_name(dev));
1738-
pm_dev_err(dev, pm_transition, " async", error);
1739-
}
17401720

1721+
__device_suspend(dev, pm_transition, true);
17411722
put_device(dev);
17421723
}
17431724

@@ -1778,12 +1759,8 @@ int dpm_suspend(pm_message_t state)
17781759

17791760
mutex_lock(&dpm_list_mtx);
17801761

1781-
if (error) {
1782-
pm_dev_err(dev, state, "", error);
1783-
dpm_save_failed_dev(dev_name(dev));
1784-
} else if (!list_empty(&dev->power.entry)) {
1762+
if (!error && !list_empty(&dev->power.entry))
17851763
list_move(&dev->power.entry, &dpm_suspended_list);
1786-
}
17871764

17881765
mutex_unlock(&dpm_list_mtx);
17891766

0 commit comments

Comments
 (0)