Skip to content

soundwire: qcom: serialize WCD AHB bridge transactions and validate FIFO depth - #201

Open
robertijtsma wants to merge 1 commit into
linux-surface:spx/v7.3from
robertijtsma:spx-soundwire-ahb-lock
Open

robertijtsma wants to merge 1 commit into
linux-surface:spx/v7.3from
robertijtsma:spx-soundwire-ahb-lock

Conversation

@robertijtsma

Copy link
Copy Markdown

On WCD934x-hosted Qualcomm SoundWire controllers (Surface Pro X / SC8180X), each AHB bridge register access performs two separate regmap_bulk_*() transfers (SWRM_AHB_BRIDGE_RD_ADDR_0 + RD_DATA_0 or WR_DATA_0 + WR_ADDR_0). Without controller-level serialization across the two-step pair, concurrent accesses from the threaded IRQ handler and probe/bus threads can interleave on the shared AHB bridge registers, corrupting reads/writes and occasionally reading wr_fifo_depth == 0.

Changes

  • Add struct mutex ahb_lock to struct qcom_swrm_ctrl and serialize each complete two-step AHB bridge transaction in qcom_swrm_ahb_reg_read() / qcom_swrm_ahb_reg_write().
  • Read and validate SWRM_COMP_PARAMS write FIFO capacity (supporting both pre-v3.1 and v3.1+ field masks) in qcom_swrm_probe() before requesting the SoundWire IRQ.

Verification

  • Passes scripts/checkpatch.pl with 0 errors, 0 warnings.
  • Tested on Microsoft Surface Pro X SQ2 (SC8180X, WCD934x + WSA881x, Linux 7.3.1-1-surface) across cold boots, warm reboots, and s2idle suspend/resume.
  • Ref: Support for Audio Subsystem surface-pro-x#21

…IFO depth

On WCD934x-hosted Qualcomm SoundWire controllers (such as on the Surface
Pro X / SC8180X), each AHB bridge register access consists of two separate
regmap_bulk_*() transfers (RD_ADDR followed by RD_DATA, or WR_DATA
followed by WR_ADDR). Without controller-level serialization across the
pair, concurrent transfers from the threaded IRQ handler and probe/bus
threads can interleave on the shared WCD AHB bridge registers, corrupting
register reads/writes and leaving wr_fifo_depth as zero.

Add a mutex (ahb_lock) in struct qcom_swrm_ctrl to serialize each complete
two-step AHB bridge transaction, and read/validate SWRM_COMP_PARAMS write
FIFO depth in qcom_swrm_probe() before enabling the SoundWire IRQ.

Tested on Microsoft Surface Pro X SQ2 (SC8180X, WCD934x + WSA881x).

Signed-off-by: robertijtsma <37256770+robertijtsma@users.noreply.github.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.

1 participant