Skip to contentSkip to conversation

consolidate driver_probe_done() loops into one place

PATCH Applied Arjan van de Ven 4 participants 9 messages Jan 10, 2009 – Jan 27, 2009

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

PATCH 1/2 consolidate driver_probe_done() loops into one place

Quoted 1 line

From 11b47973023398ecdb933c442bab120906946762 Mon Sep 17 00:00:00 2001

From: Arjan van de Ven <[email protected]>
Date: Fri, 9 Jan 2009 21:04:53 -0800
Subject: [PATCH] consolidate driver_probe_done() loops into one place

there's a few places that currently loop over driver_probe_done(), and I'm about to add another one. This patch abstracts it into a helper to reduce duplication.

---
 drivers/base/dd.c      |   16 ++++++++++++++++
 include/linux/device.h |    2 ++
 init/do_mounts.c       |   13 +++++++++----
 init/do_mounts_md.c    |    5 +++--
 4 files changed, 30 insertions(+), 6 deletions(-)
drivers/base/dd.c +16 -0
index 315bed8..b911fab 100644
@@ -21,6 +21,7 @@
 #include <linux/module.h>
 #include <linux/kthread.h>
 #include <linux/wait.h>
+#include <linux/async.h>
 
 #include "base.h"
 #include "power/power.h"
@@ -168,6 +169,21 @@ int driver_probe_done(void)
 }
 
 /**
+ * wait_for_device_probe
+ * Wait for device probing to be completed.
+ *
+ * Note: this function polls at 100 msec intervals.
+ */
+int wait_for_device_probe(void)
+{
+	/* wait for the known devices to complete their probing */
+	while (driver_probe_done() != 0)
+		msleep(100);
+	async_synchronize_full();
+	return 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 +2 -0
index 45e5b19..47f343c 100644
@@ -147,6 +147,8 @@ 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 int wait_for_device_probe(void);
+
 
 /* sysfs interface for exporting driver attributes */
 
init/do_mounts.c +9 -4
index 708105e..2c80113 100644
@@ -370,10 +370,14 @@ void __init prepare_namespace(void)
 		ssleep(root_delay);
 	}
 
-	/* wait for the known devices to complete their probing */
-	while (driver_probe_done() != 0)
-		msleep(100);
-	async_synchronize_full();
+	/* 
+	 * wait for the known devices to complete their probing 
+	 *
+	 * Note: this is a potential source of long boot delays.
+	 * For example, it is not atypical to wait 5 seconds here
+	 * for the touchpad of a laptop to initialize.
+	 */
+	wait_for_device_probe();
 
 	md_run_setup();
 
@@ -399,6 +403,7 @@ void __init prepare_namespace(void)
 		while (driver_probe_done() != 0 ||
 			(ROOT_DEV = name_to_dev_t(saved_root_name)) == 0)
 			msleep(100);
+		async_synchronize_full();
 	}
 
 	is_floppy = MAJOR(ROOT_DEV) == FLOPPY_MAJOR;
