From: sashiko-bot@kernel.org
To: "Rob Clark" <robin.clark@oss.qualcomm.com>,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v4 5/6] drm/msm/debugfs: Use cleanup.h for gpu state dump
Date: Tue, 03 Nov 2026 23:32:23 +0000 [thread overview]
Message-ID: <sashiko-outbox-196217@kernel.org> (raw)
In-Reply-To: <20261103231850.17493-6-robin.clark@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] drm/msm/debugfs: msm_gpu_open() takes runtime PM ref before gpu->lock
--
commit 54d158da1032ffdd109205ad3548c04fcccd04a3
Author: Rob Clark <robin.clark@oss.qualcomm.com>
drm/msm/debugfs: Use cleanup.h for gpu state dump
This commit converts msm_gpu_open() in drivers/gpu/drm/msm/msm_debugfs.c to
use cleanup.h helpers for show_priv allocation, runtime PM, and gpu->lock.
> diff --git a/drivers/gpu/drm/msm/msm_debugfs.c b/drivers/gpu/drm/msm/msm_debugfs.c
> index d05307bfa1235..9373ac19ee953 100644
> --- a/drivers/gpu/drm/msm/msm_debugfs.c
> +++ b/drivers/gpu/drm/msm/msm_debugfs.c
> @@ -70,43 +70,36 @@ static int msm_gpu_open(struct inode *inode, struct file *file)
> struct drm_device *dev = inode->i_private;
> struct msm_drm_private *priv = dev->dev_private;
> struct msm_gpu *gpu = priv->gpu;
> - struct msm_gpu_show_priv *show_priv;
> int ret;
>
> if (!gpu || !gpu->funcs->gpu_state_get)
> return -ENODEV;
>
> - show_priv = kmalloc_obj(*show_priv);
> + struct msm_gpu_show_priv *show_priv __free(kfree)
> + = kmalloc_obj(*show_priv);
> if (!show_priv)
> return -ENOMEM;
>
> - ret = mutex_lock_interruptible(&gpu->lock);
> - if (ret)
> - goto free_priv;
> -
> - pm_runtime_get_sync(&gpu->pdev->dev);
> - msm_gpu_hw_init(gpu);
> - show_priv->state = gpu->funcs->gpu_state_get(gpu);
> - pm_runtime_put_sync(&gpu->pdev->dev);
> -
> - mutex_unlock(&gpu->lock);
> + scoped_guard (pm_runtime_active, &gpu->pdev->dev) {
> + scoped_cond_guard (mutex_intr, return -EINTR, &gpu->lock) {
> + msm_gpu_hw_init(gpu);
> + show_priv->state = gpu->funcs->gpu_state_get(gpu);
> + }
> + }
[Severity: Medium]
As reported by Konrad Dybcio on v2 [1], does acquiring the runtime PM
reference before gpu->lock in msm_gpu_open() break GPU hang recovery when
debugfs is opened concurrently with recover_worker()?
Previously, msm_gpu_open() acquired gpu->lock before calling
pm_runtime_get_sync(&gpu->pdev->dev). With scoped_guard(pm_runtime_active,
&gpu->pdev->dev) placed outside scoped_cond_guard(mutex_intr, ...,
&gpu->lock), msm_gpu_open() holds an active runtime PM reference while blocked
waiting for gpu->lock.
During hang recovery, recover_worker() holds gpu->lock and calls
gpu->funcs->recover(gpu). Both a6xx_recover() in
drivers/gpu/drm/msm/adreno/a6xx_gpu.c and a8xx_recover() in
drivers/gpu/drm/msm/adreno/a8xx_gpu.c rely on dropping the runtime PM usage
count to zero to synchronously suspend the GPU and collapse the CX GDSC:
/* Drop the rpm refcount from active submits */
if (active_submits)
pm_runtime_put(&gpu->pdev->dev);
/* And the final one from recover worker */
pm_runtime_put_sync(&gpu->pdev->dev);
if (!wait_for_completion_timeout(&gmu->pd_gate, msecs_to_jiffies(1000)))
DRM_DEV_ERROR(&gpu->pdev->dev, "cx gdsc didn't collapse\n");
If msm_gpu_open() is waiting on gpu->lock with a runtime PM reference held,
pm_runtime_put_sync(&gpu->pdev->dev) will not suspend the device,
wait_for_completion_timeout(&gmu->pd_gate, ...) will time out after 1000 ms,
and the subsequent pm_runtime_get_sync() will not run runtime resume to set
gpu->needs_hw_init = true before msm_gpu_hw_init(gpu) is called.
Since the subsequent IFPC changes in the series place guard(ifpc_disable)(gpu)
inside the gpu->lock critical section after msm_gpu_hw_init(gpu), should
scoped_cond_guard(mutex_intr, return -EINTR, &gpu->lock) remain the outer
guard with scoped_guard(pm_runtime_active, &gpu->pdev->dev) nested inside it?
[1] https://lore.kernel.org/r/a4151c32-bac2-40ec-86f3-59d4dbfaae62@oss.qualcomm.com
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261103231850.17493-1-robin.clark@oss.qualcomm.com?part=5
next prev parent reply other threads:[~2026-11-03 23:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 23:18 [PATCH v4 0/6] drm/msm: Decouple IFPC disable and sysprof Rob Clark
2026-11-03 23:18 ` [PATCH v4 1/6] drm/msm: Hold runpm ref in set_sysprof() Rob Clark
2026-11-03 23:37 ` sashiko-bot
2026-11-03 23:18 ` [PATCH v4 2/6] drm/msm: Resume perfcntrs after hw_init Rob Clark
2026-11-03 23:30 ` sashiko-bot
2026-11-03 23:18 ` [PATCH v4 3/6] drm/msm: Rework IFPC disable Rob Clark
2026-11-03 23:46 ` sashiko-bot
2026-11-03 23:18 ` [PATCH v4 4/6] drm/msm: Add cleanup help for disabling IFPC Rob Clark
2026-11-03 23:18 ` [PATCH v4 5/6] drm/msm/debugfs: Use cleanup.h for gpu state dump Rob Clark
2026-11-03 23:32 ` sashiko-bot [this message]
2026-11-03 23:18 ` [PATCH v4 6/6] drm/msm: Inhibit IFPC for state snapshot Rob Clark
2026-11-03 23:48 ` sashiko-bot
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=sashiko-outbox-196217@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=robin.clark@oss.qualcomm.com \
--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.