linux-ide.vger.kernel.org archive mirror
 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>,
	torvalds@linux-foundation.org, mingo@elte.hu, fweisbec@gmail.com,
	linux-scsi@vger.kernel.org, linux-ide@vger.kernel.org,
	linux-acpi@vger.kernel.org, akpm@linux-foundation.org
Subject: [PATCH 3/4] fastboot: make the libata port scan asynchronous
Date: Sun, 4 Jan 2009 09:30:26 -0800	[thread overview]
Message-ID: <20090104093026.34d016eb@infradead.org> (raw)
In-Reply-To: <20090104092430.7ffd2c41@infradead.org>


>From 2eb80a6c7b7c33a9053cfd286169d5163027f0cd Mon Sep 17 00:00:00 2001
From: Arjan van de Ven <arjan@linux.intel.com>
Date: Sun, 4 Jan 2009 05:32:28 -0800
Subject: [PATCH] fastboot: make the libata port scan asynchronous

This patch makes the libata port scanning asynchronous (per device).
There is a synchronization point before doing the actual disk scan
so that device ordering is not affected.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
---
 drivers/ata/libata-core.c |   84 ++++++++++++++++++++++++--------------------
 1 files changed, 46 insertions(+), 38 deletions(-)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index fecca42..fe2c208 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -56,6 +56,7 @@
 #include <linux/workqueue.h>
 #include <linux/scatterlist.h>
 #include <linux/io.h>
+#include <linux/async.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_host.h>
@@ -5909,6 +5910,48 @@ void ata_host_init(struct ata_host *host, struct device *dev,
 	host->ops = ops;
 }
 
+
+void async_port_probe(void *data, async_cookie_t cookie)
+{
+	int rc;
+	struct ata_port *ap = data;
+	/* probe */
+	if (ap->ops->error_handler) {
+		struct ata_eh_info *ehi = &ap->link.eh_info;
+		unsigned long flags;
+
+		ata_port_probe(ap);
+
+		/* kick EH for boot probing */
+		spin_lock_irqsave(ap->lock, flags);
+
+		ehi->probe_mask |= ATA_ALL_DEVICES;
+		ehi->action |= ATA_EH_RESET | ATA_EH_LPM;
+		ehi->flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET;
+
+		ap->pflags &= ~ATA_PFLAG_INITIALIZING;
+		ap->pflags |= ATA_PFLAG_LOADING;
+		ata_port_schedule_eh(ap);
+
+		spin_unlock_irqrestore(ap->lock, flags);
+
+		/* wait for EH to finish */
+		ata_port_wait_eh(ap);
+	} else {
+		DPRINTK("ata%u: bus probe begin\n", ap->print_id);
+		rc = ata_bus_probe(ap);
+		DPRINTK("ata%u: bus probe end\n", ap->print_id);
+
+		if (rc) {
+			/* FIXME: do something useful here?
+			 * Current libata behavior will
+			 * tear down everything when
+			 * the module is removed
+			 * or the h/w is unplugged.
+			 */
+		}
+	}
+}
 /**
  *	ata_host_register - register initialized ATA host
  *	@host: ATA host to register
@@ -5988,45 +6031,9 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
 	DPRINTK("probe begin\n");
 	for (i = 0; i < host->n_ports; i++) {
 		struct ata_port *ap = host->ports[i];
-
-		/* probe */
-		if (ap->ops->error_handler) {
-			struct ata_eh_info *ehi = &ap->link.eh_info;
-			unsigned long flags;
-
-			ata_port_probe(ap);
-
-			/* kick EH for boot probing */
-			spin_lock_irqsave(ap->lock, flags);
-
-			ehi->probe_mask |= ATA_ALL_DEVICES;
-			ehi->action |= ATA_EH_RESET | ATA_EH_LPM;
-			ehi->flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET;
-
-			ap->pflags &= ~ATA_PFLAG_INITIALIZING;
-			ap->pflags |= ATA_PFLAG_LOADING;
-			ata_port_schedule_eh(ap);
-
-			spin_unlock_irqrestore(ap->lock, flags);
-
-			/* wait for EH to finish */
-			ata_port_wait_eh(ap);
-		} else {
-			DPRINTK("ata%u: bus probe begin\n", ap->print_id);
-			rc = ata_bus_probe(ap);
-			DPRINTK("ata%u: bus probe end\n", ap->print_id);
-
-			if (rc) {
-				/* FIXME: do something useful here?
-				 * Current libata behavior will
-				 * tear down everything when
-				 * the module is removed
-				 * or the h/w is unplugged.
-				 */
-			}
-		}
+		async_schedule(async_port_probe, ap);
 	}
