NetBSD Problem Report #43753

From Wolfgang.Stukenbrock@nagler-company.com  Fri Aug 13 11:57:51 2010
Return-Path: <Wolfgang.Stukenbrock@nagler-company.com>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 826A763BBBA
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 13 Aug 2010 11:57:51 +0000 (UTC)
Message-Id: <20100813115741.962D01E80CE@test-s0.nagler-company.com>
Date: Fri, 13 Aug 2010 13:57:41 +0200 (CEST)
From: Wolfgang.Stukenbrock@nagler-company.com
Reply-To: Wolfgang.Stukenbrock@nagler-company.com
To: gnats-bugs@gnats.NetBSD.org
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
>Organization:
Dr. Nagler & Company GmbH

>Environment:


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
>Description:
	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.
>How-To-Repeat:
	Try to set a timeout and send more data as the device is actual able to accept.
	The write() call will hang forever ...
>Fix:
	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);
 	case USB_SET_BULK_RA:
 #ifdef UGEN_BULK_RA_WB

>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.