summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2014-04-06 20:17:24 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2014-04-06 20:17:24 +0000
commit93bfc2a9bbdbddb117eef2e2e08dd704ddec54ca (patch)
treec45b06f15f346f01c8a4d31b27ed6c27885b3cb7 /sys/dev
parent87b8ec8be89f6028cee38d8d03b2f2ef9bf9fed5 (diff)
Rework the command polling loop in a similar fashion as was done for qla(4).
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ic/qlw.c44
1 files changed, 17 insertions, 27 deletions
diff --git a/sys/dev/ic/qlw.c b/sys/dev/ic/qlw.c
index 3fffaaba58b..325c7611786 100644
--- a/sys/dev/ic/qlw.c
+++ b/sys/dev/ic/qlw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: qlw.c,v 1.21 2014/04/06 18:28:35 kettenis Exp $ */
+/* $OpenBSD: qlw.c,v 1.22 2014/04/06 20:17:23 kettenis Exp $ */
/*
* Copyright (c) 2011 David Gwynne <dlg@openbsd.org>
@@ -61,7 +61,6 @@ struct cfdriver qlw_cd = {
};
void qlw_scsi_cmd(struct scsi_xfer *);
-struct qlw_ccb *qlw_scsi_cmd_poll(struct qlw_softc *);
int qlw_scsi_probe(struct scsi_link *);
u_int16_t qlw_read(struct qlw_softc *, bus_size_t);
@@ -803,8 +802,8 @@ qlw_scsi_cmd(struct scsi_xfer *xs)
struct qlw_ccb *ccb;
struct qlw_iocb_req0 *iocb;
struct qlw_ccb_list list;
- u_int16_t req;
- int offset, error;
+ u_int16_t req, rspin;
+ int offset, error, done;
bus_dmamap_t dmap;
int bus;
int seg;
@@ -904,27 +903,9 @@ qlw_scsi_cmd(struct scsi_xfer *xs)
return;
}
+ done = 0;
SIMPLEQ_INIT(&list);
do {
- ccb = qlw_scsi_cmd_poll(sc);
- SIMPLEQ_INSERT_TAIL(&list, ccb, ccb_link);
- } while (xs->io != ccb);
-
- mtx_leave(&sc->sc_queue_mtx);
-
- while ((ccb = SIMPLEQ_FIRST(&list)) != NULL) {
- SIMPLEQ_REMOVE_HEAD(&list, ccb_link);
- scsi_done(ccb->ccb_xs);
- }
-}
-
-struct qlw_ccb *
-qlw_scsi_cmd_poll(struct qlw_softc *sc)
-{
- u_int16_t rspin;
- struct qlw_ccb *ccb = NULL;
-
- while (ccb == NULL) {
u_int16_t isr, info;
delay(100);
@@ -941,18 +922,27 @@ qlw_scsi_cmd_poll(struct qlw_softc *sc)
qlw_clear_isr(sc, isr);
rspin = qlw_queue_read(sc, QLW_RESP_IN);
- if (rspin != sc->sc_last_resp_id) {
+ while (rspin != sc->sc_last_resp_id) {
ccb = qlw_handle_resp(sc, sc->sc_last_resp_id);
sc->sc_last_resp_id++;
if (sc->sc_last_resp_id == sc->sc_maxresponses)
sc->sc_last_resp_id = 0;
- qlw_queue_write(sc, QLW_RESP_OUT, sc->sc_last_resp_id);
+ if (ccb != NULL)
+ SIMPLEQ_INSERT_TAIL(&list, ccb, ccb_link);
+ if (ccb == xs->io)
+ done = 1;
}
- }
+ qlw_queue_write(sc, QLW_RESP_OUT, rspin);
+ } while (done == 0);
- return (ccb);
+ mtx_leave(&sc->sc_queue_mtx);
+
+ while ((ccb = SIMPLEQ_FIRST(&list)) != NULL) {
+ SIMPLEQ_REMOVE_HEAD(&list, ccb_link);
+ scsi_done(ccb->ccb_xs);
+ }
}
u_int16_t