summaryrefslogtreecommitdiff
path: root/sys/scsi
diff options
context:
space:
mode:
authorcheloha <cheloha@cvs.openbsd.org>2020-01-22 00:17:47 +0000
committercheloha <cheloha@cvs.openbsd.org>2020-01-22 00:17:47 +0000
commit91fa0f39f49809d9110de9b084844c6ed57a24e8 (patch)
treea452caa483e3a5656512c3942d1e04dbb0c2e31f /sys/scsi
parent5aa7556e4d812af3a62e4492f999c068d39cc536 (diff)
scsi_delay(): sleep without lbolt
If we want to sleep for a multiple of seconds we can do that without involving lbolt. This may cause some paths to sleep longer than they have on average, as sleeping on lbolt wakes you up within one second, not after one second. If this is a problem we will need to shorten the intervals given to scsi_delay(). With insight from deraadt@. ok krw@
Diffstat (limited to 'sys/scsi')
-rw-r--r--sys/scsi/scsi_base.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c
index 114b1d1f7d8..4befb67ddc3 100644
--- a/sys/scsi/scsi_base.c
+++ b/sys/scsi/scsi_base.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsi_base.c,v 1.260 2019/12/06 13:53:26 krw Exp $ */
+/* $OpenBSD: scsi_base.c,v 1.261 2020/01/22 00:17:46 cheloha Exp $ */
/* $NetBSD: scsi_base.c,v 1.43 1997/04/02 02:29:36 mycroft Exp $ */
/*
@@ -1559,6 +1559,8 @@ scsi_xs_error(struct scsi_xfer *xs)
int
scsi_delay(struct scsi_xfer *xs, int seconds)
{
+ int ret;
+
switch (xs->flags & (SCSI_POLL | SCSI_NOSLEEP)) {
case SCSI_POLL:
delay(1000000 * seconds);
@@ -1571,12 +1573,11 @@ scsi_delay(struct scsi_xfer *xs, int seconds)
return EIO;
}
- while (seconds-- > 0) {
- if (tsleep_nsec(&lbolt, PRIBIO|PCATCH, "scbusy", INFSLP)) {
- /* Signal == abort xs. */
- return EIO;
- }
- }
+ ret = tsleep_nsec(&ret, PRIBIO|PCATCH, "scbusy", SEC_TO_NSEC(seconds));
+
+ /* Signal == abort xs. */
+ if (ret == ERESTART || ret == EINTR)
+ return EIO;
return ERESTART;
}