From 40bdaa02e4d8136e66d3ac36c808fc3f57ca65d8 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Fri, 6 Nov 2026 11:36:00 +0800 Subject: [PATCH] fixup! ASoC: SOF: Intel: wait and verifies the presence of SoundWire peripherals Use a common deadline so that we will still wait at most x seconds when there are more than 1 ghost peripherals. Signed-off-by: Bard Liao --- sound/soc/sof/intel/hda.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index 45e968fb19104b..6ee05a2fccfbec 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -1320,8 +1320,9 @@ static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev struct snd_soc_acpi_mach *mach; struct sof_intel_hda_dev *hdev; struct sdw_slave *slave; + unsigned long deadline; int link_index, link_num; - unsigned long time; + long remaining; int amp_index = 1; u32 link_mask = 0; int i; @@ -1428,28 +1429,22 @@ static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev * not enumerated */ link_mask = 0; + /* One timeout budget shared by all peripherals */ + deadline = jiffies + msecs_to_jiffies(SDW_ENUM_TIMEOUT_MS); /* Generate snd_soc_acpi_link_adr struct for each peripheral reported by the ACPI table */ for (i = 0; i < peripherals->num_peripherals; i++) { slave = peripherals->array[i]; - if (slave->dev_num_sticky) - goto skip_wait_link_enumeration; - - time = wait_for_completion_timeout(&slave->enumeration_complete, - msecs_to_jiffies(SDW_ENUM_TIMEOUT_MS)); - if (!time) { - dev_warn(&slave->dev, "The peripheral is not present\n"); - continue; - } - - /* Check if the SoundWire peripheral is present */ if (!slave->dev_num_sticky) { - dev_warn(&slave->dev, "SoundWire peripheral is not present\n"); - continue; + remaining = max_t(long, (long)(deadline - jiffies), 0); + if (!wait_for_completion_timeout(&slave->enumeration_complete, + remaining) || + !slave->dev_num_sticky) { + dev_warn(&slave->dev, "SoundWire peripheral is not present\n"); + continue; + } } -skip_wait_link_enumeration: - /* link_index = the number of used links below the current link */ link_index = hweight32(link_mask & (BIT(slave->bus->link_id) - 1)); links[link_index].adr_d = find_acpi_adr_device(sdev->dev, slave,