summaryrefslogtreecommitdiff
path: root/sys/dev/ata
diff options
context:
space:
mode:
authorthorpej <thorpej@NetBSD.org>2004-08-13 02:16:40 +0000
committerthorpej <thorpej@NetBSD.org>2004-08-13 02:16:40 +0000
commit577bf670148d9ce5050c8f3693503ed16c970c64 (patch)
tree15de64b79fae1e2906753d0e341d0acb57c79cf7 /sys/dev/ata
parent996c3ca90e2571624bdff8efdc29503573abb3eb (diff)
Move wdcstart() to ata.c and rename it to atastart().
Diffstat (limited to 'sys/dev/ata')
-rw-r--r--sys/dev/ata/ata.c67
-rw-r--r--sys/dev/ata/ata_wdc.c8
-rw-r--r--sys/dev/ata/atavar.h3
3 files changed, 69 insertions, 9 deletions
diff --git a/sys/dev/ata/ata.c b/sys/dev/ata/ata.c
index d480f654c15..381ac7666dd 100644
--- a/sys/dev/ata/ata.c
+++ b/sys/dev/ata/ata.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ata.c,v 1.44 2004/08/13 02:10:43 thorpej Exp $ */
+/* $NetBSD: ata.c,v 1.45 2004/08/13 02:16:40 thorpej Exp $ */
/*
* Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.44 2004/08/13 02:10:43 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.45 2004/08/13 02:16:40 thorpej Exp $");
#ifndef WDCDEBUG
#define WDCDEBUG
@@ -516,9 +516,68 @@ ata_exec_xfer(struct wdc_channel *chp, struct ata_xfer *xfer)
/* insert at the end of command list */
TAILQ_INSERT_TAIL(&chp->ch_queue->queue_xfer, xfer, c_xferchain);
- WDCDEBUG_PRINT(("wdcstart from ata_exec_xfer, flags 0x%x\n",
+ WDCDEBUG_PRINT(("atastart from ata_exec_xfer, flags 0x%x\n",
chp->ch_flags), DEBUG_XFERS);
- wdcstart(chp);
+ atastart(chp);
+}
+
+/*
+ * Start I/O on a controller, for the given channel.
+ * The first xfer may be not for our channel if the channel queues
+ * are shared.
+ */
+void
+atastart(struct wdc_channel *chp)
+{
+ struct wdc_softc *wdc = chp->ch_wdc;
+ struct ata_xfer *xfer;
+
+#ifdef WDC_DIAGNOSTIC
+ int spl1, spl2;
+
+ spl1 = splbio();
+ spl2 = splbio();
+ if (spl2 != spl1) {
+ printf("atastart: not at splbio()\n");
+ panic("atastart");
+ }
+ splx(spl2);
+ splx(spl1);
+#endif /* WDC_DIAGNOSTIC */
+
+ /* is there a xfer ? */
+ if ((xfer = TAILQ_FIRST(&chp->ch_queue->queue_xfer)) == NULL)
+ return;
+
+ /* adjust chp, in case we have a shared queue */
+ chp = xfer->c_chp;
+
+ if (chp->ch_queue->active_xfer != NULL) {
+ return; /* channel aleady active */
+ }
+ if (__predict_false(chp->ch_queue->queue_freeze > 0)) {
+ return; /* queue froozen */
+ }
+#ifdef DIAGNOSTIC
+ if ((chp->ch_flags & WDCF_IRQ_WAIT) != 0)
+ panic("atastart: channel waiting for irq");
+#endif
+ if (wdc->cap & WDC_CAPABILITY_HWLOCK)
+ if (!(*wdc->claim_hw)(chp, 0))
+ return;
+
+ WDCDEBUG_PRINT(("atastart: xfer %p channel %d drive %d\n", xfer,
+ chp->ch_channel, xfer->c_drive), DEBUG_XFERS);
+ if (chp->ch_drive[xfer->c_drive].drive_flags & DRIVE_RESET) {
+ chp->ch_drive[xfer->c_drive].drive_flags &= ~DRIVE_RESET;
+ chp->ch_drive[xfer->c_drive].state = 0;
+ }
+ chp->ch_queue->active_xfer = xfer;
+ TAILQ_REMOVE(&chp->ch_queue->queue_xfer, xfer, c_xferchain);
+
+ if (wdc->cap & WDC_CAPABILITY_NOIRQ)
+ KASSERT(xfer->c_flags & C_POLL);
+ xfer->c_start(chp, xfer);
}
struct ata_xfer *
diff --git a/sys/dev/ata/ata_wdc.c b/sys/dev/ata/ata_wdc.c
index 53f08e9b9a3..e3142223fc2 100644
--- a/sys/dev/ata/ata_wdc.c
+++ b/sys/dev/ata/ata_wdc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ata_wdc.c,v 1.68 2004/08/13 02:10:43 thorpej Exp $ */
+/* $NetBSD: ata_wdc.c,v 1.69 2004/08/13 02:16:40 thorpej Exp $ */
/*
* Copyright (c) 1998, 2001, 2003 Manuel Bouyer.
@@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.68 2004/08/13 02:10:43 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.69 2004/08/13 02:16:40 thorpej Exp $");
#ifndef WDCDEBUG
#define WDCDEBUG
@@ -733,9 +733,9 @@ wdc_ata_bio_done(struct wdc_channel *chp, struct ata_xfer *xfer)
ata_bio->flags |= ATA_ITSDONE;
WDCDEBUG_PRINT(("wdc_ata_done: drv_done\n"), DEBUG_XFERS);
(*chp->ch_drive[drive].drv_done)(chp->ch_drive[drive].drv_softc);
- WDCDEBUG_PRINT(("wdcstart from wdc_ata_done, flags 0x%x\n",
+ WDCDEBUG_PRINT(("atastart from wdc_ata_done, flags 0x%x\n",
chp->ch_flags), DEBUG_XFERS);
- wdcstart(chp);
+ atastart(chp);
}
static int
diff --git a/sys/dev/ata/atavar.h b/sys/dev/ata/atavar.h
index e7e3abec39d..7aa2dbcdb19 100644
--- a/sys/dev/ata/atavar.h
+++ b/sys/dev/ata/atavar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: atavar.h,v 1.57 2004/08/13 02:10:43 thorpej Exp $ */
+/* $NetBSD: atavar.h,v 1.58 2004/08/13 02:16:40 thorpej Exp $ */
/*
* Copyright (c) 1998, 2001 Manuel Bouyer.
@@ -318,6 +318,7 @@ void ata_kill_pending(struct ata_drive_datas *);
int ata_addref(struct wdc_channel *);
void ata_delref(struct wdc_channel *);
+void atastart(struct wdc_channel *);
void ata_print_modes(struct wdc_channel *);
int ata_downgrade_mode(struct ata_drive_datas *, int);
void ata_probe_caps(struct ata_drive_datas *);