diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2004-12-22 21:07:30 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2004-12-22 21:07:30 +0000 |
commit | c3fa11489bc70df304099c5e2f61333e1c2074cd (patch) | |
tree | 7dcf60e300c6e347628549e93019067615f88dd2 /sys/arch/hp300 | |
parent | 483081f6b95aaf6481d6f1c8e638433a6b2c95cc (diff) |
Do not use DMA for odd-size transfers, as the last byte will not be
transferred correctly.
Diffstat (limited to 'sys/arch/hp300')
-rw-r--r-- | sys/arch/hp300/dev/mb89352.c | 25 | ||||
-rw-r--r-- | sys/arch/hp300/dev/mb89352var.h | 4 | ||||
-rw-r--r-- | sys/arch/hp300/dev/spc.c | 15 |
3 files changed, 30 insertions, 14 deletions
diff --git a/sys/arch/hp300/dev/mb89352.c b/sys/arch/hp300/dev/mb89352.c index ec504e94146..911a2b04bc8 100644 --- a/sys/arch/hp300/dev/mb89352.c +++ b/sys/arch/hp300/dev/mb89352.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mb89352.c,v 1.8 2004/09/29 09:55:48 miod Exp $ */ +/* $OpenBSD: mb89352.c,v 1.9 2004/12/22 21:07:29 miod Exp $ */ /* $NetBSD: mb89352.c,v 1.5 2000/03/23 07:01:31 thorpej Exp $ */ /* NecBSD: mb89352.c,v 1.4 1998/03/14 07:31:20 kmatsuda Exp */ @@ -96,7 +96,9 @@ * kernel debugger. If you set SPC_DEBUG to 0 they are not included (the * kernel uses less memory) but you lose the debugging facilities. */ -/* #define SPC_DEBUG */ +#if 0 +#define SPC_DEBUG +#endif #define SPC_ABORT_TIMEOUT 2000 /* time to wait for abort */ @@ -1811,9 +1813,11 @@ dophase: SPC_MISC(("dataout dleft=%d ", sc->sc_dleft)); if (sc->sc_dma_start != NULL && sc->sc_dleft > SPC_MIN_DMA_LEN) { - (*sc->sc_dma_start)(sc, sc->sc_dp, sc->sc_dleft, 0); - sc->sc_prevphase = PH_DATAOUT; - goto out; + if ((*sc->sc_dma_start) + (sc, sc->sc_dp, sc->sc_dleft, 0) == 0) { + sc->sc_prevphase = PH_DATAOUT; + goto out; + } } n = spc_dataout_pio(sc, sc->sc_dp, sc->sc_dleft); sc->sc_dp += n; @@ -1827,9 +1831,11 @@ dophase: SPC_MISC(("datain ")); if (sc->sc_dma_start != NULL && sc->sc_dleft > SPC_MIN_DMA_LEN) { - (*sc->sc_dma_start)(sc, sc->sc_dp, sc->sc_dleft, 1); - sc->sc_prevphase = PH_DATAIN; - goto out; + if ((*sc->sc_dma_start) + (sc, sc->sc_dp, sc->sc_dleft, 1) == 0) { + sc->sc_prevphase = PH_DATAIN; + goto out; + } } n = spc_datain_pio(sc, sc->sc_dp, sc->sc_dleft); sc->sc_dp += n; @@ -2007,7 +2013,8 @@ spc_dump_driver(struct spc_softc *sc) struct spc_tinfo *ti; int i; - printf("nexus=%p prevphase=%x\n", sc->sc_nexus, sc->sc_prevphase); + printf("nexus=%p phase=%x prevphase=%x\n", + sc->sc_nexus, sc->sc_phase, sc->sc_prevphase); printf("state=%x msgin=%x msgpriq=%x msgoutq=%x lastmsg=%x " "currmsg=%x\n", sc->sc_state, sc->sc_imess[0], sc->sc_msgpriq, sc->sc_msgoutq, sc->sc_lastmsg, sc->sc_currmsg); diff --git a/sys/arch/hp300/dev/mb89352var.h b/sys/arch/hp300/dev/mb89352var.h index 2d24b994a25..d9c4d78f9e2 100644 --- a/sys/arch/hp300/dev/mb89352var.h +++ b/sys/arch/hp300/dev/mb89352var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mb89352var.h,v 1.3 2004/08/21 18:00:26 miod Exp $ */ +/* $OpenBSD: mb89352var.h,v 1.4 2004/12/22 21:07:29 miod Exp $ */ /* $NetBSD: mb89352var.h,v 1.6 2003/08/02 12:48:09 tsutsui Exp $ */ /* NecBSD: mb89352var.h,v 1.4 1998/03/14 07:31:22 kmatsuda Exp */ @@ -175,7 +175,7 @@ struct spc_softc { int sc_ctlflags; /* DMA function set from MD code */ - void (*sc_dma_start)(struct spc_softc *, void *, size_t, int); + int (*sc_dma_start)(struct spc_softc *, void *, size_t, int); void (*sc_dma_done)(struct spc_softc *); /* Reset hook */ diff --git a/sys/arch/hp300/dev/spc.c b/sys/arch/hp300/dev/spc.c index 32695bb0f75..0106b7f09e2 100644 --- a/sys/arch/hp300/dev/spc.c +++ b/sys/arch/hp300/dev/spc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spc.c,v 1.9 2004/09/29 07:35:52 miod Exp $ */ +/* $OpenBSD: spc.c,v 1.10 2004/12/22 21:07:29 miod Exp $ */ /* $NetBSD: spc.c,v 1.2 2003/11/17 14:37:59 tsutsui Exp $ */ /* @@ -54,7 +54,7 @@ int spc_dio_match(struct device *, void *, void *); void spc_dio_attach(struct device *, struct device *, void *); -void spc_dio_dmastart(struct spc_softc *, void *, size_t, int); +int spc_dio_dmastart(struct spc_softc *, void *, size_t, int); void spc_dio_dmadone(struct spc_softc *); void spc_dio_dmago(void *); void spc_dio_dmastop(void *); @@ -169,11 +169,18 @@ spc_dio_attach(struct device *parent, struct device *self, void *aux) hpspc_write(HPSCSI_CSR, CSR_IE); } -void +int spc_dio_dmastart(struct spc_softc *sc, void *addr, size_t size, int datain) { struct spc_dio_softc *dsc = (struct spc_dio_softc *)sc; + /* + * The HP98658 hardware cannot do odd length transfers, the + * last byte of data will always be 0x00. + */ + if ((size & 1) != 0) + return (EINVAL); + dsc->sc_dq.dq_chan = DMA0 | DMA1; dsc->sc_dflags |= SCSI_HAVEDMA; if (datain) @@ -185,6 +192,8 @@ spc_dio_dmastart(struct spc_softc *sc, void *addr, size_t size, int datain) /* DMA channel is available, so start DMA immediately */ spc_dio_dmago((void *)dsc); /* else dma start function will be called later from dmafree(). */ + + return (0); } void |