All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Daniel Golle" <daniel@makrotopia.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v6 12/13] drm/bridge: it6505: Add audio support
Date: Sat, 25 Jul 2026 05:25:29 +0000	[thread overview]
Message-ID: <20260725052530.1247F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <849db02af75f9f8bab9e211395435fda12d27c3e.1784947240.git.daniel@makrotopia.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Missing PM runtime reference in audio callbacks leads to TOCTOU race with device power-off.
--

--- Patch [12]: [PATCH v6 12/13] drm/bridge: it6505: Add audio support ---
commit 10341e11c958ca412de2f96980c0f7ee9f5854c5
Author: Jiaxin Yu <jiaxin.yu@mediatek.com>

drm/bridge: it6505: Add audio support
    
Add audio support for it6505 by bridging to the hdmi-codec: register
an "hdmi-audio-codec" platform device from probe and wire up the
previously unused audio helpers via hdmi_codec_ops. This unblocks the
mt8186-mt6366 sound card which references it6505 as the I2S3 codec.

Link: https://lore.kernel.org/all/20230730180803.22570-4-jiaxin.yu@mediatek.com/

> diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
> index aeaa7b5ecf5aa..c560f1258f6d7 100644
> --- a/drivers/gpu/drm/bridge/ite-it6505.c
> +++ b/drivers/gpu/drm/bridge/ite-it6505.c
[ ... ]
> -static void __maybe_unused it6505_audio_shutdown(struct device *dev, void *data)
> +static void it6505_audio_shutdown(struct device *dev, void *data)
>  {
>  	struct it6505 *it6505 = dev_get_drvdata(dev);
>  
> +	mutex_lock(&it6505->audio_lock);
> +	it6505->audio.mute = true;
>  	if (it6505->powered)
> -		it6505_disable_audio(it6505);
> +		__it6505_disable_audio(it6505);
> +	mutex_unlock(&it6505->audio_lock);
> +	cancel_delayed_work_sync(&it6505->delayed_audio);
> +}
[ ... ]
> +static int it6505_audio_mute(struct device *dev, void *data,
> +			     bool enable, int direction)
> +{
> +	struct it6505 *it6505 = dev_get_drvdata(dev);
> +
> +	DRM_DEV_DEBUG_DRIVER(dev, "mute: %d", enable);
> +
> +	/*
> +	 * Delay enabling audio until the stream is unmuted; InfoFrames
> +	 * without audio data upset some DP-to-HDMI dongles.
> +	 */
> +	if (enable) {
> +		mutex_lock(&it6505->audio_lock);
> +		it6505->audio.mute = true;
> +		if (it6505->powered)
> +			__it6505_disable_audio(it6505);
> +		mutex_unlock(&it6505->audio_lock);
> +		cancel_delayed_work_sync(&it6505->delayed_audio);
> +	} else {
> +		mutex_lock(&it6505->audio_lock);
> +		it6505->audio.mute = false;
> +		mutex_unlock(&it6505->audio_lock);
> +		queue_delayed_work(system_wq, &it6505->delayed_audio,
> +				   msecs_to_jiffies(180));
> +	}
> +
> +	return 0;
> +}

[Severity: High]
Does this code race with device power-off?

If the audio stream is unmuted via ALSA, it6505_audio_mute() queues
it6505->delayed_audio to run after 180ms.

If a user unplugs the DP cable during this delay, it6505_extcon_work() calls
pm_runtime_put_sync() on the parent device, invoking the runtime suspend
callback it6505_poweroff().

it6505_poweroff() disables regulators and asserts the reset GPIO before
clearing the it6505->powered flag at the very end of the function. It does
not cancel the delayed work.

If it6505_delayed_audio() (or a concurrent it6505_audio_mute() /
it6505_audio_shutdown()) checks it6505->powered before it6505_poweroff()
updates the flag, they could proceed to issue I2C writes while the device's
power is physically cut. This can result in I2C bus lockups since unpowered
chips may pull SDA/SCL lines low.

Should these functions use a PM runtime reference (e.g., via
pm_runtime_get_if_active()) to safely access the hardware?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1784947240.git.daniel@makrotopia.org?part=12

  reply	other threads:[~2026-07-25  5:25 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-25  2:57 [PATCH v6 00/13] drm/bridge: it6505: DP audio support + shared-DAI hw_params fix Daniel Golle
2026-07-25  2:58 ` [PATCH v6 01/13] drm/bridge: it6505: quiesce event sources and work on remove() Daniel Golle
2026-07-25  3:23   ` sashiko-bot
2026-07-25  2:58 ` [PATCH v6 02/13] drm/bridge: it6505: balance and disable runtime PM on remove Daniel Golle
2026-07-25  3:18   ` sashiko-bot
2026-07-25  2:58 ` [PATCH v6 03/13] drm/bridge: it6505: unregister DP AUX adapter on bridge detach Daniel Golle
2026-07-25  3:17   ` sashiko-bot
2026-07-25  2:58 ` [PATCH v6 04/13] drm/bridge: it6505: complete poweroff even if disabling regulators fails Daniel Golle
2026-07-25  3:17   ` sashiko-bot
2026-07-25  2:58 ` [PATCH v6 05/13] drm/bridge: it6505: bail out of the IRQ handler when status reads fail Daniel Golle
2026-07-25  2:59 ` [PATCH v6 06/13] drm/bridge: it6505: avoid division by zero in pixel clock calculation Daniel Golle
2026-07-25  3:20   ` sashiko-bot
2026-07-25  2:59 ` [PATCH v6 07/13] drm/bridge: it6505: avoid division by zero in audio FS debug print Daniel Golle
2026-07-25  3:16   ` sashiko-bot
2026-07-25  2:59 ` [PATCH v6 08/13] drm/bridge: it6505: guard against zero channel count in audio infoframe Daniel Golle
2026-07-25  3:00 ` [PATCH v6 09/13] drm/bridge: it6505: hold endpoint OF node reference while parsing it Daniel Golle
2026-07-25  3:15   ` sashiko-bot
2026-07-25  3:00 ` [PATCH v6 10/13] drm/bridge: it6505: reject a too short link-frequencies property Daniel Golle
2026-07-25  3:00 ` [PATCH v6 11/13] drm/bridge: it6505: don't write an error code back to the reset register Daniel Golle
2026-07-25  3:19   ` sashiko-bot
2026-07-25  3:01 ` [PATCH v6 12/13] drm/bridge: it6505: Add audio support Daniel Golle
2026-07-25  5:25   ` sashiko-bot [this message]
2026-07-25  3:01 ` [PATCH v6 13/13] drm/bridge: it6505: Don't reject audio hw_params without an encoder Daniel Golle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260725052530.1247F1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=daniel@makrotopia.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.