diff mbox series

[3/3] ASoC: hdmi-codec: use DAI ID and Name for ELD entry

Message ID 87bjup6wx3.wl-kuninori.morimoto.gx@renesas.com (mailing list archive)
State New
Headers show
Series ASoC: bug fix patches | expand

Commit Message

Kuninori Morimoto Feb. 26, 2025, 6:29 a.m. UTC
commit 0ecd24a6d8b2 ("ASoC: hdmi-codec: dump ELD through procfs") adds
"eld#%d" entry for sound proc. It is using DAI ID. But it is possible to
have duplicate DAI ID on same Sound Card. In such case, we will get below
error. To avoid duplicate entry name, use RTD ID instead of DAI ID.

	proc_dir_entry 'card0/eld#0' already registered
	WARNING: CPU: 3 PID: 74 at fs/proc/generic.c:377 proc_register+0x11c/0x1a4
	Modules linked in:
	CPU: 3 UID: 0 PID: 74 Comm: kworker/u33:5 Not tainted 6.14.0-rc1-next-20250206-arm64-renesas #174
	Hardware name: Renesas Salvator-X 2nd version board based on r8a77951 (DT)
	Workqueue: events_unbound deferred_probe_work_func
	pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
	pc : proc_register+0x11c/0x1a4
	ata1: SATA link down (SStatus 0 SControl 300)
	lr : proc_register+0x11c/0x1a4
	sp : ffff8000847db880
	x29: ffff8000847db880 x28: 0000000000000000 x27: ffff0004c3403c98
	x26: 0000000000000005 x25: ffff0004c14b03e4 x24: 0000000000000005
	x23: ffff0004c361adb8 x22: ffff800082f24860 x21: ffff0004c361ad00
	x20: ffff0004c14b0300 x19: ffff0004c14b02c0 x18: 00000000ffffffff
	x17: 0000000000000000 x16: 00400034b5503510 x15: ffff8001047db447
	x14: 0000000000000000 x13: 6465726574736967 x12: ffff800082e66d30
	x11: 000000000000028e x10: ffff800082e66d30 x9 : 00000000ffffefff
	x8 : ffff800082ebed30 x7 : 0000000000017fe8 x6 : 0000000000000000
	x5 : 80000000fffff000 x4 : 0000000000000000 x3 : 0000000000000000
	x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff0004c15b3600
	Call trace:
	 proc_register+0x11c/0x1a4 (P)
	 proc_create_data+0x3c/0x60
	 snd_info_register+0xd0/0x130
	 snd_info_register+0x30/0x130
	 snd_info_card_register+0x1c/0xbc
	 snd_card_register+0x194/0x1ec
	 snd_soc_bind_card+0x7f8/0xad0
	 snd_soc_register_card+0xe8/0xfc
	 devm_snd_soc_register_card+0x48/0x98
	 audio_graph_parse_of+0x1c4/0x1f8
	 graph_probe+0x6c/0x80
	...

Reported-by: Thuan Nguyen <thuan.nguyen-hong@banvien.com.vn>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Thuan Nguyen <thuan.nguyen-hong@banvien.com.vn>
---
 sound/soc/codecs/hdmi-codec.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

Comments

Mark Brown Feb. 26, 2025, 12:52 p.m. UTC | #1
On Wed, Feb 26, 2025 at 06:29:44AM +0000, Kuninori Morimoto wrote:

> commit 0ecd24a6d8b2 ("ASoC: hdmi-codec: dump ELD through procfs") adds
> "eld#%d" entry for sound proc. It is using DAI ID. But it is possible to
> have duplicate DAI ID on same Sound Card. In such case, we will get below
> error. To avoid duplicate entry name, use RTD ID instead of DAI ID.

Acked-by: Mark Brown <broonie@kernel.org>

Given that this doesn't depend on the first two patches it'd probably
have been better sent separately, especially since it needs to get
merged via a separate tree.
Kuninori Morimoto Feb. 26, 2025, 11:11 p.m. UTC | #2
Hi Mark, Takashi

> > commit 0ecd24a6d8b2 ("ASoC: hdmi-codec: dump ELD through procfs") adds
> > "eld#%d" entry for sound proc. It is using DAI ID. But it is possible to
> > have duplicate DAI ID on same Sound Card. In such case, we will get below
> > error. To avoid duplicate entry name, use RTD ID instead of DAI ID.
> 
> Acked-by: Mark Brown <broonie@kernel.org>
> 
> Given that this doesn't depend on the first two patches it'd probably
> have been better sent separately, especially since it needs to get
> merged via a separate tree.

OK, thanks. Will do

# I noticed that the Subject was not matched, and the patch is missing
# Fixes tag. I will post it as v2 patch, soon


Thank you for your help !!

Best regards
---
Kuninori Morimoto
Kuninori Morimoto Feb. 26, 2025, 11:26 p.m. UTC | #3
Hi Takashi

> > > commit 0ecd24a6d8b2 ("ASoC: hdmi-codec: dump ELD through procfs") adds
> > > "eld#%d" entry for sound proc. It is using DAI ID. But it is possible to
> > > have duplicate DAI ID on same Sound Card. In such case, we will get below
> > > error. To avoid duplicate entry name, use RTD ID instead of DAI ID.
> > 
> > Acked-by: Mark Brown <broonie@kernel.org>
> > 
> > Given that this doesn't depend on the first two patches it'd probably
> > have been better sent separately, especially since it needs to get
> > merged via a separate tree.
> 
> OK, thanks. Will do
> 
> # I noticed that the Subject was not matched, and the patch is missing
> # Fixes tag. I will post it as v2 patch, soon

This patch has "ASoC: " on Subject, but commit 0ecd24a6d8b2 exists only on
your tree, not on Mark tree. Will post v2

Thank you for your help !!

Best regards
---
Kuninori Morimoto
diff mbox series

Patch

diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
index 17019b1d680b..bc01ff65bd6f 100644
--- a/sound/soc/codecs/hdmi-codec.c
+++ b/sound/soc/codecs/hdmi-codec.c
@@ -842,12 +842,28 @@  static void print_eld_info(struct snd_info_entry *entry,
 static int hdmi_dai_proc_new(struct hdmi_codec_priv *hcp,
 			     struct snd_soc_dai *dai)
 {
+	struct snd_soc_component *component = dai->component;
+	struct snd_soc_card *card = component->card;
+	struct snd_soc_dai *d;
+	struct snd_soc_pcm_runtime *rtd;
 	struct snd_info_entry *entry;
 	char name[32];
-	int err;
+	int err, i, id = 0;
 
-	snprintf(name, sizeof(name), "eld#%d", dai->id);
-	err = snd_card_proc_new(dai->component->card->snd_card, name, &entry);
+	/*
+	 * To avoid duplicate proc entry, find its rtd and use rtd->id
+	 * instead of dai->id
+	 */
+	for_each_card_rtds(card, rtd) {
+		for_each_rtd_dais(rtd, i, d)
+			if (d == dai) {
+				id = rtd->id;
+				goto found;
+			}
+	}
+found:
+	snprintf(name, sizeof(name), "eld#%d", id);
+	err = snd_card_proc_new(card->snd_card, name, &entry);
 	if (err < 0)
 		return err;