]> git.baikalelectronics.ru Git - kernel.git/commit
ASoC: mchp-spdifrx: fix controls that works with completion mechanism
authorClaudiu Beznea <claudiu.beznea@microchip.com>
Mon, 30 Jan 2023 12:06:42 +0000 (14:06 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:33:19 +0000 (09:33 +0100)
commit9bf0b7f31d95e56af09c64b627401bab794f3211
treeb201d179f609b710f63c7c694fe4677b612d9949
parent04890aa6c59e33e8c5090c3653058ac0e7764354
ASoC: mchp-spdifrx: fix controls that works with completion mechanism

[ Upstream commit fc2e8f2ec503489188a33d0ce69d80c317f03ee6 ]

Channel status get and channel subcode get controls relies on data
returned by controls when certain IRQs are raised. To achieve that
completions are used b/w controls and interrupt service routine. The
concurrent accesses to these controls are protected by
struct snd_card::controls_rwsem.

Issues identified:
- reinit_completion() may be called while waiting for completion
  which should be avoided
- in case of multiple threads waiting, the complete() call in interrupt
  will signal only one waiting thread per interrupt which may lead to
  timeout for the others
- in case of channel status get as the CSC interrupt is not refcounted
  ISR may disable interrupt for threads that were just enabled it.

To solve these the access to controls were protected by a mutex. Along
with this there is no need for spinlock to protect the software cache
reads/updates b/w controls and ISR as the update is happening only when
requested from control, and only one reader can reach the control.

Fixes: 5c8954cfbcfe ("ASoC: mchp-spdifrx: add driver for SPDIF RX")
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Link: https://lore.kernel.org/r/20230130120647.638049-4-claudiu.beznea@microchip.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/soc/atmel/mchp-spdifrx.c