NetBSD Problem Report #43753

From  Fri Aug 13 11:57:51 2010
Return-Path: <>
Received: from ( [])
	by (Postfix) with ESMTP id 826A763BBBA
	for <>; Fri, 13 Aug 2010 11:57:51 +0000 (UTC)
Message-Id: <>
Date: Fri, 13 Aug 2010 13:57:41 +0200 (CEST)
Subject: write-timeout in ugen(4) cannot be set
X-Send-Pr-Version: 3.95

>Number:         43753
>Category:       kern
>Synopsis:       write-timeout in ugen(4) cannot be set
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Aug 13 12:00:00 +0000 2010
>Originator:     Wolfgang Stukenbrock
>Release:        NetBSD 5.0.2
Dr. Nagler & Company GmbH


System: NetBSD test-s0 4.0 NetBSD 4.0 (NSW-WS) #1: Fri Aug 13 13:24:12 CEST 2010 wgstuken@test-s0:/usr/src/sys/arch/amd64/compile/NSW-WS amd64
Architecture: x86_64
Machine: amd64
	In the current implementation it is impossible to set a timeout on write operations
	in the ugen(4) driver.
	The USB_SET_TIMEOUT sets the timeout value only for the IN pipe. The OUT pipe is not
	modified. There seems to be no way to set a value other than the default assigned
	durint openening the endpoint to the OUT pipe. I've check the most reachend file
	in the CVS repository - so this problem is in current too.

	The manual to ugen(4) say: USB_SET_TIMEOUT will set the timeout on the device operations.
	This meens both IN and OUT - at least this is my understanding.
	If only setting of the IN-timeout is desired, this should be clarified in the manual.

	There are at least two ways to fix this problem:
	1: set the OUT-timeout to the same value as for the IN pipe in the USB_SET_TIMEOUT.
	2. add another ioctl to set the OUT-timeout seperately.
	   Perhaps the USB_SET_TIMEOUT should set both timeouts and two new ioctls (e.g.
	   USB_SET_IN_TIMEOUT and USB_SET_OUT_TIMEOUT) should be created to support
	   different timeout settings for read(2) and write(2) operations.

	The fix below just does version 1, but I think the second one would be the most flexible.
	Try to set a timeout and send more data as the device is actual able to accept.
	The write() call will hang forever ...
	The following patch will set the timeout for the OUT pipe to the same value as the
	IN pipe on USB_SET_TIMEOUT ioctl.
	remark: This fix will return EINVAL if the IN-pipe is invalid, even if an OUT-pipe
		is present. As far as I've seen in the code, this situation will never happen.

--- ugen.c.orig	2010-08-13 13:38:39.000000000 +0200
+++ ugen.c	2010-08-13 13:38:17.000000000 +0200
@@ -1427,6 +1427,8 @@
 			return (EINVAL);
 		sce->timeout = *(int *)addr;
+		if ((sce = &sc->sc_endpoints[endpt][OUT]) != NULL)
+			sce->timeout = *(int *)addr;
 		return (0);


NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD:,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.