dri-devel.lists.freedesktop.org archive mirror
 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 v7 13/14] drm/bridge: it6505: Add audio support
Date: Thu, 24 Sep 2026 19:01:18 +0000	[thread overview]
Message-ID: <20260924190118.A25911F000FF@smtp.kernel.org> (raw)
In-Reply-To: <9467f1fde989ec3914344c129a039fe7b7ed91e1.1790275151.git.daniel@makrotopia.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] drm/bridge: it6505: missing audio_lock in it6505_poweron() causes I2C data race
--

commit 180d8c850bc807b0a0b106e27c0aef15c059c696
Author: Jiaxin Yu <jiaxin.yu@mediatek.com>

drm/bridge: it6505: Add audio support
    
This commit adds audio support for the it6505 bridge. It registers
an "hdmi-audio-codec" platform device, wires up audio helpers, and
introduces an audio_lock mutex to serialize audio enable/disable
against other tasks.

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
> --- a/drivers/gpu/drm/bridge/ite-it6505.c
> +++ b/drivers/gpu/drm/bridge/ite-it6505.c
> @@ -2823,6 +2829,8 @@ static int it6505_poweroff(struct it6505 *it6505)
>  	cancel_work_sync(&it6505->hdcp_wait_ksv_list);
>  	cancel_delayed_work_sync(&it6505->hdcp_work);
>  
> +	mutex_lock(&it6505->audio_lock);
> +
>  	if (pdata->gpiod_reset)
>  		gpiod_set_value_cansleep(pdata->gpiod_reset, 1);
>  
> @@ -2842,6 +2850,7 @@ static int it6505_poweroff(struct it6505 *it6505)
>  
>  	it6505->powered = false;
>  	it6505->sink_count = 0;
> +	mutex_unlock(&it6505->audio_lock);
>  
>  	return 0;
>  }

[ ... ]

> @@ -2988,25 +2997,28 @@ static void it6505_remove_notifier_module(struct it6505 *it6505)
>  	flush_work(&it6505->extcon_wq);
>  }
>  
> -static void __maybe_unused it6505_delayed_audio(struct work_struct *work)
> +static void it6505_delayed_audio(struct work_struct *work)
>  {
>  	struct it6505 *it6505 = container_of(work, struct it6505,
>  					     delayed_audio.work);
>  
>  	DRM_DEV_DEBUG_DRIVER(it6505->dev, "start");
>  
> -	if (!it6505->powered)
> +	if (it6505->enable_drv_hold)
>  		return;
>  
> -	if (!it6505->enable_drv_hold)
> -		it6505_enable_audio(it6505);
> +	mutex_lock(&it6505->audio_lock);
> +	if (it6505->powered && !it6505->audio.mute)
> +		__it6505_enable_audio(it6505);
> +	mutex_unlock(&it6505->audio_lock);
>  }

[Severity: High]
Does it6505_poweron() need to take the new audio_lock as well?

While this patch adds audio_lock to it6505_poweroff() to serialize with the
new it6505_delayed_audio() worker, it6505_poweron() sets it6505->powered = true
and performs hardware initialization without holding the lock:

drivers/gpu/drm/bridge/ite-it6505.c:it6505_poweron() {
    ...
	it6505->powered = true;
	it6505_reset_logic(it6505);
	it6505_int_mask_enable(it6505);
	it6505_init(it6505);
    ...
}

If a device is runtime resumed and it6505_poweron() is called, could
it6505_delayed_audio() run concurrently? Since it6505->powered is set to true
early, it6505_delayed_audio() can acquire the audio_lock and execute
__it6505_enable_audio() while it6505_poweron() is still doing
it6505_reset_logic() and it6505_init().

For example, this sequence might occur when the bridge is powered off and an
ALSA stream is unmuted, queuing it6505_delayed_audio() with a 180ms delay.
If the device is runtime resumed shortly after (e.g., via cable hotplug),
it invokes it6505_poweron().

If it6505_delayed_audio() fires exactly as it6505_poweron() sets
it6505->powered = true, it can grab the audio_lock and begin I2C writes.
Meanwhile, it6505_poweron() continues concurrently because it doesn't take
the audio_lock.

Can this lead to a regression where the audio configuration is wiped out or
causes general I2C race conditions since the __it6505_enable_audio() 
configuration could be interleaved with it6505_init() or wiped out by the 
ALL_LOGIC_RESET in it6505_reset_logic()?

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

  reply	other threads:[~2026-09-24 19:01 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24 18:39 [PATCH v7 00/14] drm/bridge: it6505: DP audio support + shared-DAI hw_params fix Daniel Golle
2026-09-24 18:40 ` [PATCH v7 01/14] drm/bridge: it6505: quiesce event sources and work on remove() Daniel Golle
2026-09-24 18:40 ` [PATCH v7 02/14] drm/bridge: it6505: quiesce work items before powering off Daniel Golle
2026-09-24 18:40 ` [PATCH v7 03/14] drm/bridge: it6505: balance and disable runtime PM on remove Daniel Golle
2026-09-24 18:40 ` [PATCH v7 04/14] drm/bridge: it6505: unregister DP AUX adapter on bridge detach Daniel Golle
2026-09-24 18:57   ` sashiko-bot
2026-09-24 18:40 ` [PATCH v7 05/14] drm/bridge: it6505: complete poweroff even if disabling regulators fails Daniel Golle
2026-09-24 18:49   ` sashiko-bot
2026-09-24 18:40 ` [PATCH v7 06/14] drm/bridge: it6505: bail out of the IRQ handler when status reads fail Daniel Golle
2026-09-24 18:40 ` [PATCH v7 07/14] drm/bridge: it6505: avoid division by zero in pixel clock calculation Daniel Golle
2026-09-24 18:41 ` [PATCH v7 08/14] drm/bridge: it6505: avoid division by zero in audio FS debug print Daniel Golle
2026-09-24 18:41 ` [PATCH v7 09/14] drm/bridge: it6505: guard against zero channel count in audio infoframe Daniel Golle
2026-09-24 18:41 ` [PATCH v7 10/14] drm/bridge: it6505: hold endpoint OF node reference while parsing it Daniel Golle
2026-09-24 18:42 ` [PATCH v7 11/14] drm/bridge: it6505: reject a too short link-frequencies property Daniel Golle
2026-09-24 18:42 ` [PATCH v7 12/14] drm/bridge: it6505: don't write an error code back to the reset register Daniel Golle
2026-09-24 18:42 ` [PATCH v7 13/14] drm/bridge: it6505: Add audio support Daniel Golle
2026-09-24 19:01   ` sashiko-bot [this message]
2026-09-24 18:42 ` [PATCH v7 14/14] 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=20260924190118.A25911F000FF@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).