Skip to content

soundwire: cadence_master: use full data slots in BRA frames #5482

Closed
bardliao wants to merge 2 commits intothesofproject:topic/sof-devfrom
bardliao:fix-bra
Closed

soundwire: cadence_master: use full data slots in BRA frames #5482
bardliao wants to merge 2 commits intothesofproject:topic/sof-devfrom
bardliao:fix-bra

Conversation

@bardliao
Copy link
Collaborator

@bardliao bardliao commented Jul 4, 2025

For some reason, the transport may not complete if the last frame is not
fully used. Always fully use the date slots in the frames and ignore the
unrequired data can avoid the transport issue.

bardliao added 2 commits July 4, 2025 16:21
The existing code uses i as the frame index which is 0 based. And
"bad frame %d/%d", i, num_frames where num_frames is 1 based. Change the
frame index to i + 1 to align with num_frames and more readable.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
For some reason, the transport may not complete if the last frame is not
fully used. Always fully use the date slots in the frames and ignore the
unrequired data can avoid the transport issue.

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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

The PR ensures that all BRA frames use the full data_per_frame length—even the last frame—to avoid transport hangs.

  • Always calculate num_frames with DIV_ROUND_UP and apply full-slot sizing for both reads and writes in sdw_cdns_bpt_find_buffer_sizes.
  • Simplify sdw_cdns_prepare_read_dma_buffer by removing partial‐frame handling and using while (data_size >= 0) to emit every frame at full length.
  • Convert error‐message frame indices from 0‐based to 1‐based in both write and read response checks.

Reviewed Changes

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

File Description
drivers/soundwire/cadence_master.c Unify buffer‐size calculation to always use full slots; remove remainder logic in sdw_cdns_bpt_find_buffer_sizes.
drivers/soundwire/cadence_master.c Change loop condition and remove special‐case for partial frames in sdw_cdns_prepare_read_dma_buffer.
drivers/soundwire/cadence_master.c Adjust dev_err format to report frames as i+1 in sdw_cdns_check_write_response and sdw_cdns_check_read_response.

* Set message length = data_per_frame even if the required data is less then
* data_per_frame in the last frame.
*/
while (data_size >= 0) {
Copy link

Copilot AI Jul 4, 2025

Choose a reason for hiding this comment

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

Looping on data_size >= 0 introduces an extra iteration when data_size hits zero, causing an unintended frame. Consider using while (data_size > 0) or a do { ... } while (data_size > 0) to accurately emit exactly DIV_ROUND_UP frames.

Suggested change
while (data_size >= 0) {
while (data_size > 0) {

Copilot uses AI. Check for mistakes.
* which may only transport fewer bytes.
* For reads for some reason the transport may not complete if the last frame is not
* fully used. We will set the data length of all frames are fully used to the BPT
* header and ignore the unrequested date.
Copy link

Copilot AI Jul 4, 2025

Choose a reason for hiding this comment

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

Typo in comment: 'date' should be 'data'.

Suggested change
* header and ignore the unrequested date.
* header and ignore the unrequested data.

Copilot uses AI. Check for mistakes.
len = buffer_size - total_num_bytes;

crc = extract_read_data(p_data, len, p_buf);
crc = extract_read_data(p_data, data_per_frame, p_buf);
Copy link

Copilot AI Jul 4, 2025

Choose a reason for hiding this comment

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

Removed boundary check means extract_read_data may write beyond the target buffer when the last frame is smaller than data_per_frame. Reintroduce logic to cap the extracted length to the remaining buffer size (buffer_size - total_num_bytes).

Copilot uses AI. Check for mistakes.
@bardliao bardliao closed this Jul 4, 2025
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.

2 participants