From 4a6526668e790fe7e921d20e1e810df36be22c72 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 26 Jun 2026 12:02:14 +0000 Subject: [PATCH 1/3] Initial plan From 5a0be1bc333dcf308cabf28bf220a382339e1959 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 26 Jun 2026 12:14:58 +0000 Subject: [PATCH 2/3] Fix restore_params to restore all buses in multi-link streams The restore_params block in _sdw_prepare_stream() was restoring only the last bus iterated when an error occurred. For multi-link streams with multiple buses, this left other buses in a partially reconfigured state. Fix this by: 1. Adding bpt_hstop to sdw_bus to track the BPT stream hstop value. 2. Adding saved_params and saved_bpt_hstop to sdw_master_runtime to store per-bus backup state. 3. Pre-saving all buses' params and bpt_hstop before the modify loop. 4. Restoring all buses from their per-bus saved state in restore_params. Addresses review comment: https://github.com/thesofproject/linux/pull/5604#discussion_r3480595955 --- drivers/soundwire/bus.h | 2 ++ drivers/soundwire/stream.c | 15 ++++++++++++--- include/linux/soundwire/sdw.h | 2 ++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/soundwire/bus.h b/drivers/soundwire/bus.h index 8115c64dd48e2f..f065270c614a16 100644 --- a/drivers/soundwire/bus.h +++ b/drivers/soundwire/bus.h @@ -172,6 +172,8 @@ struct sdw_master_runtime { struct list_head port_list; struct list_head stream_node; struct list_head bus_node; + struct sdw_bus_params saved_params; + int saved_bpt_hstop; }; struct sdw_transport_data { diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c index cbf7bd3d4e7bac..275600f5ae9660 100644 --- a/drivers/soundwire/stream.c +++ b/drivers/soundwire/stream.c @@ -1479,14 +1479,19 @@ static int _sdw_prepare_stream(struct sdw_stream_runtime *stream, struct sdw_master_runtime *m_rt; struct sdw_bus *bus; struct sdw_master_prop *prop; - struct sdw_bus_params params; int ret; + /* Pre-save all buses' params before making any changes, for error recovery */ + list_for_each_entry(m_rt, &stream->master_list, stream_node) { + bus = m_rt->bus; + memcpy(&m_rt->saved_params, &bus->params, sizeof(bus->params)); + m_rt->saved_bpt_hstop = bus->bpt_hstop; + } + /* Prepare Master(s) and Slave(s) port(s) associated with stream */ list_for_each_entry(m_rt, &stream->master_list, stream_node) { bus = m_rt->bus; prop = &bus->prop; - memcpy(¶ms, &bus->params, sizeof(params)); /* TODO: Support Asynchronous mode */ if ((prop->max_clk_freq % stream->params.rate) != 0) { @@ -1542,7 +1547,11 @@ static int _sdw_prepare_stream(struct sdw_stream_runtime *stream, return ret; restore_params: - memcpy(&bus->params, ¶ms, sizeof(params)); + list_for_each_entry(m_rt, &stream->master_list, stream_node) { + bus = m_rt->bus; + memcpy(&bus->params, &m_rt->saved_params, sizeof(bus->params)); + bus->bpt_hstop = m_rt->saved_bpt_hstop; + } return ret; } diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h index 3e0d21132ef2f7..f84704a7f3311e 100644 --- a/include/linux/soundwire/sdw.h +++ b/include/linux/soundwire/sdw.h @@ -1003,6 +1003,7 @@ struct sdw_stream_runtime { * @stream_refcount: number of streams currently using this bus * @bpt_stream_refcount: number of BTP streams currently using this bus (should * be zero or one, multiple streams per link is not supported). + * @bpt_hstop: The hstop of the BPT stream. * @bpt_stream: pointer stored to handle BTP streams. * @ops: Master callback ops * @port_ops: Master port callback ops @@ -1043,6 +1044,7 @@ struct sdw_bus { struct sdw_bus_params params; int stream_refcount; int bpt_stream_refcount; + int bpt_hstop; struct sdw_stream_runtime *bpt_stream; const struct sdw_master_ops *ops; const struct sdw_master_port_ops *port_ops; From 054c3ac43bbff9234d407c61d91eb8787a1535c1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 26 Jun 2026 12:15:39 +0000 Subject: [PATCH 3/3] Improve bpt_hstop field documentation in sdw_bus --- include/linux/soundwire/sdw.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h index f84704a7f3311e..4789747edb1139 100644 --- a/include/linux/soundwire/sdw.h +++ b/include/linux/soundwire/sdw.h @@ -1003,7 +1003,9 @@ struct sdw_stream_runtime { * @stream_refcount: number of streams currently using this bus * @bpt_stream_refcount: number of BTP streams currently using this bus (should * be zero or one, multiple streams per link is not supported). - * @bpt_hstop: The hstop of the BPT stream. + * @bpt_hstop: The column stop index (hstop) used by the BPT stream's DP0 port. + * This value determines the last column allocated to the BPT data path on + * lane 0, allowing audio streams to use the remaining columns. * @bpt_stream: pointer stored to handle BTP streams. * @ops: Master callback ops * @port_ops: Master port callback ops