dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Adrián Larumbe" <adrian.larumbe@collabora.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v11 05/15] drm/panfrost: Consolidate device clock management and reset
Date: Fri, 25 Sep 2026 18:57:09 +0000	[thread overview]
Message-ID: <20260925185710.40ABA1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260925-claude-fixes-v11-5-0dbf5a58e7ce@collabora.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] drm/panfrost: Unintended global prepare_lock contention in runtime PM
--

commit b64fb23518fa629aff18538498a7ba6190344212
Author: Adrián Larumbe <adrian.larumbe@collabora.com>

drm/panfrost: Consolidate device clock management and reset

This commit gathers clock enables and disables into a single function to avoid
repetitions between driver init/fini and device resume/suspend. It also
combines clock prepares and enables together, simplifying the management API.

> diff --git a/drivers/gpu/drm/panfrost/panfrost_device.c b/drivers/gpu/drm/panfrost/panfrost_device.c
> index b3a53504bd016..9f2b1967a3984 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_device.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_device.c
[ ... ]
> +static int panfrost_clks_enable(struct panfrost_device *pfdev, bool on_resume)
>  {
>  	int err;
> +
> +	err = clk_prepare_enable(pfdev->clock);

[Severity: Medium]
Will this introduce global lock contention during runtime PM wake-ups?

The commit message notes that clk_prepare can simply increase the refcnt
of an already prepared clock. However, clk_prepare() and clk_unprepare()
always acquire the global prepare_lock mutex to do so.

Furthermore, since the GPU driver is the sole consumer of its specific leaf
clocks, the refcount might drop to 0, forcing a full hardware
unprepare/prepare cycle which can be quite slow.

Because panfrost_clks_enable() is called from
panfrost_device_runtime_resume(), this replaces the previous clk_enable()
calls (which only take a fast spinlock) with clk_prepare_enable(), causing
the driver to contend for the global prepare_lock mutex every time the GPU
wakes up from runtime suspend.

> +	if (err)
> +		return err;
> +
> +	err = clk_prepare_enable(pfdev->bus_clock);
> +	if (err)
> +		goto disable_clock;
> +
> +	if (on_resume) {
> +		err = clk_prepare_enable(pfdev->bus_ace_clock);
> +		if (err)
> +			goto disable_bus_clock;
> +	}
> +
> +	return 0;
> +
> +disable_bus_clock:
> +	clk_disable_unprepare(pfdev->bus_clock);
> +disable_clock:
> +	clk_disable_unprepare(pfdev->clock);
> +
> +	return err;
> +}
> +
> +static void panfrost_clks_disable(struct panfrost_device *pfdev, bool on_suspend)
> +{
> +	if (on_suspend)
> +		clk_disable_unprepare(pfdev->bus_ace_clock);
> +	clk_disable_unprepare(pfdev->bus_clock);
> +	clk_disable_unprepare(pfdev->clock);

[Severity: Medium]
Similar to the resume path, since this is called from
panfrost_device_runtime_suspend(), will replacing clk_disable() with
clk_disable_unprepare() cause unintended global prepare_lock contention
every time the GPU idles?

[ ... ]
> @@ -436,34 +450,17 @@ static int panfrost_device_runtime_resume(struct device *dev)
[ ... ]
> -		ret = clk_enable(pfdev->clock);
> -		if (ret)
> -			goto err_clk;
> -
> -		ret = clk_enable(pfdev->bus_clock);
> -		if (ret)
> -			goto err_bus_clk;
> -
> -		ret = clk_enable(pfdev->bus_ace_clock);
> -		if (ret)
> -			goto err_bus_ace_clk;
> +		ret = panfrost_clks_enable(pfdev, true);
[ ... ]
> @@ -480,9 +477,7 @@ static int panfrost_device_runtime_suspend(struct device *dev)
[ ... ]
>  	if (pfdev->comp->pm_features & BIT(GPU_PM_RT)) {
> -		clk_disable(pfdev->bus_ace_clock);
> -		clk_disable(pfdev->bus_clock);
> -		clk_disable(pfdev->clock);
> +		panfrost_clks_disable(pfdev, true);
>  		reset_control_assert(pfdev->rstc);
>  	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260925-claude-fixes-v11-0-0dbf5a58e7ce@collabora.com?part=5

  reply	other threads:[~2026-09-25 18:57 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-25 18:45 [PATCH v11 00/15] Collection of fixes for Panfrost: Perfcnt, RPM, refactorings Adrián Larumbe
2026-09-25 18:45 ` [PATCH v11 01/15] drm/panfrost: Move shrinker initialization and unplug one level down Adrián Larumbe
2026-09-25 18:45 ` [PATCH v11 02/15] drm/panfrost: Move lock and modparam initialisations into their subsystems Adrián Larumbe
2026-09-25 18:45 ` [PATCH v11 03/15] drm/panfrost: Move debugfs initialisation to relevant subsystems Adrián Larumbe
2026-09-25 18:45 ` [PATCH v11 04/15] drm/panfrost: Skip NULL checks for clock enable/disabling Adrián Larumbe
2026-09-25 18:45 ` [PATCH v11 05/15] drm/panfrost: Consolidate device clock management and reset Adrián Larumbe
2026-09-25 18:57   ` sashiko-bot [this message]
2026-09-25 18:45 ` [PATCH v11 06/15] drm/panfrost: Fix PM refcnt and autosuspend issues at device probe/remove Adrián Larumbe
2026-09-25 18:57   ` sashiko-bot
2026-09-25 18:45 ` [PATCH v11 07/15] drm/panfrost: Explicitly enable MMU interrupts at device init Adrián Larumbe
2026-09-25 18:45 ` [PATCH v11 08/15] drm/panfrost: Move all DRM device initialisation into device_init() Adrián Larumbe
2026-09-25 18:58   ` sashiko-bot
2026-09-25 19:45   ` Adrián Larumbe
2026-09-25 18:45 ` [PATCH v11 09/15] drm/panfrost: Add warning messages to fatal error conditions Adrián Larumbe
2026-09-25 18:45 ` [PATCH v11 10/15] drm/panfrost: Add debugfs knob for manually triggering a GPU reset Adrián Larumbe
2026-09-25 18:45 ` [PATCH v11 11/15] drm/panfrost: Move perfcnt GPU disable sequence into a helper Adrián Larumbe
2026-09-25 18:45 ` [PATCH v11 12/15] drm/panfrost: Skip cache flush/invalidate when enabling perfcnt Adrián Larumbe
2026-09-25 18:45 ` [PATCH v11 13/15] drm/panfrost: Avoid cache flush after perfcnt sample in fully coherent systems Adrián Larumbe
2026-09-25 18:45 ` [PATCH v11 14/15] drm/panfrost: Introduce a reset lock Adrián Larumbe
2026-09-25 18:45 ` [PATCH v11 15/15] drm/panfrost: Fix races between perfcnt and reset sequence Adrián Larumbe
2026-09-25 19:02   ` sashiko-bot
2026-09-25 20:29   ` Adrián Larumbe

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=20260925185710.40ABA1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=adrian.larumbe@collabora.com \
    --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