Skip to content

soundwire: add BRA properties#5710

Open
bardliao wants to merge 4 commits intothesofproject:topic/sof-devfrom
bardliao:bra-properties
Open

soundwire: add BRA properties#5710
bardliao wants to merge 4 commits intothesofproject:topic/sof-devfrom
bardliao:bra-properties

Conversation

@bardliao
Copy link
Collaborator

Add mipi-sdw-bra-mode-max-data-per-frame and mipi-sdw-bra-mode-block-alignment properties support

Add a property to struct sdw_slave_prop equivalent to the Disco
property "mipi-sdw-bra-mode-block-alignment".

The SoundWire Disco specification defines this as:

"The data payload size for this BRA Mode shall be an integer
multiple of the value of this Property."

Change-Id: I27ab84b0ed0f236a5eae58600400a4c386132480
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Co-developed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
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

Adds support for new MIPI SoundWire DisCo/BRA device properties so BPT/BRA transfers can respect per-device constraints (max payload per frame and block alignment).

Changes:

  • Extend struct sdw_slave_prop with bra_block_alignment and bra_max_data_per_frame, and parse them from firmware properties.
  • Thread BRA constraints into Cadence BPT/BRA buffer-size calculations and Intel ACE2x BPT stream setup.
  • Update SDW_BPT_MSG_MAX_BYTES definition/comment to reference the DisCo spec limit.

Reviewed changes

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

Show a summary per file
File Description
include/linux/soundwire/sdw.h Adds BRA properties to slave props; changes SDW_BPT_MSG_MAX_BYTES definition/comment.
drivers/soundwire/mipi_disco.c Reads the new BRA properties from device properties.
drivers/soundwire/intel_ace2x.c Uses new props to select max bytes/frame and pass alignment into buffer sizing.
drivers/soundwire/cadence_master.h Updates sdw_cdns_bpt_find_buffer_sizes() signature to accept alignment.
drivers/soundwire/cadence_master.c Applies block-alignment when computing actual bytes/frame in BPT/BRA sizing.

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

* @bra_block_alignment: If non-zero the length of data in a BRA frame must be
* a multiple of this number of bytes.
* @bra_max_data_per_frame: If non-zero the maximum data payload size (in bytes per
frame excluding header, CRC, and footer) for this BRA Mode
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

The kernel-doc for @bra_max_data_per_frame has a continuation line that is missing the leading *, which breaks kernel-doc formatting and can trigger documentation/checkpatch warnings. Please format the wrapped description lines using the standard * continuation prefix (and keep indentation consistent with nearby fields).

Suggested change
frame excluding header, CRC, and footer) for this BRA Mode
* frame excluding header, CRC, and footer) for this BRA Mode

Copilot uses AI. Check for mistakes.
Comment on lines +840 to +844
/*
* Add a practical limit to BPT transfer sizes. BPT is typically used
* to transfer firmware, and larger firmware transfers will increase
* the cold latency beyond typical OS or user requirements.
* According to mipi SoundWire DisCo Specification_v2-1,
* this maximum value shall not exceed 470.
*/
#define SDW_BPT_MSG_MAX_BYTES (1024 * 1024)
#define SDW_BPT_MSG_MAX_BYTES 470
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

SDW_BPT_MSG_MAX_BYTES is used as a total BPT message size limit (e.g., sdw_bpt_send_async() rejects messages larger than this), and bus.h explicitly mentions transfers larger than 64KB being possible with this practical cap. Changing the value from 1MB to 470 will cause legitimate BPT transfers (e.g., firmware payloads) to fail with -EINVAL. Consider keeping a separate practical message-size limit (or removing/raising the check) and introducing a new constant for the DisCo/BRA per-frame max payload (470) that is only used for requested_bytes_per_frame calculations.

Copilot uses AI. Check for mistakes.
Comment on lines +2168 to +2169
/* align to a multiple of bra_block_alignment */
actual_bpt_bytes -= (actual_bpt_bytes % bra_block_alignment);
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

Aligning actual_bpt_bytes by subtracting actual_bpt_bytes % bra_block_alignment can reduce it to 0 when bra_block_alignment is larger than actual_bpt_bytes (or when requested_bytes_per_frame is smaller than the alignment). That will lead to division-by-zero in the subsequent DIV_ROUND_UP() / / operations. Please validate the alignment input and/or ensure actual_bpt_bytes remains >= 1 (typically return -EINVAL if the alignment cannot be satisfied).

Suggested change
/* align to a multiple of bra_block_alignment */
actual_bpt_bytes -= (actual_bpt_bytes % bra_block_alignment);
/* align to a multiple of bra_block_alignment */
if (actual_bpt_bytes < bra_block_alignment)
return -EINVAL;
actual_bpt_bytes -= (actual_bpt_bytes % bra_block_alignment);
if (!actual_bpt_bytes)
return -EINVAL;

Copilot uses AI. Check for mistakes.
The data pre frame size should be a multiple of bra_block_alignment.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Get the mipi-sdw-bra-mode-max-data-per-frame property which indicates
the maximum data payload size (in bytes per frame excluding header,
CRC, and footer) for the BRA Mode.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
The optional property indicates the maximum data payload size for the
BRA mode.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.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