[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100226081217.GA17444@core.coreip.homeip.net>
Date: Fri, 26 Feb 2010 00:12:17 -0800
From: Dmitry Torokhov <dmitry.torokhov@...il.com>
To: "Rick L. Vinyard, Jr." <rvinyard@...nmsu.edu>
Cc: Jiri Kosina <jkosina@...e.cz>, Oliver Neukum <oliver@...kum.org>,
Bruno Prémont <bonbons@...ux-vserver.org>,
linux-input@...r.kernel.org, linux-usb@...r.kernel.org,
linux-fbdev@...r.kernel.org, linux-kernel@...r.kernel.org,
Nicu Pavel <npavel@...ner.com>
Subject: Re: [PATCH 1/3] picolcd: driver for PicoLCD HID device
On Thu, Feb 25, 2010 at 08:34:42AM -0700, Rick L. Vinyard, Jr. wrote:
> Jiri Kosina wrote:
> > On Wed, 24 Feb 2010, Rick L. Vinyard, Jr. wrote:
> >
> >> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists