RE: [PATCH 1/2] ASoC: SOF: Intel: reuse name prefix for duplicate SoundWire devices
From: Liao, Bard
Date: Mon Aug 31 2026 - 08:36:24 EST
> -----Original Message-----
> From: Amaan Lalani <zlzzm2014@xxxxxxxxxxx>
> Sent: Saturday, August 29, 2026 3:04 AM
> To: Mark Brown <broonie@xxxxxxxxxx>
> Cc: Liam Girdwood <lgirdwood@xxxxxxxxx>; Jaroslav Kysela
> <perex@xxxxxxxx>; Takashi Iwai <tiwai@xxxxxxxx>; Peter Ujfalusi
> <peter.ujfalusi@xxxxxxxxxxxxxxx>; Bard Liao <yung-
> chuan.liao@xxxxxxxxxxxxxxx>; Pierre-Louis Bossart <pierre-
> louis.bossart@xxxxxxxxx>; linux-sound@xxxxxxxxxxxxxxx; sound-open-
> firmware@xxxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; Amaan Lalani
> <zlzzm2014@xxxxxxxxxxx>
> Subject: [PATCH 1/2] ASoC: SOF: Intel: reuse name prefix for duplicate
> SoundWire devices
>
> Some firmware describes a single physical SoundWire peripheral with
> multiple _ADR entries that differ only in SDCA class ID.
>
> These entries currently consume separate amplifier indices when the
> SoundWire machine description is built. This can cause the peripheral
> that actually enumerates to receive a different name prefix from the
> one expected by UCM.
>
> Detect entries which differ only in class ID and reuse the name prefix
> assigned to the first entry. Do not increment the amplifier index for
> the duplicate entry.
>
> Fixes: 5226d19d4cae ("ASoC: SOF: Intel: use sof_sdw as default SDW machine
> driver")
>
> Assisted-by: LLM
> Signed-off-by: Amaan Lalani <zlzzm2014@xxxxxxxxxxx>
> ---
> sound/soc/sof/intel/hda.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c
> index 4dbba9186b29..c785e27089ea 100644
> --- a/sound/soc/sof/intel/hda.c
> +++ b/sound/soc/sof/intel/hda.c
> @@ -1245,6 +1245,20 @@ static struct snd_soc_acpi_adr_device
> *find_acpi_adr_device(struct device *dev,
> ((u64)(sdw_device->id.sdw_version & 0xF) << 44) |
> ((u64)(sdw_device->bus->link_id & 0xF) << 48);
>
> + /*
> + * Firmware may describe the same physical peripheral with multiple
> + * _ADR entries that differ only in SDCA class ID. Reuse the prefix
> + * so duplicate entries do not consume another amplifier index.
> + */
> +
> + for (j = 0; j < index; j++) {
> + if ((adr_dev[j].adr & ~SDW_CLASS_ID_MASK) ==
> + (adr_dev[index].adr & ~SDW_CLASS_ID_MASK)) {
> + adr_dev[index].name_prefix =
> adr_dev[j].name_prefix;
> + goto done_name_prefix;
> + }
> + }
> +
It seems be a valid assumption that 2 peripherals with the same vendor
and part ID but different class ID will never coexist in the same device.
However, the implementation is not correct. We should skip the duplicated
peripheral completely not just reuse the name_prefix.
> if (!codec_info_list[i].is_amp) {
> /* For non-amp codecs, get name_prefix from
> codec_info_list[] */
> adr_dev[index].name_prefix = devm_kasprintf(dev,
> GFP_KERNEL, "%s", name_prefix);
> --
> 2.55.0
>