Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Nov 2008 16:47:22 +0100
From:      Rink Springer <rink@FreeBSD.org>
To:        Hans Petter Selasky <hselasky@c2i.net>
Cc:        usb@freebsd.org, freebsd-usb@freebsd.org
Subject:   Re: Patch to convert usb2 to use cdev
Message-ID:  <20081109154722.GC78524@rink.nu>
In-Reply-To: <200811091515.26123.hselasky@c2i.net>
References:  <20081109120257.GA78524@rink.nu> <200811091515.26123.hselasky@c2i.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20081109154722.GC78524>