Skip to contentSkip to conversation

ASoC: soc-core: use the device tree card name as long_name

RFC PATCH In review Val Packett 5 participants 7 messages May 6 – Sep 14

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 ASoC: soc-core: use the device tree card name as long_name

When setting the model property for the sound card on an OF/DT system, the expectation is that that model name would be used in the UCM config path lookup. However, the DT model name was only used as the "short" name, which gets overriden by the "long" name during loading, and the "long" name is automatically set based on DMI data if available. As a result, adding an intermediate bootloader such as U-Boot which provides DMI data on a device that didn't have it before would break the UCM config loading by suddenly looking at the "wrong" path.

Fix by assigning the DT model name to the long_name field as well.

---

For more context/examples, see:
https://gitlab.postmarketos.org/postmarketOS/pmaports/-/work_items/4386

err, for some reason that link requires an account to view right now, hopefully that's fixed by the time you're reading this. if not, quoting:

Quoted 6 lines

ALSA looks for wrong device name when using U-Boot

What's the expected behaviour?
ALSA finds Fairphone 5.conf
What's the current behaviour?
ALSA looks for fairphone-Fairphone5-.conf, doesn't find it, and results in no audio.

("Fairphone 5.conf" coming from model = "Fairphone 5"; in .dts)

So it's totally unexpected in the DT world that adding DMI info would change which UCM path is used.

Now the question is, could this possibly break anything for anyone???..

Qcom laptops do not rely on these model-based paths at all, instead having custom DMI match If conditions inside of "fallback" SoC-wide UCM .conf files such as:
https://github.com/alsa-project/alsa-ucm-conf/blob/980fb83651e82c3e53d3a0ab7fa9b7d6fc2d809b/ucm2/Qualcomm/x1e80100/x1e80100.conf

So there it shouldn't make a difference. But does *anyone* use DMI-based soundcard names intentionally on *any* DT platform?

Thanks,
~val

P.S. I don't understand the lifecycle of these strings but it seeeems that the expectation is that they point to static data so they're never freed?

---
 sound/soc/soc-core.c | 8 ++++++++
 1 file changed, 8 insertions(+)
sound/soc/soc-core.c +8 -0
index 3fecf9fc903c..8456595bb41d 100644
@@ -2995,6 +2995,14 @@ int snd_soc_of_parse_card_name(struct snd_soc_card *card,
 		return ret;
 	}
 
+	/*
+	 * When setting the OF property in a device tree, the expectation is
+	 * that the UCM config matching the value would be loaded. However if
+	 * a long_name is set, it would be used in the config path instead, and
+	 * snd_soc_set_dmi_name sets long_name to the DMI name if it's unset.
+	 */
+	card->long_name = card->name;
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(snd_soc_of_parse_card_name);
Signature · 1 line
2.53.0
Tested-by on v1 1/1
#1 lore raw
Quoted 9 lines · Val Packett

When setting the model property for the sound card on an OF/DT system, the expectation is that that model name would be used in the UCM config path lookup. However, the DT model name was only used as the "short" name, which gets overriden by the "long" name during loading, and the "long" name is automatically set based on DMI data if available. As a result, adding an intermediate bootloader such as U-Boot which provides DMI data on a device that didn't have it before would break the UCM config loading by suddenly looking at the "wrong" path.

Quoted 4 lines

Fix by assigning the DT model name to the long_name field as well.

---

Thanks for the patch! This fixed audio on my Google Pixel 3a, which booted the 7.1.3 kernel (on postmarketOS) via u-boot.

-Clayton

#2 lore raw
In reply to Val Packett
Quoted 46 lines · Val Packett

When setting the model property for the sound card on an OF/DT system, the expectation is that that model name would be used in the UCM config path lookup. However, the DT model name was only used as the "short" name, which gets overriden by the "long" name during loading, and the "long" name is automatically set based on DMI data if available. As a result, adding an intermediate bootloader such as U-Boot which provides DMI data on a device that didn't have it before would break the UCM config loading by suddenly looking at the "wrong" path.

Fix by assigning the DT model name to the long_name field as well.

---

For more context/examples, see:
https://gitlab.postmarketos.org/postmarketOS/pmaports/-/work_items/4386

err, for some reason that link requires an account to view right now, hopefully that's fixed by the time you're reading this. if not, quoting:

Quoted 6 lines

ALSA looks for wrong device name when using U-Boot

