* [PATCH] driver core: Move deferred devices to the end of dpm_list before probing
@ 2012-07-05 13:04 Mark Brown
2012-07-05 13:15 ` Rafael J. Wysocki
0 siblings, 1 reply; 2+ messages in thread
From: Mark Brown @ 2012-07-05 13:04 UTC (permalink / raw)
To: Alan Stern, Greg Kroah-Hartman, Grant Likely, Rafael J. Wysocki,
Thomas Gleixner
Cc: linux-kernel, Mark Brown
When deferred probe was originally added the idea was that devices which
defer their probes would move themselves to the end of dpm_list in order
to try to keep the assumptions that we're making about the list being in
roughly the order things should be suspended correct. However this hasn't
been what's been happening and doing it requires a lot of duplicated code
to do the moves.
Instead take a simple, brute force solution and have the deferred probe
code push devices to the end of dpm_list before it retries the probe. This
does mean we lock the dpm_list a bit more often but it's very simple and
the code shouldn't be a fast path. We do the move with the deferred mutex
dropped since doing things with fewer locks held simultaneously seems like
a good idea.
This approach was most recently suggested by Grant Likely.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
drivers/base/dd.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 6cd2c6c..9b0aca4 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -85,8 +85,20 @@ static void deferred_probe_work_func(struct work_struct *work)
* manipulate the deferred list
*/
mutex_unlock(&deferred_probe_mutex);
+
+ /*
+ * Force the device to the end of the dpm_list since
+ * the PM code assumes that the order we add things to
+ * the list is a good order for suspend but deferred
+ * probe makes that very unsafe.
+ */
+ device_pm_lock();
+ device_pm_move_last(dev);
+ device_pm_unlock();
+
dev_dbg(dev, "Retrying from deferred list\n");
bus_probe_device(dev);
+
mutex_lock(&deferred_probe_mutex);
put_device(dev);
--
1.7.10
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] driver core: Move deferred devices to the end of dpm_list before probing
2012-07-05 13:04 [PATCH] driver core: Move deferred devices to the end of dpm_list before probing Mark Brown
@ 2012-07-05 13:15 ` Rafael J. Wysocki
0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2012-07-05 13:15 UTC (permalink / raw)
To: Mark Brown
Cc: Alan Stern, Greg Kroah-Hartman, Grant Likely, Thomas Gleixner,
linux-kernel
On Thursday, July 05, 2012, Mark Brown wrote:
> When deferred probe was originally added the idea was that devices which
> defer their probes would move themselves to the end of dpm_list in order
> to try to keep the assumptions that we're making about the list being in
> roughly the order things should be suspended correct. However this hasn't
> been what's been happening and doing it requires a lot of duplicated code
> to do the moves.
>
> Instead take a simple, brute force solution and have the deferred probe
> code push devices to the end of dpm_list before it retries the probe. This
> does mean we lock the dpm_list a bit more often but it's very simple and
> the code shouldn't be a fast path. We do the move with the deferred mutex
> dropped since doing things with fewer locks held simultaneously seems like
> a good idea.
>
> This approach was most recently suggested by Grant Likely.
>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Looks good.
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
> ---
> drivers/base/dd.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index 6cd2c6c..9b0aca4 100644
> --- a/drivers/base/dd.c
> +++ b/drivers/base/dd.c
> @@ -85,8 +85,20 @@ static void deferred_probe_work_func(struct work_struct *work)
> * manipulate the deferred list
> */
> mutex_unlock(&deferred_probe_mutex);
> +
> + /*
> + * Force the device to the end of the dpm_list since
> + * the PM code assumes that the order we add things to
> + * the list is a good order for suspend but deferred
> + * probe makes that very unsafe.
> + */
> + device_pm_lock();
> + device_pm_move_last(dev);
> + device_pm_unlock();
> +
> dev_dbg(dev, "Retrying from deferred list\n");
> bus_probe_device(dev);
> +
> mutex_lock(&deferred_probe_mutex);
>
> put_device(dev);
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-07-05 13:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-05 13:04 [PATCH] driver core: Move deferred devices to the end of dpm_list before probing Mark Brown
2012-07-05 13:15 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®