Skip to content

soundwire: add runtime BPT support - #5604

Open
bardliao wants to merge 10 commits into
thesofproject:topic/sof-devfrom
bardliao:runtime-bra
Open

bardliao wants to merge 10 commits into
thesofproject:topic/sof-devfrom
bardliao:runtime-bra

Conversation

@bardliao

Copy link
Copy Markdown
Collaborator

The driver may want to use BPT stream to download the firmware while an audio stream is running. This series calculates the available columns in a SoundWire frame and use them for the BPT stream. The streams are on on a first-come, first-served basis but will reserve 2 columns for the audio stream if possible. That should apply to most cases.

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.

Pull request overview

This PR implements runtime BPT (Bulk Point-to-Point) stream support for SoundWire, enabling firmware downloads while audio streams are active. The changes calculate available columns in SoundWire frames and allocate them to BPT streams on a first-come, first-served basis, with a reservation of 2 columns for audio streams when possible.

Key changes:

  • Modified bandwidth calculation to exclude BPT streams and use remaining available bandwidth
  • Added bpt_hstop field to track BPT stream column allocation
  • Updated frame column allocation logic to dynamically reserve space for audio streams

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
include/linux/soundwire/sdw.h Added bpt_hstop field to track BPT stream column boundaries
drivers/soundwire/stream.c Excluded BPT streams from bandwidth calculations during prepare/deprepare
drivers/soundwire/intel_ace2x.c Updated to use bpt_hstop instead of total columns for BPT buffer calculations
drivers/soundwire/generic_bandwidth_allocation.c Implemented dynamic column allocation logic with BPT stream filtering and reservation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread include/linux/soundwire/sdw.h Resolved

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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

Comment thread drivers/soundwire/stream.c Resolved

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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment on lines 1541 to 1544
restore_params:
memcpy(&bus->params, &params, sizeof(params));
bus->bpt_hstop = prev_bpt_hstop;
return ret;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This should belong to another PR. I will fix it later.

ghost 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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

ghost 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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Bard Liao added 6 commits July 2, 2026 10:54
Restore_params restores bus->params and bus->bpt_hstop from single
backups that are overwritten in the first master_list loop. If failure
happens later (e.g. do_bank_switch() or port prepare in the second
loop), the current bus may not match the saved snapshot, so multi-link
streams can restore the wrong state into the wrong bus and leave other
buses partially reconfigured.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
We should get as much as bandwidth for the BPT stream.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
The DP0 (BPT) params are computed in sdw_compute_dp0_port_params(). We
should exclude the BPT stream when calculating the audio streams.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
We just need to conunt the audio stream bandwidth and BRA stream will
use the remaining bandwidth.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
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>
To allow BPT and audio stream work simultaneously, we need to record the
hstop of the BPT stream. And use column bpt_hstop + 1 to the last column
for audio streams.
No function changed since bus->params.bpt_hstop is set to
bus->params.col - 1 for now. Will update bus->audio_stream_hstart in the
follow up commit.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>

ghost 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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

ghost 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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Bard Liao added 3 commits July 2, 2026 14:06
Update bus->params.bpt_hstop to record the hstop of the BPT stream.
And return -EAGAIN when there is no bandwidth for the BPT stream.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
When a BPT stream is running, we should subtract the columns that is
used by the BPT stream in bandwidth calculation.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Now the SoundWire BPT stream and the audio stream can share the
SoundWire bus bandwidth. However, it is still not allowed to have more
than 1 BPT stream running simultaneously.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>

ghost 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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment on lines 1471 to 1475
struct sdw_master_runtime *m_rt;
struct sdw_bus *bus;
struct sdw_master_prop *prop;
struct sdw_bus_params params;
int ret;

ghost Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ret = do_bank_switch(stream); is always called. In other words, ret will never be uninitialized

@bardliao
bardliao marked this pull request as ready for review July 3, 2026 11:14
@bardliao bardliao changed the title [RFC] soundwire: add runtime BPT support soundwire: add runtime BPT support Jul 16, 2026
@bardliao

ghost commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator Author

@charleskeepax @simontrimmer @rfvirgil Could you take a look?

ghost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The problem is the same as in other BPT/BRA PRs, all the logic is driven by the use of non-audio bandwidth at a given time without clarifying what happens if another audio stream starts while BPT/BRA is running.
Returning -EBUSY for an audio stream is a big no-no IMHO.

I think we will need to model the fact that the BPT/BRA makes the most sense during initial and resume stages, which could avoid the need for these complicated concurrency policies.

continue;
}

/* Don't count BPT stream bandwidth, it will use the remaining bandwidth */

ghost Aug 6, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

that's a problem, if you allocated all the remaining bandwidth to BPT/BRA, then what happens if a new stream starts while BPT/BRA is on-going?

If you want to have concurrent audio/BPT streams, you need to have enough bandwidth for all, and make sure the 'remaining' non-audio part is still enough for BPT/BRA to be efficient compared to the command protocol.

ghost Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I reserve 2 columns for the audio stream. I think it should be good enough for in practice.

@bardliao

ghost commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

The problem is the same as in other BPT/BRA PRs, all the logic is driven by the use of non-audio bandwidth at a given time without clarifying what happens if another audio stream starts while BPT/BRA is running. Returning -EBUSY for an audio stream is a big no-no IMHO.

Yes, audio stream should always be at the first priority.

I think we will need to model the fact that the BPT/BRA makes the most sense during initial and resume stages, which could avoid the need for these complicated concurrency policies.

One scenario is that a codec and an amp are on the same bus and the amp needs to load the firmware before starting playback. When we switch from headphone to speaker while a stream is active, it is more efficient to download the firmware via BRA.
@charleskeepax Any input on this?

@bardliao

ghost commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator Author

@rfvirgil @simontrimmer FYI

@rfvirgil

ghost commented Aug 10, 2026

Copy link
Copy Markdown

@plbossart

I think we will need to model the fact that the BPT/BRA makes the most sense during initial and resume stages, which could avoid the need for these complicated concurrency policies.

We can't limit BRA to only happening during boot and resume. There are real reasons why it can be needed at other times.

Apart from firmware download, the other big use-case is voice trigger.

  • for extracting faster-than-realtime voice trigger audio from buffers on the device.
  • for downloading voice trigger model data (our experience with Android voice trigger is that setting the trigger model can happen any time, it's not a boot-time-only operation)

Also the SDCA spec allows a device to request a "firmware" (really, any blob of data) at any time to satisfy a use-case.

@bardliao

ghost commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator Author

@plbossart

I think we will need to model the fact that the BPT/BRA makes the most sense during initial and resume stages, which could avoid the need for these complicated concurrency policies.

We can't limit BRA to only happening during boot and resume. There are real reasons why it can be needed at other times.

Apart from firmware download, the other big use-case is voice trigger.

  • for extracting faster-than-realtime voice trigger audio from buffers on the device.
  • for downloading voice trigger model data (our experience with Android voice trigger is that setting the trigger model can happen any time, it's not a boot-time-only operation)

Also the SDCA spec allows a device to request a "firmware" (really, any blob of data) at any time to satisfy a use-case.

@plbossart @rfvirgil Maybe I should send this to upstream for further discussion?

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.

4 participants