linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Linux PM <linux-pm@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Lukas Wunner <lukas@wunner.de>,
	Saravana Kannan <saravanak@google.com>,
	Xiang Chen <chenxiang66@hisilicon.com>
Subject: [PATCH 3/3] PM: runtime: Resume the device earlier in __device_release_driver()
Date: Wed, 21 Oct 2020 21:14:18 +0200	[thread overview]
Message-ID: <1708806.S9fAqql2gf@kreacher> (raw)
In-Reply-To: <6543936.FbWAdBN1tG@kreacher>

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Since the device is resumed from runtime-suspend in
__device_release_driver() anyway, it is better to do that before
looking for busy managed device links from it to consumers, because
if there are any, device_links_unbind_consumers() will be called
and it will cause the consumer devices' drivers to unbind, so the
consumer devices will be runtime-resumed.  In turn, resuming each
consumer device will cause the supplier to be resumed and when the
runtime PM references from the given consumer to it are dropped, it
may be suspended.  Then, the runtime-resume of the next consumer
will cause the supplier to resume again and so on.

Update the code accordingly.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Fixes: 9ed9895370ae ("driver core: Functional dependencies tracking support")
Cc: All applicable <stable@vger.kernel.org> # All applicable
---
 drivers/base/dd.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: linux-pm/drivers/base/dd.c
===================================================================
--- linux-pm.orig/drivers/base/dd.c
+++ linux-pm/drivers/base/dd.c
@@ -1117,6 +1117,8 @@ static void __device_release_driver(stru
 
 	drv = dev->driver;
 	if (drv) {
+		pm_runtime_get_sync(dev);
+
 		while (device_links_busy(dev)) {
 			__device_driver_unlock(dev, parent);
 
@@ -1132,8 +1134,6 @@ static void __device_release_driver(stru
 				return;
 		}
 
-		pm_runtime_get_sync(dev);
-
 		driver_sysfs_remove(dev);
 
 		if (dev->bus)




  parent reply	other threads:[~2020-10-21 19:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-21 19:10 [PATCH 0/3] PM: runtime: Fixes related to device links management Rafael J. Wysocki
2020-10-21 19:12 ` [PATCH 1/3] PM: runtime: Drop runtime PM references to supplier on link removal Rafael J. Wysocki
2020-10-21 19:13 ` [PATCH 2/3] PM: runtime: Drop pm_runtime_clean_up_links() Rafael J. Wysocki
2020-10-21 19:14 ` Rafael J. Wysocki [this message]
2020-10-22 13:40   ` [PATCH 3/3] PM: runtime: Resume the device earlier in __device_release_driver() chenxiang (M)
2020-10-22 14:16     ` Rafael J. Wysocki
2020-10-22 15:38   ` [PATCH update " Rafael J. Wysocki
     [not found] ` <7ebacb82-dc0c-3938-660d-52810607ac00@hisilicon.com>
2020-10-23 15:06   ` [PATCH 0/3] PM: runtime: Fixes related to device links management Rafael J. Wysocki
2020-10-30 16:38 ` Rafael J. Wysocki
2020-11-01  9:36 ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1708806.S9fAqql2gf@kreacher \
    --to=rjw@rjwysocki.net \
    --cc=chenxiang66@hisilicon.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=saravanak@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).