NetBSD Problem Report #10974

Received: (qmail 15575 invoked from network); 7 Sep 2000 21:42:54 -0000
Message-Id: <20000907214252.00A0153C1@woffi.planix.com>
Date: Thu,  7 Sep 2000 17:42:52 -0400 (EDT)
From: Andreas Wrede <andreas@planix.com>
Sender: andreas@woffi.planix.com
Reply-To: andreas@planix.com
To: gnats-bugs@gnats.netbsd.org
Subject: Infinite Interrupt loop in com.c
X-Send-Pr-Version: 3.95

>Number:         10974
>Category:       kern
>Synopsis:       Infinite interrupt loop in com.c
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    mycroft
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Sep 07 21:43:00 +0000 2000
>Closed-Date:    Sun Jul 04 15:06:25 +0000 2004
>Last-Modified:  Mon Jul 05 21:58:00 +0000 2004
>Originator:     Andreas Wrede
>Release:        1.5_ALPHA2
>Organization:
Planix, Inc
>Environment:

System: NetBSD woffi.planix.com 1.5_ALPHA2 NetBSD 1.5_ALPHA2 (PLANIX-IPv6) #0: Thu Sep 7 12:21:01 EDT 2000 root@woffi.planix.com:/usr/src/sys/arch/i386/compile/WOFFI i386


>Description:
The comintr routine in sys/dev/ic/com.c checks for and services additional
interrupts requests before exiting. This can cause the system to freeze
with interrupts disabled if the com device produces an interrupt strom,
as it did for me with a Lava Quattro-PCI 4-port serial card. 

>How-To-Repeat:
Install faulty com hardware. Boot. Observe that machine is non-reponsive
after the "Setting tty flags." message.
>Fix:
The patch below forces the loop to exit every 10000 interrupts. It produces
a message if we reach that limit and more importantly, it lets the you 
get into the kernel debugger :-). The number is 10000 is magic, maybe 100
is more appropriate?


Index: com.c
===================================================================
RCS file: //u5/NetBSD-CVS/main//syssrc/sys/dev/ic/com.c,v
retrieving revision 1.175
diff -c -r1.175 com.c
*** com.c	2000/08/18 13:22:39	1.175
--- com.c	2000/09/07 21:17:22
***************
*** 1929,1934 ****
--- 1929,1935 ----
  	u_char *put, *end;
  	u_int cc;
  	u_char lsr, iir;
+ 	int looplim = 10000;

  	if (COM_ISALIVE(sc) == 0)
  		return (0);
***************
*** 2099,2106 ****

  			sc->sc_st_check = 1;
  		}
! 	} while (!ISSET((iir = bus_space_read_1(iot, ioh, com_iir)), IIR_NOPEND));

  	/*
  	 * Done handling any receive interrupts. See if data can be
  	 * transmitted as well. Schedule tx done event if no data left
--- 2100,2110 ----

  			sc->sc_st_check = 1;
  		}
! 		looplim--;
! 	} while (!ISSET((iir = bus_space_read_1(iot, ioh, com_iir)), IIR_NOPEND) && looplim);

+ 	if (!looplim) 
+ 		printf("%s: excessive interrupts\n", sc->sc_dev.dv_xname);
  	/*
  	 * Done handling any receive interrupts. See if data can be
  	 * transmitted as well. Schedule tx done event if no data left
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: kern-bug-people->fredb 
Responsible-Changed-By: tls 
Responsible-Changed-When: Wed Mar 31 21:55:57 UTC 2004 
Responsible-Changed-Why:  
I discussed a related problem with fredb some time ago and I was under 
the impression that he was working on changes that would address this. 
If I'm wrong, he can of course just give the PR back to kern-bug-people, 
wher eit can languish forever again. :-) 

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@gnats.netbsd.org
Cc: tls@netbsd.org, kern-bug-people@netbsd.org, fredb@netbsd.org
Subject: Re: kern/10974
Date: Thu, 1 Apr 2004 00:13:59 +0200

 On Wed, Mar 31, 2004 at 10:10:24PM -0000, tls@netbsd.org wrote:
 > If I'm wrong, he can of course just give the PR back to kern-bug-people,
 > wher eit can languish forever again. :-)

 That's ok, at least with this half of kern-bug-people. (Hint: join now!)

 Martin

From: Frederick Bruckman <fredb@immanent.net>
To: gnats-bugs@gnats.netbsd.org
Cc: tls@netbsd.org, kern-bug-people@netbsd.org,
  Andreas Wrede <andreas@planix.com>
Subject: Re: kern/10974
Date: Thu, 1 Apr 2004 10:15:59 -0600 (CST)

 On Wed, 31 Mar 2004 tls@netbsd.org wrote:

 > I discussed a related problem with fredb some time ago and I was under
 > the impression that he was working on changes that would address this.
 > If I'm wrong, he can of course just give the PR back to kern-bug-people,
 > wher eit can languish forever again. :-)

 I am indeed experimenting with different hardware and hacking at the
 com driver, trying to get good performance out of NetBSD with an ISDN
 T/A.

 This problem, though, was supposed to have been addressed by rev 1.88
 of "sys/dev/ic/com.c". That clears and resets the interrupt enable
 register in the case of RXRDY being set, but no data to receive. It
 obviously didn't work in this case. I suggest a proper fix for this PR
 will build on that. We could set a flag, so if IIR_RXRDY is serviced
 twice in a row without LSR_RXRDY ever being set, then we clear
 com_ier, leave it cleared until next open, and emit a diagnostic -- no
 magic number.

 I would also like to point out that the hardware interrupt dispatcher
 is twisty, and doesn't obviously check and service the interrupts in
 priority order, even though it effectively does so (mostly). I have
 patches to re-order and make it easier to follow, but the benefits, so
 far, have been elusive. Andreas, if you're still interested in NetBSD,
 and if you still have the problem hardware, I'll prepare a patch. If
 not, I'll be sure to work a "failsafe" into the other changes I intend
 to propose for the com(4)  driver.

 Regards,

 Frederick

From: Andreas Wrede <andreas@planix.com>
To: Frederick Bruckman <fredb@immanent.net>
Cc: tls@netbsd.org, kern-bug-people@netbsd.org, gnats-bugs@gnats.netbsd.org
Subject: Re: kern/10974
Date: Thu, 1 Apr 2004 11:45:16 -0500

 --Apple-Mail-2--548498355
 Content-Transfer-Encoding: 7bit
 Content-Type: text/plain; charset=US-ASCII; format=flowed


 On Apr 1, 2004, at 11:15, Frederick Bruckman wrote:

 > On Wed, 31 Mar 2004 tls@netbsd.org wrote:
 >
 >> I discussed a related problem with fredb some time ago and I was under
 >> the impression that he was working on changes that would address this.
 >> If I'm wrong, he can of course just give the PR back to 
 >> kern-bug-people,
 >> wher eit can languish forever again. :-)
 >
 > I am indeed experimenting with different hardware and hacking at the
 > com driver, trying to get good performance out of NetBSD with an ISDN
 > T/A.
 >
 > This problem, though, was supposed to have been addressed by rev 1.88
 > of "sys/dev/ic/com.c". That clears and resets the interrupt enable
 > register in the case of RXRDY being set, but no data to receive. It
 > obviously didn't work in this case. I suggest a proper fix for this PR
 > will build on that. We could set a flag, so if IIR_RXRDY is serviced
 > twice in a row without LSR_RXRDY ever being set, then we clear
 > com_ier, leave it cleared until next open, and emit a diagnostic -- no
 > magic number.
 >
 > I would also like to point out that the hardware interrupt dispatcher
 > is twisty, and doesn't obviously check and service the interrupts in
 > priority order, even though it effectively does so (mostly). I have
 > patches to re-order and make it easier to follow, but the benefits, so
 > far, have been elusive. Andreas, if you're still interested in NetBSD,
 > and if you still have the problem hardware, I'll prepare a patch. If
 > not, I'll be sure to work a "failsafe" into the other changes I intend
 > to propose for the com(4)  driver.

 I am definitely still interested in NetBSD but unfortunately don't have 
 the faulty serial card any more (it was warranty-exchanged for a 
 working card).  A failsafe would be great - anything that improves 
 robustness, especially in the face of faulty hardware, is a win!

 Thanks for looking into this.
 -- 
 	aew

 --Apple-Mail-2--548498355
 content-type: application/pgp-signature; x-mac-type=70674453;
 	name=PGP.sig
 content-description: This is a digitally signed message part
 content-disposition: inline; filename=PGP.sig
 content-transfer-encoding: 7bit

 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.2.4 (Darwin)

 iD8DBQFAbEcjEh/h9J/TQyERAi+lAKCENQvVOS9sAYq4I485Rhi77vnlZACdGAJG
 7n/0DVXQyO4tC5vVaYwqmPw=
 =uGSq
 -----END PGP SIGNATURE-----

 --Apple-Mail-2--548498355--

Responsible-Changed-From-To: fredb->mycroft 
Responsible-Changed-By: mycroft 
Responsible-Changed-When: Sun Jul 4 07:01:35 UTC 2004 
Responsible-Changed-Why:  
. 

From: "Charles M. Hannum" <mycroft@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/10974 CVS commit: src/sys/dev/ic
Date: Sun,  4 Jul 2004 08:09:03 +0000 (UTC)

 Module Name:	src
 Committed By:	mycroft
 Date:		Sun Jul  4 08:09:03 UTC 2004

 Modified Files:
 	src/sys/dev/ic: com.c

 Log Message:
 Incorporate 4 changes that have been suggested:
 * At high speed, set the FIFO trigger to the maximum value to reduce interrupt
   load.  PR 15448.
 * Handler the case of IIR=RXRDY and LSR=!LSR_RCV_MASK differently, to avoid a
   hang with some chips.  PR 21184, and possibly PR 10974 and PR 8248.
 * Remove the extra wait at the end of com_common_putc(), after writing a
   character out, so that we get another TXRDY interrupt.  This prevents stalls
   when normal output and kernel output are mixed.  PR 4263.
 * Do not "preload" the TX FIFO; wait for a TXRDY interrupt to come in after
   enabling it.


 To generate a diff of this commit:
 cvs rdiff -r1.227 -r1.228 src/sys/dev/ic/com.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->feedback 
State-Changed-By: mycroft 
State-Changed-When: Sun Jul 4 09:00:07 UTC 2004 
State-Changed-Why:  
If you still have this hardware, can you test it with com.c 1.228? 

From: Andreas Wrede <andreas@planix.com>
To: gnats-bugs@gnats.netbsd.org
Cc: mycroft@netbsd.org
Subject: Re: kern/10974
Date: Sun, 4 Jul 2004 07:25:40 -0400

 --Apple-Mail-1--1036009364
 Content-Transfer-Encoding: 7bit
 Content-Type: text/plain; charset=US-ASCII; format=flowed


 On 4-Jul-04, at 5:01 AM, mycroft@netbsd.org wrote:

 > Synopsis: Infinite interrupt loop in com.c
 >
 > State-Changed-From-To: open->feedback
 > State-Changed-By: mycroft
 > State-Changed-When: Sun Jul 4 09:00:07 UTC 2004
 > State-Changed-Why:
 > If you still have this hardware, can you test it with com.c 1.228?

 Sorry, no. But my assortment of serial cards (2-port, 4-port, Lava and 
 others) works fine with com.c 1.228.
 -- 
 	aew

 --Apple-Mail-1--1036009364
 content-type: application/pgp-signature; x-mac-type=70674453;
 	name=PGP.sig
 content-description: This is a digitally signed message part
 content-disposition: inline; filename=PGP.sig
 content-transfer-encoding: 7bit

 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.2.4 (Darwin)

 iD8DBQFA5+k0Eh/h9J/TQyERAvp2AJ9PhjbuljjgbRNBPXsGOA8h0OunEACg39DE
 CRRWxmZd83tP6Otqs0YDdmw=
 =zsaa
 -----END PGP SIGNATURE-----

 --Apple-Mail-1--1036009364--

State-Changed-From-To: feedback->closed 
State-Changed-By: mycroft 
State-Changed-When: Sun Jul 4 15:04:47 UTC 2004 
State-Changed-Why:  
See user comment. 

From: Havard Eidnes <he@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/10974 CVS commit: [netbsd-2-0] src/sys/dev/ic
Date: Mon,  5 Jul 2004 21:57:45 +0000 (UTC)

 Module Name:	src
 Committed By:	he
 Date:		Mon Jul  5 21:57:45 UTC 2004

 Modified Files:
 	src/sys/dev/ic [netbsd-2-0]: com.c

 Log Message:
 Pull up revisions 1.228-1.230 (requested by mycroft in ticket #603):
   Incorporate 4 changes:
    o At high speed, set the FIFO trigger to a higher
      value to reduce interrupt load.  Fixes PR#15448.
    o Handle the case of IIR=RXRDY and LSR=!LSR_RCV_MASK
      differently, to avoid a hang with some chips.  Fixes
      PR#21184, and possibly PR#10974 and PR#8248.
    o Remove the extra wait at the end of com_common_putc(),
      after writing a character out, so that we get another
      TXRDY interrupt.  This prevents stalls when normal
      output and kernel output are mixed.  Fixes PR#4263.
    o Do not ``preload'' the TX FIFO; wait for a TXRDY
      interrupt to come in after enabling it.


 To generate a diff of this commit:
 cvs rdiff -r1.224.2.1 -r1.224.2.2 src/sys/dev/ic/com.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>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.