summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2014-04-06 20:17:23 +0000
committerkettenis <kettenis@openbsd.org>2014-04-06 20:17:23 +0000
commit399e7f0169887f31eef1165adfa08bca887b3002 (patch)
treee0b246035a3a1ef904aff839f5bcdf55736491fc
parentClear the interrupt before reading the response queue pointer register in (diff)
downloadwireguard-openbsd-399e7f0169887f31eef1165adfa08bca887b3002.tar.xz
wireguard-openbsd-399e7f0169887f31eef1165adfa08bca887b3002.zip
Rework the command polling loop in a similar fashion as was done for qla(4).
-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