diff options
author | mjacob <mjacob@cvs.openbsd.org> | 2001-12-14 00:20:56 +0000 |
---|---|---|
committer | mjacob <mjacob@cvs.openbsd.org> | 2001-12-14 00:20:56 +0000 |
commit | 17d4cdf5fb28cbcf2a7f35a2029314c30369a46f (patch) | |
tree | b39666b472468774f4e8f103699528500aa0af0b /sys/arch/sparc/dev/isp_sbus.c | |
parent | b3b7dc842a6cac27f1954516ba9e702ba2b1ef05 (diff) |
Major restructuring for swizzling to the request queue and unswizzling from
the response queue. Instead of the ad hoc ISP_SWIZZLE_REQUEST, we now have
a complete set of inline functions in isp_inline.h. Each platform is
responsible for providing just one of a set of ISP_IOX_{GET,PUT}{8,16,32}
macros.
The reason this needs to be done is that we need to have a single set of
functions that will work correctly on multiple architectures for both little
and big endian machines. It also needs to work correctly in the case that
we have the request or response queues in memory that has to be treated
specially (e.g., have ddi_dma_sync called on it for Solaris after we update
it or before we read from it).
One thing that falls out of this is that we no longer build requests in the
request queue itself. Instead, we build the request locally (e.g., on the
stack) and then as part of the swizzling operation, copy it to the request
queue entry we've allocated. I thought long and hard about whether this was
too expensive a change to make as it in a lot of cases requires an extra
copy. On balance, the flexbility is worth it. With any luck, the entry that
we build locally stays in a processor writeback cache (after all, it's only
64 bytes) so that the cost of actually flushing it to the memory area that is
the shared queue with the PCI device is not all that expensive. We may examine
this again and try to get clever in the future to try and avoid copies.
Another change that falls out of this is that MEMORYBARRIER should be taken
a lot more seriously. The macro ISP_ADD_REQUEST does a MEMORYBARRIER on the
entry being added. But there had been many other places this had been missing.
It's now very important that it be done.
For OpenSD, it does a ddi_dmamap_sync as appropriate. This gets us out of
the explicit ddi_dmamap_sync on the whole response queue that we did for SBus
cards at each interrupt. Now, because SBus/sparc doesn't use bus_dma, some
shenanigans were done to support this. But Jason was nice enough to test the
SBus/sparcv9 changes for me, and they did the right thing as well.
Set things up so that platforms that cannot have an SBus don't get a lot of
the SBus code checks (dead coded out).
Additional changes:
Fix a longstanding buglet of sorts. When we get an entry via isp_getrqentry,
the iptr value that gets returned is the value we intend to eventually plug
into the ISP registers as the entry *one past* the last one we've written-
*not* the current entry we're updating. All along we've been calling sync
functions on the wrong index value. Argh. The 'fix' here is to rename all
'iptr' variables as 'nxti' to remember that this is the 'next' pointer-
not the current pointer.
Devote a single bit to mboxbsy- and set aside bits for output mbox registers
that we need to pick up- we can have at least one command which does not
have any defined output registers (MBOX_EXECUTE_FIRMWARE).
Explicitly decode GetAllNext SNS Response back *as* a GetAllNext response.
Otherwise, we won't unswizzle it correctly.
Nuke some additional __P macros.
Diffstat (limited to 'sys/arch/sparc/dev/isp_sbus.c')
-rw-r--r-- | sys/arch/sparc/dev/isp_sbus.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/sys/arch/sparc/dev/isp_sbus.c b/sys/arch/sparc/dev/isp_sbus.c index c564086e0e1..99548e366e3 100644 --- a/sys/arch/sparc/dev/isp_sbus.c +++ b/sys/arch/sparc/dev/isp_sbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: isp_sbus.c,v 1.18 2001/09/01 07:16:39 mjacob Exp $ */ +/* $OpenBSD: isp_sbus.c,v 1.19 2001/12/14 00:20:54 mjacob Exp $ */ /* * SBus specific probe and attach routines for Qlogic ISP SCSI adapters. * @@ -47,6 +47,15 @@ #include <dev/microcode/isp/asm_sbus.h> #endif +#define ISP_SBUSIFY_ISPHDR(isp, hdrp) \ + ISP_SWAP8((hdrp)->rqs_entry_count, (hdrp)->rqs_entry_type); \ + ISP_SWAP8((hdrp)->rqs_flags, (hdrp)->rqs_seqno); + +#define ISP_SWIZZLE_REQUEST(a, b) \ + ISP_SBUSIFY_ISPHDR(a, &(b)->req_header); \ + ISP_SWAP8((b)->req_target, (b)->req_lun_trn) + + static int isp_sbus_rd_isr(struct ispsoftc *, u_int16_t *, u_int16_t *, u_int16_t *); static u_int16_t isp_sbus_rd_reg(struct ispsoftc *, int); @@ -80,7 +89,7 @@ struct isp_sbussoftc { struct ispsoftc sbus_isp; sdparam sbus_dev; struct intrhand sbus_ih; - volatile u_char *sbus_reg; + volatile u_int16_t *sbus_reg; int sbus_node; int sbus_pri; struct ispmdvec sbus_mdvec; @@ -148,9 +157,9 @@ isp_sbus_attach(struct device *parent, struct device *self, void *aux) sbc->sbus_mdvec = mdvec; if (ca->ca_ra.ra_vaddr) { - sbc->sbus_reg = (volatile u_char *) ca->ca_ra.ra_vaddr; + sbc->sbus_reg = (volatile u_int16_t *) ca->ca_ra.ra_vaddr; } else { - sbc->sbus_reg = (volatile u_char *) + sbc->sbus_reg = (volatile u_int16_t *) mapiodev(ca->ca_ra.ra_reg, 0, ca->ca_ra.ra_len); } sbc->sbus_node = ca->ca_ra.ra_node; @@ -273,15 +282,14 @@ isp_sbus_attach(struct device *parent, struct device *self, void *aux) (((struct isp_sbussoftc *)a)->sbus_poff[((x) & _BLK_REG_MASK) >> \ _BLK_REG_SHFT] + ((x) & 0xff)) -#define BXR2(pcs, off) \ - (*((u_int16_t *) &sbc->sbus_reg[off])) +#define BXR2(pcs, off) (sbc->sbus_reg[off >> 1]) static int isp_sbus_rd_isr(struct ispsoftc *isp, u_int16_t *isrp, u_int16_t *semap, u_int16_t *mbp) { struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) isp; - u_int16_t isr, sema; + volatile u_int16_t isr, sema; isr = BXR2(pcs, IspVirt2Off(isp, BIU_ISR)); sema = BXR2(pcs, IspVirt2Off(isp, BIU_SEMA)); @@ -304,7 +312,7 @@ isp_sbus_rd_reg(struct ispsoftc *isp, int regoff) struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) isp; int offset = sbc->sbus_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT]; offset += (regoff & 0xff); - return (*((u_int16_t *) &sbc->sbus_reg[offset])); + return ((u_int16_t) sbc->sbus_reg[offset >> 1]); } static void @@ -313,7 +321,7 @@ isp_sbus_wr_reg(struct ispsoftc *isp, int regoff, u_int16_t val) struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) isp; int offset = sbc->sbus_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT]; offset += (regoff & 0xff); - *((u_int16_t *) &sbc->sbus_reg[offset]) = val; + sbc->sbus_reg[offset >> 1] = val; } @@ -382,10 +390,12 @@ isp_sbus_dmasetup(struct ispsoftc *isp, struct scsi_xfer *xs, ispreq_t *rq, u_int16_t *iptrp, u_int16_t optr) { struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) isp; + ispreq_t *qe; ispcontreq_t *crq; vaddr_t kdvma; int dosleep = (xs->flags & SCSI_NOSLEEP) != 0; + qe = (ispreq_t *) ISP_QUEUE_ENTRY(isp->isp_rquest, isp->isp_reqidx); if (xs->datalen == 0) { rq->req_seg_count = 1; goto mbxsync; @@ -444,6 +454,7 @@ isp_sbus_dmasetup(struct ispsoftc *isp, struct scsi_xfer *xs, ispreq_t *rq, mbxsync: ISP_SWIZZLE_REQUEST(isp, rq); + bcopy(rq, qe, sizeof (ispreq_t)); return (CMD_QUEUED); } @@ -478,11 +489,6 @@ isp_sbus_intr(void *arg) isp->isp_intbogus++; return (0); } else { -#if 0 - struct iss_sbussoftc *s = (struct isp_sbussoftc *)isp; - bus_dmamap_sync(s->pci_dmat, s->pci_result_dmap, - BUS_DMASYNC_POSTREAD); -#endif isp->isp_osinfo.onintstack = 1; isp_intr(isp, isr, sema, mbox); isp->isp_osinfo.onintstack = 0; |