Skip to content

Commit 9539202

Browse files
committed
soundwire: generic_bandwidth_allocation: check bandwidth with real
colume The existing code assumes the column number will not change, but it could change if curr_dr_freq changes. Calculate the new column number before checking the bandwidth to make the checking be more accurate. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
1 parent 86c4ff7 commit 9539202

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

drivers/soundwire/generic_bandwidth_allocation.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,12 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
580580
if (!is_clock_scaling_supported(bus) || bus->bpt_stream_refcount)
581581
clk_values = 1;
582582

583+
if (!mstr_prop->default_frame_rate || !mstr_prop->default_row)
584+
return -EINVAL;
585+
583586
for (i = 0; i < clk_values; i++) {
587+
int total_col;
588+
584589
if (!clk_buf)
585590
curr_dr_freq = bus->params.max_dr_freq;
586591
else
@@ -592,8 +597,10 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
592597
if (bus->bpt_stream_refcount)
593598
curr_dr_freq = bus->params.max_dr_freq;
594599

595-
if (curr_dr_freq * (mstr_prop->default_col - 1) >=
596-
bus->params.bandwidth * mstr_prop->default_col)
600+
total_col = curr_dr_freq / mstr_prop->default_frame_rate / mstr_prop->default_row;
601+
602+
if (curr_dr_freq * (total_col - 1) >=
603+
bus->params.bandwidth * total_col)
597604
break;
598605

599606
list_for_each_entry(m_rt, &bus->m_rt_list, bus_node) {
@@ -655,9 +662,6 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
655662
}
656663
}
657664

658-
if (!mstr_prop->default_frame_rate || !mstr_prop->default_row)
659-
return -EINVAL;
660-
661665
mstr_prop->default_col = curr_dr_freq / mstr_prop->default_frame_rate /
662666
mstr_prop->default_row;
663667

0 commit comments

Comments
 (0)