Subject: usb control endpoint exclusive access
To: None <>
From: Berndt Josef Wulf <>
List: tech-kern
Date: 05/16/2005 13:29:23

I'm currently working with the USRP development board that uses a FX2 USB-2.0 
interface. NetBSD has no problems in assigning it to the ugen device. The 
application expects to be able to open endpoint 0, the designated USB
control endpoint, by more than one process. The applications use libusb to 
access the USB interface.

On inspection of the ugen source code it can be seen that the ugen device 
driver only permits exclusive access to the control endpoint and any other 
endpoint for this matter. I suspect other USB devices will do likewise.

My current work around to this problem by using a modified version of the 
kernel permitting multiple access to the control endpoint of the USB 
interface. The applied patch is shown below:

--- ugen.c.orig 2005-05-16 02:46:59.000000000 +0930
+++ ugen.c      2005-05-16 03:18:59.000000000 +0930
@@ -333,14 +333,14 @@
        if (sc == NULL || sc->sc_dying)
                return (ENXIO);

-       if (sc->sc_is_open[endpt])
-               return (EBUSY);
        if (endpt == USB_CONTROL_ENDPOINT) {
                sc->sc_is_open[USB_CONTROL_ENDPOINT] = 1;
                return (0);

+       if (sc->sc_is_open[endpt])
+               return (EBUSY);
        /* Make sure there are pipes for all directions. */
        for (dir = OUT; dir <= IN; dir++) {
                if (flag & (dir == OUT ? FWRITE : FREAD)) {

This grants shared access to the control endpoint but only exclusive access 
rights to the other endpoints.

The applications work fine with the above work around applied.

What is the best and more importantly the correct way of solving this problem?

cheerio Berndt
Every man who says frankly and fully what he thinks is doing a public service.
[Leslie Stephen]