alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Mark Brown <broonie@kernel.org>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>
Subject: Re: [PATCH] ASoC: soc-core: use client_mutex for snd_soc_find_dai()
Date: 18 Aug 2020 11:52:53 +0900	[thread overview]
Message-ID: <87wo1wfz0j.wl-kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <871rk4hean.wl-kuninori.morimoto.gx@renesas.com>


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);
> 		...
> 	}
> 
> 	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
> 
> Many drivers are already calling snd_soc_find_dai() and/or snd_soc_dai_link_set_capabilities().
> Thus, same thing can be happen on these drivers, too.
> 
> 	> grep snd_soc_find_dai -rl sound/soc/*
> 	sound/soc/samsung/tm2_wm5110.c
> 	sound/soc/soc-core.c
> 	sound/soc/soc-dai.c
> 	sound/soc/soc-topology.c
> 	sound/soc/sof/topology.c
> 
> 	> grep snd_soc_dai_link_set_capabilities -rl sound/soc/*
> 	sound/soc/generic/simple-card.c
> 	sound/soc/generic/audio-graph-card.c
> 	sound/soc/qcom/common.c
> 	sound/soc/soc-dai.c

I noticed that samsung / sof are using snd_soc_find_dai() under client_mutex.
This means this patch creates deadlock for these.
Hmm... we need both _with_mutex() and _without_mutex().


Thank you for your help !!

Best regards
---
Kuninori Morimoto

      reply	other threads:[~2020-08-18  2:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-18  2:37 [PATCH] ASoC: soc-core: use client_mutex for snd_soc_find_dai() Kuninori Morimoto
2020-08-18  2:52 ` Kuninori Morimoto [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wo1wfz0j.wl-kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=pierre-louis.bossart@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).