From nobody Fri Sep 25 07:22:49 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F308C3B058F; Tue, 15 Sep 2026 13:13:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789478024; cv=none; b=qKQE4eNmcUc+NEkeeOfgCxcw53WOEdCe127m/Lu0YXm+qZ2LlxBPv8LDvLycqS+PC9/L5aEpXXUmnf1R8aZ8r1f574XywvVHAnjHZucBaDGBpIrhMrEJ3mak8C7SWUBzWJhoIZptDptZJVzR75Wj6xJdwIAR+2hf70T7reL9w7E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789478024; c=relaxed/simple; bh=cHNyYf0whMNio1HC5Qu2rPk8sI1KNF4JK9Q47XIFc1o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jEj23vJwQJO0wuT7moPuqIwcYwjRLv3JVfI/wN0zO4FukdH8qa1u07GMy3gW/1oqldj8syrIgBu1uKhHzK0j4zeeRyi5IAKsi9aZqD9tp1LalkAb726YBVmKUGA1m2bN5SGceGfsrgWwOQMZkGH25q8zC5OjaOiM5ObdPmA0oAU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=L8uuOfBT; arc=none smtp.client-ip=198.175.65.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="L8uuOfBT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789478023; x=1821014023; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cHNyYf0whMNio1HC5Qu2rPk8sI1KNF4JK9Q47XIFc1o=; b=L8uuOfBTgNHjRcHPb5jAfT9UA7F+yI7q5y9qVG+JE3kbIVNn7VkFRtNA 6SGFpkDxipC4u72qsl/Z/TcvubWC2sLURucPa1UPfqiwIkwYLIlYOBK2p eUnGNMNdCqkNMbsUW4u9MqbACJRT/0A3QY1kXDPzw0oY7Kw/LE9UtImS+ pzM9ZGLel5Aj+z6t8HKpwvsyddDg2CtW3qRcZe75fLILHIxXo2w7IR3Ql VbOZ6Oqi3v0EZ7IzBUD1tv0PmDaVDHSAtjZ0C/LHeoTJh2WV8NmGkxtIA dJvTftGoX5i8Up6PcePdeUS7yqsYPRNQEgJ58v9YMRR5FwxEUGC23V+VA w==; X-CSE-ConnectionGUID: a1DCBQaSTz2LmjEemcw5FQ== X-CSE-MsgGUID: mF1EVBKVSWW2Fr5x1VNzNw== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="112608436" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="112608436" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2026 06:13:43 -0700 X-CSE-ConnectionGUID: vScParh7T1yg2zGWIJl0Ww== X-CSE-MsgGUID: o0QBtJYNSU+sC2iFmF+Oqg== X-ExtLoop1: 1 Received: from yungchua-desk.itwn.intel.com ([10.227.8.136]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2026 06:13:40 -0700 From: Bard Liao 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 1/3] soundwire: allow drivers to check whether the peripheral is present Date: Tue, 15 Sep 2026 21:13:25 +0800 Message-ID: <20260915131327.1783551-2-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260915131327.1783551-1-yung-chuan.liao@linux.intel.com> References: <20260915131327.1783551-1-yung-chuan.liao@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A ghost peripheral may be listed in the ACPI table and we want to skip it. Add enumeration_complete and is_present in struct sdw_bus{} allow the driver to wait and check whether a peripheral is present. Signed-off-by: Bard Liao Reviewed-by: Charles Keepax --- drivers/soundwire/bus.c | 7 +++++++ include/linux/soundwire/sdw.h | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c index aeaae5a57c89..b49864ca683a 100644 --- a/drivers/soundwire/bus.c +++ b/drivers/soundwire/bus.c @@ -161,7 +161,13 @@ int sdw_bus_master_add(struct sdw_bus *bus, struct dev= ice *parent, bus->params.curr_dr_freq =3D bus->params.max_dr_freq; bus->params.curr_bank =3D SDW_BANK0; bus->params.next_bank =3D SDW_BANK1; + /* + * Set is_present =3D true by default. It will be set to false when no pe= ripherals + * are attached on the bus. + */ + bus->is_present =3D true; =20 + init_completion(&bus->enumeration_complete); return 0; } EXPORT_SYMBOL(sdw_bus_master_add); @@ -847,6 +853,7 @@ static int sdw_program_device_num(struct sdw_bus *bus, = bool *programmed) if (ret =3D=3D -ENODATA) { /* end of device id reads */ dev_dbg(bus->dev, "No more devices to enumerate\n"); ret =3D 0; + complete_all(&bus->enumeration_complete); break; } if (ret < 0) { diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h index f710e5932b4b..0cb7e4fef00e 100644 --- a/include/linux/soundwire/sdw.h +++ b/include/linux/soundwire/sdw.h @@ -1001,6 +1001,8 @@ struct sdw_stream_runtime { * transport and port parameters * @defer_msg: Defer message * @params: Current bus parameters + * @enumeration_complete: completion utility to control potential races be= tween + * enumeration completion and peripheral presence checks. * @stream_refcount: number of streams currently using this bus * @bpt_stream_refcount: number of BTP streams currently using this bus (s= hould * be zero or one, multiple streams per link is not supported). @@ -1029,6 +1031,7 @@ struct sdw_stream_runtime { * are supported. This flag is populated by drivers after reading * appropriate firmware (ACPI/DT). * @lane_used_bandwidth: how much bandwidth in bits per second is used by = each lane + * @is_present: indicates whether any peripheral is present on the bus. */ struct sdw_bus { struct device *dev; @@ -1042,6 +1045,7 @@ struct sdw_bus { struct list_head m_rt_list; struct sdw_defer defer_msg; struct sdw_bus_params params; + struct completion enumeration_complete; int stream_refcount; int bpt_stream_refcount; struct sdw_stream_runtime *bpt_stream; @@ -1064,6 +1068,7 @@ struct sdw_bus { #endif bool multi_link; unsigned int lane_used_bandwidth[SDW_MAX_LANES]; + bool is_present; }; =20 struct sdw_stream_runtime *sdw_alloc_stream(const char *stream_name, enum = sdw_stream_type type); --=20 2.43.0 From nobody Fri Sep 25 07:22:49 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 778D13BF662; Tue, 15 Sep 2026 13:13:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789478026; cv=none; b=S1pD+0vozhMfRVFlU7oG0mi27OkNpe7zhBqqEZ6wAW9I9FuuHLKgyouPt6kBZVGNAGHkoHMFFP/LImD33vyWRL+0kCX+hdu8n7zs3FzXGrghPq63t2lUNdcfDLjmDtY5fwc+3rvb7/mqJ5oPrJ3X3ZaA2d+ln3tMLXyMnLCQTzk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789478026; c=relaxed/simple; bh=PRL54LCiUIIEeMNsl/VPIKHNCvOrIYrCSHO1Io9SjtA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qm7sqGLnNknNtHcysVH6gjM/9l9fcwxWTP18d97S1ixZOZKH4BGLKJeHGOFlNyDd6hEg6ZTiV74NH3ckF05c0nNrPjKzdhrUaXZA1RYh5cSEfQKUBDQ8Ov//7Aw9APlt/aYezrAGhJJf5BBasNmLrgdyu6cw6NvcOjuYcI50LFM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=XxqxOo+l; arc=none smtp.client-ip=198.175.65.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="XxqxOo+l" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789478025; x=1821014025; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PRL54LCiUIIEeMNsl/VPIKHNCvOrIYrCSHO1Io9SjtA=; b=XxqxOo+lV+xkxBMYbYFtf/m379aL9T20pN2LXub/kFMTgQwS/DJFscka YcJuunGBibuOrPX7dszOUpGDzQc7x2NHMaX/y8OISezhi6Ot7o+gEjqH1 UPADf1Q5VA+Sf1KFf1Htj08j96NVA6IywWy08LRNP8Ehs4Zd96ueRwdi4 0FIfMUEFR5wmdFCfGc54YoJdZ9HkAineh+t25iaB765O3LTFqKXe7pUXF 9ljakpsgYAIUwPdMHPpKwgKfrx/hN8LGkda2Hy/bi1I2XcYaGaQBxAgME P+XRm/6kh8x385ijaFNNQyijv02J0AqzoD0j7J/DllSzH6u3yXinP2EZm Q==; X-CSE-ConnectionGUID: 5sk+nHtvQLmwX7j2MoSKIg== X-CSE-MsgGUID: NZhlIZ7MQ62nzRvLuy0Zqw== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="112608442" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="112608442" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2026 06:13:45 -0700 X-CSE-ConnectionGUID: W3igsj5HQ/WD94Av0kjtJA== X-CSE-MsgGUID: R4+iSvYfRWClYtj/1qlihA== X-ExtLoop1: 1 Received: from yungchua-desk.itwn.intel.com ([10.227.8.136]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2026 06:13:42 -0700 From: Bard Liao 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 2/3] soundwire: change sdw_show_ping_status type to int Date: Tue, 15 Sep 2026 21:13:26 +0800 Message-ID: <20260915131327.1783551-3-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260915131327.1783551-1-yung-chuan.liao@linux.intel.com> References: <20260915131327.1783551-1-yung-chuan.liao@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" So that the caller can get the ping results. Signed-off-by: Bard Liao Reviewed-by: Charles Keepax --- drivers/soundwire/bus.c | 16 +++++++++++----- include/linux/soundwire/sdw.h | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c index b49864ca683a..ee90f7d3233e 100644 --- a/drivers/soundwire/bus.c +++ b/drivers/soundwire/bus.c @@ -314,13 +314,16 @@ int sdw_transfer(struct sdw_bus *bus, struct sdw_msg = *msg) * sdw_show_ping_status() - Direct report of PING status, to be used by Pe= ripheral drivers * @bus: SDW bus * @sync_delay: Delay before reading status + * + * returns 0 if there is no peripherals attached, 1 if there are periphera= ls attached + * or a negative error code. */ -void sdw_show_ping_status(struct sdw_bus *bus, bool sync_delay) +int sdw_show_ping_status(struct sdw_bus *bus, bool sync_delay) { u32 status; =20 if (!bus->ops->read_ping_status) - return; + return -ENOTSUPP; =20 /* * wait for peripheral to sync if desired. 10-15ms should be more than @@ -335,10 +338,13 @@ void sdw_show_ping_status(struct sdw_bus *bus, bool s= ync_delay) =20 mutex_unlock(&bus->msg_lock); =20 - if (!status) + if (!status) { dev_warn(bus->dev, "%s: no peripherals attached\n", __func__); - else - dev_dbg(bus->dev, "PING status: %#x\n", status); + return 0; + } + + dev_dbg(bus->dev, "PING status: %#x\n", status); + return 1; } EXPORT_SYMBOL(sdw_show_ping_status); =20 diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h index 0cb7e4fef00e..1b03bfad2e6b 100644 --- a/include/linux/soundwire/sdw.h +++ b/include/linux/soundwire/sdw.h @@ -901,7 +901,7 @@ int sdw_bus_master_add(struct sdw_bus *bus, struct devi= ce *parent, struct fwnode_handle *fwnode); void sdw_bus_master_delete(struct sdw_bus *bus); =20 -void sdw_show_ping_status(struct sdw_bus *bus, bool sync_delay); +int sdw_show_ping_status(struct sdw_bus *bus, bool sync_delay); =20 /** * struct sdw_port_config: Master or Slave Port configuration --=20 2.43.0 From nobody Fri Sep 25 07:22:49 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 023E23F4DD0; Tue, 15 Sep 2026 13:13:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789478028; cv=none; b=X3V3Nh45LBlBxBVVr/4oV4V7MHiUod9Z47Nzg4/PEk2SV227NUbYJWEbd/9zTyTWFuO6a2/pu4HDIxsmMwojQQsAIlji1eOtWrvdvNIsyBGGjWptjluMT5fKq6W213bnfFgg6UhjBffb+Y3WeTEYQ1pxygA4LPNyp3/CBg7moAw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789478028; c=relaxed/simple; bh=byas6azvYHTCZERk/vafvd8gjLFgeA6zisT+bW3iEik=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YAMZ04Mz6v81/CXyECKhhCxdSN938qJ2oFXqFuRpzuEl+8HS8XBrvYjHeEAMR5AGWqQdKesMXveLaSF61XAl35Ar+oNIhKiuPjP94CDJFkRUzzSoyUYUbNuL6CSJasuio3aNSp+V2N1Zd+do5HO7J1uCnfbYv4keKGq8+JFzlx8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=lFk/boQ9; arc=none smtp.client-ip=198.175.65.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lFk/boQ9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789478027; x=1821014027; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=byas6azvYHTCZERk/vafvd8gjLFgeA6zisT+bW3iEik=; b=lFk/boQ9c8h0eLp6FB6N5gueK0fEIy0xePaxWvszsr9FSoh7JfjiAzrY cv6gIRofAqBp+PUkLqRuniIwS+ZgJ8VefBcDurvhH9a8v9VEWu+XosEoP jsHSI3ePiw+Eb6zK/EMULdBItpiusPyusUTYFI57djgGG/MlU3clYlCdo nkLjbs1UMpvxNSV0z4jJQyVzoHdEUu/CdJkLnGdA9ZN3YnO47qCO/qavb CHFkZPnIu1lHM8K7DkVmKPJdy21e2g1nwNt3sI0G2wWRIyahozPrb33fw BwTgDpUqOWP0rBn53S8LWE5OAoKyXrH3S7ybyswuEcZHZBoMR6rupbMTj w==; X-CSE-ConnectionGUID: xLmeJY9JTOKCLS3ka0eV+g== X-CSE-MsgGUID: Ov3Niq1jRV2ZaWyzqQbCdw== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="112608449" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="112608449" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2026 06:13:47 -0700 X-CSE-ConnectionGUID: FX6OGsXGQKSoOpmGkSDflw== X-CSE-MsgGUID: ixNK6jJwR8C1Y+ZZTQO2Cg== X-ExtLoop1: 1 Received: from yungchua-desk.itwn.intel.com ([10.227.8.136]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2026 06:13:44 -0700 From: Bard Liao 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 Message-ID: <20260915131327.1783551-4-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260915131327.1783551-1-yung-chuan.liao@linux.intel.com> References: <20260915131327.1783551-1-yung-chuan.liao@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Charles Keepax --- 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; } =20 +#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 =3D sdev->pdata; @@ -1313,7 +1315,9 @@ static struct snd_soc_acpi_mach *hda_sdw_machine_sele= ct(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 =3D 1; u32 link_mask =3D 0; int i; @@ -1415,14 +1419,53 @@ static struct snd_soc_acpi_mach *hda_sdw_machine_se= lect(struct snd_sof_dev *sdev if (!links) return NULL; =20 + /* + * Recalculate the link_mask as a link will be empty if all peripherals o= n the link are + * not enumerated + */ + link_mask =3D 0; /* Generate snd_soc_acpi_link_adr struct for each peripheral reported by = the ACPI table */ for (i =3D 0; i < peripherals->num_peripherals; i++) { + slave =3D 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) =3D=3D 0) { + /* no peripherals attached on this link */ + slave->bus->is_present =3D false; + continue; + } + + time =3D 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 =3D 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 =3D the number of used links below the current link */ - link_index =3D hweight32(link_mask & (BIT(peripherals->array[i]->bus->li= nk_id) - 1)); - links[link_index].adr_d =3D find_acpi_adr_device(sdev->dev, peripherals-= >array[i], + link_index =3D hweight32(link_mask & (BIT(slave->bus->link_id) - 1)); + links[link_index].adr_d =3D find_acpi_adr_device(sdev->dev, slave, &links[link_index], &_index); if (!links[link_index].adr_d) return NULL; + link_mask |=3D BIT(slave->bus->link_id); } =20 mach->drv_name =3D "sof_sdw"; --=20 2.43.0