NetBSD Problem Report #10575

Received: (qmail 21671 invoked from network); 13 Jul 2000 03:22:54 -0000
Message-Id: <200007130322.e6D3Mmj00386@dahan.metonymy.com>
Date: Wed, 12 Jul 2000 22:22:48 -0500 (CDT)
From: Dave Huang <khym@bga.com>
Reply-To: khym@bga.com
To: gnats-bugs@gnats.netbsd.org
Subject: siop driver can't handle large timeouts
X-Send-Pr-Version: 3.95

>Number:         10575
>Category:       kern
>Synopsis:       siop driver can't handle large timeouts
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jul 13 03:23:00 +0000 2000
>Closed-Date:    Sun Jul 30 16:46:19 +0000 2000
>Last-Modified:  Sun Jul 30 16:46:19 +0000 2000
>Originator:     Dave Huang
>Release:        NetBSD-1.5_ALPHA as of July 11, 2000
>Organization:
Name: Dave Huang     |   Mammal, mammal / their names are called /
INet: khym@bga.com   |   they raise a paw / the bat, the cat /
FurryMUCK: Dahan     |   dolphin and dog / koala bear and hog -- TMBG
Dahan: Hani G Y+C 23 Y++ L+++ W- C++ T++ A+ E+ S++ V++ F- Q+++ P+ B+ PA+ PL++
>Environment:

System: NetBSD dahan.metonymy.com 1.5_ALPHA NetBSD 1.5_ALPHA (SPIFF) #375: Wed Jul 12 21:43:55 CDT 2000 khym@dahan.metonymy.com:/usr/src.local/sys/arch/i386/compile/SPIFF i386


>Description:
	The timeout calculation in the siop driver overflows a 32-bit int
if the requested timeout is sufficiently large... for example, scsictl's
low level format option asks for 21600000ms (6 hours); if hz=100 (i386),
21600000 * hz = 2160000000 (0x80BEFC00), slightly too big for a signed
int.
>How-To-Repeat:
	Try to do a low level format with scsictl. E.g.
# scsictl /dev/rsd3d format
sd3(siop1:1:0): command timeout
siop1: scsi bus reset
cmd 0xc05e28d0 (target 1) in reset list
cmd 0xc05e28d0 about to be processed
siop1: target 1 now synchronous at 5.0Mhz, offset 8
siop1: target 0 now synchronous at 10.0Mhz, offset 8

>Fix:
This seems to work, although it increases the granularity to 1 second...

--- /usr/src/sys/dev/ic/siop.c	Tue Jun 27 05:27:17 2000
+++ siop.c	Wed Jul 12 21:43:25 2000
@@ -1355,8 +1355,8 @@
 					    XS_CTL_POLL) == 0) {
 						/* start exire timer */
 						timeout =
-						    siop_cmd->xs->timeout *
-						    hz / 1000;
+						    siop_cmd->xs->timeout /
+						    1000 * hz;
 						if (timeout == 0)
 							timeout = 1;
 						callout_reset(
>Release-Note:
>Audit-Trail:

From: Manuel Bouyer <bouyer@antioche.lip6.fr>
To: Dave Huang <khym@bga.com>
Cc: gnats-bugs@gnats.netbsd.org, tech-kern@netbsd.org
Subject: Re: kern/10575: siop driver can't handle large timeouts
Date: Tue, 18 Jul 2000 21:02:24 +0200

 On Wed, Jul 12, 2000 at 10:22:48PM -0500, Dave Huang wrote:
 > 	The timeout calculation in the siop driver overflows a 32-bit int
 > if the requested timeout is sufficiently large... for example, scsictl's
 > low level format option asks for 21600000ms (6 hours); if hz=100 (i386),
 > 21600000 * hz = 2160000000 (0x80BEFC00), slightly too big for a signed
 > int.

 The problem is more critical on alpha, where hz is > 1000
 > [...]
 > >Fix:
 > This seems to work, although it increases the granularity to 1 second...

 This can be a problem, some commands requires much less than 1s.
 What about using 64bit integers instead ?

 > 
 > --- /usr/src/sys/dev/ic/siop.c	Tue Jun 27 05:27:17 2000
 > +++ siop.c	Wed Jul 12 21:43:25 2000
 > @@ -1355,8 +1355,8 @@
 >  					    XS_CTL_POLL) == 0) {
 >  						/* start exire timer */
 >  						timeout =
 > -						    siop_cmd->xs->timeout *
 > -						    hz / 1000;
 > +						    siop_cmd->xs->timeout /
 > +						    1000 * hz;
 >  						if (timeout == 0)
 >  							timeout = 1;
 >  						callout_reset(

 --
 Manuel Bouyer <bouyer@antioche.eu.org>
 --
State-Changed-From-To: open->feedback 
State-Changed-By: bouyer 
State-Changed-When: Thu Jul 27 14:28:49 PDT 2000 
State-Changed-Why:  
Can you try sys/dev/ic/siop.c rev 1.27 ? I think I've fixed the problem, 
but in a different way (64bit arithmetic). 
State-Changed-From-To: feedback->closed 
State-Changed-By: bouyer 
State-Changed-When: Sun Jul 30 09:45:41 PDT 2000 
State-Changed-Why:  
Fix tested by author, and pulled up to 1.5. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.