Skip to content

Commit 80eac18

Browse files
Alexander Duyckgregkh
authored andcommitted
driver core: Move async_synchronize_full call
[ Upstream commit c37d721 ] Move the async_synchronize_full call out of __device_release_driver and into driver_detach. The idea behind this is that the async_synchronize_full call will only guarantee that any existing async operations are flushed. This doesn't do anything to guarantee that a hotplug event that may occur while we are doing the release of the driver will not be asynchronously scheduled. By moving this into the driver_detach path we can avoid potential deadlocks as we aren't holding the device lock at this point and we should not have the driver we want to flush loaded so the flush will take care of any asynchronous events the driver we are detaching might have scheduled. Fixes: 765230b ("driver-core: add asynchronous probing support for drivers") Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Alexander Duyck <alexander.h.duyck@linux.intel.com> Reviewed-by: Luis Chamberlain <mcgrof@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 1de47c0 commit 80eac18

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎drivers/base/dd.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -926,9 +926,6 @@ static void __device_release_driver(struct device *dev, struct device *parent)
926926

927927
drv = dev->driver;
928928
if (drv) {
929-
if (driver_allows_async_probing(drv))
930-
async_synchronize_full();
931-
932929
while (device_links_busy(dev)) {
933930
device_unlock(dev);
934931
if (parent && dev->bus->need_parent_lock)
@@ -1034,6 +1031,9 @@ void driver_detach(struct device_driver *drv)
10341031
struct device_private *dev_prv;
10351032
struct device *dev;
10361033

1034+
if (driver_allows_async_probing(drv))
1035+
async_synchronize_full();
1036+
10371037
for (;;) {
10381038
spin_lock(&drv->p->klist_devices.k_lock);
10391039
if (list_empty(&drv->p->klist_devices.k_list)) {

0 commit comments

Comments
 (0)