What's the expected behaviour?
ALSA finds Fairphone 5.conf
What's the current behaviour?
ALSA looks for fairphone-Fairphone5-.conf, doesn't find it, and results in no audio.

("Fairphone 5.conf" coming from model = "Fairphone 5"; in .dts)

So it's totally unexpected in the DT world that adding DMI info would change which UCM path is used.

Now the question is, could this possibly break anything for anyone???..

Qcom laptops do not rely on these model-based paths at all, instead having custom DMI match If conditions inside of "fallback" SoC-wide UCM .conf files such as:
https://github.com/alsa-project/alsa-ucm-conf/blob/980fb83651e82c3e53d3a0ab7fa9b7d6fc2d809b/ucm2/Qualcomm/x1e80100/x1e80100.conf

So there it shouldn't make a difference. But does *anyone* use DMI-based soundcard names intentionally on *any* DT platform?

Thanks,
~val

Quoted 7 lines

P.S. I don't understand the lifecycle of these strings but it seeeems that the expectation is that they point to static data so they're never freed?

---
  sound/soc/soc-core.c | 8 ++++++++
  1 file changed, 8 insertions(+)

Would be great to hear what what maintainers think about this, this causing some level of unpleasantness.

Also there is my slightly related question about the DT model property naming [1].

Thanks
David

[1] https://lore.kernel.org/all/[email protected]/

#3 lore raw
In reply to Val Packett

Hi,

Quoted 34 lines · Val Packett

When setting the model property for the sound card on an OF/DT system, the expectation is that that model name would be used in the UCM config path lookup. However, the DT model name was only used as the "short" name, which gets overriden by the "long" name during loading, and the "long" name is automatically set based on DMI data if available. As a result, adding an intermediate bootloader such as U-Boot which provides DMI data on a device that didn't have it before would break the UCM config loading by suddenly looking at the "wrong" path.

Fix by assigning the DT model name to the long_name field as well.

---

For more context/examples, see:
https://gitlab.postmarketos.org/postmarketOS/pmaports/-/work_items/4386

err, for some reason that link requires an account to view right now, hopefully that's fixed by the time you're reading this. if not, quoting:

Quoted 6 lines

ALSA looks for wrong device name when using U-Boot

What's the expected behaviour?
ALSA finds Fairphone 5.conf
What's the current behaviour?
ALSA looks for fairphone-Fairphone5-.conf, doesn't find it, and results in no audio.

("Fairphone 5.conf" coming from model = "Fairphone 5"; in .dts)

So it's totally unexpected in the DT world that adding DMI info would change which UCM path is used.

Now the question is, could this possibly break anything for anyone???..

Quoted 7 lines

Qcom laptops do not rely on these model-based paths at all, instead having custom DMI match If conditions inside of "fallback" SoC-wide UCM .conf files such as:
https://github.com/alsa-project/alsa-ucm-conf/blob/980fb83651e82c3e53d3a0ab7fa9b7d6fc2d809b/ucm2/Qualcomm/x1e80100/x1e80100.conf

So there it shouldn't make a difference. But does *anyone* use DMI-based soundcard names intentionally on *any* DT platform?

Would be great to have some guidance from the subsystem / alsa ucm maintainers as multiple distros are patching around it atm (either with this patch or symlinks in the ucm profiles).

Cheers,
-- Guido

Quoted 34 lines

Thanks,
~val

P.S. I don't understand the lifecycle of these strings but it seeeems that the expectation is that they point to static data so they're never freed?

---
 sound/soc/soc-core.c | 8 ++++++++
 1 file changed, 8 insertions(+)
sound/soc/soc-core.c +8 -0
index 3fecf9fc903c..8456595bb41d 100644
@@ -2995,6 +2995,14 @@ int snd_soc_of_parse_card_name(struct snd_soc_card *card,
 		return ret;
 	}
 
+	/*
+	 * When setting the OF property in a device tree, the expectation is
+	 * that the UCM config matching the value would be loaded. However if
+	 * a long_name is set, it would be used in the config path instead, and
+	 * snd_soc_set_dmi_name sets long_name to the DMI name if it's unset.
+	 */
+	card->long_name = card->name;
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(snd_soc_of_parse_card_name);
Signature · 1 line
2.53.0
maintainer
#4 lore raw
Quoted 11 lines · Guido Günther
Quoted 10 lines · Val Packett