init/do_mounts_md.c +3 -2
index ff95e31..9bdddbc 100644
@@ -281,8 +281,9 @@ 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);
+
+	wait_for_device_probe();
+
 	fd = sys_open("/dev/md0", 0, 0);
 	if (fd >= 0) {
 		sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
Signature · 8 lines
1.6.0.6



-- 
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#1 lore raw

PATCH 2/2 resume: wait for device probing to finish

(this patch needs testing on a few different machines; compile tested only)

Quoted 1 line

From 10b3e25671c817933e232498a56640fd48964345 Mon Sep 17 00:00:00 2001

From: Arjan van de Ven <[email protected]>
Date: Fri, 9 Jan 2009 21:11:23 -0800
Subject: [PATCH] resume: wait for device probing to finish

the resume code does not currently wait for device probing to finish. Even without async function calls this is dicey and not correct, but with async function calls during the boot sequence this is going to get hit more...

This patch adds the synchronization using the newly introduced helper.

---
 kernel/power/disk.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
kernel/power/disk.c +11 -0
index 45e8541..d2d24b7 100644
@@ -585,6 +585,12 @@ static int software_resume(void)
 	unsigned int flags;
 
 	/*
+	 * If the user said "noresume".. bail out early.
+	 */
+	if (noresume)
+		return 0;
+
+	/*
 	 * name_to_dev_t() below takes a sysfs buffer mutex when sysfs
 	 * is configured into the kernel. Since the regular hibernate
 	 * trigger path is via sysfs which takes a buffer mutex before
@@ -600,6 +606,11 @@ static int software_resume(void)
 			mutex_unlock(&pm_mutex);
 			return -ENOENT;
 		}
+		/*
+		 * Some device discovery might still be in progress; we need
+		 * to wait for this to finish.
+		 */
+		wait_for_device_probe();
 		swsusp_resume_device = name_to_dev_t(resume_file);
 		pr_debug("PM: Resume from partition %s\n", resume_file);
 	} else {
Signature · 8 lines
1.6.0.6



-- 
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#2 lore raw

Re: [PATCH 2/2] resume: wait for device probing to finish

Quoted 8 lines · Arjan van de Ven

(this patch needs testing on a few different machines; compile tested only)

From 10b3e25671c817933e232498a56640fd48964345 Mon Sep 17 00:00:00 2001
From: Arjan van de Ven <[email protected]>
Date: Fri, 9 Jan 2009 21:11:23 -0800
Subject: [PATCH] resume: wait for device probing to finish

Quoted 8 lines

the resume code does not currently wait for device probing to finish. Even without async function calls this is dicey and not correct, but with async function calls during the boot sequence this is going to get hit more...

This patch adds the synchronization using the newly introduced helper.

Sorry for the delay, but I only could do the testing today.

It appears that 2.6.29-rc1 with the two patches in this series applied resumes from hibernation correctly.

Please push the second one to Len with my ack.

Thanks,
Rafael

Quoted 35 lines
---
 kernel/power/disk.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
kernel/power/disk.c +11 -0
index 45e8541..d2d24b7 100644
@@ -585,6 +585,12 @@ static int software_resume(void)
 	unsigned int flags;
 
 	/*
+	 * If the user said "noresume".. bail out early.
+	 */
+	if (noresume)
+		return 0;
+
+	/*
 	 * name_to_dev_t() below takes a sysfs buffer mutex when sysfs
 	 * is configured into the kernel. Since the regular hibernate
 	 * trigger path is via sysfs which takes a buffer mutex before
@@ -600,6 +606,11 @@ static int software_resume(void)
 			mutex_unlock(&pm_mutex);
 			return -ENOENT;
 		}
+		/*
+		 * Some device discovery might still be in progress; we need
+		 * to wait for this to finish.
+		 */
+		wait_for_device_probe();
 		swsusp_resume_device = name_to_dev_t(resume_file);
 		pr_debug("PM: Resume from partition %s\n", resume_file);
 	} else {
Signature · 1 line
1.6.0.6
Acked-by Greg Kroah-Hartman on v1 1/2
#3 lore raw
In reply to Arjan van de Ven
Quoted 10 lines · Arjan van de Ven

From 11b47973023398ecdb933c442bab120906946762 Mon Sep 17 00:00:00 2001
From: Arjan van de Ven <[email protected]>
Date: Fri, 9 Jan 2009 21:04:53 -0800
Subject: [PATCH] consolidate driver_probe_done() loops into one place

there's a few places that currently loop over driver_probe_done(), and I'm about to add another one. This patch abstracts it into a helper to reduce duplication.

Do you need me to take this through my tree? Or is it going through the acpi tree?

thanks,

greg k-h

#4 lore raw
Quoted 10 lines · Greg KH
Quoted 9 lines · Arjan van de Ven

From 11b47973023398ecdb933c442bab120906946762 Mon Sep 17 00:00:00 2001
From: Arjan van de Ven <[email protected]>
Date: Fri, 9 Jan 2009 21:04:53 -0800
Subject: [PATCH] consolidate driver_probe_done() loops into one place

there's a few places that currently loop over driver_probe_done(), and I'm about to add another one. This patch abstracts it into a helper to reduce duplication.

Quoted 6 lines
Quoted 1 line

Do you need me to take this through my tree? Or is it going through the acpi tree?

I've lost the track.

Anyway, it's a part of a two-patch series and I think both are in -mm.

Andrew, do you have them?

Rafael

#5 lore raw
Quoted 15 lines · On Mon, 26 Jan 2009 17:48:05 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
Quoted 14 lines · Greg KH
Quoted 10 lines · Arjan van de Ven

From 11b47973023398ecdb933c442bab120906946762 Mon Sep 17 00:00:00 2001
From: Arjan van de Ven <[email protected]>
Date: Fri, 9 Jan 2009 21:04:53 -0800
Subject: [PATCH] consolidate driver_probe_done() loops into one place

there's a few places that currently loop over driver_probe_done(), and I'm about to add another one. This patch abstracts it into a helper to reduce duplication.

Quoted 9 lines
Quoted 2 lines

Do you need me to take this through my tree? Or is it going through the acpi tree?

I've lost the track.

Anyway, it's a part of a two-patch series and I think both are in -mm.

Andrew, do you have them?

I have these:

early-platform-drivers-v2.patch drivers-consolidate-driver_probe_done-loops-into-one-place.patch drivers-consolidate-driver_probe_done-loops-into-one-place-fix.patch drivers-consolidate-driver_probe_done-loops-into-one-place-checkpatch-fixes.patch resume-wait-for-device-probing-to-finish.patch sysfs-use-standard-magich-for-sysfs.patch

queued up for sending into Greg for his "driver core" tree.

#6 lore raw
Quoted 29 lines · Andrew Morton
Quoted 15 lines · On Mon, 26 Jan 2009 17:48:05 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
Quoted 14 lines · Greg KH
Quoted 10 lines · Arjan van de Ven

From 11b47973023398ecdb933c442bab120906946762 Mon Sep 17 00:00:00 2001
From: Arjan van de Ven <[email protected]>
Date: Fri, 9 Jan 2009 21:04:53 -0800
Subject: [PATCH] consolidate driver_probe_done() loops into one place

there's a few places that currently loop over driver_probe_done(), and I'm about to add another one. This patch abstracts it into a helper to reduce duplication.

Quoted 9 lines
Quoted 2 lines

Do you need me to take this through my tree? Or is it going through the acpi tree?

I've lost the track.

Anyway, it's a part of a two-patch series and I think both are in -mm.

Andrew, do you have them?

I have these:

Quoted 8 lines

early-platform-drivers-v2.patch drivers-consolidate-driver_probe_done-loops-into-one-place.patch drivers-consolidate-driver_probe_done-loops-into-one-place-fix.patch drivers-consolidate-driver_probe_done-loops-into-one-place-checkpatch-fixes.patch resume-wait-for-device-probing-to-finish.patch sysfs-use-standard-magich-for-sysfs.patch

queued up for sending into Greg for his "driver core" tree.

Thanks!

Greg, I assume you're going to get them from Andrew shortly. 2-4 definitely are .29 material (they fix a regression), the others two I don't know.

Rafael

#7 lore raw
Quoted 37 lines · Rafael J. Wysocki
Quoted 36 lines · Andrew Morton
Quoted 15 lines · On Mon, 26 Jan 2009 17:48:05 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
Quoted 14 lines · Greg KH
Quoted 10 lines · Arjan van de Ven

From 11b47973023398ecdb933c442bab120906946762 Mon Sep 17 00:00:00 2001
From: Arjan van de Ven <[email protected]>
Date: Fri, 9 Jan 2009 21:04:53 -0800
Subject: [PATCH] consolidate driver_probe_done() loops into one place

there's a few places that currently loop over driver_probe_done(), and I'm about to add another one. This patch abstracts it into a helper to reduce duplication.

Quoted 9 lines
Quoted 2 lines

Do you need me to take this through my tree? Or is it going through the acpi tree?

I've lost the track.

Anyway, it's a part of a two-patch series and I think both are in -mm.

Andrew, do you have them?

I have these:

early-platform-drivers-v2.patch drivers-consolidate-driver_probe_done-loops-into-one-place.patch drivers-consolidate-driver_probe_done-loops-into-one-place-fix.patch drivers-consolidate-driver_probe_done-loops-into-one-place-checkpatch-fixes.patch resume-wait-for-device-probing-to-finish.patch sysfs-use-standard-magich-for-sysfs.patch

Quoted 6 lines
Quoted 1 line

queued up for sending into Greg for his "driver core" tree.

Thanks!

Greg, I assume you're going to get them from Andrew shortly. 2-4 definitely are .29 material (they fix a regression), the others two I don't know.

They are? I didn't realize this, sorry. What regression do they solve?

thanks,

greg k-h

#8 lore raw
Quoted 38 lines · Greg KH
Quoted 37 lines · Rafael J. Wysocki
Quoted 36 lines · Andrew Morton
Quoted 15 lines · On Mon, 26 Jan 2009 17:48:05 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
Quoted 14 lines · Greg KH
Quoted 10 lines · Arjan van de Ven

From 11b47973023398ecdb933c442bab120906946762 Mon Sep 17 00:00:00 2001
From: Arjan van de Ven <[email protected]>
Date: Fri, 9 Jan 2009 21:04:53 -0800
Subject: [PATCH] consolidate driver_probe_done() loops into one place

there's a few places that currently loop over driver_probe_done(), and I'm about to add another one. This patch abstracts it into a helper to reduce duplication.

Quoted 9 lines
Quoted 2 lines

Do you need me to take this through my tree? Or is it going through the acpi tree?

I've lost the track.

Anyway, it's a part of a two-patch series and I think both are in -mm.

Andrew, do you have them?

I have these:

early-platform-drivers-v2.patch drivers-consolidate-driver_probe_done-loops-into-one-place.patch drivers-consolidate-driver_probe_done-loops-into-one-place-fix.patch drivers-consolidate-driver_probe_done-loops-into-one-place-checkpatch-fixes.patch resume-wait-for-device-probing-to-finish.patch sysfs-use-standard-magich-for-sysfs.patch

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

queued up for sending into Greg for his "driver core" tree.

Thanks!

Greg, I assume you're going to get them from Andrew shortly. 2-4 definitely are .29 material (they fix a regression), the others two I don't know.

They are? I didn't realize this, sorry. What regression do they solve?

Resume from hibernation is broken after the async stuff from Arjan has been merged. In fact this is due to a long-standing bug, but the async code has just made it show up.

Thanks,
Rafael