Message ID | 20220725130925.1781791-2-claudiu.beznea@microchip.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | ASoC: atmel: one fix and few cleanups | expand |
On Mon, Jul 25, 2022 at 04:09:21PM +0300, Claudiu Beznea wrote: > +++ b/sound/soc/atmel/mchp-spdifrx.c > @@ -288,15 +288,17 @@ static void mchp_spdifrx_isr_blockend_en(struct mchp_spdifrx_dev *dev) > spin_unlock_irqrestore(&dev->blockend_lock, flags); > } > > -/* called from atomic context only */ > +/* called from atomic/non-atomic context */ > static void mchp_spdifrx_isr_blockend_dis(struct mchp_spdifrx_dev *dev) > { > - spin_lock(&dev->blockend_lock); > + unsigned int flags; > + > + spin_lock_irqsave(&dev->blockend_lock); > dev->blockend_refcount--; > /* don't enable BLOCKEND interrupt if it's already enabled */ > if (dev->blockend_refcount == 0) > regmap_write(dev->regmap, SPDIFRX_IDR, SPDIFRX_IR_BLOCKEND); > - spin_unlock(&dev->blockend_lock); > + spin_unlock_irqrestore(&dev->blockend_lock); > } This breaks an x86_64 allmodconfig build: /build/stage/linux/sound/soc/atmel/mchp-spdifrx.c: In function ‘mchp_spdifrx_isr_blockend_dis’: /build/stage/linux/sound/soc/atmel/mchp-spdifrx.c:296:46: error: macro "spin_lock_irqsave" requires 2 arguments, but only 1 given 296 | spin_lock_irqsave(&dev->blockend_lock); | ^ In file included from /build/stage/linux/include/linux/rwsem.h:15, from /build/stage/linux/include/linux/notifier.h:15, from /build/stage/linux/include/linux/clk.h:14, from /build/stage/linux/sound/soc/atmel/mchp-spdifrx.c:9: /build/stage/linux/include/linux/spinlock.h:377: note: macro "spin_lock_irqsave" defined here 377 | #define spin_lock_irqsave(lock, flags) \ | /build/stage/linux/sound/soc/atmel/mchp-spdifrx.c:296:9: error: ‘spin_lock_irqsave’ undeclared (first use in this function); did you mean ‘spin_lock_irq’? 296 | spin_lock_irqsave(&dev->blockend_lock); | ^~~~~~~~~~~~~~~~~ | spin_lock_irq /build/stage/linux/sound/soc/atmel/mchp-spdifrx.c:296:9: note: each undeclared identifier is reported only once for each function it appears in /build/stage/linux/sound/soc/atmel/mchp-spdifrx.c:301:9: error: too few arguments to function ‘spin_unlock_irqrestore’ 301 | spin_unlock_irqrestore(&dev->blockend_lock); | ^~~~~~~~~~~~~~~~~~~~~~ In file included from /build/stage/linux/include/linux/rwsem.h:15, from /build/stage/linux/include/linux/notifier.h:15, from /build/stage/linux/include/linux/clk.h:14, from /build/stage/linux/sound/soc/atmel/mchp-spdifrx.c:9: /build/stage/linux/include/linux/spinlock.h:402:29: note: declared here 402 | static __always_inline void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags) | ^~~~~~~~~~~~~~~~~~~~~~ /build/stage/linux/sound/soc/atmel/mchp-spdifrx.c:294:22: error: unused variable ‘flags’ [-Werror=unused-variable] 294 | unsigned int flags; | ^~~~~ cc1: all warnings being treated as errors
diff --git a/sound/soc/atmel/mchp-spdifrx.c b/sound/soc/atmel/mchp-spdifrx.c index 0d37b78b94a0..b6a753893d90 100644 --- a/sound/soc/atmel/mchp-spdifrx.c +++ b/sound/soc/atmel/mchp-spdifrx.c @@ -288,15 +288,17 @@ static void mchp_spdifrx_isr_blockend_en(struct mchp_spdifrx_dev *dev) spin_unlock_irqrestore(&dev->blockend_lock, flags); } -/* called from atomic context only */ +/* called from atomic/non-atomic context */ static void mchp_spdifrx_isr_blockend_dis(struct mchp_spdifrx_dev *dev) { - spin_lock(&dev->blockend_lock); + unsigned int flags; + + spin_lock_irqsave(&dev->blockend_lock); dev->blockend_refcount--; /* don't enable BLOCKEND interrupt if it's already enabled */ if (dev->blockend_refcount == 0) regmap_write(dev->regmap, SPDIFRX_IDR, SPDIFRX_IR_BLOCKEND); - spin_unlock(&dev->blockend_lock); + spin_unlock_irqrestore(&dev->blockend_lock); } static irqreturn_t mchp_spdif_interrupt(int irq, void *dev_id) @@ -575,6 +577,7 @@ static int mchp_spdifrx_subcode_ch_get(struct mchp_spdifrx_dev *dev, if (ret <= 0) { dev_dbg(dev->dev, "user data for channel %d timeout\n", channel); + mchp_spdifrx_isr_blockend_dis(dev); return ret; }
Disable end of block interrupt in case of wait for completion timeout or errors to undo previously enable operation (done in mchp_spdifrx_isr_blockend_en()). Otherwise we can end up with an unbalanced reference counter for this interrupt. Fixes: ef265c55c1ac ("ASoC: mchp-spdifrx: add driver for SPDIF RX") Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> --- sound/soc/atmel/mchp-spdifrx.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)