From nobody@FreeBSD.org  Mon Jan 26 11:10:49 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 4444C10657BB
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 26 Jan 2009 11:10:49 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 1B56F8FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 26 Jan 2009 11:10:47 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n0QBAkwR040601
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 26 Jan 2009 11:10:46 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n0QBAkSK040599;
	Mon, 26 Jan 2009 11:10:46 GMT
	(envelope-from nobody)
Message-Id: <200901261110.n0QBAkSK040599@www.freebsd.org>
Date: Mon, 26 Jan 2009 11:10:46 GMT
From: Timo Rikkonen <timo.rikkonen@syncrontech.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: /dev/cuau* ports hang after a while
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         131006
>Category:       kern
>Synopsis:       [uart] /dev/cuau* ports hang after a while
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    marcel
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jan 26 11:20:00 UTC 2009
>Closed-Date:    Mon May 18 22:46:59 UTC 2009
>Last-Modified:  Mon May 18 22:50:02 UTC 2009
>Originator:     Timo Rikkonen
>Release:        7.0 RELEASE /  7.1-RELEASE-p2
>Organization:
Syncron Tech Oy
>Environment:
FreeBSD connect38.dyndns.syncrontech.net 7.1-RELEASE-p2 FreeBSD 7.1-RELEASE-p2 #0: Mon Jan 26 09:38:26 EET 2009     st@connect38.dyndns.syncrontech.net:/usr/src/sys/i386/compile/GENERIC  i386

>Description:
Hi,

We are using "VScom PCI-200L" and "Moxa Technologies, C168H/PCI" -cards for serial ports. After installing 7.0 the ports or the connection to the port hang after a while. A "while" could be half-a-day or 10 minutes.
There is no error message to be seen anywhere.

Not all ports hang at the same time, it could be just one or two of them. Earlier versions (6.2-RELEASE) work just fine.
The ports have different devicenames after 7.0, in 6.2 they were /dev/cuad4-7, now they are /dev/cuau0-3 (uart?)

dmesg-output considering the card:
puc0: <VScom PCI-200L> port 0xbc00-0xbc07,0xb800-0xb807,0xb400-0xb407,0xb000-0xb007 mem 0xfe5ffc00-0xfe5ffc3f irq 21 at device 0.0 on pci1
puc0: [FILTER]
uart0: <16550 or compatible> on puc0
uart0: [FILTER]
uart1: <16550 or compatible> on puc0
uart1: [FILTER]

the same in 6.2:
puc0: <VScom PCI-200L> port 0xbc00-0xbc07,0xb800-0xb807,0xb400-0xb407,0xb000-
0xb007 mem 0xfe5ffc00-0xfe5ffc3f irq 21 at device 0.0 on pci1
sio4: <VScom PCI-200L> on puc0
sio4: type 16550A
sio4: unable to activate interrupt in fast mode - using normal mode
sio5: <VScom PCI-200L> on puc0
sio5: type 16550A
sio5: unable to activate interrupt in fast mode - using normal mode

We have over 20 installations, now two of them have been upgraded to 7.0 with mentioned side effects.

Yours,
Timo Rikkonen
>How-To-Repeat:

>Fix:
In our case we restart the web server, under which all the connection-progams run.

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-i386->ed 
Responsible-Changed-By: remko 
Responsible-Changed-When: Tue Jan 27 18:39:00 UTC 2009 
Responsible-Changed-Why:  
Ed, do you have any idea how this might come between 6 and 7? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=131006 
Responsible-Changed-From-To: ed->marcel 
Responsible-Changed-By: remko 
Responsible-Changed-When: Thu Jan 29 14:59:01 UTC 2009 
Responsible-Changed-Why:  
Hi Marcel, Ed doesn't know about this under 6/7, perhaps you know? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=131006 

