Skip to content

soundwire: stream: Fix bandwidth leak in multi-link aggregation failure - #5964

Open
davidlin923 wants to merge 1 commit into
thesofproject:topic/sof-devfrom
davidlin923:sdw_bandwidth_leak
Open

davidlin923 wants to merge 1 commit into
thesofproject:topic/sof-devfrom
davidlin923:sdw_bandwidth_leak

Conversation

@davidlin923

Copy link
Copy Markdown

When preparing a multi-link aggregation stream, a failure on a subsequent link during _sdw_prepare_stream() causes the stream preparation to fail. However, the bandwidth allocated on the preceding successful links is never released, causing a cumulative bandwidth leak.

Fix this by introducing sdw_rollback_master_bandwidth() to iterate through all successfully processed masters prior to the failed one, and accurately deduct their allocated port bandwidth from the bus parameters.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Rollback remains incorrect for disabled streams, later preparation phases, asynchronous-rate failures, and multi-lane accounting.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds bandwidth rollback when multi-link stream preparation fails.

Changes:

  • Introduces master bandwidth rollback logic.
  • Invokes rollback from the parameter restoration path.
File Description
drivers/​soundwire/​stream.c Adds failed-preparation bandwidth cleanup.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread drivers/soundwire/stream.c Outdated
Comment on lines +1497 to +1500
list_for_each_entry(rollback_m_rt, &stream->master_list, stream_node) {
/* Only process masters that were successfully configured before the failure */
if (rollback_m_rt == fail_m_rt)
break;
Comment thread drivers/soundwire/bus.h Outdated
When preparing a multi-link aggregation stream, a failure on a subsequent
link during _sdw_prepare_stream() causes the stream preparation to fail.
However, the bandwidth allocated on the preceding successful links is never
released, causing a cumulative bandwidth leak.

Fix this by saving a snapshot of each bus's parameters before making any
modifications. In case of failure, we iterate through the stream's master
list and restore each bus to its original parameter state, ensuring an
atomic rollback and preventing any bandwidth leaks.

Signed-off-by: David Lin <david.lin@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants