Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/jdolecek-ncq]: src/sys/dev/ic fix the driver to work again - switch to u...
details: https://anonhg.NetBSD.org/src/rev/c21c3e7e045a
branches: jdolecek-ncq
changeset: 822914:c21c3e7e045a
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Fri Jun 09 20:18:58 2017 +0000
description:
fix the driver to work again - switch to using tag from xfer, adjust
to framework changes (queue dynamically allocated), and do not store
pointer to xfer inside internal structures
unhide the ATAPI code and fix to compile, keep it disabled however
no indended functional changes, logic kept as close as possible to what was
there before; tested with Adaptec 1430SA (88SX7042)
diffstat:
sys/dev/ic/mvsata.c | 277 +++++++++++++++++++-----------------------------
sys/dev/ic/mvsatavar.h | 10 +-
2 files changed, 116 insertions(+), 171 deletions(-)
diffs (truncated from 691 to 300 lines):
diff -r 814c16a3a697 -r c21c3e7e045a sys/dev/ic/mvsata.c
--- a/sys/dev/ic/mvsata.c Tue Apr 25 20:55:05 2017 +0000
+++ b/sys/dev/ic/mvsata.c Fri Jun 09 20:18:58 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mvsata.c,v 1.35.6.6 2017/04/19 20:49:17 jdolecek Exp $ */
+/* $NetBSD: mvsata.c,v 1.35.6.7 2017/06/09 20:18:58 jdolecek Exp $ */
/*
* Copyright (c) 2008 KIYOHARA Takashi
* All rights reserved.
@@ -26,17 +26,12 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mvsata.c,v 1.35.6.6 2017/04/19 20:49:17 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mvsata.c,v 1.35.6.7 2017/06/09 20:18:58 jdolecek Exp $");
#include "opt_mvsata.h"
-/* ATAPI implementation not finished. */
-//#include "atapibus.h"
-
#include <sys/param.h>
-#if NATAPIBUS > 0
#include <sys/buf.h>
-#endif
#include <sys/bus.h>
#include <sys/cpu.h>
#include <sys/device.h>
@@ -55,16 +50,15 @@
#include <dev/ata/satareg.h>
#include <dev/ata/satavar.h>
-#if NATAPIBUS > 0
#include <dev/scsipi/scsi_all.h> /* for SCSI status */
-#endif
-
-#include <dev/pci/pcidevs.h>
+
+#include "atapibus.h"
+
+#include <dev/pci/pcidevs.h> /* XXX should not be here */
#include <dev/ic/mvsatareg.h>
#include <dev/ic/mvsatavar.h>
-
#define MVSATA_DEV(sc) ((sc)->sc_wdcdev.sc_atac.atac_dev)
#define MVSATA_DEV2(mvport) ((mvport)->port_ata_channel.ch_atac->atac_dev)
@@ -152,13 +146,13 @@
static void mvsata_atapi_polldsc(void *);
#endif
-static int mvsata_edma_enqueue(struct mvsata_port *, struct ata_bio *, void *);
+static int mvsata_edma_enqueue(struct mvsata_port *, struct ata_xfer *);
static int mvsata_edma_handle(struct mvsata_port *, struct ata_xfer *);
static int mvsata_edma_wait(struct mvsata_port *, struct ata_xfer *, int);
static void mvsata_edma_timeout(void *);
static void mvsata_edma_rqq_remove(struct mvsata_port *, struct ata_xfer *);
#if NATAPIBUS > 0
-static int mvsata_bdma_init(struct mvsata_port *, struct scsipi_xfer *, void *);
+static int mvsata_bdma_init(struct mvsata_port *, struct ata_xfer *);
static void mvsata_bdma_start(struct mvsata_port *);
#endif
#endif
@@ -166,9 +160,8 @@
static int mvsata_port_init(struct mvsata_hc *, int);
static int mvsata_wdc_reg_init(struct mvsata_port *, struct wdc_regs *);
#ifndef MVSATA_WITHOUTDMA
-static inline void mvsata_quetag_init(struct mvsata_port *);
-static inline int mvsata_quetag_get(struct mvsata_port *);
-static inline void mvsata_quetag_put(struct mvsata_port *, int);
+static inline void mvsata_quetag_get(struct mvsata_port *, uint8_t);
+static inline void mvsata_quetag_put(struct mvsata_port *, uint8_t);
static void *mvsata_edma_resource_prepare(struct mvsata_port *, bus_dma_tag_t,
bus_dmamap_t *, size_t, int);
static void mvsata_edma_resource_purge(struct mvsata_port *, bus_dma_tag_t,
@@ -187,8 +180,8 @@
static int mvsata_edma_disable(struct mvsata_port *, int, int);
static void mvsata_edma_config(struct mvsata_port *, int);
-static void mvsata_edma_setup_crqb(struct mvsata_port *, int, int,
- struct ata_bio *);
+static void mvsata_edma_setup_crqb(struct mvsata_port *, int,
+ struct ata_xfer *);
#endif
static uint32_t mvsata_read_preamps_gen1(struct mvsata_port *);
static void mvsata_fix_phy_gen1(struct mvsata_port *);
@@ -197,8 +190,8 @@
static uint32_t mvsata_read_preamps_gen2(struct mvsata_port *);
static void mvsata_fix_phy_gen2(struct mvsata_port *);
#ifndef MVSATA_WITHOUTDMA
-static void mvsata_edma_setup_crqb_gen2e(struct mvsata_port *, int, int,
- struct ata_bio *);
+static void mvsata_edma_setup_crqb_gen2e(struct mvsata_port *, int,
+ struct ata_xfer *);
#ifdef MVSATA_DEBUG
static void mvsata_print_crqb(struct mvsata_port *, int);
@@ -206,7 +199,7 @@
static void mvsata_print_eprd(struct mvsata_port *, int);
#endif
-struct ata_bustype mvsata_ata_bustype = {
+static const struct ata_bustype mvsata_ata_bustype = {
SCSIPI_BUSTYPE_ATA,
mvsata_bio,
mvsata_reset_drive,
@@ -260,7 +253,7 @@
void (*_fix_phy)(struct mvsata_port *) = NULL;
#ifndef MVSATA_WITHOUTDMA
void (*edma_setup_crqb)
- (struct mvsata_port *, int, int, struct ata_bio *) = NULL;
+ (struct mvsata_port *, int, struct ata_xfer *) = NULL;
#endif
int hc, port, channel;
@@ -540,8 +533,6 @@
", bcount=%ld\n", device_xname(atac->atac_dev), chp->ch_channel,
drvp->drive, ata_bio->blkno, ata_bio->bcount));
- if (xfer == NULL)
- return ATACMD_TRY_AGAIN;
if (atac->atac_cap & ATAC_CAP_NOIRQ)
ata_bio->flags |= ATA_POLL;
if (ata_bio->flags & ATA_POLL)
@@ -625,13 +616,10 @@
}
for (i = 0; i < MVSATA_EDMAQ_LEN; i++) {
- xfer = mvport->port_reqtbl[i].xfer;
- if (xfer == NULL)
+ if ((mvport->port_quetagidx & __BIT(i)) == 0)
continue;
-#if 0
- /* This doesn't seem to be needed? */
- chp->ch_queue->active_xfers[0] = xfer; /* XXX slot */
-#endif
+
+ xfer = ata_queue_hwslot_to_xfer(chp->ch_queue, i);
xfer->c_kill_xfer(chp, xfer, KILL_RESET);
}
@@ -742,8 +730,10 @@
chan->chan_ntargets = 1;
chan->chan_nluns = 1;
+#if 0 /* XXX ATAPI implementation not finished. */
chp->atapibus =
config_found_ia(ata_sc->sc_dev, "atapi", chan, atapiprint);
+#endif
}
static void
@@ -1108,8 +1098,7 @@
if (xfer->c_flags & C_POLL)
sc->sc_enable_intr(mvport, 0 /*off*/);
- error = mvsata_edma_enqueue(mvport, ata_bio,
- (char *)xfer->c_databuf + xfer->c_skip);
+ error = mvsata_edma_enqueue(mvport, xfer);
if (error) {
if (error == EINVAL) {
/*
@@ -1126,7 +1115,7 @@
"channel %d: EDMA Queue full\n",
chp->ch_channel);
/*
- * XXXX: Perhaps, after it waits for
+ * XXX: Perhaps, after it waits for
* a while, it is necessary to call
* bio_start again.
*/
@@ -1950,17 +1939,11 @@
wdctimeout, xfer);
MVSATA_WDC_WRITE_1(mvport, SRB_H, WDSD_IBM);
- switch (wdc_wait_for_unbusy(chp, ATAPI_DELAY, wait_flags) < 0) {
- case WDCWAIT_OK:
- break;
- case WDCWAIT_TOUT:
+ if (wdc_wait_for_unbusy(chp, ATAPI_DELAY, wait_flags)) {
aprint_error_dev(atac->atac_dev, "not ready, st = %02x\n",
chp->ch_status);
sc_xfer->error = XS_TIMEOUT;
mvsata_atapi_reset(chp, xfer);
- return;
- case WDCWAIT_THR:
- return;
}
/*
@@ -2100,8 +2083,7 @@
DPRINTF(("PHASE_CMDOUT\n"));
/* Init the DMA channel if necessary */
if (xfer->c_flags & C_DMA) {
- error = mvsata_bdma_init(mvport, sc_xfer,
- (char *)xfer->c_databuf + xfer->c_skip);
+ error = mvsata_bdma_init(mvport, xfer);
if (error) {
if (error == EINVAL) {
/*
@@ -2269,6 +2251,7 @@
static void
mvsata_atapi_reset(struct ata_channel *chp, struct ata_xfer *xfer)
{
+ struct mvsata_port *mvport = (struct mvsata_port *)chp;
struct atac_softc *atac = chp->ch_atac;
struct ata_drive_datas *drvp = &chp->ch_drive[xfer->c_drive];
struct scsipi_xfer *sc_xfer = xfer->c_scsipi;
@@ -2346,17 +2329,19 @@
return;
}
}
- if (xfer->c_bcount != 0)
+ if (xfer->c_bcount != 0) {
DPRINTFN(1, ("%s:%d:%d: mvsata_atapi_intr:"
" bcount value is %d after io\n",
device_xname(atac->atac_dev), chp->ch_channel,
xfer->c_drive, xfer->c_bcount));
+ }
#ifdef DIAGNOSTIC
- if (xfer->c_bcount < 0)
+ if (xfer->c_bcount < 0) {
aprint_error_dev(atac->atac_dev,
"channel %d drive %d: mvsata_atapi_intr:"
" warning: bcount value is %d after io\n",
chp->ch_channel, xfer->c_drive, xfer->c_bcount);
+ }
#endif
DPRINTFN(1, ("%s:%d:%d: mvsata_atapi_phase_complete:"
@@ -2369,30 +2354,28 @@
static void
mvsata_atapi_done(struct ata_channel *chp, struct ata_xfer *xfer)
{
- struct atac_softc *atac = chp->ch_atac;
struct scsipi_xfer *sc_xfer = xfer->c_scsipi;
int drive = xfer->c_drive;
DPRINTFN(1, ("%s:%d:%d: mvsata_atapi_done: flags 0x%x\n",
- device_xname(atac->atac_dev), chp->ch_channel, xfer->c_drive,
- (u_int)xfer->c_flags));
+ device_xname(chp->ch_atac->atac_dev), chp->ch_channel,
+ xfer->c_drive, (u_int)xfer->c_flags));
/* mark controller inactive and free the command */
ata_deactivate_xfer(chp, xfer);
- ata_free_xfer(chp, xfer);
-
- if (chp->ch_drive[drive].drive_flags & ATA_DRIVE_WAITDRAIN) {
+
+ if (ata_waitdrain_check(chp, drive))
sc_xfer->error = XS_DRIVER_STUFFUP;
- chp->ch_drive[drive].drive_flags &= ~ATA_DRIVE_WAITDRAIN;
- wakeup(chp->ch_queue->active_xfers);
- }
+
+ ata_free_xfer(chp, xfer);
DPRINTFN(1, ("%s:%d: mvsata_atapi_done: scsipi_done\n",
- device_xname(atac->atac_dev), chp->ch_channel));
+ device_xname(chp->ch_atac->atac_dev), chp->ch_channel));
scsipi_done(sc_xfer);
DPRINTFN(1, ("%s:%d: atastart from wdc_atapi_done, flags 0x%x\n",
- device_xname(atac->atac_dev), chp->ch_channel, chp->ch_flags));
+ device_xname(chp->ch_atac->atac_dev), chp->ch_channel,
+ chp->ch_flags));
atastart(chp);
}
@@ -2411,16 +2394,16 @@
* if this is called only to the thread of atabus.
*/
static int
-mvsata_edma_enqueue(struct mvsata_port *mvport, struct ata_bio *ata_bio,
- void *databuf)
+mvsata_edma_enqueue(struct mvsata_port *mvport, struct ata_xfer *xfer)
{
struct mvsata_softc *sc = device_private(MVSATA_DEV2(mvport));
- struct ata_channel *chp = &mvport->port_ata_channel;
+ struct ata_bio *ata_bio = &xfer->c_bio;
+ void *databuf = (uint8_t *)xfer->c_databuf + xfer->c_skip;
struct eprd *eprd;
bus_addr_t crqb_base_addr;
bus_dmamap_t data_dmamap;
uint32_t reg;
- int quetag, erqqip, erqqop, next, rv, i;
+ int erqqip, erqqop, next, rv, i;
DPRINTFN(2, ("%s:%d:%d: mvsata_edma_enqueue:"
" blkno=0x%" PRIx64 ", nbytes=%d, flags=0x%x\n",
@@ -2433,27 +2416,23 @@
erqqip = (reg & EDMA_REQQP_ERQQP_MASK) >> EDMA_REQQP_ERQQP_SHIFT;
next = erqqip;
MVSATA_EDMAQ_INC(next);
- if (next == erqqop)
+ if (next == erqqop) {
/* queue full */
Home |
Main Index |
Thread Index |
Old Index