Skip to contentSkip to conversation

driver core: Move device_links_purge() after bus_remove_device()

PATCH Superseded Jeffy Chen 2 participants 3 messages Oct 19, 2017 – Oct 20, 2017 Driver core

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Jeffy Chen

author
#0 lore raw

PATCH v2 1/1 driver core: Move device_links_purge() after bus_remove_device()

The current ordering of code in device_del() triggers a WARN_ON() in device_links_purge(), because of an unexpected link status.

The device_links_unbind_consumers() call in device_release_driver() has to take place before device_links_purge() for the status of all links to be correct, so move the device_links_purge() call in device_del() after the invocation of bus_remove_device() which calls device_release_driver().

---

Changes in v2:
Update commit message provided by Rafael.

 drivers/base/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/core.c +1 -1
index 12ebd055724c..2e683cdf4a08 100644
@@ -1958,7 +1958,6 @@ void device_del(struct device *dev)
 		blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
 					     BUS_NOTIFY_DEL_DEVICE, dev);
 
-	device_links_purge(dev);
 	dpm_sysfs_remove(dev);
 	if (parent)
 		klist_del(&dev->p->knode_parent);
@@ -1986,6 +1985,7 @@ void device_del(struct device *dev)
 	device_pm_remove(dev);
 	driver_deferred_probe_del(dev);
 	device_remove_properties(dev);
+	device_links_purge(dev);
 
 	/* Notify the platform of the removal, in case they
 	 * need to do anything...
Signature · 1 line
2.11.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 10 lines · Jeffy Chen

The current ordering of code in device_del() triggers a WARN_ON() in device_links_purge(), because of an unexpected link status.

The device_links_unbind_consumers() call in device_release_driver() has to take place before device_links_purge() for the status of all links to be correct, so move the device_links_purge() call in device_del() after the invocation of bus_remove_device() which calls device_release_driver().

It has not been signed off by me, so you should not have added the line above.

Quoted 1 line

For the patch itself and the changelog *except* for the S-o-b line:

Quoted 28 lines

---

Changes in v2:
Update commit message provided by Rafael.

  drivers/base/core.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/core.c +1 -1
index 12ebd055724c..2e683cdf4a08 100644
@@ -1958,7 +1958,6 @@ void device_del(struct device *dev)
  		blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
  					     BUS_NOTIFY_DEL_DEVICE, dev);
 
-	device_links_purge(dev);
  	dpm_sysfs_remove(dev);
  	if (parent)
  		klist_del(&dev->p->knode_parent);
@@ -1986,6 +1985,7 @@ void device_del(struct device *dev)
  	device_pm_remove(dev);
  	driver_deferred_probe_del(dev);
  	device_remove_properties(dev);
+	device_links_purge(dev);
 
  	/* Notify the platform of the removal, in case they
  	 * need to do anything...