]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
soundwire: only compute port params in specific stream states
authorBard Liao <yung-chuan.liao@linux.intel.com>
Thu, 8 May 2025 06:20:29 +0000 (14:20 +0800)
committerVinod Koul <vkoul@kernel.org>
Wed, 14 May 2025 11:44:01 +0000 (12:44 +0100)
Currently, sdw_compute_master_ports() is blindly called for every single
Manager runtime. However, we should not take into account the stream's
bandwidth if the stream is just allocated or already deprepared.

Fixes: 25befdf32aa4 ("soundwire: generic_bandwidth_allocation: count the bandwidth of active streams only")
Link: https://github.com/thesofproject/linux/issues/5398
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20250508062029.6596-1-yung-chuan.liao@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/soundwire/generic_bandwidth_allocation.c

index 1cfaccf43eac50029527093bb5d3a8ff064baf1b..c18f0c16f9297379096422303afed7a78124ba39 100644 (file)
@@ -204,6 +204,13 @@ static void _sdw_compute_port_params(struct sdw_bus *bus,
                        port_bo = 1;
 
                        list_for_each_entry(m_rt, &bus->m_rt_list, bus_node) {
+                               /*
+                                * Only runtimes with CONFIGURED, PREPARED, ENABLED, and DISABLED
+                                * states should be included in the bandwidth calculation.
+                                */
+                               if (m_rt->stream->state > SDW_STREAM_DISABLED ||
+                                   m_rt->stream->state < SDW_STREAM_CONFIGURED)
+                                       continue;
                                sdw_compute_master_ports(m_rt, &params[i], &port_bo, hstop);
                        }