* [PATCH] ASoC: soc-core: add snd_soc_find_dai_with_mutex()
@ 2020-08-26 23:55 Kuninori Morimoto
2020-08-27 13:56 ` Mark Brown
0 siblings, 1 reply; 4+ messages in thread
From: Kuninori Morimoto @ 2020-08-26 23:55 UTC (permalink / raw)
To: Mark Brown, Pierre-Louis Bossart; +Cc: Linux-ALSA
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
commit 25612477d20b52 ("ASoC: soc-dai: set dai_link dpcm_ flags with a helper")
added snd_soc_dai_link_set_capabilities().
But it is using snd_soc_find_dai() (A) which is required client_mutex (B).
And client_mutex is soc-core.c local.
struct snd_soc_dai *snd_soc_find_dai(xxx)
{
...
(B) lockdep_assert_held(&client_mutex);
...
}
void snd_soc_dai_link_set_capabilities(xxx)
{
...
for_each_pcm_streams(direction) {
...
for_each_link_cpus(dai_link, i, cpu) {
(A) dai = snd_soc_find_dai(cpu);
...
}
...
for_each_link_codecs(dai_link, i, codec) {
(A) dai = snd_soc_find_dai(codec);
...
}
}
...
}
Because of these background, we will get WARNING if .config has CONFIG_LOCKDEP.
WARNING: CPU: 2 PID: 53 at sound/soc/soc-core.c:814 snd_soc_find_dai+0xf8/0x100
CPU: 2 PID: 53 Comm: kworker/2:1 Not tainted 5.7.0-rc1+ #328
Hardware name: Renesas H3ULCB Kingfisher board based on r8a77951 (DT)
Workqueue: events deferred_probe_work_func
pstate: 60000005 (nZCv daif -PAN -UAO)
pc : snd_soc_find_dai+0xf8/0x100
lr : snd_soc_find_dai+0xf4/0x100
...
Call trace:
snd_soc_find_dai+0xf8/0x100
snd_soc_dai_link_set_capabilities+0xa0/0x16c
graph_dai_link_of_dpcm+0x390/0x3c0
graph_for_each_link+0x134/0x200
graph_probe+0x144/0x230
platform_drv_probe+0x5c/0xb0
really_probe+0xe4/0x430
driver_probe_device+0x60/0xf4
snd_soc_find_dai() will be used from (X) CPU/Codec/Platform driver with
mutex lock, and (Y) Card driver without mutex lock.
This snd_soc_dai_link_set_capabilities() is for Card driver,
this means called without mutex.
This patch adds snd_soc_find_dai_with_mutex() to solve it.
Fixes: 25612477d20b52 ("ASoC: soc-dai: set dai_link dpcm_ flags with a helper")
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
This patch was originally "ASoC: soc-core: move snd_soc_dai_link_set_capabilities() to soc-core.c".
This is for asoc/for-5.9 branch
include/sound/soc.h | 2 ++
sound/soc/soc-core.c | 13 +++++++++++++
sound/soc/soc-dai.c | 4 ++--
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 5e3919ffb00c..4176071f61bf 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1361,6 +1361,8 @@ void snd_soc_unregister_dai(struct snd_soc_dai *dai);
struct snd_soc_dai *snd_soc_find_dai(
const struct snd_soc_dai_link_component *dlc);
+struct snd_soc_dai *snd_soc_find_dai_with_mutex(
+ const struct snd_soc_dai_link_component *dlc);
#include <sound/soc-dai.h>
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 2fe1b2ec7c8f..fe11856d7a63 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -834,6 +834,19 @@ struct snd_soc_dai *snd_soc_find_dai(
}
EXPORT_SYMBOL_GPL(snd_soc_find_dai);
+struct snd_soc_dai *snd_soc_find_dai_with_mutex(
+ const struct snd_soc_dai_link_component *dlc)
+{
+ struct snd_soc_dai *dai;
+
+ mutex_lock(&client_mutex);
+ dai = snd_soc_find_dai(dlc);
+ mutex_unlock(&client_mutex);
+
+ return dai;
+}
+EXPORT_SYMBOL_GPL(snd_soc_find_dai_with_mutex);
+
static int soc_dai_link_sanity_check(struct snd_soc_card *card,
struct snd_soc_dai_link *link)
{
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 91a2551e4cef..0dbd312aad08 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -412,14 +412,14 @@ void snd_soc_dai_link_set_capabilities(struct snd_soc_dai_link *dai_link)
supported_codec = false;
for_each_link_cpus(dai_link, i, cpu) {
- dai = snd_soc_find_dai(cpu);
+ dai = snd_soc_find_dai_with_mutex(cpu);
if (dai && snd_soc_dai_stream_valid(dai, direction)) {
supported_cpu = true;
break;
}
}
for_each_link_codecs(dai_link, i, codec) {
- dai = snd_soc_find_dai(codec);
+ dai = snd_soc_find_dai_with_mutex(codec);
if (dai && snd_soc_dai_stream_valid(dai, direction)) {
supported_codec = true;
break;
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ASoC: soc-core: add snd_soc_find_dai_with_mutex()
2020-08-26 23:55 [PATCH] ASoC: soc-core: add snd_soc_find_dai_with_mutex() Kuninori Morimoto
@ 2020-08-27 13:56 ` Mark Brown
2020-08-27 22:46 ` Kuninori Morimoto
0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2020-08-27 13:56 UTC (permalink / raw)
To: Pierre-Louis Bossart, Kuninori Morimoto; +Cc: Linux-ALSA
On 27 Aug 2020 08:55:39 +0900, Kuninori Morimoto wrote:
> commit 25612477d20b52 ("ASoC: soc-dai: set dai_link dpcm_ flags with a helper")
> added snd_soc_dai_link_set_capabilities().
> But it is using snd_soc_find_dai() (A) which is required client_mutex (B).
> And client_mutex is soc-core.c local.
>
> struct snd_soc_dai *snd_soc_find_dai(xxx)
> {
> ...
> (B) lockdep_assert_held(&client_mutex);
> ...
> }
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: soc-core: add snd_soc_find_dai_with_mutex()
commit: c1c277b2c425f69b9b4f4258d9db18562d9be041
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ASoC: soc-core: add snd_soc_find_dai_with_mutex()
2020-08-27 13:56 ` Mark Brown
@ 2020-08-27 22:46 ` Kuninori Morimoto
2020-08-28 10:43 ` Mark Brown
0 siblings, 1 reply; 4+ messages in thread
From: Kuninori Morimoto @ 2020-08-27 22:46 UTC (permalink / raw)
To: Mark Brown; +Cc: Linux-ALSA, Pierre-Louis Bossart
Hi Mark
> > commit 25612477d20b52 ("ASoC: soc-dai: set dai_link dpcm_ flags with a helper")
> > added snd_soc_dai_link_set_capabilities().
> > But it is using snd_soc_find_dai() (A) which is required client_mutex (B).
> > And client_mutex is soc-core.c local.
> >
> > struct snd_soc_dai *snd_soc_find_dai(xxx)
> > {
> > ...
> > (B) lockdep_assert_held(&client_mutex);
> > ...
> > }
> >
> > [...]
>
> Applied to
>
> https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
>
> Thanks!
>
> [1/1] ASoC: soc-core: add snd_soc_find_dai_with_mutex()
> commit: c1c277b2c425f69b9b4f4258d9db18562d9be041
(snip)
> This patch was originally "ASoC: soc-core: move snd_soc_dai_link_set_capabilities() to soc-core.c".
> This is for asoc/for-5.9 branch
Thank you for appling this patch.
I think it is added to for-5.10,
but is needed to for-5.9.
Thank you for your help !!
Best regards
---
Kuninori Morimoto
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ASoC: soc-core: add snd_soc_find_dai_with_mutex()
2020-08-27 22:46 ` Kuninori Morimoto
@ 2020-08-28 10:43 ` Mark Brown
0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2020-08-28 10:43 UTC (permalink / raw)
To: Kuninori Morimoto; +Cc: Linux-ALSA, Pierre-Louis Bossart
[-- Attachment #1: Type: text/plain, Size: 213 bytes --]
On Fri, Aug 28, 2020 at 07:46:41AM +0900, Kuninori Morimoto wrote:
> Thank you for appling this patch.
> I think it is added to for-5.10,
> but is needed to for-5.9.
Moved - the naming here made things unclear.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-08-28 10:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-26 23:55 [PATCH] ASoC: soc-core: add snd_soc_find_dai_with_mutex() Kuninori Morimoto
2020-08-27 13:56 ` Mark Brown
2020-08-27 22:46 ` Kuninori Morimoto
2020-08-28 10:43 ` Mark Brown
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.