public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arjan van de Ven <arjan@infradead.org>
To: linux-kernel@vger.kernel.org
Cc: Arjan van de Ven <arjan@infradead.org>,
	mingo@elte.hu, Rene Herman <rene.herman@keyaccess.nl>,
	Simon Arlott <simon@fire.lp0.eu>,
	Alan Stern <stern@rowland.harvard.edu>,
	Daniel Walker <dwalker@mvista.com>
Subject: [patch 5/3] fastboot: sync the async execution before late_initcall and move level 6s (sync) first
Date: Sun, 20 Jul 2008 09:00:41 -0700	[thread overview]
Message-ID: <20080720090041.5924f5ff@infradead.org> (raw)
In-Reply-To: <20080720085924.122feb2b@infradead.org>

From: Arjan van de Ven <arjan@linux.intel.com>
Subject: [PATCH] fastboot: sync the async execution before late_initcall and move level 6s (sync) first

Rene Herman points out several cases where it's basically needed to have all
level 6/6a/6s calls done before the level 7 (late_initcall) code runs. This patch
adds a sync point in the transition from the 6's to the 7's.

Second, this patch makes sure that level 6s (sync) happens before the async code starts,
and puts a user in driver/pci in this category that needs to happen before device init.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
---
 drivers/pci/pci.c                 |    2 +-
 include/asm-generic/vmlinux.lds.h |    3 ++-
 init/main.c                       |    8 +++++++-
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 44a46c9..d75295d 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1889,7 +1889,7 @@ static int __devinit pci_setup(char *str)
 }
 early_param("pci", pci_setup);
 
-device_initcall(pci_init);
+device_initcall_sync(pci_init);
 
 EXPORT_SYMBOL(pci_reenable_device);
 EXPORT_SYMBOL(pci_enable_device_io);
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 39c1afc..514dbdf 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -372,11 +372,12 @@
   	*(.initcall5.init)						\
   	*(.initcall5s.init)						\
 	*(.initcallrootfs.init)						\
+  	*(.initcall6s.init)						\
 	__async_initcall_start = .;					\
 	*(.initcall6a.init)						\
 	__async_initcall_end = .;					\
   	*(.initcall6.init)						\
-  	*(.initcall6s.init)						\
+	__device_initcall_end = .;					\
   	*(.initcall7.init)						\
   	*(.initcall7s.init)
 
diff --git a/init/main.c b/init/main.c
index dcb2c32..5c9e90e 100644
--- a/init/main.c
+++ b/init/main.c
@@ -741,6 +741,7 @@ int do_one_initcall(initcall_t fn)
 
 extern initcall_t __initcall_start[], __initcall_end[];
 extern initcall_t __async_initcall_start[], __async_initcall_end[];
+extern initcall_t __device_initcall_end[];
 
 static void __init do_async_initcalls(struct work_struct *dummy)
 {
@@ -764,7 +765,7 @@ static void __init do_initcalls(void)
 {
 	initcall_t *call;
 	static DECLARE_WORK(async_work, do_async_initcalls);
-	int phase = 0; /* 0 = levels 0 - 6, 1 = level 6a, 2 = after level 6a */
+	int phase = 0; /* 0 = levels 0 - 6, 1 = level 6a, 2 = after level 6a, 3 = after level 6 */
 
 	async_init_wq = create_singlethread_workqueue("kasyncinit");
 
@@ -775,6 +776,11 @@ static void __init do_initcalls(void)
 		}
 		if (phase == 1 && call >= __async_initcall_end)
 			phase = 2;
+		if (phase == 2 && call >= __device_initcall_end) {
+			phase = 3;
+			/* make sure all async work is done before level 7 */
+			flush_workqueue(async_init_wq);
+		}
 		if (phase != 1)
 			do_one_initcall(*call);
 	}
-- 
1.5.5.1


  reply	other threads:[~2008-07-20 16:00 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-20 15:59 [patch 4/3] fastboot: hold the BKL over the async init call sequence Arjan van de Ven
2008-07-20 16:00 ` Arjan van de Ven [this message]
2008-07-20 16:40   ` [patch 5/3] fastboot: sync the async execution before late_initcall and move level 6s (sync) first Ingo Molnar
2008-07-20 21:14   ` Daniel Walker
2008-07-20 21:23     ` Simon Arlott
2008-07-20 21:50     ` Arjan van de Ven
2008-07-29 21:00   ` Rene Herman
2008-07-29 21:04     ` Arjan van de Ven
2008-07-29 21:12       ` Rene Herman
2008-07-29 21:21         ` Arjan van de Ven
2008-07-29 22:30           ` Rene Herman
2008-07-29 22:34             ` Simon Arlott
2008-07-30 14:08               ` Alan Stern
2008-07-30 18:25                 ` Simon Arlott
2008-07-30 19:41                   ` Alan Stern
2008-07-31 11:49                     ` Simon Arlott
2008-07-31 15:34                       ` Alan Stern
2008-07-31 18:29                         ` Simon Arlott
2008-07-31 18:56                           ` Rene Herman
2008-07-31 19:27                             ` Simon Arlott
2008-07-31 19:16                           ` Alan Stern
2008-08-06 18:40                             ` [PATCH RFC] USB: Add HCD fastboot Simon Arlott
2008-08-06 19:11                               ` Alan Stern
2008-08-06 19:20                                 ` Simon Arlott
2008-08-06 19:29                                   ` Greg KH
2008-08-06 19:49                                   ` Alan Stern
2008-08-06 19:56                                     ` Arjan van de Ven
2008-08-06 20:09                                       ` Alan Stern
2008-08-06 20:17                                         ` Arjan van de Ven
2008-08-06 20:27                                           ` Alan Stern
2008-08-06 20:07                                     ` Simon Arlott
2008-08-06 20:26                                       ` Alan Stern
2008-08-06 21:49                                         ` Simon Arlott
2008-08-06 22:34                                           ` Alan Stern
2008-08-06 22:53                                             ` Simon Arlott
2008-08-07 14:14                                               ` Alan Stern
2008-08-07  3:29                                             ` David Brownell
2008-08-07  9:28                                           ` Emanoil Kotsev
2008-08-07 16:47                                             ` Alan Stern
2008-08-07  3:34                               ` David Brownell
2008-08-08  9:24                               ` Rene Herman
2008-08-08 11:29                                 ` Simon Arlott
2008-08-08 14:30                                   ` Rene Herman
2008-07-31 21:56                           ` [patch 5/3] fastboot: sync the async execution before late_initcall and move level 6s (sync) first Greg KH
2008-07-31 22:12                             ` Simon Arlott
2008-07-31 22:37                               ` Simon Arlott
2008-09-16 22:19                             ` Tim Bird

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=20080720090041.5924f5ff@infradead.org \
    --to=arjan@infradead.org \
    --cc=dwalker@mvista.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rene.herman@keyaccess.nl \
    --cc=simon@fire.lp0.eu \
    --cc=stern@rowland.harvard.edu \
    /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