public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Len Brown <lenb@kernel.org>
Cc: Arjan van de Ven <arjan@linux.intel.com>,
	pm list <linux-pm@lists.linux-foundation.org>,
	Greg KH <gregkh@suse.de>, LKML <linux-kernel@vger.kernel.org>,
	Arve@smtp1.linux-foundation.org,
	Alan Jenkins <alan-jenkins@tuffmail.co.uk>,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Andrey Borzenkov <arvidjaar@mail.ru>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Ingo Molnar <mingo@elte.hu>,
	Masami Hiramatsu <mhiramat@redhat.com>
Subject: [PATCH 1/9] Consolidate driver_probe_done() loops into one place
Date: Sat, 14 Feb 2009 01:59:06 +0100	[thread overview]
Message-ID: <200902140159.08252.rjw@sisk.pl> (raw)
In-Reply-To: <200902140157.40869.rjw@sisk.pl>

From: Arjan van de Ven <arjan@linux.intel.com>

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.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/base/dd.c      |   17 +++++++++++++++++
 include/linux/device.h |    2 ++
 init/do_mounts.c       |   13 +++++++++----
 init/do_mounts_md.c    |    5 +++--
 4 files changed, 31 insertions(+), 6 deletions(-)

Index: linux-2.6/drivers/base/dd.c
===================================================================
--- linux-2.6.orig/drivers/base/dd.c
+++ linux-2.6/drivers/base/dd.c
@@ -18,9 +18,11 @@
  */
 
 #include <linux/device.h>
+#include <linux/delay.h>
 #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 +170,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
Index: linux-2.6/include/linux/device.h
===================================================================
--- linux-2.6.orig/include/linux/device.h
+++ linux-2.6/include/linux/device.h
@@ -147,6 +147,8 @@ extern void put_driver(struct device_dri
 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 */
 
Index: linux-2.6/init/do_mounts.c
===================================================================
--- linux-2.6.orig/init/do_mounts.c
+++ linux-2.6/init/do_mounts.c
@@ -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;
Index: linux-2.6/init/do_mounts_md.c
===================================================================
--- linux-2.6.orig/init/do_mounts_md.c
+++ linux-2.6/init/do_mounts_md.c
@@ -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);

  reply	other threads:[~2009-02-14  0:59 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-14  0:57 [PATCH 0/9] PM: Fixes related to suspend and hibernation for 2.6.29 Rafael J. Wysocki
2009-02-14  0:59 ` Rafael J. Wysocki [this message]
2009-02-14  1:47   ` [PATCH 1/9] Consolidate driver_probe_done() loops into one place Greg KH
2009-02-22  5:29   ` Raja R Harinath
2009-02-14  1:00 ` [PATCH 2/9] PM/resume: wait for device probing to finish Rafael J. Wysocki
2009-02-14  1:01 ` [PATCH 3/9] PM/hibernate: fix "swap breaks after hibernation failures" Rafael J. Wysocki
2009-02-14  1:02 ` [PATCH 4/9] PM: fix build for CONFIG_PM unset Rafael J. Wysocki
2009-02-14  1:03 ` [PATCH 5/9] swsusp: dont fiddle with swappiness Rafael J. Wysocki
2009-02-14  1:04 ` [PATCH 6/9] swsusp: clean up shrink_all_zones() Rafael J. Wysocki
2009-02-14  1:05 ` [PATCH 7/9] PM: Fix pm_notifiers during user mode hibernation Rafael J. Wysocki
2009-02-14  1:06 ` [PATCH 8/9] PM: Wait for console in resume Rafael J. Wysocki
2009-02-14  1:07 ` [PATCH 9/9] PM: Fix suspend_console and resume_console to use only one semaphore Rafael J. Wysocki
     [not found] ` <200902140200.21022.rjw@sisk.pl>
2009-02-14  1:48   ` [PATCH 2/9] PM/resume: wait for device probing to finish Greg KH
2009-02-21  4:41 ` [PATCH 0/9] PM: Fixes related to suspend and hibernation for 2.6.29 Len Brown
     [not found] ` <alpine.LFD.2.00.0902202337040.19156@localhost.localdomain>
2009-02-21  9:38   ` Rafael J. Wysocki
     [not found]   ` <200902211038.42169.rjw@sisk.pl>
2009-02-21 18:29     ` Greg KH
     [not found]     ` <20090221182902.GB12472@suse.de>
2009-02-21 19:32       ` Arjan van de Ven
     [not found]       ` <49A056D5.5090909@linux.intel.com>
2009-02-21 19:48         ` Greg KH
     [not found]         ` <20090221194807.GA13114@suse.de>
2009-02-21 22:18           ` Linus Torvalds
2009-02-22  2:47             ` Len Brown
2009-02-22 10:07             ` Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200902140159.08252.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=Arve@smtp1.linux-foundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=alan-jenkins@tuffmail.co.uk \
    --cc=arjan@linux.intel.com \
    --cc=arvidjaar@mail.ru \
    --cc=gregkh@suse.de \
    --cc=hannes@cmpxchg.org \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=lenb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=mhiramat@redhat.com \
    --cc=mingo@elte.hu \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox