public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] driver core: add devices to deferred probe list when unbinding consumers
@ 2017-03-08 11:50 Lucas Stach
  2017-03-16  8:28 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Lucas Stach @ 2017-03-08 11:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel, patchwork-lst

When a device is unbound due to the provider of one of the resources going
away, add it to the deferred probe list. This way the consumer device
driver gets a chance to rebind itself if the provider is rebound later on.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/base/base.h | 1 +
 drivers/base/core.c | 2 ++
 drivers/base/dd.c   | 2 +-
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/base/base.h b/drivers/base/base.h
index e19b1008e5fb..c37d42450886 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -113,6 +113,7 @@ extern void device_release_driver_internal(struct device *dev,
 
 extern void driver_detach(struct device_driver *drv);
 extern int driver_probe_device(struct device_driver *drv, struct device *dev);
+extern void driver_deferred_probe_add(struct device *dev);
 extern void driver_deferred_probe_del(struct device *dev);
 static inline int driver_match_device(struct device_driver *drv,
 				      struct device *dev)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 8c25e68e67d7..860e1cf195b9 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -572,6 +572,8 @@ void device_links_unbind_consumers(struct device *dev)
 
 			device_release_driver_internal(consumer, NULL,
 						       consumer->parent);
+			driver_deferred_probe_add(consumer);
+
 			put_device(consumer);
 			goto start;
 		}
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index a1fbf55c4d3a..a0217d76a0f2 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -115,7 +115,7 @@ static void deferred_probe_work_func(struct work_struct *work)
 }
 static DECLARE_WORK(deferred_probe_work, deferred_probe_work_func);
 
-static void driver_deferred_probe_add(struct device *dev)
+void driver_deferred_probe_add(struct device *dev)
 {
 	mutex_lock(&deferred_probe_mutex);
 	if (list_empty(&dev->p->deferred_probe)) {
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] driver core: add devices to deferred probe list when unbinding consumers
  2017-03-08 11:50 [PATCH] driver core: add devices to deferred probe list when unbinding consumers Lucas Stach
@ 2017-03-16  8:28 ` Greg Kroah-Hartman
  2017-03-16  9:26   ` Lucas Stach
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2017-03-16  8:28 UTC (permalink / raw)
  To: Lucas Stach; +Cc: linux-kernel, kernel, patchwork-lst

On Wed, Mar 08, 2017 at 12:50:41PM +0100, Lucas Stach wrote:
> When a device is unbound due to the provider of one of the resources going
> away, add it to the deferred probe list. This way the consumer device
> driver gets a chance to rebind itself if the provider is rebound later on.

Ick, no, if someone unbinds the driver, it's gone, don't try to keep
things around.  Wasn't this rejected previously?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] driver core: add devices to deferred probe list when unbinding consumers
  2017-03-16  8:28 ` Greg Kroah-Hartman
@ 2017-03-16  9:26   ` Lucas Stach
  0 siblings, 0 replies; 3+ messages in thread
From: Lucas Stach @ 2017-03-16  9:26 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel, patchwork-lst

Am Donnerstag, den 16.03.2017, 17:28 +0900 schrieb Greg Kroah-Hartman:
> On Wed, Mar 08, 2017 at 12:50:41PM +0100, Lucas Stach wrote:
> > When a device is unbound due to the provider of one of the resources going
> > away, add it to the deferred probe list. This way the consumer device
> > driver gets a chance to rebind itself if the provider is rebound later on.
> 
> Ick, no, if someone unbinds the driver, it's gone, don't try to keep
> things around.  Wasn't this rejected previously?

This doesn't keep anything around. It just adds the consumer device to
the deferred probe list. So they are properly unbound, but have a chance
to re-probe once the provider comes up again.

Simple example:
1. Unload the module for regulator driver
2. All consumers get unbound due to the device dependency between the
regulator and the consumer devices
3. modprobe the regulator module again

What happens today is that the consumers stay in non-functional state
due to their drivers being gone. With the proposed patch the consumer
drivers go through their probe routine again. If all the needed
resources are available again (the regulator driver is up again) they
can return to a functional state.

All this is just normal hotplug and deferred probing, there is no
additional state kept around.

Regards,
Lucas

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-16  9:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-08 11:50 [PATCH] driver core: add devices to deferred probe list when unbinding consumers Lucas Stach
2017-03-16  8:28 ` Greg Kroah-Hartman
2017-03-16  9:26   ` Lucas Stach

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox