NetBSD Problem Report #21184
Received: (qmail 14800 invoked by uid 605); 14 Apr 2003 15:25:35 -0000
Message-Id: <200304141525.h3EFPWOl008608@o065157.ap.plala.or.jp>
Date: Tue, 15 Apr 2003 00:25:30 +0900 (JST)
From: itohy@netbsd.org
Sender: gnats-bugs-owner@netbsd.org
Reply-To: itohy@netbsd.org
To: gnats-bugs@gnats.netbsd.org
Subject: com (RS-232C serial) locks the kernel when external device is turned off
X-Send-Pr-Version: 3.95
>Number: 21184
>Category: kern
>Synopsis: com (RS-232C serial) locks the kernel when external device is turned off
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: mycroft
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Apr 14 15:26:00 +0000 2003
>Closed-Date: Mon Jul 05 15:50:44 +0000 2004
>Last-Modified: Mon Jul 05 21:58:02 +0000 2004
>Originator: ITOH Yasufumi
>Release: NetBSD 1.6L
>Organization:
>Environment:
System: NetBSD pino.my.domain 1.6L NetBSD 1.6L (PINO) #376: Sun Apr 13 23:15:10 JST 2003 itohy@pino.my.domain:/amd/fmv/w/src/sys/arch/i386/compile/PINO i386
Architecture: i386
Machine: i386
from dmesg:
com0 at pnpbios0 index 14 (PNP0501)
com0: io 3f8-3ff, irq 4
com0: ns16550a, working fifo
>Description:
On one of my machines (L: Toshiba Libretto 100),
when it (L) is used for serial console of an Alpha (A: AlphaStation),
and when A is turned off,
the kernel of console machine (L) locks solid.
The L kernel completely hangs including the keyboard, network
and clock.
When this happens, the IIR register of the com device
reads 0xcc or 0xc4 (data receive interrupt)
but the LSR register reads 0x60 (no data).
The driver tries to clear the interrupt by some magic
(clear IER and back again),
but that doesn't work on this machine (L).
The comintr() will never complete. Hence the hang.
This hang doesn't occur all machines, and probably caused
by minor difference of behavior of com compatible devices.
>How-To-Repeat:
1. Connect Libretto 100 (L) and AlphaStation (A)
with a null-modem cable with flow control
(1-7, 2-3, 3-2, 4-8&6, 5-5, 6&8-4, 7-1).
2. Add the following line to L's /etc/remote.
dec:dv=/dev/tty00:br#9600:pa=none:dc:
3. On L:
# tip dec
4. Turn A on, and then turn A off.
5. The L kernel hangs.
6. Turn A on again.
7. L kernel becomes working again.
>Fix:
The NS 16550 data sheet
<http://www.national.com/pf/PC/PC16550D.html>
says the receiver interrupt is cleared by reading
the data register.
Following to the document, read the data register
(and discard the value) to clear the interrupt.
The "(iir & 0x06) == IIR_RXRDY" matches both 0xcc and 0xc4.
(The literal constant 0x06 should probably be a macro, though.)
--- src/sys/dev/ic/com.c.orig Sat Mar 15 11:17:56 2003
+++ src/sys/dev/ic/com.c Sun Apr 13 22:45:32 2003
@@ -2061,12 +2061,19 @@ comintr(void *arg)
bus_space_write_1(iot, ioh, com_ier, sc->sc_ier);
}
} else {
+#if 0
if ((iir & IIR_IMASK) == IIR_RXRDY) {
bus_space_write_1(iot, ioh, com_ier, 0);
delay(10);
bus_space_write_1(iot, ioh, com_ier,sc->sc_ier);
continue;
}
+#else
+ if ((iir & 0x06) == IIR_RXRDY) {
+ (void) bus_space_read_1(iot, ioh, com_data);
+ continue;
+ }
+#endif
}
msr = bus_space_read_1(iot, ioh, com_msr);
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: kern-bug-people->fvdl
Responsible-Changed-By: perry
Responsible-Changed-When: Wed Apr 23 23:54:42 UTC 2003
Responsible-Changed-Why:
frank said he would take care of it.
Responsible-Changed-From-To: fvdl->mycroft
Responsible-Changed-By: mycroft
Responsible-Changed-When: Sun Jul 4 06:57:08 UTC 2004
Responsible-Changed-Why:
.
From: "Charles M. Hannum" <mycroft@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: pr/21184 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 08:10:17 UTC 2004
State-Changed-Why:
Incorporated the suggested change. Please confirm that this fixes the problem
for you.
From: itohy@netbsd.org (ITOH Yasufumi)
To: gnats-bugs@gnats.netbsd.org
Cc: mycroft@netbsd.org, itohy@netbsd.org
Subject: Re: kern/21184
Date: Mon, 5 Jul 2004 20:33:58 +0900 (JST)
mycroft@netbsd.org writes:
> Incorporated the suggested change. Please confirm that this fixes the problem
> for you.
I confirmed the fix on Libretto 100 with 2.0G kernel (source at July 4, 2004).
Thanks,
--
ITOH Yasufumi
State-Changed-From-To: feedback->closed
State-Changed-By: mycroft
State-Changed-When: Mon Jul 5 15:50:08 UTC 2004
State-Changed-Why:
User says it's fixed.
From: Havard Eidnes <he@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: pr/21184 CVS commit: [netbsd-2-0] src/sys/dev/ic
Date: Mon, 5 Jul 2004 21:57:46 +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:
(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.