]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
PM: sleep: Suppress sleeping parent warning in special case
authorXu Yang <xu.yang_2@nxp.com>
Mon, 24 Feb 2025 07:00:49 +0000 (15:00 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 May 2025 09:13:01 +0000 (11:13 +0200)
[ Upstream commit e8195f0630f1c4c2465074fe81b5fda19efd3148 ]

Currently, if power.no_callbacks is set, device_prepare() will also set
power.direct_complete for the device.  If power.direct_complete is set
in device_resume(), the clearing of power.is_prepared will be skipped
and if new children appear under the device at that point, a warning
will be printed.

After commit (f76b168b6f11 PM: Rename dev_pm_info.in_suspend to
is_prepared), power.is_prepared is generally cleared in device_resume()
before invoking the resume callback for the device which allows that
callback to add new children without triggering the warning, but this
does not happen for devices with power.direct_complete set.

This problem is visible in USB where usb_set_interface() can be called
before device_complete() clears power.is_prepared for interface devices
and since ep devices are added then, the warning is printed:

 usb 1-1: reset high-speed USB device number 3 using ci_hdrc
  ep_81: PM: parent 1-1:1.1 should not be sleeping
 PM: resume devices took 0.936 seconds

Since it is legitimate to add the ep devices at that point, the
warning above is not particularly useful, so get rid of it by
clearing power.is_prepared in device_resume() for devices with
power.direct_complete set if they have no PM callbacks, in which
case they need not actually resume for the new children to work.

Suggested-by: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Link: https://patch.msgid.link/20250224070049.3338646-1-xu.yang_2@nxp.com
[ rjw: New subject, changelog edits, rephrased new code comment ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/base/power/main.c

index 23be2d1b04079829a85b80da6119240c5ce780bc..37fe251b4c591fd4709e94003730c5b8940d22ad 100644 (file)
@@ -933,6 +933,13 @@ static void device_resume(struct device *dev, pm_message_t state, bool async)
                goto Complete;
 
        if (dev->power.direct_complete) {
+               /*
+                * Allow new children to be added under the device after this
+                * point if it has no PM callbacks.
+                */
+               if (dev->power.no_pm_callbacks)
+                       dev->power.is_prepared = false;
+
                /* Match the pm_runtime_disable() in device_suspend(). */
                pm_runtime_enable(dev);
                goto Complete;