Subject: Re: problems with ahc vs. format command
To: Chuck Silvers <chuq@chuq.com>
From: Manuel Bouyer <bouyer@antioche.lip6.fr>
List: tech-kern
Date: 06/11/2001 21:54:21
--CE+1k2dSO48ffgeK
Content-Type: text/plain; charset=us-ascii

On Sun, Jun 10, 2001 at 06:05:20PM -0700, Chuck Silvers wrote:
> the first two lines appear immediately, the rest appear after a 10-second
> pause.
> 
> there are problems with formatting with a ncr53c9x adapter as well.
> I've opened PR 13160 for this collection of format problems.

OK, there are interger overflow problems in both drivers, for such a long
(6 hours) timeout. ncr53c9x.c tried to deal with this, but it fails anyway
for long timeouts, for hz <= 100.
Can you try the attached patches ?

I wonder how many other drivers have this problem ...

--
Manuel Bouyer <bouyer@antioche.eu.org>
--

--CE+1k2dSO48ffgeK
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="aic7xxx.c.diff"

--- aic7xxx.c.orig	Mon Jun 11 21:47:59 2001
+++ aic7xxx.c	Mon Jun 11 21:50:21 2001
@@ -3336,7 +3336,8 @@
 
 			if (!(txs->xs_control & XS_CTL_POLL)) {
 				callout_reset(&scbp->xs->xs_callout,
-				    (scbp->xs->timeout * hz) / 1000,
+				    ((u_int64_t)scbp->xs->timeout *
+				     (u_int64_t)hz) / 1000,
 				    ahc_timeout, scbp);
 			}
 			scbp = LIST_NEXT(scbp, plinks);
@@ -4063,7 +4064,8 @@
 	scb->flags |= SCB_ACTIVE;
 
 	if (!(xs->xs_control & XS_CTL_POLL))
-		callout_reset(&scb->xs->xs_callout, (xs->timeout * hz) / 1000,
+		callout_reset(&scb->xs->xs_callout,
+		    ((u_int64_t)xs->timeout * (u_int64_t)hz) / 1000,
 		    ahc_timeout, scb);
 
 	if ((scb->flags & SCB_TARGET_IMMEDIATE) != 0) {
@@ -4674,7 +4676,8 @@
 				newtimeout = MAX(active_scb->xs->timeout,
 						 scb->xs->timeout);
 				callout_reset(&scb->xs->xs_callout,
-				    (newtimeout * hz) / 1000,
+				    ((u_int64_t)newtimeout *
+				     (u_int64_t)hz) / 1000,
 				    ahc_timeout, scb);
 				splx(s);
 				return;

--CE+1k2dSO48ffgeK
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="ncr53c9x.c.diff"

--- ncr53c9x.c.orig	Mon Jun 11 21:43:40 2001
+++ ncr53c9x.c	Mon Jun 11 21:47:46 2001
@@ -636,14 +636,8 @@
 	 * always possible that the interrupt may never happen.
 	 */
 	if ((ecb->xs->xs_control & XS_CTL_POLL) == 0) {
-		int timeout = ecb->timeout;
-
-		if (hz > 100 && timeout > 1000)
-			timeout = (timeout / 1000) * hz;
-		else
-			timeout = (timeout * hz) / 1000;
-
-		callout_reset(&ecb->xs->xs_callout, timeout,
+		callout_reset(&ecb->xs->xs_callout,
+		    ((u_int64_t)ecb->timeout * (u_int64_t)hz) / 1000,
 		    ncr53c9x_timeout, ecb);
 	}
 
@@ -2852,8 +2846,6 @@
 	ecb->flags |= ECB_ABORT;
 
 	if (ecb == sc->sc_nexus) {
-		int timeout;
-
 		/*
 		 * If we're still selecting, the message will be scheduled
 		 * after selection is complete.
@@ -2864,12 +2856,8 @@
 		/*
 		 * Reschedule timeout.
 		 */
-		timeout = ecb->timeout;
-		if (hz > 100 && timeout > 1000)
-			timeout = (timeout / 1000) * hz;
-		else
-			timeout = (timeout * hz) / 1000;
-		callout_reset(&ecb->xs->xs_callout, timeout,
+		callout_reset(&ecb->xs->xs_callout,
+		    ((u_int64_t)ecb->timeout * (u_int64_t)hz) / 1000,
 		    ncr53c9x_timeout, ecb);
 	} else {
 		/*

--CE+1k2dSO48ffgeK--