Re: [PATCH 1/3] picolcd: driver for PicoLCD HID device
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: 2010-02-26 08:12:24
Also in:
linux-input, lkml
On Thu, Feb 25, 2010 at 08:34:42AM -0700, Rick L. Vinyard, Jr. wrote:
Jiri Kosina wrote:quoted
On Wed, 24 Feb 2010, Rick L. Vinyard, Jr. wrote:quoted
The key difference is the replacement of spin_lock() with spin_trylock() such that if the non-interrupt code has already obtained the lock, the interrupt will not deadlock but instead take the else path and schedule a framebuffer update at the next interval.Why is _irqsave() and/or deferred work not enough? The aproach with _trylock() seems to be overly complicated for no good reason (I personally become very suspicious every time I see code that is using _trylock()).I was concerned about _irqsave() because the lock is split across two functions to protect the urb after it is handed off to the usb subsystem with usb_submit_urb(). It's locked in g13_fb_send() and unlocked in the urb completion callback. As for deferred work, the g13_fb_send() is the I/O portion of the deferred framebuffer callback. I was concerned that without a lock one deferred update could hand the urb off to the usb subsystem and a second could try to access it before it was handed back to the driver. In this case the _trylock() would fail and in the else patch we would defer yet again until the next update cycle.
What you are looking for here is called test_and_set_bit(). Do not muddy the waters with a lock. -- Dmitry