Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

driver synchronization: make scsi_wait_scan more advanced

There is currently only one way for userspace to say "wait for my storage
device to get ready for the modules I just loaded": to load the
scsi_wait_scan module. Expectations of userspace are that once this
module is loaded, all the (storage) devices for which the drivers
were loaded before the module load are present.

Now, there are some issues with the implementation, and the async
stuff got caught in the middle of this: The existing code only
waits for the scsy async probing to finish, but it did not take
into account at all that probing might not have begun yet.
(Russell ran into this problem on his computer and the fix works for him)

This patch fixes this more thoroughly than the previous "fix", which
had some bad side effects (namely, for kernel code that wanted to wait for
the scsi scan it would also do an async sync, which would deadlock if you did
it from async context already.. there's a report about that on lkml):
The patch makes the module first wait for all device driver probes, and then it
will wait for the scsi parallel scan to finish.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Tested-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Arjan van de Ven and committed by
Linus Torvalds
d4d5291c 5dd559f0

+13 -2
+1
drivers/base/dd.c
··· 179 179 wait_event(probe_waitqueue, atomic_read(&probe_count) == 0); 180 180 async_synchronize_full(); 181 181 } 182 + EXPORT_SYMBOL_GPL(wait_for_device_probe); 182 183 183 184 /** 184 185 * driver_probe_device - attempt to bind device & driver together
-2
drivers/scsi/scsi_scan.c
··· 180 180 spin_unlock(&async_scan_lock); 181 181 182 182 kfree(data); 183 - /* Synchronize async operations globally */ 184 - async_synchronize_full(); 185 183 return 0; 186 184 } 187 185
+11
drivers/scsi/scsi_wait_scan.c
··· 11 11 */ 12 12 13 13 #include <linux/module.h> 14 + #include <linux/device.h> 14 15 #include <scsi/scsi_scan.h> 15 16 16 17 static int __init wait_scan_init(void) 17 18 { 19 + /* 20 + * First we need to wait for device probing to finish; 21 + * the drivers we just loaded might just still be probing 22 + * and might not yet have reached the scsi async scanning 23 + */ 24 + wait_for_device_probe(); 25 + /* 26 + * and then we wait for the actual asynchronous scsi scan 27 + * to finish. 28 + */ 18 29 scsi_complete_async_scans(); 19 30 return 0; 20 31 }
+1
include/linux/device.h
··· 551 551 extern struct device *get_device(struct device *dev); 552 552 extern void put_device(struct device *dev); 553 553 554 + extern void wait_for_device_probe(void); 554 555 555 556 /* drivers/base/power/shutdown.c */ 556 557 extern void device_shutdown(void);