NetBSD Problem Report #50395
From www@NetBSD.org Mon Nov 2 16:05:51 2015
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id 4F7DAA6531
for <gnats-bugs@gnats.NetBSD.org>; Mon, 2 Nov 2015 16:05:51 +0000 (UTC)
Message-Id: <20151102160550.08718A6558@mollari.NetBSD.org>
Date: Mon, 2 Nov 2015 16:05:50 +0000 (UTC)
From: vchaves@ymail.com
Reply-To: vchaves@ymail.com
To: gnats-bugs@NetBSD.org
Subject: Loss of characters in serial port communication between gdb and kgdb_stub
X-Send-Pr-Version: www-1.0
>Number: 50395
>Category: kern
>Synopsis: Loss of characters in serial port communication between gdb and kgdb_stub
>Confidential: no
>Severity: critical
>Priority: high
>Responsible: kern-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Nov 02 16:10:00 +0000 2015
>Closed-Date: Sun Nov 08 04:39:51 +0000 2015
>Last-Modified: Sun Nov 08 04:39:51 +0000 2015
>Originator: Vicente Chaves
>Release: Netbsd7-current
>Organization:
>Environment:
NetBSD netbsd7.vbox.lab 7.99.21 NetBSD 7.99.21 (GENERIC) #1: Sat Aug 22 15:46:52 UTC 2015 vchaves@netbsd7.vbox.lab:/home/vchaves/current/amd64/sys/arch/amd64/compile/GENERIC amd64
>Description:
During a kernel debug session using the kgdb we can observe
losses that cause communication problems between the stub and the gdb remote.
This is because despite the com0 be reserved for kgdb, the port continues
generating interrupts when characters available on UART, this makes
the interrupt handler comintr() take the character before the stub.
Analyzing the problem, it seems to me that the function comenabledebugport() at com.c:380,
as suggested by the comment, should use the flag IER_ERLS to call the line break interrupt
instead of the flag IER_ERXRDY, as we can see their definitions in comreg. h
#define IER_ERLS 0x4 Enable line status interrupt
#define IER_ERXRDY 0x1 Enable receiver interrupt
Although it is not related to the above problem, it seems to me that the same mistake seems to occur also in comshutdown() at com.c:815.
After these fixes the stub can communicate seamlessly with the gdb remote.
Best regards
Vicente.
>How-To-Repeat:
Try to debug the kernel using kgdb between two vbox VM.
>Fix:
Index: sys/dev/ic/com.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/com.c,v
retrieving revision 1.336
diff -u -r1.336 com.c
--- sys/dev/ic/com.c 4 May 2015 22:59:36 -0000 1.336
+++ sys/dev/ic/com.c 2 Nov 2015 14:45:52 -0000
@@ -377,7 +377,7 @@
{
/* Turn on line break interrupt, set carrier. */
- sc->sc_ier = IER_ERXRDY;
+ sc->sc_ier = IER_ERLS;
if (sc->sc_type == COM_TYPE_PXA2x0)
sc->sc_ier |= IER_EUART | IER_ERXTOUT;
if (sc->sc_type == COM_TYPE_INGENIC ||
@@ -812,7 +812,7 @@
/* Turn off interrupts. */
if (ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) {
- sc->sc_ier = IER_ERXRDY; /* interrupt on break */
+ sc->sc_ier = IER_ERLS; /* interrupt on break */
if ((sc->sc_type == COM_TYPE_PXA2x0) ||
(sc->sc_type == COM_TYPE_INGENIC) ||
(sc->sc_type == COM_TYPE_TEGRA))
>Release-Note:
>Audit-Trail:
From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, kern-bug-people@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc:
Subject: Re: kern/50395: Loss of characters in serial port communication between gdb and kgdb_stub
Date: Mon, 2 Nov 2015 11:24:00 -0500
On Nov 2, 4:10pm, vchaves@ymail.com (vchaves@ymail.com) wrote:
-- Subject: kern/50395: Loss of characters in serial port communication betwe
Perhaps this?
--- com.c 4 May 2015 22:59:36 -0000 1.336
+++ com.c 2 Nov 2015 16:23:11 -0000
@@ -377,7 +377,7 @@
{
/* Turn on line break interrupt, set carrier. */
- sc->sc_ier = IER_ERXRDY;
+ sc->sc_ier = IER_ERLS;
if (sc->sc_type == COM_TYPE_PXA2x0)
sc->sc_ier |= IER_EUART | IER_ERXTOUT;
if (sc->sc_type == COM_TYPE_INGENIC ||
@@ -812,7 +812,10 @@
/* Turn off interrupts. */
if (ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) {
- sc->sc_ier = IER_ERXRDY; /* interrupt on break */
+ if (ISSET(sc->sc_hwflags, COM_HW_KGDB))
+ sc->sc_ier = IER_ERLS; /* interrupt on line break */
+ else
+ sc->sc_ier = IER_ERXRDY; /* interrupt on receive */
if ((sc->sc_type == COM_TYPE_PXA2x0) ||
(sc->sc_type == COM_TYPE_INGENIC) ||
(sc->sc_type == COM_TYPE_TEGRA))
Or do we always want ERLS on shutdown?
christos
From: Vicente Chaves de Melo <vchaves@ymail.com>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: kern/50395: Loss of characters in serial port communication
between gdb and kgdb_stub
Date: Mon, 2 Nov 2015 15:29:55 -0200
Hey Christos,
about fix in function comshutdown () I stand by my suggestion.
I believe that changing the flag IER_ERXRDY to IER_ERLS we will obtain
the following two benefits
1) there will be no more interruptions generated for this COM after the
shutdown. That would seem to be the intent of this part of the code.
2) Allow the user to enter the debugger even after the shutdown, sending
a BREAK on the serial port.
I also believe that it wasn't such a wise idea to mix the com_shutdown
subject in the same PR problem with kgdb.
Wouldn't it be better if I open another PR to deal with this matter?
Best regards
Vicente.
On 02/11/2015 14:25, Christos Zoulas wrote:
> The following reply was made to PR kern/50395; it has been noted by GNATS.
>
> From: christos@zoulas.com (Christos Zoulas)
> To: gnats-bugs@NetBSD.org, kern-bug-people@netbsd.org,
> gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
> Cc:
> Subject: Re: kern/50395: Loss of characters in serial port communication between gdb and kgdb_stub
> Date: Mon, 2 Nov 2015 11:24:00 -0500
>
> On Nov 2, 4:10pm, vchaves@ymail.com (vchaves@ymail.com) wrote:
> -- Subject: kern/50395: Loss of characters in serial port communication betwe
>
> Perhaps this?
>
> --- com.c 4 May 2015 22:59:36 -0000 1.336
> +++ com.c 2 Nov 2015 16:23:11 -0000
> @@ -377,7 +377,7 @@
> {
>
> /* Turn on line break interrupt, set carrier. */
> - sc->sc_ier = IER_ERXRDY;
> + sc->sc_ier = IER_ERLS;
> if (sc->sc_type == COM_TYPE_PXA2x0)
> sc->sc_ier |= IER_EUART | IER_ERXTOUT;
> if (sc->sc_type == COM_TYPE_INGENIC ||
> @@ -812,7 +812,10 @@
>
> /* Turn off interrupts. */
> if (ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) {
> - sc->sc_ier = IER_ERXRDY; /* interrupt on break */
> + if (ISSET(sc->sc_hwflags, COM_HW_KGDB))
> + sc->sc_ier = IER_ERLS; /* interrupt on line break */
> + else
> + sc->sc_ier = IER_ERXRDY; /* interrupt on receive */
> if ((sc->sc_type == COM_TYPE_PXA2x0) ||
> (sc->sc_type == COM_TYPE_INGENIC) ||
> (sc->sc_type == COM_TYPE_TEGRA))
>
>
> Or do we always want ERLS on shutdown?
>
> christos
>
From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, kern-bug-people@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, vchaves@ymail.com
Cc:
Subject: Re: kern/50395: Loss of characters in serial port communication between gdb and kgdb_stub
Date: Mon, 2 Nov 2015 12:43:00 -0500
On Nov 2, 5:35pm, vchaves@ymail.com (Vicente Chaves de Melo) wrote:
-- Subject: Re: kern/50395: Loss of characters in serial port communication b
| The following reply was made to PR kern/50395; it has been noted by GNATS.
|
| From: Vicente Chaves de Melo <vchaves@ymail.com>
| To: gnats-bugs@NetBSD.org
| Cc:
| Subject: Re: kern/50395: Loss of characters in serial port communication
| between gdb and kgdb_stub
| Date: Mon, 2 Nov 2015 15:29:55 -0200
|
| Hey Christos,
| about fix in function comshutdown () I stand by my suggestion.
|
| I believe that changing the flag IER_ERXRDY to IER_ERLS we will obtain
| the following two benefits
|
| 1) there will be no more interruptions generated for this COM after the
| shutdown. That would seem to be the intent of this part of the code.
|
| 2) Allow the user to enter the debugger even after the shutdown, sending
| a BREAK on the serial port.
|
| I also believe that it wasn't such a wise idea to mix the com_shutdown
| subject in the same PR problem with kgdb.
| Wouldn't it be better if I open another PR to deal with this matter?
Sure, I agree with the current changes. If you want, please open another
PR to fix the shutdown issue in a better way.
Thanks,
christos
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/50395 CVS commit: src/sys/dev/ic
Date: Mon, 2 Nov 2015 12:45:13 -0500
Module Name: src
Committed By: christos
Date: Mon Nov 2 17:45:13 UTC 2015
Modified Files:
src/sys/dev/ic: com.c
Log Message:
PR/50395: Vicente Chaves de Melo: Loss of characters in serial port
communication between gdb and kgdb_stub: switch to line break interrupt
both when entering KGDB and also on shutdown so we can re-enter the debugger
with BREAK.
To generate a diff of this commit:
cvs rdiff -u -r1.336 -r1.337 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.
From: Vicente Chaves de Melo <vchaves@ymail.com>
To: Christos Zoulas <christos@zoulas.com>, gnats-bugs@NetBSD.org,
kern-bug-people@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc:
Subject: Re: kern/50395: Loss of characters in serial port communication
between gdb and kgdb_stub
Date: Sun, 8 Nov 2015 00:20:47 -0200
On 02/11/2015 15:43, Christos Zoulas wrote:
> On Nov 2, 5:35pm, vchaves@ymail.com (Vicente Chaves de Melo) wrote:
> -- Subject: Re: kern/50395: Loss of characters in serial port communication b
>
> | The following reply was made to PR kern/50395; it has been noted by GNATS.
> |
> | From: Vicente Chaves de Melo <vchaves@ymail.com>
> | To: gnats-bugs@NetBSD.org
> | Cc:
> | Subject: Re: kern/50395: Loss of characters in serial port communication
> | between gdb and kgdb_stub
> | Date: Mon, 2 Nov 2015 15:29:55 -0200
> |
> | Hey Christos,
> | about fix in function comshutdown () I stand by my suggestion.
> |
> | I believe that changing the flag IER_ERXRDY to IER_ERLS we will obtain
> | the following two benefits
> |
> | 1) there will be no more interruptions generated for this COM after the
> | shutdown. That would seem to be the intent of this part of the code.
> |
> | 2) Allow the user to enter the debugger even after the shutdown, sending
> | a BREAK on the serial port.
> |
> | I also believe that it wasn't such a wise idea to mix the com_shutdown
> | subject in the same PR problem with kgdb.
> | Wouldn't it be better if I open another PR to deal with this matter?
>
> Sure, I agree with the current changes. If you want, please open another
> PR to fix the shutdown issue in a better way.
>
> Thanks,
>
> christos
Hey Christos,
I noticed that you already applied the fixes, so I don't think it's
necessary to open a new PR.
I believe that this PR can be close.
Thank you very much
Vicente.
State-Changed-From-To: open->closed
State-Changed-By: christos@NetBSD.org
State-Changed-When: Sat, 07 Nov 2015 23:39:51 -0500
State-Changed-Why:
patch applied to head
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.