NetBSD Problem Report #4263

Received: (qmail 16805 invoked from network); 11 Oct 1997 21:44:30 -0000
Message-Id: <199710111516.IAA05573@bsdpc.celtech.com>
Date: Sat, 11 Oct 1997 08:16:11 -0700 (PDT)
From: dms@celtech.com
Reply-To: dms@celtech.com
To: gnats-bugs@gnats.netbsd.org
Subject: com driver race condition
X-Send-Pr-Version: 3.95

>Number:         4263
>Category:       kern
>Synopsis:       com driver can hang when used as serial console
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    mycroft
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 11 14:50:01 +0000 1997
>Closed-Date:    Sun Jul 04 08:55:38 +0000 2004
>Last-Modified:  Mon Jul 05 21:58:10 +0000 2004
>Originator:     David M. Stanhope Dms
>Release:        current
>Organization:
cts

>Environment:
netbsd-i386

System: NetBSD bsdpc.celtech.com 1.2G NetBSD 1.2G (NETBSD) #1: Sun Oct 5 07:56:36 PDT 1997 dms@bsdpc.celtech.com:/usr4/netbsd/src/sys/arch/i386/compile/NETBSD i386


>Description:
        when using the com.c driver as a serial console, a race condition
        exist that can easily hang the console.  The problem occurs
        when there are lots of kernal printf's occuring and at the same
        time normal console output activity is also occuring. The problem
        happens when there is pending data in the normal serial output queue
        in the device driver, it has output a character, and is waiting for a
        tranmit interrupt before outputing another character. If while
        waiting for the transmit interrupt, a kernal printf call is made to
        'com_common_putc', this function disables the serial interrupts,
        waits for the transmit register to come free, outputs its character,
        and then again waits for the transmit register to come free,
        then it insures any pending interrupt is cleared, re-enables
        interrupts and returns. Since all pending interrupts for this port
        were cleared, the rest of the com driver never get an interrupt to
        say that it can continue output, so normal output hangs, while
        kernal console output can still happen.
>How-To-Repeat:
        on a serial console enabled machine (using mi com.c), try to use
        the console while kernal output occurs, there is a high probability
        that you will hang the console.
>Fix:
        remove the 'bus_space_read' at the end of 'com_common_putc' which 
        clears the interrupts, let the interrupts occur and let the normal
        part of the device driver handle them, even if no normal output
        is occuring, the driver will just ignore the interrupts and these
        extra interrupts only occur when kernal printf's are happening so
        this should not be a loss. This has worked well on older com.c
        drivers, looks the same in current but not tested locally yet.



>Release-Note:
>Audit-Trail:

From: Martin Husemann <martin@rumolt.teuto.de>
To: dms@celtech.com
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: kern/4263: com driver race condition
Date: Sun, 12 Oct 1997 18:58:02 +0200 (MEST)

 I'm experiencing a hang probably related to the one described here.

 Since I'm using a serial console at 19200 baud nearly every time
 I boot the computer for the first time it will hang right after printing

 fd0 at fdc0 drive 0: 1.44MB, 80 cyl, 2 head, 18 sec
 biomask 840 netmask 9840 ttymask 9842
 ISDN PPP #0 attached to interface ppp0
 ISDN PPP #1 attached to interface ppp1
 boot device: sd0
 root on sd0a dumps on sd0b
 root file system type: ffs
 init: copying out path `/sbin/init'

 On some kernel configurations (whith more debug output on attach time of some
 pseudo-devices) I never was able to boot into single user, but most of the
 time can come up to multi user. So the time between starting /sbin/init and
 first output from it (longer in multi-user-boot) and the amount of console
 output seem to be related.

 Anyway, the proposed fix didn't solve my problem.


 Martin
Responsible-Changed-From-To: kern-bug-people->mycroft 
Responsible-Changed-By: hwr 
Responsible-Changed-When: Sun May 2 13:46:10 PDT 1999 
Responsible-Changed-Why:  
Charles is among those, who new com.c best. 

From: "Charles M. Hannum" <mycroft@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/4263 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->Closed 
State-Changed-By: mycroft 
State-Changed-When: Sun Jul 4 08:11:01 UTC 2004 
State-Changed-Why:  
Incorporated the suggested change. 
State-Changed-From-To: Closed->closed 
State-Changed-By: mycroft 
State-Changed-When: Sun Jul 4 08:55:32 UTC 2004 
State-Changed-Why:  
. 

From: Havard Eidnes <he@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/4263 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:

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.