diff options
-rw-r--r-- | sys/arch/mac68k/dev/ncr5380.c | 65 | ||||
-rw-r--r-- | sys/arch/mac68k/dev/ncr5380reg.h | 5 |
2 files changed, 45 insertions, 25 deletions
diff --git a/sys/arch/mac68k/dev/ncr5380.c b/sys/arch/mac68k/dev/ncr5380.c index fcc953ae3ae..e1766799d16 100644 --- a/sys/arch/mac68k/dev/ncr5380.c +++ b/sys/arch/mac68k/dev/ncr5380.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ncr5380.c,v 1.39 2010/06/28 18:31:01 krw Exp $ */ +/* $OpenBSD: ncr5380.c,v 1.40 2011/04/03 16:37:25 krw Exp $ */ /* $NetBSD: ncr5380.c,v 1.38 1996/12/19 21:48:18 scottr Exp $ */ /* @@ -77,6 +77,9 @@ static void ncr5380_minphys(struct buf *bp, struct scsi_link *sl); static void mac68k_ncr5380_scsi_cmd(struct scsi_xfer *xs); static void ncr5380_show_scsi_cmd(struct scsi_xfer *xs); +int ncr_sc_req_free(void *, void *); +void *ncr_sc_req_alloc(void *); + struct scsi_adapter ncr5380_switch = { mac68k_ncr5380_scsi_cmd, /* scsi_cmd() */ ncr5380_minphys, /* scsi_minphys() */ @@ -88,7 +91,6 @@ struct scsi_adapter ncr5380_switch = { static SC_REQ req_queue[NREQ]; static SC_REQ *free_head = NULL; /* Free request structures */ - /* * Inline functions: */ @@ -156,7 +158,6 @@ extern __inline__ void nack_message(SC_REQ *reqp, u_char msg) extern __inline__ void finish_req(SC_REQ *reqp) { - int sps; struct scsi_xfer *xs = reqp->xs; #ifdef REAL_DMA @@ -174,15 +175,7 @@ extern __inline__ void finish_req(SC_REQ *reqp) if (reqp->xs->error != 0) show_request(reqp, "ERR_RET"); #endif - /* - * Return request to free-q - */ - sps = splbio(); - reqp->next = free_head; - free_head = reqp; - scsi_done(xs); - splx(sps); } /* @@ -207,6 +200,35 @@ struct cfdriver CFNAME(DRNAME) = { }; int +ncr_sc_req_free(void *xsc, void *xsc_req) +{ + struct ncr_softc *sc = (ncr_softc *)xsc; + struct SC_REQ *sc_req = (SC_REQ *)xsc_req; + + mtx_enter(&sc->sc_sc_req_mtx); + sc_req->next = free_head; + free_head = sc_req; + mtx_leave(&sc->sc_sc_req_mtx); +} + +void * +ncr_sc_req_alloc(void *xsc) +{ + struct ncr_softc *sc = (ncr_softc *)xsc; + struct SC_REQ *sc_req = NULL; + + mtx_enter(&sc->sc_sc_req_mtx); + if (free_head) { + sc_req = free_head; + free_head = free_head->next; + sc_req->next = NULL; + } + mtx_leave(&sc->sc_sc_req_mtx); + + return (sc_req); +} + +int ncr_match(parent, cf, aux) struct device *parent; void *cf; @@ -231,6 +253,7 @@ void *auxp; sc->sc_link.adapter_target = 7; sc->sc_link.adapter = &ncr5380_switch; sc->sc_link.openings = NREQ - 1; + sc->sc_link_pool = &sc->sc_iopool; /* * bitmasks @@ -253,6 +276,12 @@ void *auxp; } /* + * Initialize the iopool. + */ + mtx_init(&sc->sc_sc_req_mtx, IPL_BIO); + scsi_iopool_init(&sc->sc_iopool, sc, ncr_sc_req_alloc, ncr_sc_req_free); + + /* * Initialize the host adapter */ scsi_idisable(); @@ -295,19 +324,7 @@ mac68k_ncr5380_scsi_cmd(struct scsi_xfer *xs) return; } - /* - * Get a request block - */ - sps = splbio(); - if ((reqp = free_head) == 0) { - xs->error = XS_NO_CCB; - scsi_done(xs); - splx(sps); - return; - } - free_head = reqp->next; - reqp->next = NULL; - splx(sps); + reqp = xs->io; /* * Initialize our private fields diff --git a/sys/arch/mac68k/dev/ncr5380reg.h b/sys/arch/mac68k/dev/ncr5380reg.h index b0117f3e293..9314967b1aa 100644 --- a/sys/arch/mac68k/dev/ncr5380reg.h +++ b/sys/arch/mac68k/dev/ncr5380reg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ncr5380reg.h,v 1.6 2006/01/16 21:45:58 miod Exp $ */ +/* $OpenBSD: ncr5380reg.h,v 1.7 2011/04/03 16:37:25 krw Exp $ */ /* $NetBSD: ncr5380reg.h,v 1.9 1996/05/05 06:16:58 briggs Exp $ */ /* @@ -163,6 +163,9 @@ struct ncr_softc { struct via2hand sc_ih_irq, sc_ih_drq; + struct mutex sc_sc_req_mtx; + struct scsi_iopool sc_iopool; + /* * Some (pre-SCSI2) devices don't support select with ATN. * If the device responds to select with ATN by going into |