[PATCH 0/2] ASoC: fix SoundWire enumeration on Surface Pro 11
Some Surface Pro 11 systems expose duplicate SoundWire ACPI _ADR entries for the same physical peripheral, differing only in SDCA class ID. Firmware may also describe SoundWire peripherals which remain unattached. Together, these can result in incorrect amplifier name prefixes and entries being created for peripherals which are not physically present, preventing the sound card from registering correctly. The first patch reuses the amplifier name prefix when an _ADR entry differs from an earlier entry only by SDCA class ID. The second patch skips SoundWire peripherals explicitly reported as SDW_SLAVE_UNATTACHED when counting and parsing endpoints. Tested on a Microsoft Surface Pro 11 with Intel hardware by building and booting the patched kernel and verifying that the sound card registers and speaker playback works. Amaan Lalani (2): ASoC: SOF: Intel: reuse name prefix for duplicate SoundWire devices ASoC: sdw_utils: skip unattached SoundWire peripherals sound/soc/sdw_utils/soc_sdw_utils.c | 35 +++++++++++++++++++++++++++++ sound/soc/sof/intel/hda.c | 14 ++++++++++++ 2 files changed, 49 insertions(+) base-commit: 1b78070aaef63512688aebfbc82365ef9d6660f1 -- 2.55.0
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@outlook.com> --- 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; + } + } + 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
-----Original Message----- From: Amaan Lalani <zlzzm2014@outlook.com> Sent: Saturday, August 29, 2026 3:04 AM To: Mark Brown <broonie@kernel.org> Cc: Liam Girdwood <lgirdwood@gmail.com>; Jaroslav Kysela <perex@perex.cz>; Takashi Iwai <tiwai@suse.com>; Peter Ujfalusi <peter.ujfalusi@linux.intel.com>; Bard Liao <yung- chuan.liao@linux.intel.com>; Pierre-Louis Bossart <pierre- louis.bossart@linux.dev>; linux-sound@vger.kernel.org; sound-open- firmware@alsa-project.org; linux-kernel@vger.kernel.org; Amaan Lalani <zlzzm2014@outlook.com> 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@outlook.com> --- 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
-----Original Message----- From: Liao, Bard Sent: Monday, August 31, 2026 8:30 PM To: Amaan Lalani <zlzzm2014@outlook.com>; Mark Brown <broonie@kernel.org> Cc: Liam Girdwood <lgirdwood@gmail.com>; Jaroslav Kysela <perex@perex.cz>; Takashi Iwai <tiwai@suse.com>; Peter Ujfalusi <peter.ujfalusi@linux.intel.com>; Bard Liao <yung- chuan.liao@linux.intel.com>; Pierre-Louis Bossart <pierre- louis.bossart@linux.dev>; linux-sound@vger.kernel.org; sound-open- firmware@alsa-project.org; linux-kernel@vger.kernel.org Subject: RE: [PATCH 1/2] ASoC: SOF: Intel: reuse name prefix for duplicate SoundWire devices
-----Original Message----- From: Amaan Lalani <zlzzm2014@outlook.com> Sent: Saturday, August 29, 2026 3:04 AM To: Mark Brown <broonie@kernel.org> Cc: Liam Girdwood <lgirdwood@gmail.com>; Jaroslav Kysela <perex@perex.cz>; Takashi Iwai <tiwai@suse.com>; Peter Ujfalusi <peter.ujfalusi@linux.intel.com>; Bard Liao <yung- chuan.liao@linux.intel.com>; Pierre-Louis Bossart <pierre- louis.bossart@linux.dev>; linux-sound@vger.kernel.org; sound-open- firmware@alsa-project.org; linux-kernel@vger.kernel.org; Amaan Lalani <zlzzm2014@outlook.com> 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@outlook.com> ---
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.
The problem is that we don't know which one is the real one. And which one should be skipped. We may need to enumerate the peripheral before selecting the machine driver. I need to think more about it.
Firmware may describe SoundWire peripherals which do not physically enumerate on the bus. The corresponding SoundWire device can still be present with SDW_SLAVE_UNATTACHED status. Counting and parsing endpoints for such peripherals can create entries for devices which are not actually present and therefore interfere with sound card registration. Check the SoundWire slave status before counting or parsing a peripheral. Skip peripherals reported as SDW_SLAVE_UNATTACHED while preserving the existing behavior when the SoundWire device cannot be looked up. Fixes: 27fd36aefa00 ("ASoC: Intel: sof-sdw: Add new code for parsing the snd_soc_acpi structs") Assisted-by: LLM Signed-off-by: Amaan Lalani <zlzzm2014@outlook.com> --- sound/soc/sdw_utils/soc_sdw_utils.c | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/sound/soc/sdw_utils/soc_sdw_utils.c b/sound/soc/sdw_utils/soc_sdw_utils.c index 8a07ba2a29e5..381eb884efb9 100644 --- a/sound/soc/sdw_utils/soc_sdw_utils.c +++ b/sound/soc/sdw_utils/soc_sdw_utils.c @@ -1854,6 +1854,33 @@ static int is_sdca_aux_dev_present(struct device *dev, return 0; } +static bool is_peripheral_attached(struct device *dev, + const struct snd_soc_acpi_link_adr *adr_link, + int adr_index) +{ + const char *sdw_codec_name; + struct sdw_slave *slave; + + sdw_codec_name = _asoc_sdw_get_codec_name(dev, adr_link, adr_index); + if (!sdw_codec_name) + return true; + + struct device *sdw_dev __free(put_device) = + bus_find_device_by_name(&sdw_bus_type, NULL, sdw_codec_name); + if (!sdw_dev) + return true; + + slave = dev_to_sdw_dev(sdw_dev); + + if (slave->status == SDW_SLAVE_UNATTACHED) { + dev_dbg(dev, "%s not present on the bus, skipping\n", + sdw_codec_name); + return false; + } + + return true; +} + int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card, int *num_devs, int *num_ends, int *num_aux) { @@ -1870,6 +1897,11 @@ int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card, const struct snd_soc_acpi_adr_device *adr_dev = &adr_link->adr_d[i]; struct asoc_sdw_codec_info *codec_info; + if (!is_peripheral_attached(dev, adr_link, i)) { + (*num_devs)--; + continue; + } + *num_ends += adr_dev->num_endpoints; codec_info = asoc_sdw_find_codec_info_part(adr_dev->adr); @@ -2029,6 +2061,9 @@ int asoc_sdw_parse_sdw_endpoints(struct device *dev, return -EINVAL; } + if (!is_peripheral_attached(dev, adr_link, i)) + continue; + codec_info = asoc_sdw_find_codec_info_part(adr_dev->adr); if (!codec_info) return -EINVAL; -- 2.55.0
-----Original Message----- From: Amaan Lalani <zlzzm2014@outlook.com> Sent: Saturday, August 29, 2026 3:04 AM To: Mark Brown <broonie@kernel.org> Cc: Liam Girdwood <lgirdwood@gmail.com>; Jaroslav Kysela <perex@perex.cz>; Takashi Iwai <tiwai@suse.com>; Peter Ujfalusi <peter.ujfalusi@linux.intel.com>; Bard Liao <yung- chuan.liao@linux.intel.com>; Pierre-Louis Bossart <pierre- louis.bossart@linux.dev>; linux-sound@vger.kernel.org; sound-open- firmware@alsa-project.org; linux-kernel@vger.kernel.org; Amaan Lalani <zlzzm2014@outlook.com> Subject: [PATCH 2/2] ASoC: sdw_utils: skip unattached SoundWire peripherals
Firmware may describe SoundWire peripherals which do not physically enumerate on the bus. The corresponding SoundWire device can still be present with SDW_SLAVE_UNATTACHED status.
Counting and parsing endpoints for such peripherals can create entries for devices which are not actually present and therefore interfere with sound card registration.
Check the SoundWire slave status before counting or parsing a peripheral. Skip peripherals reported as SDW_SLAVE_UNATTACHED while preserving the existing behavior when the SoundWire device cannot be looked up.
Fixes: 27fd36aefa00 ("ASoC: Intel: sof-sdw: Add new code for parsing the snd_soc_acpi structs")
Assisted-by: LLM Signed-off-by: Amaan Lalani <zlzzm2014@outlook.com> --- sound/soc/sdw_utils/soc_sdw_utils.c | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
diff --git a/sound/soc/sdw_utils/soc_sdw_utils.c b/sound/soc/sdw_utils/soc_sdw_utils.c index 8a07ba2a29e5..381eb884efb9 100644 --- a/sound/soc/sdw_utils/soc_sdw_utils.c +++ b/sound/soc/sdw_utils/soc_sdw_utils.c @@ -1854,6 +1854,33 @@ static int is_sdca_aux_dev_present(struct device *dev, return 0; }
+static bool is_peripheral_attached(struct device *dev, + const struct snd_soc_acpi_link_adr *adr_link, + int adr_index) +{ + const char *sdw_codec_name; + struct sdw_slave *slave; + + sdw_codec_name = _asoc_sdw_get_codec_name(dev, adr_link, adr_index); + if (!sdw_codec_name) + return true; + + struct device *sdw_dev __free(put_device) = + bus_find_device_by_name(&sdw_bus_type, NULL, sdw_codec_name); + if (!sdw_dev) + return true; + + slave = dev_to_sdw_dev(sdw_dev); + + if (slave->status == SDW_SLAVE_UNATTACHED) { + dev_dbg(dev, "%s not present on the bus, skipping\n", + sdw_codec_name); + return false; + } + + return true; +} + int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card, int *num_devs, int *num_ends, int *num_aux) { @@ -1870,6 +1897,11 @@ int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card, const struct snd_soc_acpi_adr_device *adr_dev = &adr_link->adr_d[i]; struct asoc_sdw_codec_info *codec_info;
+ if (!is_peripheral_attached(dev, adr_link, i)) {
Sorry, but I don't think it is correct. The status just means the current state. A Peripheral aka Slave on the bus could be attached or unattached. We can't use the slave->status to determine whether a Peripheral is physically on the bus or not. Checking slave->dev_num_sticky may work. However, there is a timing issue that the Peripheral could be attached after the check.
+ (*num_devs)--; + continue; + } + *num_ends += adr_dev->num_endpoints;
codec_info = asoc_sdw_find_codec_info_part(adr_dev->adr); @@ -2029,6 +2061,9 @@ int asoc_sdw_parse_sdw_endpoints(struct device *dev, return -EINVAL; }
+ if (!is_peripheral_attached(dev, adr_link, i)) + continue; + codec_info = asoc_sdw_find_codec_info_part(adr_dev->adr); if (!codec_info) return -EINVAL; -- 2.55.0
participants (2)
-
Amaan Lalani -
Liao, Bard