[lkml]   [2007]   [Nov]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: Use of mutex in interrupt context flawed/impossible, need advice.
On Thu, 22 Nov 2007 17:02:44 +0100
"Leon Woestenberg" <> wrote:

> Hello,
> I'm converting an out-of-tree (*1) driver from binary semaphore to
> mutex.
> Userspace updates a look-up-table using write(). The driver tries to
> write this LUT to the FPGA in the (video frame) interrupt handler. It
> is important that the LUT is consistent and thus changed atomically.
> Note that it is not important that the LUT is updated each interrupt.
> The current approach is to try-down()ing a binary semaphore in
> interrupt context, and write the LUT to the FPGA if the semaphore was
> down()ed, do nothing else.
> The write() down()s the semaphore as well before updating the
> in-driver-copy of the LUT, then up()s it again.
> I understand this design is not clean (*2), and not even possible with
> mutexes, as mutex_trylock() is not interrupt safe.
> My current approach would be to have userspace write into a shadow
> copy, and use a spinlock to update the live copy. The interrupt then
> would try a spinlock.

I suspect you need to copy the userspace data anyway, so I don't see
why the spinlock approach would be wrong; if the update itself is short
and non-sleeping, it's even better than a mutex or semaphore.

If you want to reach me at my work email, use
For development, discussion and tips for power savings,
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2007-11-22 18:21    [W:0.077 / U:2.004 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site