summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorthorpej <thorpej@NetBSD.org>2004-08-20 23:26:53 +0000
committerthorpej <thorpej@NetBSD.org>2004-08-20 23:26:53 +0000
commite975b9caee6983271aaeb3b9bf08fde23ccbb2b8 (patch)
tree187499f2b4e5339591c5294c17d60250aaf634c7 /sys
parente09640d6eb1b1510ff2ff775c8a22625abc3dd33 (diff)
- Add an (*ata_reset_channel)() member to ata_bustype.
- Add an ata_reset_channel() function that performs the common parts of resetting an ATA channel, which uses the (*ata_reset_channel)() callback to do the heavy lifting. Adjust callers to use ata_reset_channel() instead of wdc_reset_channel(). This removes the last wdc-specific code from ata.c!
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/ata/ata.c58
-rw-r--r--sys/dev/ata/ata_wdc.c5
-rw-r--r--sys/dev/ata/atavar.h6
-rw-r--r--sys/dev/ic/wdc.c56
-rw-r--r--sys/dev/usb/umass_isdata.c17
5 files changed, 85 insertions, 57 deletions
diff --git a/sys/dev/ata/ata.c b/sys/dev/ata/ata.c
index f7d44ca67e2..e841fc18ae7 100644
--- a/sys/dev/ata/ata.c
+++ b/sys/dev/ata/ata.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ata.c,v 1.54 2004/08/20 22:26:23 thorpej Exp $ */
+/* $NetBSD: ata.c,v 1.55 2004/08/20 23:26:53 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.54 2004/08/20 22:26:23 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.55 2004/08/20 23:26:53 thorpej Exp $");
#ifndef ATADEBUG
#define ATADEBUG
@@ -54,7 +54,6 @@ __KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.54 2004/08/20 22:26:23 thorpej Exp $");
#include <dev/ata/atareg.h>
#include <dev/ata/atavar.h>
-#include <dev/ic/wdcvar.h>
#include "locators.h"
@@ -332,11 +331,11 @@ atabus_thread(void *arg)
s = splbio();
if (chp->ch_flags & ATACH_TH_RESET) {
/*
- * wdc_reset_channel() will freeze 2 times, so
+ * ata_reset_channel() will freeze 2 times, so
* unfreeze one time. Not a problem as we're at splbio
*/
chp->ch_queue->queue_freeze--;
- wdc_reset_channel(chp, AT_WAIT | chp->ch_reset_flags);
+ ata_reset_channel(chp, AT_WAIT | chp->ch_reset_flags);
} else if (chp->ch_queue->active_xfer != NULL &&
chp->ch_queue->queue_freeze == 1) {
/*
@@ -818,6 +817,51 @@ ata_kill_pending(struct ata_drive_datas *drvp)
splx(s);
}
+/*
+ * ata_reset_channel:
+ *
+ * Reset and ATA channel.
+ */
+void
+ata_reset_channel(struct ata_channel *chp, int flags)
+{
+ struct atac_softc *atac = chp->ch_atac;
+ int drive;
+
+ chp->ch_queue->queue_freeze++;
+
+ /*
+ * If we can poll or wait it's OK, otherwise wake up the
+ * kernel thread to do it for us.
+ */
+ if ((flags & (AT_POLL | AT_WAIT)) == 0) {
+ if (chp->ch_flags & ATACH_TH_RESET) {
+ /* No need to schedule a reset more than one time. */
+ return;
+ }
+ chp->ch_flags |= ATACH_TH_RESET;
+ chp->ch_reset_flags = flags & (AT_RST_EMERG | AT_RST_NOCMD);
+ wakeup(&chp->ch_thread);
+ return;
+ }
+
+ (*atac->atac_bustype_ata->ata_reset_channel)(chp, flags);
+
+ for (drive = 0; drive < chp->ch_ndrive; drive++)
+ chp->ch_drive[drive].state = 0;
+
+ chp->ch_flags &= ~ATACH_TH_RESET;
+ if ((flags & AT_RST_EMERG) == 0) {
+ chp->ch_queue->queue_freeze--;
+ atastart(chp);
+ } else {
+ /* make sure that we can use polled commands */
+ TAILQ_INIT(&chp->ch_queue->queue_xfer);
+ chp->ch_queue->queue_freeze = 0;
+ chp->ch_queue->active_xfer = NULL;
+ }
+}
+
int
ata_addref(struct ata_channel *chp)
{
@@ -929,7 +973,7 @@ ata_downgrade_mode(struct ata_drive_datas *drvp, int flags)
(*atac->atac_set_modes)(chp);
ata_print_modes(chp);
/* reset the channel, which will shedule all drives for setup */
- wdc_reset_channel(chp, flags | AT_RST_NOCMD);
+ ata_reset_channel(chp, flags | AT_RST_NOCMD);
return 1;
}
@@ -1219,7 +1263,7 @@ atabusioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
switch (cmd) {
case ATABUSIORESET:
s = splbio();
- wdc_reset_channel(sc->sc_chan, AT_WAIT | AT_POLL);
+ ata_reset_channel(sc->sc_chan, AT_WAIT | AT_POLL);
splx(s);
error = 0;
break;
diff --git a/sys/dev/ata/ata_wdc.c b/sys/dev/ata/ata_wdc.c
index 349a7c3ac1f..3d4000546a8 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.73 2004/08/20 06:39:38 thorpej Exp $ */
+/* $NetBSD: ata_wdc.c,v 1.74 2004/08/20 23:26:53 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.73 2004/08/20 06:39:38 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.74 2004/08/20 23:26:53 thorpej Exp $");
#ifndef ATADEBUG
#define ATADEBUG
@@ -133,6 +133,7 @@ const struct ata_bustype wdc_ata_bustype = {
SCSIPI_BUSTYPE_ATA,
wdc_ata_bio,
wdc_reset_drive,
+ wdc_reset_channel,
wdc_exec_command,
ata_get_params,
wdc_ata_addref,
diff --git a/sys/dev/ata/atavar.h b/sys/dev/ata/atavar.h
index 73789d617fa..cf91a565045 100644
--- a/sys/dev/ata/atavar.h
+++ b/sys/dev/ata/atavar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: atavar.h,v 1.63 2004/08/20 22:17:06 thorpej Exp $ */
+/* $NetBSD: atavar.h,v 1.64 2004/08/20 23:26:54 thorpej Exp $ */
/*
* Copyright (c) 1998, 2001 Manuel Bouyer.
@@ -271,7 +271,8 @@ struct ata_bustype {
int bustype_type; /* symbolic name of type */
int (*ata_bio)(struct ata_drive_datas *, struct ata_bio *);
void (*ata_reset_drive)(struct ata_drive_datas *, int);
-/* extra flags for ata_reset_drive(), in addition to AT_* */
+ void (*ata_reset_channel)(struct ata_channel *, int);
+/* extra flags for ata_reset_*(), in addition to AT_* */
#define AT_RST_EMERG 0x10000 /* emergency - e.g. for a dump */
#define AT_RST_NOCMD 0x20000 /* XXX has to go - temporary until we have tagged queuing */
@@ -425,6 +426,7 @@ void ata_free_xfer(struct ata_channel *, struct ata_xfer *);
void ata_exec_xfer(struct ata_channel *, struct ata_xfer *);
void ata_kill_pending(struct ata_drive_datas *);
+void ata_reset_channel(struct ata_channel *, int);
int ata_addref(struct ata_channel *);
void ata_delref(struct ata_channel *);
diff --git a/sys/dev/ic/wdc.c b/sys/dev/ic/wdc.c
index 2e75b4b2468..cb4151f68f8 100644
--- a/sys/dev/ic/wdc.c
+++ b/sys/dev/ic/wdc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: wdc.c,v 1.210 2004/08/20 22:17:06 thorpej Exp $ */
+/* $NetBSD: wdc.c,v 1.211 2004/08/20 23:26:54 thorpej Exp $ */
/*
* Copyright (c) 1998, 2001, 2003 Manuel Bouyer. All rights reserved.
@@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.210 2004/08/20 22:17:06 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.211 2004/08/20 23:26:54 thorpej Exp $");
#ifndef ATADEBUG
#define ATADEBUG
@@ -125,13 +125,14 @@ extern const struct ata_bustype wdc_ata_bustype; /* in ata_wdc.c */
/* A fake one, the autoconfig will print "wd at foo ... not configured */
const struct ata_bustype wdc_ata_bustype = {
SCSIPI_BUSTYPE_ATA,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL
+ NULL, /* wdc_ata_bio */
+ NULL, /* wdc_reset_drive */
+ NULL, /* wdc_reset_channel */
+ NULL, /* wdc_exec_command */
+ NULL, /* ata_get_params */
+ NULL, /* wdc_ata_addref */
+ NULL, /* wdc_ata_delref */
+ NULL /* ata_kill_pending */
};
#endif
@@ -793,12 +794,11 @@ wdc_reset_drive(struct ata_drive_datas *drvp, int flags)
struct ata_channel *chp = drvp->chnl_softc;
struct atac_softc *atac = chp->ch_atac;
- ATADEBUG_PRINT(("ata_reset_channel %s:%d for drive %d\n",
+ ATADEBUG_PRINT(("wdc_reset_drive %s:%d for drive %d\n",
atac->atac_dev.dv_xname, chp->ch_channel, drvp->drive),
DEBUG_FUNCS);
-
- wdc_reset_channel(chp, flags);
+ ata_reset_channel(chp, flags);
}
void
@@ -807,26 +807,11 @@ wdc_reset_channel(struct ata_channel *chp, int flags)
TAILQ_HEAD(, ata_xfer) reset_xfer;
struct ata_xfer *xfer, *next_xfer;
struct wdc_softc *wdc = CHAN_TO_WDC(chp);
- int drive;
- chp->ch_queue->queue_freeze++;
TAILQ_INIT(&reset_xfer);
- /* if we can poll or wait it's OK, otherwise wake up the kernel
- * thread
- */
- if ((flags & (AT_POLL | AT_WAIT)) == 0) {
- if (chp->ch_flags & ATACH_TH_RESET) {
- /* no need to schedule a reset more than one time */
- return;
- }
- chp->ch_flags |= ATACH_TH_RESET;
- chp->ch_reset_flags = flags & (AT_RST_EMERG | AT_RST_NOCMD);
- wakeup(&chp->ch_thread);
- return;
- }
-
chp->ch_flags &= ~ATACH_IRQ_WAIT;
+
/*
* if the current command if on an ATAPI device, issue a
* ATAPI_SOFT_RESET
@@ -878,7 +863,7 @@ wdc_reset_channel(struct ata_channel *chp, int flags)
xfer = chp->ch_queue->active_xfer;
if (xfer) {
if (xfer->c_chp != chp)
- wdc_reset_channel(xfer->c_chp, flags);
+ ata_reset_channel(xfer->c_chp, flags);
else {
callout_stop(&chp->ch_callout);
/*
@@ -908,19 +893,6 @@ wdc_reset_channel(struct ata_channel *chp, int flags)
xfer->c_kill_xfer(chp, xfer, KILL_RESET);
}
}
- for (drive = 0; drive < chp->ch_ndrive; drive++) {
- chp->ch_drive[drive].state = 0;
- }
- chp->ch_flags &= ~ATACH_TH_RESET;
- if ((flags & AT_RST_EMERG) == 0) {
- chp->ch_queue->queue_freeze--;
- atastart(chp);
- } else {
- /* make sure that we can use polled commands */
- TAILQ_INIT(&chp->ch_queue->queue_xfer);
- chp->ch_queue->queue_freeze = 0;
- chp->ch_queue->active_xfer = NULL;
- }
}
int
diff --git a/sys/dev/usb/umass_isdata.c b/sys/dev/usb/umass_isdata.c
index bdc9d73fcf6..dd4304c397b 100644
--- a/sys/dev/usb/umass_isdata.c
+++ b/sys/dev/usb/umass_isdata.c
@@ -1,4 +1,4 @@
-/* $NetBSD: umass_isdata.c,v 1.12 2004/08/20 17:37:16 thorpej Exp $ */
+/* $NetBSD: umass_isdata.c,v 1.13 2004/08/20 23:26:54 thorpej Exp $ */
/*
* TODO:
@@ -44,7 +44,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umass_isdata.c,v 1.12 2004/08/20 17:37:16 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umass_isdata.c,v 1.13 2004/08/20 23:26:54 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -113,7 +113,8 @@ int uisdatadebug = 0;
int uisdata_bio(struct ata_drive_datas *, struct ata_bio *);
int uisdata_bio1(struct ata_drive_datas *, struct ata_bio *);
-void uisdata_reset_channel(struct ata_drive_datas *, int);
+void uisdata_reset_drive(struct ata_drive_datas *, int);
+void uisdata_reset_channel(struct ata_channel *, int);
int uisdata_exec_command(struct ata_drive_datas *, struct ata_command *);
int uisdata_get_params(struct ata_drive_datas *, u_int8_t, struct ataparams *);
int uisdata_addref(struct ata_drive_datas *);
@@ -127,6 +128,7 @@ int uwdprint(void *, const char *);
const struct ata_bustype uisdata_bustype = {
SCSIPI_BUSTYPE_ATA,
uisdata_bio,
+ uisdata_reset_drive,
uisdata_reset_channel,
uisdata_exec_command,
uisdata_get_params,
@@ -377,7 +379,14 @@ uisdata_bio1(struct ata_drive_datas *drv, struct ata_bio *ata_bio)
}
void
-uisdata_reset_channel(struct ata_drive_datas *drv, int flags)
+uisdata_reset_drive(struct ata_drive_datas *drv, int flags)
+{
+ DPRINTFN(-1,("%s\n", __func__));
+ /* XXX what? */
+}
+
+void
+uisdata_reset_channel(struct ata_channel *chp, int flags)
{
DPRINTFN(-1,("%s\n", __func__));
/* XXX what? */