[PATCH 1/2] soundwire: move lane bandwidth into bus params
From: Bard Liao
Date: Mon Nov 02 2026 - 01:06:31 EST
lane_used_bandwidth is used to store the used bandwidth for each lane.
When we restore the bus->params, the lane_used_bandwidth value will not
be restored in current code. Move it to sdw_bus_params to fix the issue.
Fixes: 366fd59fb894 ("soundwire: generic_bandwidth_allocation: add lane in sdw_group_params")
Signed-off-by: Bard Liao <yung-chuan.liao@xxxxxxxxxxxxxxx>
Reviewed-by: David Lin <david.lin@xxxxxxxxx>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@xxxxxxxxxxxxxxx>
---
drivers/soundwire/generic_bandwidth_allocation.c | 8 ++++----
drivers/soundwire/stream.c | 4 ++--
include/linux/soundwire/sdw.h | 4 ++--
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/soundwire/generic_bandwidth_allocation.c b/drivers/soundwire/generic_bandwidth_allocation.c
index 30a495abe19e..3d6b9c895e46 100644
--- a/drivers/soundwire/generic_bandwidth_allocation.c
+++ b/drivers/soundwire/generic_bandwidth_allocation.c
@@ -196,7 +196,7 @@ static void _sdw_compute_port_params(struct sdw_bus *bus,
/* Run loop for all groups to compute transport parameters */
for (l = 0; l < SDW_MAX_LANES; l++) {
- if (l > 0 && !bus->lane_used_bandwidth[l])
+ if (l > 0 && !bus->params.lane_used_bandwidth[l])
continue;
/* reset hstop for each lane */
hstop = bus->params.col - 1;
@@ -267,7 +267,7 @@ static int sdw_compute_group_params(struct sdw_bus *bus,
}
for (l = 0; l < SDW_MAX_LANES; l++) {
- if (l > 0 && !bus->lane_used_bandwidth[l])
+ if (l > 0 && !bus->params.lane_used_bandwidth[l])
continue;
/* reset column_needed for each lane */
column_needed = 0;
@@ -507,7 +507,7 @@ static int get_manager_lane(struct sdw_bus *bus, struct sdw_master_runtime *m_rt
m_rt->stream->params.bps;
}
if (required_bandwidth <=
- curr_dr_freq - bus->lane_used_bandwidth[l]) {
+ curr_dr_freq - bus->params.lane_used_bandwidth[l]) {
/* Check if m_lane is connected to all Peripherals */
if (!is_lane_connected_to_all_peripherals(m_rt,
slave_prop->lane_maps[l])) {
@@ -518,7 +518,7 @@ static int get_manager_lane(struct sdw_bus *bus, struct sdw_master_runtime *m_rt
}
m_lane = slave_prop->lane_maps[l];
dev_dbg(&s_rt->slave->dev, "M lane %d is used\n", m_lane);
- bus->lane_used_bandwidth[l] += required_bandwidth;
+ bus->params.lane_used_bandwidth[l] += required_bandwidth;
/*
* Use non-zero manager lane, subtract the lane 0
* bandwidth that is already calculated
diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c
index 0b00fcdcab2d..96613dd0677c 100644
--- a/drivers/soundwire/stream.c
+++ b/drivers/soundwire/stream.c
@@ -1792,8 +1792,8 @@ static int _sdw_deprepare_stream(struct sdw_stream_runtime *stream)
bandwidth = m_rt->stream->params.rate * hweight32(p_rt->ch_mask) *
m_rt->stream->params.bps;
multi_lane_bandwidth += bandwidth;
- bus->lane_used_bandwidth[p_rt->lane] -= bandwidth;
- if (!bus->lane_used_bandwidth[p_rt->lane])
+ bus->params.lane_used_bandwidth[p_rt->lane] -= bandwidth;
+ if (!bus->params.lane_used_bandwidth[p_rt->lane])
p_rt->lane = 0;
}
/* TODO: Update this during Device-Device support */
diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h
index f710e5932b4b..fff30bb2d9ed 100644
--- a/include/linux/soundwire/sdw.h
+++ b/include/linux/soundwire/sdw.h
@@ -592,6 +592,7 @@ enum sdw_port_prep_ops {
* @bandwidth: Current bandwidth
* @col: Active columns
* @row: Active rows
+ * @lane_used_bandwidth: how much bandwidth in bits per second is used by each lane
* @s_data_mode: NORMAL, STATIC or PRBS mode for all Slave ports
* @m_data_mode: NORMAL, STATIC or PRBS mode for all Master ports. The value
* should be the same to detect transmission issues, but can be different to
@@ -605,6 +606,7 @@ struct sdw_bus_params {
unsigned int bandwidth;
unsigned int col;
unsigned int row;
+ unsigned int lane_used_bandwidth[SDW_MAX_LANES];
int s_data_mode;
int m_data_mode;
};
@@ -1028,7 +1030,6 @@ struct sdw_stream_runtime {
* @multi_link: Store bus property that indicates if multi links
* 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
*/
struct sdw_bus {
struct device *dev;
@@ -1063,7 +1064,6 @@ struct sdw_bus {
struct dentry *debugfs;
#endif
bool multi_link;
- unsigned int lane_used_bandwidth[SDW_MAX_LANES];
};
struct sdw_stream_runtime *sdw_alloc_stream(const char *stream_name, enum sdw_stream_type type);
--
2.43.0