diff options
author | cheloha <cheloha@cvs.openbsd.org> | 2020-01-23 01:43:18 +0000 |
---|---|---|
committer | cheloha <cheloha@cvs.openbsd.org> | 2020-01-23 01:43:18 +0000 |
commit | 9f29dc4b16d65a6895a292dd77ef8612a4f22f52 (patch) | |
tree | b9e995a0d207a013c4dc78f89e4c3e75ec9c6dfe /sys | |
parent | 6a3c50c57e648d5a68b6fc3a95c3160f11c72c3f (diff) |
ciss(4): tsleep(9) -> tsleep_nsec(9)
"i" is a count of milliseconds. We convert it to a starting interval
"ts" and determine our absolute timeout "end". Then we loop through
until the poll is successful or "end" elapses.
This could be simplified with an absolute timeout interface for
tsleep(9) but alas, we don't have one yet.
ok krw@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/ic/ciss.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/sys/dev/ic/ciss.c b/sys/dev/ic/ciss.c index 8e038ef82d7..3673a1d20be 100644 --- a/sys/dev/ic/ciss.c +++ b/sys/dev/ic/ciss.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ciss.c,v 1.77 2020/01/23 00:30:59 cheloha Exp $ */ +/* $OpenBSD: ciss.c,v 1.78 2020/01/23 01:43:17 cheloha Exp $ */ /* * Copyright (c) 2005,2006 Michael Shalayeff @@ -442,13 +442,15 @@ cissminphys(struct buf *bp, struct scsi_link *sl) int ciss_cmd(struct ciss_ccb *ccb, int flags, int wait) { + struct timespec end, now, ts; struct ciss_softc *sc = ccb->ccb_sc; struct ciss_cmd *cmd = &ccb->ccb_cmd; struct ciss_ccb *ccb1; bus_dmamap_t dmap = ccb->ccb_dmamap; u_int64_t addr; + uint64_t nsecs; u_int32_t id; - int i, tohz, error = 0; + int i, error = 0, ret; splassert(IPL_BIO); @@ -522,29 +524,27 @@ ciss_cmd(struct ciss_ccb *ccb, int flags, int wait) if (!(wait & SCSI_POLL)) return (error); - struct timeval tv; - int etick; CISS_DPRINTF(CISS_D_CMD, ("waiting ")); i = ccb->ccb_xs? ccb->ccb_xs->timeout : 60000; - tv.tv_sec = i / 1000; - tv.tv_usec = (i % 1000) * 1000; - tohz = tvtohz(&tv); - if (tohz == 0) - tohz = 1; if (!(wait & SCSI_NOSLEEP)) { - for (etick = tick + tohz;;) { + NSEC_TO_TIMESPEC(MSEC_TO_NSEC(i), &ts); + nanouptime(&now); + timespecadd(&now, &ts, &end); + + for (;;) { ccb->ccb_state = CISS_CCB_POLL; - CISS_DPRINTF(CISS_D_CMD, ("tsleep(%d) ", tohz)); - if (tsleep(ccb, PRIBIO + 1, "ciss_cmd", - tohz) == EWOULDBLOCK) { + nsecs = TIMESPEC_TO_NSEC(&ts); + CISS_DPRINTF(CISS_D_CMD, ("tsleep_nsec(%llu) ", nsecs)); + ret = tsleep_nsec(ccb, PRIBIO + 1, "ciss_cmd", nsecs); + if (ret == EWOULDBLOCK) break; - } if (ccb->ccb_state != CISS_CCB_ONQ) { - tohz = etick - tick; - if (tohz <= 0) + nanouptime(&now); + if (timespeccmp(&end, &now, <=)) break; + timespecsub(&end, &now, &ts); CISS_DPRINTF(CISS_D_CMD, ("T")); continue; } |