Repository navigation
FROMLIST: soundwire: qcom: Fix off-by-one error in port exhaustion check - #2409
Conversation
|
Change Requests Validation Check No CR numbers found in the pull request description. Please add CR numbers in the format: Example: |
|
I am not sure how to solve the above comment. Please assist. |
|
Change Requests Validation Check No CR numbers found in the pull request description. Please add CR numbers in the format: Example: |
PR #2409 — validate-patchPR: #2409
Final Summary
|
PR #2409 — checker-log-analyzerPR: #2409
Detailed report: Full report
|
cd968ac to
6bddfd4
Compare
|
Change Requests Validation Check No CR numbers found in the pull request description. Please add CR numbers in the format: Example: |
PR #2409 — validate-patchPR: #2409
Final Summary
|
PR #2409 — checker-log-analyzerPR: #2409
Detailed report: Full report
|
…m_stream_alloc_ports() qcom_swrm_stream_alloc_ports() allocates the pconfig array with ctrl->nports elements, but only checks that the assigned port number pn is below maxport. When multiple slave ports map to the same master port via m_port_map or the stream requests more slave ports than ctrl->nports, nports increments past ctrl->nports and writes out of bounds of pconfig. Verify that nports is less than maxport before writing to pconfig[nports], and clear only the port_mask bits newly allocated during the loop before returning -EBUSY. Closes: https://sashiko.dev/#/bug/linux-543ea0c0-a6e5-4b03-a041-ea0a760802c1 Signed-off-by: Lee Jones <lee@kernel.org> Signed-off-by: Vinod Koul <vkoul@kernel.org> Link: https://lore.kernel.org/linux-arm-msm/20261123075522.405347-7-lee@kernel.org/ Signed-off-by: Christopher Obbard <chris.obbard@oss.qualcomm.com>
Qualcomm SoundWire master ports are indexed from 1, with bit 0 of port_mask reserved. Valid port numbers therefore range from 1 to maxport. Commit 6ccec91 ("soundwire: qcom: Fix port exhaustion check in stream_alloc_ports") changed the port exhaustion check from pn > maxport to pn >= maxport which rejects the last valid port. On RB3gen2 (QCS6490), two WSA883x speaker amplifiers are connected to swr2, which has qcom,dout-ports = <6> and qcom,din-ports = <2> (8 ports). Each amplifier uses one port for playback and another for voltage and current sensing (VISENSE). The right amplifier's qcom,port-mapping is <4 5 6 8>, so its VISENSE port is master port 8, which is rejected by the new check. Since all ports in a SoundWire stream are allocated together during hw_params, this causes the stream to fail with: qcom-soundwire 3250000.soundwire: All ports busy The -EBUSY propagates through hw_params, preventing speaker playback. Disabling VISENSE works around the issue. Speaker protection is not enabled on this device in upstream, but with AudioReach userspace the userspace PAL mixer paths enable VISENSE on every speaker stream, so a mixer change alone does not avoid the failure. The original fix addressed an exhaustion check that could never trigger because find_first_zero_bit() returns maxport when all searched bits are set. Include the reserved bit 0 in the search so exhaustion returns maxport + 1 and restore the pn > maxport check. Tested on RB3gen2 with a v7.4-rc3 based kernel and AudioReach userspace: with the stock PAL mixer paths, which enable VISENSE on both amplifiers, speaker playback through the PAL speaker sink is audible and no longer fails with "All ports busy". Fixes: 6ccec91 ("soundwire: qcom: Fix port exhaustion check in stream_alloc_ports") Cc: stable@vger.kernel.org Signed-off-by: Christopher Obbard <chris.obbard@oss.qualcomm.com> Link: https://lore.kernel.org/all/20261126-wip-obbardc-soundwire-qcom-fix-port-off-by-one-v2-1-c424edf85968@oss.qualcomm.com/
6bddfd4 to
048de97
Compare
|
Change Requests Validation Check No CR numbers found in the pull request description. Please add CR numbers in the format: Example: |
Qualcomm SoundWire master ports are indexed from 1, with bit 0 of
port_mask reserved. Valid port numbers therefore range from 1 to
maxport.
Commit 6ccec91 ("soundwire: qcom: Fix port exhaustion check in
stream_alloc_ports") changed the port exhaustion check from
pn > maxport to pn >= maxport which rejects the last valid port.
On RB3gen2 (QCS6490), two WSA883x speaker amplifiers are connected
to swr2, which has qcom,dout-ports = <6> and qcom,din-ports = <2>
(8 ports). Each amplifier uses one port for playback and another for
voltage and current sensing (VISENSE). The right amplifier's
qcom,port-mapping is <4 5 6 8>, so its VISENSE port is master port 8,
which is rejected by the new check.
Since all ports in a SoundWire stream are allocated together during
hw_params, this causes the stream to fail with:
The -EBUSY propagates through hw_params, preventing speaker playback.
Disabling VISENSE works around the issue. Speaker protection is not
enabled on this device in upstream, but with AudioReach userspace the
userspace PAL mixer paths enable VISENSE on every speaker stream, so a
mixer change alone does not avoid the failure.
The original fix addressed an exhaustion check that could never
trigger because find_first_zero_bit() returns maxport when all
searched bits are set. Include the reserved bit 0 in the search so
exhaustion returns maxport + 1 and restore the pn > maxport check.
Tested on RB3gen2 with a v7.4-rc3 based kernel and AudioReach
userspace: with the stock PAL mixer paths, which enable VISENSE on
both amplifiers, speaker playback through the PAL speaker sink is
audible and no longer fails with "All ports busy".
Fixes: 6ccec91 ("soundwire: qcom: Fix port exhaustion check in stream_alloc_ports")
Cc: stable@vger.kernel.org
Signed-off-by: Christopher Obbard chris.obbard@oss.qualcomm.com
Link: https://lore.kernel.org/all/20261126-wip-obbardc-soundwire-qcom-fix-port-off-by-one-v2-1-c424edf85968@oss.qualcomm.com/
Notes: