On Tue, 22 May 2007, Greg KH wrote:

> On Tue, May 22, 2007 at 11:46:41AM -0400, Alan Stern wrote:
> > This patch (as908) adds central protection in usbcore for the
> > prototypical race between opening and unregistering a char device.
> > The spinlock used to protect the minor-numbers array is replaced with
> > an rwsem, which can remain locked across a call to a driver's open()
> > method.  This guarantees that open() and deregister() will be mutually
> > exclusive.
> 
> Note that you missed some places in the sysvga driver, which I tried to
> fix up.

Sheer carelessness on my part.  I don't understand how the driver was 
able to build, though...  Evidently because I didn't turn on the Text 
Console option.

>  You might want to check that I did this properly, just removing
> the lock felt "wrong" somehow :)

This is sufficiently complicated that I can't be sure; there are 
nontrivial interactions with the console subsystem, which I'm not at 
all acquainted with.

The only code protected by that mutex was sisusb_get_sisusb(), and it 
appears to be called only in situations where things should be safe.  
But I don't know for certain.  Perhaps Thomas can help out.

It might be safest to put the disconnect_mutex back.  It shouldn't be 
needed in the main sisusb.c file, only in sisusb_con.c.  But why wasn't 
the call to sisusb_console_exit() protected by the mutex?  It doesn't 
make sense...

> Anyway, thanks a lot for doing this, it makes writing drivers much
> easier.
> 
> Although I really hate rw locks, I'll let it go for now, we can easily
> change it to a "normal" mutex in the future...

In case it wasn't already obvious, the reason for making it an rwsem 
was so that multiple open() calls could run concurrently, just as 
before.

Alan Stern


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to