Skip to content

Commit 91aa327

Browse files
committed
soundwire: move lane_used_bandwidth to sdw_bus_params
The lane_used_bandwidth variable store the used bandwidth of each lane. It should belong to the sdw_bus_params struct instead of in the sdw_bus struct directly. Besides, _sdw_prepare_stream() will restore the bus->params, and the lane_used_bandwidth values will not be restored if it is not in the params. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
1 parent 0388134 commit 91aa327

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

drivers/soundwire/generic_bandwidth_allocation.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ static void _sdw_compute_port_params(struct sdw_bus *bus,
199199

200200
/* Run loop for all groups to compute transport parameters */
201201
for (l = 0; l < SDW_MAX_LANES; l++) {
202-
if (l > 0 && !bus->lane_used_bandwidth[l])
202+
if (l > 0 && !bus->params.lane_used_bandwidth[l])
203203
continue;
204204
/* reset hstop for each lane */
205205
hstop = bus->params.col - 1;
@@ -270,7 +270,7 @@ static int sdw_compute_group_params(struct sdw_bus *bus,
270270
}
271271

272272
for (l = 0; l < SDW_MAX_LANES; l++) {
273-
if (l > 0 && !bus->lane_used_bandwidth[l])
273+
if (l > 0 && !bus->params.lane_used_bandwidth[l])
274274
continue;
275275
/* reset column_needed for each lane */
276276
column_needed = 0;
@@ -510,7 +510,7 @@ static int get_manager_lane(struct sdw_bus *bus, struct sdw_master_runtime *m_rt
510510
m_rt->stream->params.bps;
511511
}
512512
if (required_bandwidth <=
513-
curr_dr_freq - bus->lane_used_bandwidth[l]) {
513+
curr_dr_freq - bus->params.lane_used_bandwidth[l]) {
514514
/* Check if m_lane is connected to all Peripherals */
515515
if (!is_lane_connected_to_all_peripherals(m_rt,
516516
slave_prop->lane_maps[l])) {
@@ -521,7 +521,7 @@ static int get_manager_lane(struct sdw_bus *bus, struct sdw_master_runtime *m_rt
521521
}
522522
m_lane = slave_prop->lane_maps[l];
523523
dev_dbg(&s_rt->slave->dev, "M lane %d is used\n", m_lane);
524-
bus->lane_used_bandwidth[l] += required_bandwidth;
524+
bus->params.lane_used_bandwidth[l] += required_bandwidth;
525525
/*
526526
* Use non-zero manager lane, subtract the lane 0
527527
* bandwidth that is already calculated

drivers/soundwire/stream.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,8 +1794,8 @@ static int _sdw_deprepare_stream(struct sdw_stream_runtime *stream)
17941794
bandwidth = m_rt->stream->params.rate * hweight32(p_rt->ch_mask) *
17951795
m_rt->stream->params.bps;
17961796
multi_lane_bandwidth += bandwidth;
1797-
bus->lane_used_bandwidth[p_rt->lane] -= bandwidth;
1798-
if (!bus->lane_used_bandwidth[p_rt->lane])
1797+
bus->params.lane_used_bandwidth[p_rt->lane] -= bandwidth;
1798+
if (!bus->params.lane_used_bandwidth[p_rt->lane])
17991799
p_rt->lane = 0;
18001800
}
18011801
/* TODO: Update this during Device-Device support */

include/linux/soundwire/sdw.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ enum sdw_port_prep_ops {
589589
* @max_dr_freq: Maximum double rate clock frequency supported, in Hz
590590
* @curr_dr_freq: Current double rate clock frequency, in Hz
591591
* @bandwidth: Current bandwidth
592+
* @lane_used_bandwidth: how much bandwidth in bits per second is used by each lane
592593
* @col: Active columns
593594
* @row: Active rows
594595
* @s_data_mode: NORMAL, STATIC or PRBS mode for all Slave ports
@@ -602,6 +603,7 @@ struct sdw_bus_params {
602603
unsigned int max_dr_freq;
603604
unsigned int curr_dr_freq;
604605
unsigned int bandwidth;
606+
unsigned int lane_used_bandwidth[SDW_MAX_LANES];
605607
unsigned int col;
606608
unsigned int row;
607609
int s_data_mode;
@@ -1027,7 +1029,6 @@ struct sdw_stream_runtime {
10271029
* @multi_link: Store bus property that indicates if multi links
10281030
* are supported. This flag is populated by drivers after reading
10291031
* appropriate firmware (ACPI/DT).
1030-
* @lane_used_bandwidth: how much bandwidth in bits per second is used by each lane
10311032
*/
10321033
struct sdw_bus {
10331034
struct device *dev;
@@ -1062,7 +1063,6 @@ struct sdw_bus {
10621063
struct dentry *debugfs;
10631064
#endif
10641065
bool multi_link;
1065-
unsigned int lane_used_bandwidth[SDW_MAX_LANES];
10661066
};
10671067

10681068
struct sdw_stream_runtime *sdw_alloc_stream(const char *stream_name, enum sdw_stream_type type);

0 commit comments

Comments
 (0)