From dd63bf99a2e07e9e0fae2c230c2dc6505f21618d Mon Sep 17 00:00:00 2001 From: smh Date: Fri, 21 Nov 2014 21:01:24 +0000 Subject: 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 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 --- sys/dev/arcmsr/arcmsr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sys/dev/arcmsr') diff --git a/sys/dev/arcmsr/arcmsr.c b/sys/dev/arcmsr/arcmsr.c index 4c9210e..f9885d3 100644 --- a/sys/dev/arcmsr/arcmsr.c +++ b/sys/dev/arcmsr/arcmsr.c @@ -2705,7 +2705,9 @@ static void arcmsr_execute_srb(void *arg, bus_dma_segment_t *dm_segs, int nseg, if (pccb->ccb_h.timeout != CAM_TIME_INFINITY) { arcmsr_callout_init(&srb->ccb_callout); - callout_reset(&srb->ccb_callout, ((pccb->ccb_h.timeout + (ARCMSR_TIMEOUT_DELAY * 1000)) * hz) / 1000, arcmsr_srb_timeout, srb); + callout_reset_sbt(&srb->ccb_callout, SBT_1MS * + (pccb->ccb_h.timeout + (ARCMSR_TIMEOUT_DELAY * 1000)), 0, + arcmsr_srb_timeout, srb, 0); srb->srb_flags |= SRB_FLAG_TIMER_START; } } -- cgit v1.1