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

William Breathitt Gray vilhelm.gray at gmail.com
Mon Feb 15 21:16:03 EST 2021


On Sun, Feb 14, 2021 at 06:19:46PM +0000, Jonathan Cameron wrote:
> On Fri, 12 Feb 2021 21:13:45 +0900
> William Breathitt Gray <vilhelm.gray at gmail.com> wrote:
> 
> > 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 <syednwaris at gmail.com>
> > Signed-off-by: William Breathitt Gray <vilhelm.gray at gmail.com>
> 
> 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]
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20210216/8ffbacec/attachment.sig>


More information about the linux-arm-kernel mailing list