Re: [PATCH v1 2/2] genirq/irqdesc: Balance locking to make sparse happy
From: Andy Shevchenko
Date: Wed Apr 16 2025 - 07:52:36 EST
On Wed, Apr 16, 2025 at 02:40:34PM +0300, Andy Shevchenko wrote:
> Sparse is not happy right now about conditional locking and
> complains:
>
> irqdesc.c:899:17: warning: context imbalance in '__irq_get_desc_lock' - wrong count at exit
>
> Refactor the code and use __acquire() to make it happy.
> Annotate the function that it acquires the lock in the
> similar way how __irq_put_desc_unlock() is marked.
Oh, scratch this, it basically will diminish the idea for the users.
…
> __irq_get_desc_lock(unsigned int irq, unsigned long *flags, bool bus,
> unsigned int check)
> + __acquires(&desc->lock)
This is correct annotation, but it doesn't help alone.
We need __cond_acquires() to be supported by sparse...
...
It can be still fixed by using macros, but this is not probably what we want.
For the reference: d795e38df4b7 ("iio: core: Rework claim and release of direct
mode to work with sparse.")
--
With Best Regards,
Andy Shevchenko