From: Bard Liao <yung-chuan.liao@linux.intel.com>
To: linux-sound@vger.kernel.org, vkoul@kernel.org,
broonie@kernel.org, tiwai@suse.de
Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org,
pierre-louis.bossart@linux.dev, peter.ujfalusi@linux.intel.com,
bard.liao@intel.com
Subject: [PATCH 3/3] ASoC: SOF: Intel: wait and verifies the presence of SoundWire peripherals
Date: Tue, 15 Sep 2026 21:13:27 +0800 [thread overview]
Message-ID: <20260915131327.1783551-4-yung-chuan.liao@linux.intel.com> (raw)
In-Reply-To: <20260915131327.1783551-1-yung-chuan.liao@linux.intel.com>
Wait and verifies the presence of SoundWire peripherals listed in the
ACPI table. This prevents the system from probing non-existent (ghost)
SoundWire devices.
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
sound/soc/sof/intel/hda.c | 47 +++++++++++++++++++++++++++++++++++++--
1 file changed, 45 insertions(+), 2 deletions(-)
diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c
index 4dbba9186b29..e1815bfe358b 100644
--- a/sound/soc/sof/intel/hda.c
+++ b/sound/soc/sof/intel/hda.c
@@ -1304,6 +1304,8 @@ static struct snd_soc_acpi_adr_device *find_acpi_adr_device(struct device *dev,
return adr_dev;
}
+#define SDW_ENUM_TIMEOUT_MS 3000
+
static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev)
{
struct snd_sof_pdata *pdata = sdev->pdata;
@@ -1313,7 +1315,9 @@ static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev
struct sdw_peripherals *peripherals;
struct snd_soc_acpi_mach *mach;
struct sof_intel_hda_dev *hdev;
+ struct sdw_slave *slave;
int link_index, link_num;
+ unsigned long time;
int amp_index = 1;
u32 link_mask = 0;
int i;
@@ -1415,14 +1419,53 @@ static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev
if (!links)
return NULL;
+ /*
+ * Recalculate the link_mask as a link will be empty if all peripherals on the link are
+ * not enumerated
+ */
+ link_mask = 0;
/* 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->bus->is_present)
+ continue;
+
+ if (link_mask & BIT(slave->bus->link_id)) {
+ /*
+ * At least one peripheral is present on the link which means that this
+ * link has already been enumerated
+ */
+ goto skip_wait_link_enumeration;
+ }
+
+ if (sdw_show_ping_status(slave->bus, true) == 0) {
+ /* no peripherals attached on this link */
+ slave->bus->is_present = false;
+ continue;
+ }
+
+ time = wait_for_completion_timeout(&slave->bus->enumeration_complete,
+ msecs_to_jiffies(SDW_ENUM_TIMEOUT_MS));
+ if (!time) {
+ dev_warn(slave->bus->dev, "No peripheral is present\n");
+ slave->bus->is_present = false;
+ continue;
+ }
+
+skip_wait_link_enumeration:
+ /* Check if the SoundWire peripheral is present */
+ if (!slave->dev_num_sticky) {
+ dev_warn(&slave->dev, "SoundWire peripheral is not present\n");
+ continue;
+ }
/* link_index = the number of used links below the current link */
- link_index = hweight32(link_mask & (BIT(peripherals->array[i]->bus->link_id) - 1));
- links[link_index].adr_d = find_acpi_adr_device(sdev->dev, peripherals->array[i],
+ link_index = hweight32(link_mask & (BIT(slave->bus->link_id) - 1));
+ links[link_index].adr_d = find_acpi_adr_device(sdev->dev, slave,
&links[link_index], &_index);
if (!links[link_index].adr_d)
return NULL;
+ link_mask |= BIT(slave->bus->link_id);
}
mach->drv_name = "sof_sdw";
--
2.43.0
next prev parent reply other threads:[~2026-09-15 13:13 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 13:13 [PATCH 0/3] ASoC/soundwire: remove ghost peripherals from the mach table Bard Liao
2026-09-15 13:13 ` [PATCH 1/3] soundwire: allow drivers to check whether the peripheral is present Bard Liao
2026-09-15 17:32 ` Cezary Rojewski
2026-09-15 18:31 ` Pierre-Louis Bossart
2026-09-16 2:50 ` Liao, Bard
2026-09-15 13:13 ` [PATCH 2/3] soundwire: change sdw_show_ping_status type to int Bard Liao
2026-09-15 13:13 ` Bard Liao [this message]
2026-09-15 19:08 ` [PATCH 0/3] ASoC/soundwire: remove ghost peripherals from the mach table Pierre-Louis Bossart
2026-09-16 4:08 ` Liao, Bard
2026-10-07 2:25 ` Liao, Bard
2026-10-07 16:37 ` Pierre-Louis Bossart
2026-10-08 3:14 ` Liao, Bard
2026-10-08 17:09 ` Pierre-Louis Bossart
2026-10-12 14:46 ` Liao, Bard
2026-10-18 8:25 ` Pierre-Louis Bossart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260915131327.1783551-4-yung-chuan.liao@linux.intel.com \
--to=yung-chuan.liao@linux.intel.com \
--cc=bard.liao@intel.com \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=peter.ujfalusi@linux.intel.com \
--cc=pierre-louis.bossart@linux.dev \
--cc=tiwai@suse.de \
--cc=vinod.koul@linaro.org \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®