On Tue, Nov 01, 2005 at 02:03:32AM +0100, Laurent Pinchart wrote: > Hi everybody, > > I spent some time getting familiar with USB driver development, and ran into > a > locking issue (that was to be expected, I'd like to meet a kernel developper > who never faced a locking issue :-)). > > The issue here deals with the USB disconnect function and the file open > function. The problem is that the device disconnection can interrupt the file > open operation before it has the opportunity to kref_get the device, and > leave it with invalid data. > > The usb-skeleton driver deals with the issue using lock_kernel in the USB > disconnection handler. I had a look at the fs code, and found out that the > open call is protected by lock_kernel as well, so this looks fine to me. > > However, I have a few questions which are left unanswered by reading the > kernel source code and googling around. > > 1. I read that the BKL (big kernel lock) is not a proper lock anymore, and > can > be interrupted. How does that impact my locking issue ? > 2. Isn't there a better way to handle the problem than locking the whole > kernel ?
Yes, if you don't like using the BKL (and I admit that it was a fun hack for me to use it), just have a static semaphore in your driver for all devices. Your only requirement is that it is outside of your local device structure so that you can syncronize things. Hope this helps, greg k-h ------------------------------------------------------- SF.Net email is sponsored by: Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel