Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ic Fix negative timeout symptoms caused by integer m...



details:   https://anonhg.NetBSD.org/src/rev/fca3f60cb681
branches:  trunk
changeset: 494217:fca3f60cb681
user:      nisimura <nisimura%NetBSD.org@localhost>
date:      Tue Jul 04 01:10:18 2000 +0000

description:
Fix negative timeout symptoms caused by integer multiply overflow,
which is revealed with larger HZ systems like NetBSD/pmax (256Hz)
and NetBSD/alpha (1024Hz) as reported by PR#8645.  Polled tape
drive access is done with maximum 6 hour timeout which ended up
with negative time and then confused SCSI bus severely.

diffstat:

 sys/dev/ic/ncr53c9x.c |  22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diffs (51 lines):

diff -r 9691c475f28a -r fca3f60cb681 sys/dev/ic/ncr53c9x.c
--- a/sys/dev/ic/ncr53c9x.c     Mon Jul 03 23:40:59 2000 +0000
+++ b/sys/dev/ic/ncr53c9x.c     Tue Jul 04 01:10:18 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ncr53c9x.c,v 1.51 2000/06/05 15:19:42 tsutsui Exp $    */
+/*     $NetBSD: ncr53c9x.c,v 1.52 2000/07/04 01:10:18 nisimura Exp $   */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -541,9 +541,16 @@
         * expecting to come back due to an interrupt, because it is
         * always possible that the interrupt may never happen.
         */
-       if ((ecb->xs->xs_control & XS_CTL_POLL) == 0)
-               callout_reset(&ecb->xs->xs_callout, (ecb->timeout * hz) / 1000,
+       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,
                    ncr53c9x_timeout, ecb);
+       }
 
        /*
         * The docs say the target register is never reset, and I
@@ -2179,6 +2186,8 @@
        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.
@@ -2189,7 +2198,12 @@
                /*
                 * Reschedule timeout.
                 */
-               callout_reset(&ecb->xs->xs_callout, (ecb->timeout * hz) / 1000,
+               timeout = ecb->timeout;
+               if (hz > 100 && timeout > 1000)
+                       timeout = (timeout / 1000) * hz;
+               else
+                       timeout = (timeout * hz) / 1000;
+               callout_reset(&ecb->xs->xs_callout, timeout,
                    ncr53c9x_timeout, ecb);
        } else {
                /* The command should be on the nexus list */



Home | Main Index | Thread Index | Old Index