drm/msm/dp: return 0 from audio_prepare when cable is disconnected
PATCH 1/1 drm/msm/dp: return 0 from audio_prepare when cable is disconnected
PipeWire treats a non-zero return from prepare as fatal, marking the DP audio device as a dummy sink when the cable is unplugged. The active_stream_cnt guard already prevents any unclocked hardware access, so return success instead of -EINVAL when the link is not active.
--- drivers/gpu/drm/msm/dp/dp_audio.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/msm/dp/dp_audio.c +1 -3
@@ -284,10 +284,8 @@ int msm_dp_audio_prepare(struct drm_bridge *bridge,* such cases check for connection status and bail out if not * connected. */ -if (!msm_dp_display->active_stream_cnt) { - rc = -EINVAL ; +if (!msm_dp_display->active_stream_cnt) goto end; - } audio =msm_dp_audio_get_data (msm_dp_display);if (IS_ERR (audio)) {
Signature · 1 line
2.34.1
PATCH 1/1 drm/msm/dp: return 0 from audio_prepare when cable is disconnected
PipeWire treats a non-zero return from prepare as fatal, marking the DP audio device as a dummy sink when the cable is unplugged. The active_stream_cnt guard already prevents any unclocked hardware access, so return success instead of -EINVAL when the link is not active.
--- drivers/gpu/drm/msm/dp/dp_audio.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/msm/dp/dp_audio.c +1 -3
@@ -284,10 +284,8 @@ int msm_dp_audio_prepare(struct drm_bridge *bridge,* such cases check for connection status and bail out if not * connected. */ -if (!msm_dp_display->power_on) { - rc = -EINVAL ; +if (!msm_dp_display->power_on) goto end; - } audio =msm_dp_audio_get_data (msm_dp_display);if (IS_ERR (audio)) {
Signature · 1 line
2.34.1
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Returning success (0) from msm_dp_audio_prepare when the display is disconnected causes silent audio failures upon hotplug and NoC errors due to unclocked DSP hardware access.
Pre-existing issues:
- [High] Race condition between msm_dp_audio_prepare and msm_dp_display_disable causes unclocked MMIO accesses. --
commit bfb65364e66313dc1385a42e09172f44a1e1fbd1
Author: Kumar Anurag <[email protected]>
drm/msm/dp: return 0 from audio_prepare when cable is disconnected
PipeWire treats a non-zero return from prepare as fatal, marking the DP audio device as a dummy sink when the cable is unplugged.
Quoted 2 lines
The
active_stream_cntguard already prevents any unclocked hardware access, so return success instead of-EINVALwhen the link is not active.
[Severity: High]
Is this commit message accurate for the upstream tree? There doesn't appear to be an active_stream_cnt guard in the mainline driver. Without this guard, will the DSP push data to powered-off, unclocked DP hardware and cause NoC errors?
drivers/gpu/drm/msm/dp/dp_audio.c int msm_dp_audio_prepare(struct drm_bridge *bridge, · line 288
Quoted 12 lines
drivers/gpu/drm/msm/dp/dp_audio.c +1
-2@@ -284,10 +284,8 @@ int msm_dp_audio_prepare(struct drm_bridge *bridge,* such cases check for connection status and bail out if not * connected. */ -if (!msm_dp_display->power_on) { - rc = -EINVAL ; +if (!msm_dp_display->power_on) goto end;
[Severity: High]
Does returning 0 here trick the ALSA/ASoC framework into marking the stream as successfully prepared?
If the stream is marked RUNNING, ALSA won't re-invoke prepare() when the display is later connected. Could this regression result in silent playback because the DP hardware is never actually configured?
[Severity: High]
This is a pre-existing issue, but does this lockless check of power_on race with msm_dp_display_disable()?
If msm_dp_display_disable() runs concurrently (e.g., from a hotplug interrupt) immediately after this check but before audio_enabled is set to true, it will skip waiting and disable the DP link and clocks.
When msm_dp_audio_prepare() resumes, it will call msm_dp_audio_setup_sdp() and attempt MMIO operations on unclocked DP audio registers. Could this lead to a synchronous external abort?
Quoted 4 lines
drivers/gpu/drm/msm/dp/dp_audio.c +0
-1- } audio =msm_dp_audio_get_data (msm_dp_display);if (IS_ERR (audio)) {
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 17 lines · On Tue, Jun 16, 2026 at 03:25:36PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Returning success (0) frommsm_dp_audio_preparewhen the display is disconnected causes silent audio failures upon hotplug and NoC errors due to unclocked DSP hardware access.Pre-existing issues:
- [High] Race condition betweenmsm_dp_audio_prepareandmsm_dp_display_disablecauses unclocked MMIO accesses. --commit
bfb65364e66313dc1385a42e09172f44a1e1fbd1
Author: Kumar Anurag <[email protected]>drm/msm/dp: return 0 from
audio_preparewhen cable is disconnectedPipeWire treats a non-zero return from prepare as fatal, marking the DP audio device as a dummy sink when the cable is unplugged.
Quoted 8 lines
Quoted 2 lines
The
active_stream_cntguard already prevents any unclocked hardware access, so return success instead of-EINVALwhen the link is not active.[Severity: High]
Is this commit message accurate for the upstream tree? There doesn't appear to be anactive_stream_cntguard in the mainline driver. Without this guard, will the DSP push data to powered-off, unclocked DP hardware and cause NoC errors?
$ git describe v7.2-rc2-4669-gb9810cd75b9f $ git grep active_stream_cnt $
Which tree has this commit message been based on?
Quoted 26 lines
drivers/gpu/drm/msm/dp/dp_audio.c int msm_dp_audio_prepare(struct drm_bridge *bridge, · line 288
Quoted 13 lines
drivers/gpu/drm/msm/dp/dp_audio.c +1
-2@@ -284,10 +284,8 @@ int msm_dp_audio_prepare(struct drm_bridge *bridge,* such cases check for connection status and bail out if not * connected. */ -if (!msm_dp_display->power_on) { - rc = -EINVAL ; +if (!msm_dp_display->power_on) goto end;[Severity: High]
Does returning 0 here trick the ALSA/ASoC framework into marking the stream as successfully prepared?If the stream is marked RUNNING, ALSA won't re-invoke
prepare()when the display is later connected. Could this regression result in silent playback because the DP hardware is never actually configured?[Severity: High]
This is a pre-existing issue, but does this lockless check ofpower_onrace withmsm_dp_display_disable()?
Quoted 7 lines
If
msm_dp_display_disable()runs concurrently (e.g., from a hotplug interrupt) immediately after this check but beforeaudio_enabledis set to true, it will skip waiting and disable the DP link and clocks.When
msm_dp_audio_prepare()resumes, it will callmsm_dp_audio_setup_sdp()and attempt MMIO operations on unclocked DP audio registers. Could this lead to a synchronous external abort?
I'd agree with Sashiko here. Do we guard against the unlocked access? Or how do we ensure that the stream will be prepared later?
I think this needs to be fixed on the other side of the pipe. Do we need to define a special prepare error code, which means "working, but not available now" and make PulseAudio / PipeWire handle those errors specially? How is it solved for other platforms? I don't think that msm/dp is unique here.
Mark, would you have any particular recommendations?
Signature · 2 lines
With best wishes Dmitry
Quoted 68 lines · Dmitry Baryshkov
Quoted 17 lines · On Tue, Jun 16, 2026 at 03:25:36PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Returning success (0) frommsm_dp_audio_preparewhen the display is disconnected causes silent audio failures upon hotplug and NoC errors due to unclocked DSP hardware access.Pre-existing issues:
- [High] Race condition betweenmsm_dp_audio_prepareandmsm_dp_display_disablecauses unclocked MMIO accesses. --commit
bfb65364e66313dc1385a42e09172f44a1e1fbd1
Author: Kumar Anurag <[email protected]>drm/msm/dp: return 0 from
audio_preparewhen cable is disconnectedPipeWire treats a non-zero return from prepare as fatal, marking the DP audio device as a dummy sink when the cable is unplugged.
Quoted 8 lines
Quoted 2 lines
The
active_stream_cntguard already prevents any unclocked hardware access, so return success instead of-EINVALwhen the link is not active.[Severity: High]
Is this commit message accurate for the upstream tree? There doesn't appear to be anactive_stream_cntguard in the mainline driver. Without this guard, will the DSP push data to powered-off, unclocked DP hardware and cause NoC errors?$ git describe v7.2-rc2-4669-gb9810cd75b9f $ git grep active_stream_cnt $Which tree has this commit message been based on?
Quoted 26 lines
drivers/gpu/drm/msm/dp/dp_audio.c int msm_dp_audio_prepare(struct drm_bridge *bridge, · line 288
Quoted 13 lines
drivers/gpu/drm/msm/dp/dp_audio.c +1
-2@@ -284,10 +284,8 @@ int msm_dp_audio_prepare(struct drm_bridge *bridge,* such cases check for connection status and bail out if not * connected. */ -if (!msm_dp_display->power_on) { - rc = -EINVAL ; +if (!msm_dp_display->power_on) goto end;[Severity: High]
Does returning 0 here trick the ALSA/ASoC framework into marking the stream as successfully prepared?If the stream is marked RUNNING, ALSA won't re-invoke
prepare()when the display is later connected. Could this regression result in silent playback because the DP hardware is never actually configured?[Severity: High]
This is a pre-existing issue, but does this lockless check ofpower_onrace withmsm_dp_display_disable()?Quoted 7 lines
If
msm_dp_display_disable()runs concurrently (e.g., from a hotplug interrupt) immediately after this check but beforeaudio_enabledis set to true, it will skip waiting and disable the DP link and clocks.When
msm_dp_audio_prepare()resumes, it will callmsm_dp_audio_setup_sdp()and attempt MMIO operations on unclocked DP audio registers. Could this lead to a synchronous external abort?
Quoted 8 lines
I'd agree with Sashiko here. Do we guard against the unlocked access? Or how do we ensure that the stream will be prepared later?
I think this needs to be fixed on the other side of the pipe. Do we need to define a special prepare error code, which means "working, but not available now" and make PulseAudio / PipeWire handle those errors specially? How is it solved for other platforms? I don't think that msm/dp is unique here.
AFAIU,There is no special error code for prepare to flag that cable is not connected, the standard way is to read Jack events. Wireplumber is is one which deals with Jack event, even before getting to there pipewire will fail to probe the devices on the card if prepare fails.
Once we are at Wireplumber level we are good, and stream will never sent to the sinks which are in disconnected state (via Jack).
This has been a known issue for very long time, most of the codecs like
Its also interesting to note that same Qualcomm SoC drivers deal with this situation by returning zero, so why dp has to be different?
drivers/gpu/drm/msm/hdmi/hdmi_audio.c
Other drivers that do not care about plug state in prepare are. sound/x86/intel_hdmi_audio.c drivers/gpu/drm/mediatek/mtk_hdmi.c sound/hda/codecs/hdmi/hdmi.c drivers/gpu/drm/xlnx/zynqmp_dp_audio.c
I think there is enough evidence how this is handled in the codec drivers, we should consider this patch.
--srini
Quoted 3 lines
Mark, would you have any particular recommendations?
Dmitry Baryshkov
Reviewed-byQuoted 100 lines · Srinivas Kandagatla
Quoted 68 lines · Dmitry Baryshkov
Quoted 17 lines · On Tue, Jun 16, 2026 at 03:25:36PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Returning success (0) frommsm_dp_audio_preparewhen the display is disconnected causes silent audio failures upon hotplug and NoC errors due to unclocked DSP hardware access.Pre-existing issues:
- [High] Race condition betweenmsm_dp_audio_prepareandmsm_dp_display_disablecauses unclocked MMIO accesses. --commit
bfb65364e66313dc1385a42e09172f44a1e1fbd1
Author: Kumar Anurag <[email protected]>drm/msm/dp: return 0 from
audio_preparewhen cable is disconnectedPipeWire treats a non-zero return from prepare as fatal, marking the DP audio device as a dummy sink when the cable is unplugged.
Quoted 8 lines
Quoted 2 lines
The
active_stream_cntguard already prevents any unclocked hardware access, so return success instead of-EINVALwhen the link is not active.[Severity: High]
Is this commit message accurate for the upstream tree? There doesn't appear to be anactive_stream_cntguard in the mainline driver. Without this guard, will the DSP push data to powered-off, unclocked DP hardware and cause NoC errors?$ git describe v7.2-rc2-4669-gb9810cd75b9f $ git grep active_stream_cnt $Which tree has this commit message been based on?
Quoted 26 lines
drivers/gpu/drm/msm/dp/dp_audio.c int msm_dp_audio_prepare(struct drm_bridge *bridge, · line 288
Quoted 13 lines
drivers/gpu/drm/msm/dp/dp_audio.c +1
-2@@ -284,10 +284,8 @@ int msm_dp_audio_prepare(struct drm_bridge *bridge,* such cases check for connection status and bail out if not * connected. */ -if (!msm_dp_display->power_on) { - rc = -EINVAL ; +if (!msm_dp_display->power_on) goto end;[Severity: High]
Does returning 0 here trick the ALSA/ASoC framework into marking the stream as successfully prepared?If the stream is marked RUNNING, ALSA won't re-invoke
prepare()when the display is later connected. Could this regression result in silent playback because the DP hardware is never actually configured?[Severity: High]
This is a pre-existing issue, but does this lockless check ofpower_onrace withmsm_dp_display_disable()?Quoted 7 lines
If
msm_dp_display_disable()runs concurrently (e.g., from a hotplug interrupt) immediately after this check but beforeaudio_enabledis set to true, it will skip waiting and disable the DP link and clocks.When
msm_dp_audio_prepare()resumes, it will callmsm_dp_audio_setup_sdp()and attempt MMIO operations on unclocked DP audio registers. Could this lead to a synchronous external abort?Quoted 8 lines
I'd agree with Sashiko here. Do we guard against the unlocked access? Or how do we ensure that the stream will be prepared later?
I think this needs to be fixed on the other side of the pipe. Do we need to define a special prepare error code, which means "working, but not available now" and make PulseAudio / PipeWire handle those errors specially? How is it solved for other platforms? I don't think that msm/dp is unique here.
AFAIU,There is no special error code for prepare to flag that cable is not connected, the standard way is to read Jack events. Wireplumber is is one which deals with Jack event, even before getting to there pipewire will fail to probe the devices on the card if prepare fails.
Once we are at Wireplumber level we are good, and stream will never sent to the sinks which are in disconnected state (via Jack).
This has been a known issue for very long time, most of the codecs like
Its also interesting to note that same Qualcomm SoC drivers deal with this situation by returning zero, so why dp has to be different?
drivers/gpu/drm/msm/hdmi/hdmi_audio.cOther drivers that do not care about plug state in prepare are.
sound/x86/intel_hdmi_audio.cdrivers/gpu/drm/mediatek/mtk_hdmi.csound/hda/codecs/hdmi/hdmi.cdrivers/gpu/drm/xlnx/zynqmp_dp_audio.c
Quoted 2 lines
I think there is enough evidence how this is handled in the codec drivers, we should consider this patch.
Let's discuss this at the LPC or some other F2F where we can get other parties. I'd like to sort out the issue. Or maybe next year's pipewire workshop.
For now:
Signature · 2 lines
With best wishes Dmitry