From: Saravana Kannan <saravanak@google.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>, Toan Le <toanle@apm.com>,
Feng Kan <fkan@apm.com>, Saravana Kannan <saravanak@google.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
kernel-team@android.com,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH v1] driver core: Fix suspend/resume order issue with deferred probe
Date: Wed, 24 Jun 2020 20:24:30 -0700 [thread overview]
Message-ID: <20200625032430.152447-1-saravanak@google.com> (raw)
Under the following conditions:
- driver A is built in and can probe device-A
- driver B is a module and can probe device-B
- device-A is supplier of device-B
Without this patch:
1. device-A is added.
2. device-B is added.
3. dpm_list is now [device-A, device-B].
4. driver-A defers probe of device-A.
5. deferred probe of device-A is reattempted
6. device-A is moved to end of dpm_list.
6. dpm_list is now [device-B, device-A].
7. driver-B is loaded and probes device-B.
8. dpm_list stays as [device-B, device-A].
Suspend (which goes in the reverse order of dpm_list) fails because
device-A (supplier) is suspended before device-B (consumer).
With this patch:
1. device-A is added.
2. device-B is added.
3. dpm_list is now [device-A, device-B].
4. driver-A defers probe of device-A.
5. deferred probe of device-A is reattempted later.
6. dpm_list is now [device-B, device-A].
7. driver-B is loaded and probes device-B.
8. dpm_list is now [device-A, device-B].
Suspend works because device-B (consumer) is suspended before device-A
(supplier).
Fixes: 494fd7b7ad10 ("PM / core: fix deferred probe breaking suspend resume order")
Fixes: 716a7a259690 ("driver core: fw_devlink: Add support for batching fwnode parsing")
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Saravana Kannan <saravanak@google.com>
---
drivers/base/dd.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 9a1d940342ac..52b2148c7983 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -109,6 +109,8 @@ static void deferred_probe_work_func(struct work_struct *work)
* probe makes that very unsafe.
*/
device_pm_move_to_tail(dev);
+ /* Greg/Rafael: SHOULD I DELETE THIS? ^^ I think I should, but
+ * I'm worried if it'll have some unintended consequeneces. */
dev_dbg(dev, "Retrying from deferred list\n");
bus_probe_device(dev);
@@ -557,6 +559,20 @@ static int really_probe(struct device *dev, struct device_driver *drv)
goto re_probe;
}
+ /*
+ * The devices are added to the dpm_list (resume/suspend (reverse
+ * order) list) as they are registered with the driver core. But the
+ * order the devices are added doesn't necessarily match the real
+ * dependency order.
+ *
+ * The successful probe order is a much better signal. If a device just
+ * probed successfully, then we know for sure that all the devices that
+ * probed before it don't depend on the device. So, we can safely move
+ * the device to the end of the dpm_list. As more devices probe,
+ * they'll automatically get ordered correctly.
+ */
+ device_pm_move_to_tail(dev);
+
pinctrl_init_done(dev);
if (dev->pm_domain && dev->pm_domain->sync)
--
2.27.0.111.gc72c7da667-goog
next reply other threads:[~2020-06-25 3:29 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-25 3:24 Saravana Kannan [this message]
2020-06-25 8:57 ` [PATCH v1] driver core: Fix suspend/resume order issue with deferred probe Geert Uytterhoeven
2020-06-25 17:02 ` Saravana Kannan
2020-06-25 15:19 ` Rafael J. Wysocki
2020-06-25 16:48 ` Saravana Kannan
2020-06-25 16:58 ` Rafael J. Wysocki
2020-06-25 17:01 ` Saravana Kannan
2020-06-25 17:03 ` Rafael J. Wysocki
2020-06-25 17:08 ` Saravana Kannan
2020-06-25 17:46 ` Rafael J. Wysocki
2020-06-25 17:51 ` Saravana Kannan
2020-06-26 11:27 ` Rafael J. Wysocki
2020-06-26 20:34 ` Saravana Kannan
2020-06-26 20:53 ` Geert Uytterhoeven
2020-06-30 13:50 ` Rafael J. Wysocki
2020-06-30 15:38 ` Greg Kroah-Hartman
2020-06-30 16:11 ` Rafael J. Wysocki
2020-06-30 17:11 ` Saravana Kannan
2020-06-30 17:15 ` Rafael J. Wysocki
2020-07-10 13:21 ` Greg Kroah-Hartman
2020-07-10 20:47 ` Saravana Kannan
2020-07-01 11:07 ` Geert Uytterhoeven
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=20200625032430.152447-1-saravanak@google.com \
--to=saravanak@google.com \
--cc=fkan@apm.com \
--cc=geert@linux-m68k.org \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael.j.wysocki@intel.com \
--cc=rafael@kernel.org \
--cc=toanle@apm.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