From owner-freebsd-usb@FreeBSD.ORG Sun Nov 9 15:47:22 2008 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 91E491065676; Sun, 9 Nov 2008 15:47:21 +0000 (UTC) (envelope-from rink@rink.nu) Received: from mx1.rink.nu (gloom.rink.nu [213.34.49.2]) by mx1.freebsd.org (Postfix) with ESMTP id 1A0558FC19; Sun, 9 Nov 2008 15:47:20 +0000 (UTC) (envelope-from rink@rink.nu) Received: from localhost (localhost [127.0.0.1]) by mx1.rink.nu (Postfix) with ESMTP id 9280F6D439; Sun, 9 Nov 2008 16:47:26 +0100 (CET) X-Virus-Scanned: amavisd-new at rink.nu Received: from mx1.rink.nu ([213.34.49.2]) by localhost (gloom.rink.nu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NpE0z56g91gY; Sun, 9 Nov 2008 16:47:22 +0100 (CET) Received: by mx1.rink.nu (Postfix, from userid 1000) id C78196D42B; Sun, 9 Nov 2008 16:47:22 +0100 (CET) Date: Sun, 9 Nov 2008 16:47:22 +0100 From: Rink Springer To: Hans Petter Selasky Message-ID: <20081109154722.GC78524@rink.nu> References: <20081109120257.GA78524@rink.nu> <200811091515.26123.hselasky@c2i.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200811091515.26123.hselasky@c2i.net> User-Agent: Mutt/1.5.18 (2008-05-17) Cc: usb@freebsd.org, freebsd-usb@freebsd.org Subject: Re: Patch to convert usb2 to use cdev X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Nov 2008 15:47:22 -0000 Hi Hans, On Sun, Nov 09, 2008 at 03:15:25PM +0100, Hans Petter Selasky wrote: > 1) You don't have to create an alias in "usb2_fifo_attach". The > alias /dev/usbX.Y.Z.T is mostly for internal usage. > > + make_dev_alias(f_sc->dev, buf); OK, I'll remove it - I assumed it might be used elsewhere, but appearantly this is not the case. > > 2) struct usb2_privdata > > I would call the structure "usb2_fs_privdata" so that it is clear that this is > File-System related private data. There is also a field > called "xfer->priv_sc" so it might be confusing? Yeah, after some though that is way too generic - I've renamed it to 'usb2_cdev_privdata' as it's really private cdev data. > 3) You need to solve the problem about a per-open-call context > for /dev/ugenX.Y . This device is supposed to be cloneable, that means > multiple processes are allowed to open it and establish independant > connections to the USB stack. Here are also some tricky issues with > permissions, because I allow trunking of multiple endpoints through the same > file-handle, called USB FS, and you have to verify that the current thread > has permission to open the endpoint inside an ioctl function. Well, multiple opens aren't a problem to implement - but I fail the permissions problem. I think allowing multiple opens is useful for as you can do ioctl() to them - but why would you ever want to be able to read/write the same endpoint from multiple processes? > 4) You need to generate dummy /dev/ugenX.Y.0 ... 15 inclusivly, endpoint > holders. Typically there are not 15 endpoints, but it is difficult to > in-advance figure out this number. OK, will do. > 5) Given that you use "destroy_dev_sched_cb" it becomes very easy to end up in > a situation with multiple cdev instances having identical names, because > the "destroy_dev_sched_cb" does not delete the device until the process which > has the device opened closes it. Especially when re-attaching an USB device. Yeah, I agree this is a problem. Robert Watson suggested that maybe a worker thread that does all make_dev and destroy_dev calls may be a good idea (appearantly, pccard does this already) - so they can be adequately serialized to prevent duplicant devices from existing. I'll think about this some more and talk to pccard people about how they did it. -- Rink P.W. Springer - http://rink.nu "Anyway boys, this is America. Just because you get more votes doesn't mean you win." - Fox Mulder