-
+	async_synchronize_full();
 	/* probes are done, now scan each port's disk(s) */
 	DPRINTK("host probe begin\n");
 	for (i = 0; i < host->n_ports; i++) {
@@ -6034,6 +6041,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
 
 		ata_scsi_scan_host(ap, 1);
 	}
+	DPRINTK("host probe end\n");
 
 	return 0;
 }
-- 
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

  parent reply	other threads:[~2009-01-04 17:30 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-04 17:24 [PATCH 0/4] Fastboot revisited: Asynchronous function calls Arjan van de Ven
2009-01-04 17:28 ` [PATCH 1/4] fastboot: Asynchronous function calls to speed up kernel boot Arjan van de Ven
2009-01-04 18:33   ` Linus Torvalds
2009-01-04 18:40     ` Arjan van de Ven
2009-01-04 18:49     ` Arjan van de Ven
2009-01-04 19:05   ` Andi Kleen
2009-01-04 19:09     ` Arjan van de Ven
2009-01-04 19:49       ` Andi Kleen
2009-01-04 19:52         ` Andrew Morton
2009-01-04 17:29 ` [PATCH 2/4] fastboot: make scsi probes asynchronous Arjan van de Ven
2009-01-04 18:05   ` Matthew Wilcox
2009-01-04 18:13     ` Arjan van de Ven
2009-01-04 18:38       ` Jaswinder Singh Rajput
2009-01-04 18:44         ` Arjan van de Ven
2009-01-04 17:30 ` Arjan van de Ven [this message]
2009-01-04 17:31 ` [PATCH 4/4] fastboot: make ACPI bus drivers probe asynchronous Arjan van de Ven
2009-01-05  2:03   ` Zhao Yakui
2009-01-05  1:58     ` Arjan van de Ven
2009-01-05  2:51       ` Zhao Yakui
2009-01-05  2:51         ` Arjan van de Ven
2009-01-05  5:30           ` Zhao Yakui
2009-01-04 18:16 ` [PATCH 0/4] Fastboot revisited: Asynchronous function calls Linus Torvalds
2009-01-04 18:31   ` Arjan van de Ven
2009-01-04 18:54     ` Linus Torvalds
2009-01-04 19:05       ` Arjan van de Ven
2009-01-04 19:11         ` Linus Torvalds
2009-01-04 19:19           ` Arjan van de Ven
2009-01-05 16:21         ` Alan Cox
2009-01-05 21:13           ` Arjan van de Ven
2009-01-05 21:21             ` Linus Torvalds
2009-01-04 19:11       ` Andi Kleen
2009-01-04 19:46         ` Robert Hancock
2009-01-04 19:27   ` Linus Torvalds
2009-01-04 19:48     ` Arjan van de Ven
2009-01-04 21:44   ` Alan Cox
2009-01-11 13:14   ` Pavel Machek
2009-01-05  6:01 ` Nigel Cunningham
2009-01-05  8:47   ` Frederic Weisbecker
2009-01-05 10:53   ` Arjan van de Ven
2009-01-05 11:18     ` Nigel Cunningham
2009-01-07  2:41     ` Shaohua Li

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=20090104093026.34d016eb@infradead.org \
    --to=arjan@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=fweisbec@gmail.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).