Thread (67 messages) 67 messages, 5 authors, 2021-02-28

Re: [PATCH v8 21/22] counter: 104-quad-8: Replace mutex with spinlock

flat view

From: Jonathan Cameron <jic23@kernel.org>
Date: 2021-02-16 19:28:43
Also in: linux-iio, lkml

On Tue, 16 Feb 2021 11:16:03 +0900
William Breathitt Gray [off-list ref] wrote:
On Sun, Feb 14, 2021 at 06:19:46PM +0000, Jonathan Cameron wrote:
quoted
On Fri, 12 Feb 2021 21:13:45 +0900
William Breathitt Gray [off-list ref] wrote:
  
quoted
This patch replaces the mutex I/O lock with a spinlock. This is in
preparation for a subsequent patch adding IRQ support for 104-QUAD-8
devices; we can't sleep in an interrupt context, so we'll need to use a
spinlock instead.

Cc: Syed Nayyar Waris <redacted>
Signed-off-by: William Breathitt Gray <redacted>  
Why do these need to be raw_spin_locks?
Normally only need to do that if in code related to interrupt chips etc,
not their use.

Jonathan  
This lock can be taken in an interrupt context in a subsequent patch:
counter_push_event() called by quad8_irq_handler() can end up calling
the Counter component callbacks which take this lock. We can't use a
mutex nor a regular spinlock because those can sleep on RT setups [1]
But on RT setups the interrupts become threads and are preemptable etc,
so that shouldn't matter.  There are a few corner cases that cause
trouble, but in most normal drivers you should be fine with a
spin_lock.

Jonathan

which would result in a deadlock due to the interrupt context here -- so
therefore we're left with using raw_spin_lock.

[1] https://lwn.net/Articles/367219/

William Breathitt Gray

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help