Skip to contentSkip to conversation

driver core: remove polling for driver_probe_done(v3)

PATCH/RESEND [email protected] 2 participants 2 messages Feb 17, 2009 – Feb 19, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

From: Ming Lei <[email protected]>

This patch adds a function : driver_wait_probe_done, which waits on condition of probing done to replace polling for driver_probe_done in fs initialization.

There is no better way to avoid polling for driver_probe_done _and_ existence of the root device, so we does not replace the driver_probe_done with driver_wait_probe_done in such special case.

Removing polling in fs initialization may lead to a faster boot.

---
 drivers/base/dd.c      |   12 ++++++++++++
 include/linux/device.h |    1 +
 init/do_mounts.c       |    4 ++--
 init/do_mounts_md.c    |    3 +--
 4 files changed, 16 insertions(+), 4 deletions(-)
drivers/base/dd.c +12 -0
index 9b721d3..8f9f6fb 100644
@@ -168,6 +168,18 @@ int driver_probe_done(void)
 }
 
 /**
+ * driver_wait_probe_done
+ * Wait until the probe sequence is finished.
+ *
+ */
+void driver_wait_probe_done(void)
+{
+	pr_debug("%s: probe_count = %d\n", __func__,
+		 atomic_read(&probe_count));
+	wait_event(probe_waitqueue, atomic_read(&probe_count) == 0);
+}
+
+/**
  * driver_probe_device - attempt to bind device & driver together
  * @drv: driver to bind a device to
  * @dev: device to try to bind to the driver
include/linux/device.h +1 -0
index 45e5b19..c53cdbf 100644
@@ -147,6 +147,7 @@ extern void put_driver(struct device_driver *drv);
 extern struct device_driver *driver_find(const char *name,
 					 struct bus_type *bus);
 extern int driver_probe_done(void);
+extern void driver_wait_probe_done(void);
 
 /* sysfs interface for exporting driver attributes */
 
init/do_mounts.c +2 -2
index 708105e..9cb1985 100644
@@ -371,8 +371,8 @@ void __init prepare_namespace(void)
 	}
 
 	/* wait for the known devices to complete their probing */
-	while (driver_probe_done() != 0)
-		msleep(100);
+	driver_wait_probe_done();
+
 	async_synchronize_full();
 
 	md_run_setup();
init/do_mounts_md.c +1 -2
index ff95e31..63b77f0 100644
@@ -281,8 +281,7 @@ static void __init autodetect_raid(void)
 	 */
 	printk(KERN_INFO "md: Waiting for all devices to be available before autodetect\n");
 	printk(KERN_INFO "md: If you don't use raid, use raid=noautodetect\n");
-	while (driver_probe_done() < 0)
-		msleep(100);
+	driver_wait_probe_done();
 	fd = sys_open("/dev/md0", 0, 0);
 	if (fd >= 0) {
 		sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
Signature · 1 line
1.6.0
#1 lore raw

This conflicts with a patch from Arjan in this same area that I've now applied to my tree (used to be in the -mm tree).

Care to rebase it on the next linux-next release?

thanks,

greg k-h

Quoted 90 lines · On Tue, Feb 17, 2009 at 10:54:04PM +0800, [email protected] wrote:

From: Ming Lei <[email protected]>

This patch adds a function : driver_wait_probe_done, which waits on condition of probing done to replace polling for driver_probe_done in fs initialization.

There is no better way to avoid polling for driver_probe_done _and_ existence of the root device, so we does not replace the driver_probe_done with driver_wait_probe_done in such special case.

Removing polling in fs initialization may lead to a faster boot.

---
 drivers/base/dd.c      |   12 ++++++++++++
 include/linux/device.h |    1 +
 init/do_mounts.c       |    4 ++--
 init/do_mounts_md.c    |    3 +--
 4 files changed, 16 insertions(+), 4 deletions(-)
drivers/base/dd.c +12 -0
index 9b721d3..8f9f6fb 100644
@@ -168,6 +168,18 @@ int driver_probe_done(void)
 }
 
 /**
+ * driver_wait_probe_done
+ * Wait until the probe sequence is finished.
+ *
+ */
+void driver_wait_probe_done(void)
+{
+	pr_debug("%s: probe_count = %d\n", __func__,
+		 atomic_read(&probe_count));
+	wait_event(probe_waitqueue, atomic_read(&probe_count) == 0);
+}
+
+/**
  * driver_probe_device - attempt to bind device & driver together
  * @drv: driver to bind a device to
  * @dev: device to try to bind to the driver
include/linux/device.h +1 -0
index 45e5b19..c53cdbf 100644
@@ -147,6 +147,7 @@ extern void put_driver(struct device_driver *drv);
 extern struct device_driver *driver_find(const char *name,
 					 struct bus_type *bus);
 extern int driver_probe_done(void);
+extern void driver_wait_probe_done(void);
 
 /* sysfs interface for exporting driver attributes */
 
init/do_mounts.c +2 -2
index 708105e..9cb1985 100644
@@ -371,8 +371,8 @@ void __init prepare_namespace(void)
 	}
 
 	/* wait for the known devices to complete their probing */
-	while (driver_probe_done() != 0)
-		msleep(100);
+	driver_wait_probe_done();
+
 	async_synchronize_full();
 
 	md_run_setup();
init/do_mounts_md.c +1 -2
index ff95e31..63b77f0 100644
@@ -281,8 +281,7 @@ static void __init autodetect_raid(void)
 	 */
 	printk(KERN_INFO "md: Waiting for all devices to be available before autodetect\n");
 	printk(KERN_INFO "md: If you don't use raid, use raid=noautodetect\n");
-	while (driver_probe_done() < 0)
-		msleep(100);
+	driver_wait_probe_done();
 	fd = sys_open("/dev/md0", 0, 0);
 	if (fd >= 0) {
 		sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
Signature · 1 line
1.6.0