NetBSD Problem Report #33452

From www@netbsd.org  Tue May  9 10:41:12 2006
Return-Path: <www@netbsd.org>
Received: by narn.netbsd.org (Postfix, from userid 31301)
	id AFE3A63B898; Tue,  9 May 2006 10:41:12 +0000 (UTC)
Message-Id: <20060509104112.AFE3A63B898@narn.netbsd.org>
Date: Tue,  9 May 2006 10:41:12 +0000 (UTC)
From: NevilTh@nat.com.au
Reply-To: NevilTh@nat.com.au
To: gnats-bugs@netbsd.org
Subject: ugen:  timeout does not work in function ugen_do_read  (interrupt mode)
X-Send-Pr-Version: www-1.0

>Number:         33452
>Category:       kern
>Synopsis:       ugen:  timeout does not work in function ugen_do_read  (interrupt mode)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed May 10 10:19:47 +0000 2006
>Closed-Date:    Mon Nov 21 10:52:56 +0000 2011
>Last-Modified:  Wed Jan 25 17:35:01 +0000 2012
>Originator:     Nevil Thatcher
>Release:        netBSD 3.0 amd64
>Organization:
>Environment:
NetBSD lamborghini.nat.com.au 3.0.0_STABLE NetBSD 3.0.0_STABLE (lamborghini) #9: Sat Mar 11 11:10:07 EST 2006  nevil@lamborghini.nat.com.au:/usr/src/sys/arch/amd64/compile/lamborghini amd64
>Description:
This has come about whilst trying to get nut (ups monitoring) software operational under netBSD. Nut uses libusb as the layer to access usb devices(/dev/ugen), the device I am using being a MGE Nova 1100 UPS.



Software versions are:
  netBSD 3.0_STABLE (amd64)
  libusb 0.1.12
  nut 2.0.3

Libusb offers a function usb_interrupt_read, the function looks like
int usb_interrupt_read(usb_dev_handle *dev, int ep, char *bytes, int size, int timeout)

A call to this should return with *char buffer filled with data from usb device OR timeout after int timeout seconds.

Note: timeout is set within usb_interrup_read with the following call 
ret = ioctl(fd, USB_SET_TIMEOUT, &timeout);

The problem seems to be that the dev/ugen code ugen_do_read does not respect this timeout and will not return until such time as data is returned from the usb device.

End result is that when libusb usb_interrupt_read is called it won’t return until data is received from the usb device and the buffer filled, so effectively hangs.


>How-To-Repeat:
Install 

libusb 0.1.12
nut 2.0.3 (after installation move to work directory and do 
make usb 
make installusb 
to get usb support)

Remove uhid from kernel config , recompile and install

Connect UPS 

Run /usr/local/libexec/nut/newhidups -u root -DDDDD /dev/ugen0 to run in debug mode.

Following output is observed..

--cut

process_status_info: !shutdownimm
entering string_to_path()
Looking up UPS
Looking up PowerSummary
Looking up PresentStatus
Looking up BelowRemainingCapacityLimit
Report : (8 bytes) => 02 23 00 01 00 80 FF FF
hu_find_infoval: searching for value = 0

hu_find_infoval: found !lowbatt (value: 0)

process_status_info: !lowbatt
new connection on fd 7
upsdrv_updateinfo...
Waiting for notifications...

And here it sits indefinitly.

Debugging has identified that at this point it is sitting in ugen_do_read waiting for data from device.
>Fix:
ugen_do_read should respect timeout set by 
ioctl(fd, USB_SET_TIMEOUT, &timeout)

>Release-Note:

>Audit-Trail:
From: "Gavan Fantom" <gavan@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/33452 CVS commit: src/sys/dev/usb
Date: Sun, 20 Nov 2011 22:27:40 +0000

 Module Name:	src
 Committed By:	gavan
 Date:		Sun Nov 20 22:27:39 UTC 2011

 Modified Files:
 	src/sys/dev/usb: ugen.c

 Log Message:
 Implement timeouts when blocking the calling process with tsleep.

 Fixes PR kern/33452


 To generate a diff of this commit:
 cvs rdiff -u -r1.111 -r1.112 src/sys/dev/usb/ugen.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: gavan@NetBSD.org
State-Changed-When: Sun, 20 Nov 2011 22:38:21 +0000
State-Changed-Why:
Feedback requested from submitter


State-Changed-From-To: feedback->closed
State-Changed-By: gavan@NetBSD.org
State-Changed-When: Mon, 21 Nov 2011 10:52:56 +0000
State-Changed-Why:
Submitter no longer uses NetBSD.


From: "Jeff Rizzo" <riz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/33452 CVS commit: [netbsd-5] src/sys/dev/usb
Date: Wed, 25 Jan 2012 17:33:17 +0000

 Module Name:	src
 Committed By:	riz
 Date:		Wed Jan 25 17:33:17 UTC 2012

 Modified Files:
 	src/sys/dev/usb [netbsd-5]: ugen.c

 Log Message:
 Pull up following revision(s) (requested by gavan in ticket #1697):
 	sys/dev/usb/ugen.c: revision 1.112
 Implement timeouts when blocking the calling process with tsleep.
 Fixes PR kern/33452


 To generate a diff of this commit:
 cvs rdiff -u -r1.99.8.3 -r1.99.8.4 src/sys/dev/usb/ugen.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.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.