From: Roy Badami <roy.badami@globalgraphics.com>
To: freebsd-gnats-submit@FreeBSD.org, timo.rikkonen@syncrontech.com
Cc:  
Subject: Re: kern/131006: [uart] /dev/cuau* ports hang after a while
Date: Wed, 4 Mar 2009 20:17:49 +0000

 I don't know if this is related, but I've had recent problems with a SIIG 
 CyberSerial 4S card (16550-based) under 7.1-RELEASE.
 
 The symptoms were the same, in that the application (SMS Server Tools 3) 
 lost connection with the device connected to the serial port after a while 
 (where a while was generally between a few tens of minutes and a few 
 hours).
 
 I also had one application that could fairly reliably freeze the entire 
 box (i.e. cause FreeBSD to lock up entirely) by accessing the serial port. 
  Unfortunately it requires custom hardware to reproduce this (although the 
 protocol is trivial enough that it the hardware trivially be simulated by 
 another PC.  The protocol is pretty self-explanatory, but if anyone does 
 want to try to reproduce this feel free to ask me to clarify.
 
 Building a kernel without uart(4) - i.e. using sio(4) instead - has solved 
 both the above issues and the system has been behaving solidly for two 
 weeks now.
 
 I've never used this hardware under FreeBSD 6 though (I believe it's one 
 of the SIIG cards with the 10x Crystal and hence not supported before 
 7.0-RELEASE).
 
 Here's the message I posted to freebsd-hardware
 
     
 http://lists.freebsd.org/pipermail/freebsd-hardware/2009-February/005791.html
 
 -roy

From: Marcel Moolenaar <xcllnt@mac.com>
To: bug-followup@FreeBSD.org, timo.rikkonen@syncrontech.com
Cc: roy.badami@globalgraphics.com
Subject: Re: kern/131006: [uart] /dev/cuau* ports hang after a while
Date: Sun, 08 Mar 2009 18:17:17 -0700

 --Boundary_(ID_I9ttDtIKGGbZiYtmZeHtcA)
 Content-type: text/plain; charset=US-ASCII; format=flowed
 Content-transfer-encoding: 7BIT
 
 Timo/Roy,
 
 I don't really know what it means when the port hangs.  I think
 one of the primary causes for this is that the highest priority
 interrupt is not being services (and thus cleared). This avoids
 that the  interrupt pending condition is cleared, which can
 result in a hard hang of the machine (as observed by Roy).  If
 the interrupt is shared with a non-fast interrupt handler, then
 the machine will not hang but the port will. The attached patch
 addresses the problem described above.
 
 Roy: can you tell me if this addresses the lockup.
 Timo/Roy: let me know if this also fixes the port hang.
 
 FYI,
 
 -- 
 Marcel Moolenaar
 xcllnt@mac.com
 
 
 
 --Boundary_(ID_I9ttDtIKGGbZiYtmZeHtcA)
 Content-type: application/octet-stream; x-unix-mode=0644; name=uart7.diff
 Content-transfer-encoding: 7bit
 Content-disposition: attachment; filename=uart7.diff
 
 Index: dev/uart/uart_dev_ns8250.c
 ===================================================================
 --- dev/uart/uart_dev_ns8250.c	(revision 189450)
 +++ dev/uart/uart_dev_ns8250.c	(working copy)
 @@ -50,14 +50,16 @@
  static void
  ns8250_clrint(struct uart_bas *bas)
  {
 -	uint8_t iir;
 +	uint8_t iir, lsr;
  
  	iir = uart_getreg(bas, REG_IIR);
  	while ((iir & IIR_NOPEND) == 0) {
  		iir &= IIR_IMASK;
 -		if (iir == IIR_RLS)
 -			(void)uart_getreg(bas, REG_LSR);
 -		else if (iir == IIR_RXRDY || iir == IIR_RXTOUT)
 +		if (iir == IIR_RLS) {
 +			lsr = uart_getreg(bas, REG_LSR);
 +			if (lsr & (LSR_BI|LSR_FE|LSR_PE))
 +				(void)uart_getreg(bas, REG_DATA);
 +		} else if (iir == IIR_RXRDY || iir == IIR_RXTOUT)
  			(void)uart_getreg(bas, REG_DATA);
  		else if (iir == IIR_MLSC)
  			(void)uart_getreg(bas, REG_MSR);
 @@ -563,7 +565,6 @@
  	ipend = 0;
  	if (iir & IIR_RXRDY) {
  		lsr = uart_getreg(bas, REG_LSR);
 -		uart_unlock(sc->sc_hwmtx);
  		if (lsr & LSR_OE)
  			ipend |= SER_INT_OVERRUN;
  		if (lsr & LSR_BI)
 @@ -571,12 +572,14 @@
  		if (lsr & LSR_RXRDY)
  			ipend |= SER_INT_RXREADY;
  	} else {
 -		uart_unlock(sc->sc_hwmtx);
  		if (iir & IIR_TXRDY)
  			ipend |= SER_INT_TXIDLE;
  		else
  			ipend |= SER_INT_SIGCHG;
  	}
 +	if (ipend == 0)
 +		ns8250_clrint(bas);
 +	uart_unlock(sc->sc_hwmtx);
  	return ((sc->sc_leaving) ? 0 : ipend);
  }
  
 
 --Boundary_(ID_I9ttDtIKGGbZiYtmZeHtcA)--

From: Timo Rikkonen <Timo.Rikkonen@syncrontech.com>
To: Marcel Moolenaar <xcllnt@mac.com>,
        "bug-followup@FreeBSD.org"
	<bug-followup@FreeBSD.org>
Cc: "roy.badami@globalgraphics.com" <roy.badami@globalgraphics.com>
Subject: RE: kern/131006: [uart] /dev/cuau* ports hang after a while
Date: Mon, 9 Mar 2009 08:25:07 +0200

 Hi,=20
 
 My problems were solved by building the kernel without uart. The ports were=
  after that sio's and no more hanging occurred.
 
 -Timo
 =20
 
 -----Original Message-----
 From: Marcel Moolenaar [mailto:xcllnt@mac.com]=20
 Sent: 9. maaliskuuta 2009 3:17
 To: bug-followup@FreeBSD.org; Timo Rikkonen
 Cc: roy.badami@globalgraphics.com
 Subject: Re: kern/131006: [uart] /dev/cuau* ports hang after a while
 
 Timo/Roy,
 
 I don't really know what it means when the port hangs.  I think one of the =
 primary causes for this is that the highest priority interrupt is not being=
  services (and thus cleared). This avoids that the  interrupt pending condi=
 tion is cleared, which can result in a hard hang of the machine (as observe=
 d by Roy).  If the interrupt is shared with a non-fast interrupt handler, t=
 hen the machine will not hang but the port will. The attached patch address=
 es the problem described above.
 
 Roy: can you tell me if this addresses the lockup.
 Timo/Roy: let me know if this also fixes the port hang.
 
 FYI,
 
 --
 Marcel Moolenaar
 xcllnt@mac.com
 
 
State-Changed-From-To: open->patched 
State-Changed-By: marcel 
State-Changed-When: Wed Apr 8 00:14:59 UTC 2009 
State-Changed-Why:  
Fix committed to head. MFC planned in 3 days. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=131006 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/131006: commit references a PR
Date: Wed,  8 Apr 2009 00:14:21 +0000 (UTC)

 Author: marcel
 Date: Wed Apr  8 00:14:06 2009
 New Revision: 190834
 URL: http://svn.freebsd.org/changeset/base/190834
 
 Log:
   Fix hangs caused by hardware that signals receive errors
   (framing, parity, etc), but does not indicate characters
   being received. Since no chracters have been received,
   ignore the line errors.
   
   PR:		131006
   MFC after:	3 days
 
 Modified:
   head/sys/dev/uart/uart_dev_ns8250.c
 
 Modified: head/sys/dev/uart/uart_dev_ns8250.c
 ==============================================================================
 --- head/sys/dev/uart/uart_dev_ns8250.c	Tue Apr  7 22:26:53 2009	(r190833)
 +++ head/sys/dev/uart/uart_dev_ns8250.c	Wed Apr  8 00:14:06 2009	(r190834)
 @@ -50,14 +50,16 @@ __FBSDID("$FreeBSD$");
  static void
  ns8250_clrint(struct uart_bas *bas)
  {
 -	uint8_t iir;
 +	uint8_t iir, lsr;
  
  	iir = uart_getreg(bas, REG_IIR);
  	while ((iir & IIR_NOPEND) == 0) {
  		iir &= IIR_IMASK;
 -		if (iir == IIR_RLS)
 -			(void)uart_getreg(bas, REG_LSR);
 -		else if (iir == IIR_RXRDY || iir == IIR_RXTOUT)
 +		if (iir == IIR_RLS) {
 +			lsr = uart_getreg(bas, REG_LSR);
 +			if (lsr & (LSR_BI|LSR_FE|LSR_PE))
 +				(void)uart_getreg(bas, REG_DATA);
 +		} else if (iir == IIR_RXRDY || iir == IIR_RXTOUT)
  			(void)uart_getreg(bas, REG_DATA);
  		else if (iir == IIR_MLSC)
  			(void)uart_getreg(bas, REG_MSR);
 @@ -587,7 +589,6 @@ ns8250_bus_ipend(struct uart_softc *sc)
  	ipend = 0;
  	if (iir & IIR_RXRDY) {
  		lsr = uart_getreg(bas, REG_LSR);
 -		uart_unlock(sc->sc_hwmtx);
  		if (lsr & LSR_OE)
  			ipend |= SER_INT_OVERRUN;
  		if (lsr & LSR_BI)
 @@ -595,12 +596,14 @@ ns8250_bus_ipend(struct uart_softc *sc)
  		if (lsr & LSR_RXRDY)
  			ipend |= SER_INT_RXREADY;
  	} else {
 -		uart_unlock(sc->sc_hwmtx);
  		if (iir & IIR_TXRDY)
  			ipend |= SER_INT_TXIDLE;
  		else
  			ipend |= SER_INT_SIGCHG;
  	}
 +	if (ipend == 0)
 +		ns8250_clrint(bas);
 +	uart_unlock(sc->sc_hwmtx);
  	return ((sc->sc_leaving) ? 0 : ipend);
  }
  
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: marcel 
State-Changed-When: Mon May 18 22:46:23 UTC 2009 
State-Changed-Why:  
Fixed in 7-STABLE. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=131006 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/131006: commit references a PR
Date: Mon, 18 May 2009 22:45:24 +0000 (UTC)

 Author: marcel
 Date: Mon May 18 22:45:09 2009
 New Revision: 192352
 URL: http://svn.freebsd.org/changeset/base/192352
 
 Log:
   MFC r190834:
   Fix hangs caused by hardware that signals receive errors
   (framing, parity, etc), but does not indicate characters
   being received. Since no chracters have been received,
   ignore the line errors.
   
   PR:		131006
 
 Modified:
   stable/7/sys/   (props changed)
   stable/7/sys/contrib/pf/   (props changed)
   stable/7/sys/dev/ath/ath_hal/   (props changed)
   stable/7/sys/dev/cxgb/   (props changed)
   stable/7/sys/dev/uart/uart_dev_ns8250.c
 
 Modified: stable/7/sys/dev/uart/uart_dev_ns8250.c
 ==============================================================================
 --- stable/7/sys/dev/uart/uart_dev_ns8250.c	Mon May 18 22:34:44 2009	(r192351)
 +++ stable/7/sys/dev/uart/uart_dev_ns8250.c	Mon May 18 22:45:09 2009	(r192352)
 @@ -50,14 +50,16 @@ __FBSDID("$FreeBSD$");
  static void
  ns8250_clrint(struct uart_bas *bas)
  {
 -	uint8_t iir;
 +	uint8_t iir, lsr;
  
  	iir = uart_getreg(bas, REG_IIR);
  	while ((iir & IIR_NOPEND) == 0) {
  		iir &= IIR_IMASK;
 -		if (iir == IIR_RLS)
 -			(void)uart_getreg(bas, REG_LSR);
 -		else if (iir == IIR_RXRDY || iir == IIR_RXTOUT)
 +		if (iir == IIR_RLS) {
 +			lsr = uart_getreg(bas, REG_LSR);
 +			if (lsr & (LSR_BI|LSR_FE|LSR_PE))
 +				(void)uart_getreg(bas, REG_DATA);
 +		} else if (iir == IIR_RXRDY || iir == IIR_RXTOUT)
  			(void)uart_getreg(bas, REG_DATA);
  		else if (iir == IIR_MLSC)
  			(void)uart_getreg(bas, REG_MSR);
 @@ -563,7 +565,6 @@ ns8250_bus_ipend(struct uart_softc *sc)
  	ipend = 0;
  	if (iir & IIR_RXRDY) {
  		lsr = uart_getreg(bas, REG_LSR);
 -		uart_unlock(sc->sc_hwmtx);
  		if (lsr & LSR_OE)
  			ipend |= SER_INT_OVERRUN;
  		if (lsr & LSR_BI)
 @@ -571,12 +572,14 @@ ns8250_bus_ipend(struct uart_softc *sc)
  		if (lsr & LSR_RXRDY)
  			ipend |= SER_INT_RXREADY;
  	} else {
 -		uart_unlock(sc->sc_hwmtx);
  		if (iir & IIR_TXRDY)
  			ipend |= SER_INT_TXIDLE;
  		else
  			ipend |= SER_INT_SIGCHG;
  	}
 +	if (ipend == 0)
 +		ns8250_clrint(bas);
 +	uart_unlock(sc->sc_hwmtx);
  	return ((sc->sc_leaving) ? 0 : ipend);
  }
  
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
