All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rob Clark" <robin.clark@oss.qualcomm.com>,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v4 2/6] drm/msm: Resume perfcntrs after hw_init
Date: Tue, 03 Nov 2026 23:30:52 +0000	[thread overview]
Message-ID: <sashiko-outbox-196213@kernel.org> (raw)
In-Reply-To: <20261103231850.17493-3-robin.clark@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] drm/msm: self-deadlock on perfcntr_lock in sel_worker() via msm_gpu_hw_init()
--

commit 5d6d3def9b6235a74e135666a5a4eea2adca8e09
Author: Rob Clark <robin.clark@oss.qualcomm.com>

drm/msm: Resume perfcntrs after hw_init

This commit moves msm_perfcntr_resume() from adreno_runtime_resume() and
adreno_recover() into msm_gpu_hw_init() so that performance counter sampling
resumes only after hardware initialization completes.

> diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
> index 0c2c356362518..b9a8c641001d0 100644
> --- a/drivers/gpu/drm/msm/msm_gpu.c
> +++ b/drivers/gpu/drm/msm/msm_gpu.c
> @@ -168,8 +168,10 @@ int msm_gpu_hw_init(struct msm_gpu *gpu)
>  
>  	disable_irq(gpu->irq);
>  	ret = gpu->funcs->hw_init(gpu);
> -	if (!ret)
> +	if (!ret) {
> +		msm_perfcntr_resume(gpu);
>  		gpu->needs_hw_init = false;
> +	}

[Severity: High]
Can calling msm_perfcntr_resume() inside msm_gpu_hw_init() deadlock on
gpu->perfcntr_lock when invoked from sel_worker()?

In drivers/gpu/drm/msm/msm_perfcntr.c, sel_worker() acquires both gpu->lock
and gpu->perfcntr_lock before calling msm_gpu_hw_init():

drivers/gpu/drm/msm/msm_perfcntr.c:sel_worker() {
	...
	scoped_guard (mutex, &gpu->lock) {
		guard(mutex)(&gpu->perfcntr_lock);

		if (stream == gpu->perfcntrs->stream) {
			msm_gpu_hw_init(gpu);
			gpu->funcs->perfcntr_configure(gpu, ring, stream);
		}
	}
}

And msm_perfcntr_resume() acquires gpu->perfcntr_lock again:

drivers/gpu/drm/msm/msm_perfcntr.c:msm_perfcntr_resume() {
	if (!gpu->perfcntrs)
		return 0;
	guard(mutex)(&gpu->perfcntr_lock);
	return msm_perfcntr_resume_locked(gpu->perfcntrs->stream);
}

If the GPU is runtime-PM active while gpu->needs_hw_init is still true (for
example, after adreno_runtime_resume() runs via pm_runtime_get_sync() in
adreno_get_param() or msm_context_set_sysprof() before any job submission
calls msm_gpu_hw_init()), opening a stream in msm_ioctl_perfcntr_config()
unconditionally calls msm_perfcntr_resume_locked(), which starts
stream->sample_timer and queues stream->sel_work.

When sel_worker() runs and calls msm_gpu_hw_init(gpu) with
gpu->needs_hw_init set, msm_gpu_hw_init() disables gpu->irq, runs
gpu->funcs->hw_init(gpu), and calls msm_perfcntr_resume(gpu), which attempts
to take gpu->perfcntr_lock while sel_worker() already holds it.

Even without the recursive lock acquisition, wouldn't calling
msm_perfcntr_resume() from the sel_worker() -> msm_gpu_hw_init() path also
redundantly re-queue stream->sel_work right before sel_worker() calls
gpu->funcs->perfcntr_configure()?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261103231850.17493-1-robin.clark@oss.qualcomm.com?part=2

  reply	other threads:[~2026-11-03 23:31 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 [this message]
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
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-196213@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.