aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/ahci/ahci.c
diff options
context:
space:
mode:
authorSteven Hartland <smh@FreeBSD.org>2014-11-21 21:01:24 +0000
committerSteven Hartland <smh@FreeBSD.org>2014-11-21 21:01:24 +0000
commit85c9dd9d895261632d58cf98da6608b93dd5d7f8 (patch)
tree5ebdafcf9900ec8ee871257dadfca8fdc7f4aa95 /sys/dev/ahci/ahci.c
parent7db6c5cde6083b3cf76f1f85225c19052722dfd5 (diff)
downloadsrc-85c9dd9d895261632d58cf98da6608b93dd5d7f8.tar.gz
src-85c9dd9d895261632d58cf98da6608b93dd5d7f8.zip
Prevent overflow issues in timeout processing
Previously, any timeout value for which (timeout * hz) will overflow the signed integer, will give weird results, since callout(9) routines will convert negative values of ticks to '1'. For unsigned integer overflow we will get sufficiently smaller timeout values than expected. Switch from callout_reset, which requires conversion to int based ticks to callout_reset_sbt to avoid this. Also correct isci to correctly resolve ccb timeout. This was based on the original work done by Eygene Ryabinkin <rea@freebsd.org> back in 5 Aug 2011 which used a macro to help avoid the overlow. Differential Revision: https://reviews.freebsd.org/D1157 Reviewed by: mav, davide MFC after: 1 month Sponsored by: Multiplay
Notes
Notes: svn path=/head/; revision=274819
Diffstat (limited to 'sys/dev/ahci/ahci.c')
-rw-r--r--sys/dev/ahci/ahci.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/sys/dev/ahci/ahci.c b/sys/dev/ahci/ahci.c
index f6d5d4aea176..583983bff7ec 100644
--- a/sys/dev/ahci/ahci.c
+++ b/sys/dev/ahci/ahci.c
@@ -1582,8 +1582,8 @@ ahci_execute_transaction(struct ahci_slot *slot)
return;
}
/* Start command execution timeout */
- callout_reset(&slot->timeout, (int)ccb->ccb_h.timeout * hz / 2000,
- (timeout_t*)ahci_timeout, slot);
+ callout_reset_sbt(&slot->timeout, SBT_1MS * ccb->ccb_h.timeout / 2,
+ 0, (timeout_t*)ahci_timeout, slot, 0);
return;
}
@@ -1618,9 +1618,9 @@ ahci_rearm_timeout(struct ahci_channel *ch)
continue;
if ((ch->toslots & (1 << i)) == 0)
continue;
- callout_reset(&slot->timeout,
- (int)slot->ccb->ccb_h.timeout * hz / 2000,
- (timeout_t*)ahci_timeout, slot);
+ callout_reset_sbt(&slot->timeout,
+ SBT_1MS * slot->ccb->ccb_h.timeout / 2, 0,
+ (timeout_t*)ahci_timeout, slot, 0);
}
}
@@ -1652,9 +1652,9 @@ ahci_timeout(struct ahci_slot *slot)
slot->state = AHCI_SLOT_EXECUTING;
}
- callout_reset(&slot->timeout,
- (int)slot->ccb->ccb_h.timeout * hz / 2000,
- (timeout_t*)ahci_timeout, slot);
+ callout_reset_sbt(&slot->timeout,
+ SBT_1MS * slot->ccb->ccb_h.timeout / 2, 0,
+ (timeout_t*)ahci_timeout, slot, 0);
return;
}