Re: [PATCH v8 21/21] drm/bridge: synopsys: dw-dp: Add audio support

[email protected]
Newsgroups org.freedesktop.lists.dri-devel,org.kernel.vger.linux-devicetree
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Missing lock in dw_dp_audio_mute_stream() creates a data race on dp->audio_muted and hardware registers, leading to state inconsistency.
--

--- Patch [21]: [PATCH v8 21/21] drm/bridge: synopsys: dw-dp: Add audio support ---
commit 4c38ba6f108f1bab4d60be41675a0058796ffe6a
Author: Sebastian Reichel <[email protected]>

drm/bridge: synopsys: dw-dp: Add audio support
    
Implement audio support for the Synopsys DesignWare DisplayPort controller.

> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-dp.c b/drivers/gpu/drm/bridge/synopsys/dw-dp.c
> index a39007f13a052..a62fca20ac2fe 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-dp.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-dp.c

[ ... ]

> +static int __dw_dp_audio_enable(struct dw_dp *dp)
> +{

[ ... ]

> +	regmap_update_bits(dp->regmap, DW_DP_AUD_CONFIG1,
> +			   AUDIO_DATA_IN_EN | NUM_CHANNELS | AUDIO_DATA_WIDTH |
> +			   AUDIO_INF_SELECT | HBR_MODE_ENABLE | AUDIO_MUTE,
> +			   FIELD_PREP(AUDIO_DATA_IN_EN, audio_data_in_en) |
> +			   FIELD_PREP(NUM_CHANNELS, dp->audio_channels - 1) |
> +			   FIELD_PREP(AUDIO_DATA_WIDTH, dp->audio_sample_width) |
> +			   FIELD_PREP(AUDIO_INF_SELECT, dp->audio_interface) |
> +			   FIELD_PREP(HBR_MODE_ENABLE, 0) |
> +			   FIELD_PREP(AUDIO_MUTE, dp->audio_muted));

[ ... ]

> +static int dw_dp_audio_mute_stream(struct drm_bridge *bridge,
> +				   struct drm_connector *connector,
> +				   bool enable, int direction)
> +{
> +	struct dw_dp *dp = bridge_to_dp(bridge);
> +
> +	dev_dbg(dp->dev, "audio %smute\n", enable ? "" : "un");
> +
> +	dp->audio_muted = enable;
> +
> +	regmap_update_bits(dp->regmap, DW_DP_AUD_CONFIG1, AUDIO_MUTE,
> +			   FIELD_PREP(AUDIO_MUTE, enable));
> +
> +	return 0;
> +}

[Severity: Medium]
Does this function need to hold dp->audio_lock when modifying dp->audio_muted
and the DW_DP_AUD_CONFIG1 register?

If ALSA calls dw_dp_audio_mute_stream() concurrently with a modeset that is
calling __dw_dp_audio_enable(), could it lead to a desync between the hardware
state and dp->audio_muted?

For example, if __dw_dp_audio_enable() reads dp->audio_muted as false, and
before it writes to DW_DP_AUD_CONFIG1, dw_dp_audio_mute_stream() executes,
updates dp->audio_muted to true, and successfully mutes the hardware.

Would __dw_dp_audio_enable() then overwrite the hardware register with its
stale false value, leaving the audio stream unexpectedly unmuted?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260731-synopsys-dw-dp-improvements-v8-0-ac1e6a75782f@collabora.com?part=21
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.