Skip to content

Commit ec85720

Browse files
committed
Merge tag 'pm-5.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull power management fixes from Rafael Wysocki: "Revert two problematic commits. Specifics: - Revert ACPI PM commit that attempted to improve reboot handling on some systems, but it caused other systems to panic() during reboot (Josef Bacik) - Revert PM-runtime commit that attempted to improve the handling of suppliers during PM-runtime suspend of a consumer device, but it introduced a race condition potentially leading to unexpected behavior (Rafael Wysocki)" * tag 'pm-5.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: Revert "PM: runtime: Update device status before letting suppliers suspend" Revert "PM: ACPI: reboot: Use S5 for reboot"
2 parents 65a1037 + 49cb71a commit ec85720

2 files changed

Lines changed: 25 additions & 39 deletions

File tree

drivers/base/power/runtime.c

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -325,22 +325,22 @@ static void rpm_put_suppliers(struct device *dev)
325325
static int __rpm_callback(int (*cb)(struct device *), struct device *dev)
326326
__releases(&dev->power.lock) __acquires(&dev->power.lock)
327327
{
328-
bool use_links = dev->power.links_count > 0;
329-
bool get = false;
330328
int retval, idx;
331-
bool put;
329+
bool use_links = dev->power.links_count > 0;
332330

333331
if (dev->power.irq_safe) {
334332
spin_unlock(&dev->power.lock);
335-
} else if (!use_links) {
336-
spin_unlock_irq(&dev->power.lock);
337333
} else {
338-
get = dev->power.runtime_status == RPM_RESUMING;
339-
340334
spin_unlock_irq(&dev->power.lock);
341335

342-
/* Resume suppliers if necessary. */
343-
if (get) {
336+
/*
337+
* Resume suppliers if necessary.
338+
*
339+
* The device's runtime PM status cannot change until this
340+
* routine returns, so it is safe to read the status outside of
341+
* the lock.
342+
*/
343+
if (use_links && dev->power.runtime_status == RPM_RESUMING) {
344344
idx = device_links_read_lock();
345345

346346
retval = rpm_get_suppliers(dev);
@@ -355,36 +355,24 @@ static int __rpm_callback(int (*cb)(struct device *), struct device *dev)
355355

356356
if (dev->power.irq_safe) {
357357
spin_lock(&dev->power.lock);
358-
return retval;
359-
}
360-
361-
spin_lock_irq(&dev->power.lock);
362-
363-
if (!use_links)
364-
return retval;
365-
366-
/*
367-
* If the device is suspending and the callback has returned success,
368-
* drop the usage counters of the suppliers that have been reference
369-
* counted on its resume.
370-
*
371-
* Do that if the resume fails too.
372-
*/
373-
put = dev->power.runtime_status == RPM_SUSPENDING && !retval;
374-
if (put)
375-
__update_runtime_status(dev, RPM_SUSPENDED);
376-
else
377-
put = get && retval;
378-
379-
if (put) {
380-
spin_unlock_irq(&dev->power.lock);
381-
382-
idx = device_links_read_lock();
358+
} else {
359+
/*
360+
* If the device is suspending and the callback has returned
361+
* success, drop the usage counters of the suppliers that have
362+
* been reference counted on its resume.
363+
*
364+
* Do that if resume fails too.
365+
*/
366+
if (use_links
367+
&& ((dev->power.runtime_status == RPM_SUSPENDING && !retval)
368+
|| (dev->power.runtime_status == RPM_RESUMING && retval))) {
369+
idx = device_links_read_lock();
383370

384-
fail:
385-
rpm_put_suppliers(dev);
371+
fail:
372+
rpm_put_suppliers(dev);
386373

387-
device_links_read_unlock(idx);
374+
device_links_read_unlock(idx);
375+
}
388376

389377
spin_lock_irq(&dev->power.lock);
390378
}

kernel/reboot.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,6 @@ void migrate_to_reboot_cpu(void)
244244
void kernel_restart(char *cmd)
245245
{
246246
kernel_restart_prepare(cmd);
247-
if (pm_power_off_prepare)
248-
pm_power_off_prepare();
249247
migrate_to_reboot_cpu();
250248
syscore_shutdown();
251249
if (!cmd)

0 commit comments

Comments
 (0)