soundwire: add runtime BPT support#5604
Conversation
There was a problem hiding this comment.
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_hstopfield 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.
f0c9b03 to
7a5ec92
Compare
| restore_params: | ||
| memcpy(&bus->params, ¶ms, sizeof(params)); | ||
| bus->bpt_hstop = prev_bpt_hstop; | ||
| return ret; |
There was a problem hiding this comment.
This should belong to another PR. I will fix it later.
The restore_params block in _sdw_prepare_stream() was restoring only the last bus iterated when an error occurred. For multi-link streams with multiple buses, this left other buses in a partially reconfigured state. Fix this by: 1. Adding bpt_hstop to sdw_bus to track the BPT stream hstop value. 2. Adding saved_params and saved_bpt_hstop to sdw_master_runtime to store per-bus backup state. 3. Pre-saving all buses' params and bpt_hstop before the modify loop. 4. Restoring all buses from their per-bus saved state in restore_params. Addresses review comment: #5604 (comment)
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>
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>
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>
| struct sdw_master_runtime *m_rt; | ||
| struct sdw_bus *bus; | ||
| struct sdw_master_prop *prop; | ||
| struct sdw_bus_params params; | ||
| int ret; | ||
|
|
There was a problem hiding this comment.
ret = do_bank_switch(stream); is always called. In other words, ret will never be uninitialized
|
@charleskeepax @simontrimmer @rfvirgil Could you take a look? |
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.