NetBSD Problem Report #39044

From leo@marco.de  Thu Jun 26 16:40:08 2008
Return-Path: <leo@marco.de>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id 2641D63B880
	for <gnats-bugs@gnats.netbsd.org>; Thu, 26 Jun 2008 16:40:08 +0000 (UTC)
Message-Id: <20080626153838.B0864748494@hera.dachau.marco.de>
Date: Thu, 26 Jun 2008 17:38:38 +0200 (CEST)
From: leo@marco.de
Reply-To: leo@marco.de
To: gnats-bugs@gnats.NetBSD.org
Subject: spurious '\n' received from USB-Modems
X-Send-Pr-Version: 3.95

>Number:         39044
>Category:       kern
>Synopsis:       spurious '\n' received from USB-Modems
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 26 16:45:00 +0000 2008
>Last-Modified:  Fri Jul 04 13:20:03 +0000 2008
>Originator:     Matthias Pfaller
>Release:        NetBSD 4.99.62
>Organization:
Matthias Pfaller                            Software Entwicklung
marco Systemanalyse und Entwicklung GmbH    Tel   +49 8131 5161-41
Hans-Böckler-Str. 2, D 85221 Dachau         Fax   +49 8131 5161-66
http://www.marco.de/                        Email leo@dachau.marco.de
>Environment:
System: NetBSD joghurt 4.99.62 NetBSD 4.99.62 (JOGHURT) #1: Sat May 3 14:51:54 CEST 2008 leo@joghurt:/usr/src/sys/arch/i386/compile/JOGHURT i386
Architecture: i386
Machine: i386
>Description:
	When using an USB communications class device, I will sometimes
	read a spurious '\n' directly after the open. It happens only if
	the device was used (open/close) before.
>How-To-Repeat:
	Get an USB communications class device. connect and disconnect several
	times and get a '\n'.
>Fix:
	Don't really know, but there is the following in sys/dev/usb/ucom.c:

		ucomreadcb(usbd_xfer_handle xfer, usbd_private_handle p, usbd_status status)
		{
			struct ucom_softc *sc = (struct ucom_softc *)p;
			struct tty *tp = sc->sc_tty;
			int (*rint)(int, struct tty *) = tp->t_linesw->l_rint;
			usbd_status err;
			u_int32_t cc;
			u_char *cp;
			int s;

			DPRINTFN(5,("ucomreadcb: status=%d\n", status));

			if (status == USBD_CANCELLED || status == USBD_IOERROR ||
			    sc->sc_dying) {
				DPRINTF(("ucomreadcb: dying\n"));
				/* Send something to wake upper layer */
				s = spltty();
				(*rint)('\n', tp);

	I think this where my '\n' gets injected. Is it safe to remove this
	code?

Regards, Matthias

>Audit-Trail:
From: Matthias Pfaller <leo@marco.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/39044: spurious '\n' received from USB-Modems
Date: Mon, 30 Jun 2008 10:58:39 +0200

 Removing the
 				(*rint)('\n', tp);

 line from ucom.c doesn't seem to harm and I'm no longer getting the 
 spurious 0x0a characters. Somebody knowing the usb code needs to approve 
 and commit this.

 Matthias
 -- 
 Matthias Pfaller                          Software-Entwicklung
 marco Systemanalyse und Entwicklung GmbH  Tel   +49 8131 5161 41
 Hans-Böckler-Str. 2, D 85221 Dachau       Fax   +49 8131 5161 66
 http://www.marco.de/                      Email leo@marco.de
 Geschäftsführer Martin Reuter             HRB 171775 Amtsgericht München

From: Matthias Drochner <M.Drochner@fz-juelich.de>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org,
	netbsd-bugs@NetBSD.org, leo@marco.de
Subject: Re: kern/39044: spurious '\n' received from USB-Modems 
Date: Tue, 01 Jul 2008 13:51:41 +0200

 leo@marco.de said:
 > Removing the
 >  				(*rint)('\n', tp);
 >    line from ucom.c doesn't seem to harm

 Maybe, but to understand what's going on it would help
 to know which of the 3 possible conditions trigger this.
 (status == USBD_CANCELLED || status == USBD_IOERROR ||
 sc->sc_dying)

 best regards
 Matthias




 -------------------------------------------------------------------
 -------------------------------------------------------------------
 Forschungszentrum Juelich GmbH
 52425 Juelich

 Sitz der Gesellschaft: Juelich
 Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
 Vorsitzende des Aufsichtsrats: MinDir'in Baerbel Brumme-Bothe
 Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
 Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr. Harald Bolt,
 Dr. Sebastian M. Schmidt
 -------------------------------------------------------------------
 -------------------------------------------------------------------

From: Matthias Pfaller <leo@marco.de>
To: M.Drochner@fz-juelich.de
Cc: gnats-bugs@NetBSD.org, kern-bug-people@NetBSD.org, 
 gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org
Subject: Re: kern/39044: spurious '\n' received from USB-Modems
Date: Fri, 04 Jul 2008 15:18:04 +0200

 Matthias Drochner wrote:
 > leo@marco.de said:
 >> Removing the
 >>  				(*rint)('\n', tp);
 >>    line from ucom.c doesn't seem to harm
 > 
 > Maybe, but to understand what's going on it would help
 > to know which of the 3 possible conditions trigger this.
 > (status == USBD_CANCELLED || status == USBD_IOERROR ||
 > sc->sc_dying)

 I inserted:
                  logprintf("status = %d, sc->sc_dying = %d\n", status,
                          sc->sc_dying);

 The result is:
      Jul  1 14:05:49 joghurt /netbsd: status = 6, sc->sc_dying = 0

 status = 6 is USBD_CANCELLED.

 Some more investigation showed (and a mail from Matthias Drochner) 
 showed, that it is ucomclose calling ucom_cleanup that triggers the 
 spurious \n. The \n is inserted into the tty queue at device close time 
 and delivered, when I open the device. Is there any reason to to insert 
 the \n into the queue when doing a device close?

 Regards, Matthias
 -- 
 Matthias Pfaller                          Software-Entwicklung
 marco Systemanalyse und Entwicklung GmbH  Tel   +49 8131 5161 41
 Hans-Böckler-Str. 2, D 85221 Dachau       Fax   +49 8131 5161 66
 http://www.marco.de/                      Email leo@marco.de
 Geschäftsführer Martin Reuter             HRB 171775 Amtsgericht München

NetBSD Home
NetBSD PR Database Search

(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-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.