When setting the model property for the sound card on an OF/DT system, the expectation is that that model name would be used in the UCM config path lookup. However, the DT model name was only used as the "short" name, which gets overriden by the "long" name during loading, and the "long" name is automatically set based on DMI data if available. As a result, adding an intermediate bootloader such as U-Boot which provides DMI data on a device that didn't have it before would break the UCM config loading by suddenly looking at the "wrong" path.

Fix by assigning the DT model name to the long_name field as well.

I'm not convinced that there is a clear expectation here, any change will doubtless upset some other user (for example someone using a system derived from a reference board that happens to work with it's device tree, or something where the firmware puts discovered information into DMI). Really you're just not supposed to combine DMI and DT based discovery methods, having a system shipping both is just going to lead to confusion and there's no way we can possibly get it right. You have decided that for your systems the DMI information is bad and you want to override it but that doesn't mean that the next person won't make the opposite choice. Any decision here should be policy based in userspace based on the full system information.

Please don't send content free pings and please allow a reasonable time for review. People get busy, go on holiday, attend conferences and so on so unless there is some reason for urgency (like critical bug fixes) please allow at least a couple of weeks for review. If there have been review comments then people may be waiting for those to be addressed.

Sending content free pings adds to the mail volume (if they are seen at all) which is often the problem and since they can't be reviewed directly if something has gone wrong you'll have to resend the patches anyway, so sending again is generally a better approach though there are some other maintainers who like them - if in doubt look at how patches for the subsystem are normally handled.

#5 lore raw

Hi Mark,

Quoted 13 lines · Mark Brown
Quoted 11 lines · Guido Günther
Quoted 10 lines · Val Packett

When setting the model property for the sound card on an OF/DT system, the expectation is that that model name would be used in the UCM config path lookup. However, the DT model name was only used as the "short" name, which gets overriden by the "long" name during loading, and the "long" name is automatically set based on DMI data if available. As a result, adding an intermediate bootloader such as U-Boot which provides DMI data on a device that didn't have it before would break the UCM config loading by suddenly looking at the "wrong" path.

Fix by assigning the DT model name to the long_name field as well.

Quoted 11 lines

I'm not convinced that there is a clear expectation here, any change will doubtless upset some other user (for example someone using a system derived from a reference board that happens to work with it's device tree, or something where the firmware puts discovered information into DMI). Really you're just not supposed to combine DMI and DT based discovery methods, having a system shipping both is just going to lead to confusion and there's no way we can possibly get it right. You have decided that for your systems the DMI information is bad and you want to override it but that doesn't mean that the next person won't make the opposite choice. Any decision here should be policy based in userspace based on the full system information.

Thanks for the hint. So that would mean we should do something similar to what Lenovo does in UCM (that Val pointed to)?

https://github.com/alsa-project/alsa-ucm-conf/blob/980fb83651e82c3e53d3a0ab7fa9b7d6fc2d809b/ucm2/Qualcomm/x1e80100/x1e80100.conf

Quoted 6 lines

Please don't send content free pings and please allow a reasonable time for review. People get busy, go on holiday, attend conferences and so on so unless there is some reason for urgency (like critical bug fixes) please allow at least a couple of weeks for review. If there have been review comments then people may be waiting for those to be addressed.

The original mail was from May so I figured ~ half a year would be o.k.? Sorry I got that wrong.

Cheers,
-- Guido

maintainer
#6 lore raw
Quoted 9 lines · Guido Günther
Quoted 2 lines · Mark Brown

opposite choice. Any decision here should be policy based in userspace based on the full system information.

Thanks for the hint. So that would mean we should do something similar to what Lenovo does in UCM (that Val pointed to)?

https://github.com/alsa-project/alsa-ucm-conf/blob/980fb83651e82c3e53d3a0ab7fa9b7d6fc2d809b/ucm2/Qualcomm/x1e80100/x1e80100.conf

That looks plausibe, or possibly some more generic thing that teaches UCM about when to use DMI.

Quoted 8 lines
Quoted 5 lines

Please don't send content free pings and please allow a reasonable time for review. People get busy, go on holiday, attend conferences and so on so unless there is some reason for urgency (like critical bug fixes) please allow at least a couple of weeks for review. If there have been review comments then people may be waiting for those to be addressed.

The original mail was from May so I figured ~ half a year would be o.k.? Sorry I got that wrong.

Note the bit in the mail about resending if you think things have been dropped.