All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jiawen Liu" <1298662399@qq.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/tegra: nvjpg: fix runtime PM setup in probe
Date: Sun, 29 Nov 2026 14:00:15 +0000	[thread overview]
Message-ID: <sashiko-outbox-239667@kernel.org> (raw)
In-Reply-To: <tencent_A7D12B6489AE96132560FAEF56E5517D5106@qq.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] drm/tegra: nvjpg: double runtime PM disable across
  nvjpg_exit() and nvjpg_remove()
- [Medium] drm/tegra: nvjpg: pm_runtime_enable() called after
  host1x_client_register() in nvjpg_probe()
- [Medium] drm/tegra: nvjpg: runtime PM disabled after falcon_exit() in
  nvjpg_remove()
--

commit 38180484ce9eb95d6bcaa5e7c4e2dae6f0f9c4fd
Author: Jiawen Liu <1298662399@qq.com>

drm/tegra: nvjpg: fix runtime PM setup in probe

This commit replaces devm_pm_runtime_enable() with pm_runtime_enable() in
nvjpg_probe() and adds runtime PM cleanup to nvjpg_remove().

> diff --git a/drivers/gpu/drm/tegra/nvjpg.c b/drivers/gpu/drm/tegra/nvjpg.c
> index e302a8d1f6e7f..0b6a8467f5183 100644
> --- a/drivers/gpu/drm/tegra/nvjpg.c
> +++ b/drivers/gpu/drm/tegra/nvjpg.c
> @@ -292,7 +292,7 @@ static int nvjpg_probe(struct platform_device *pdev)
>  
>  	pm_runtime_use_autosuspend(dev);
>  	pm_runtime_set_autosuspend_delay(dev, 500);
> -	devm_pm_runtime_enable(dev);
> +	pm_runtime_enable(dev);

[Severity: Medium]
Should pm_runtime_enable() be called before host1x_client_register() (and
disabled on registration failure), as in gr2d_probe() and gr3d_probe()?

Because tegra_nvjpg_driver is the last entry in drivers[], calling
host1x_client_register() as the final Host1x subdevice synchronously runs
host1x_drm_probe() -> nvjpg_init() -> drm_dev_register() before
host1x_client_register() returns.  Channel submissions to NVJPG during that
window hit pm_runtime_resume_and_get() while runtime PM is still disabled
and fail with -EACCES.  Also, if host1x_drm_probe() fails after
host1x_device_init(), its error path runs host1x_device_exit() ->
nvjpg_exit() -> pm_runtime_force_suspend() -> pm_runtime_disable(),
incrementing dev->power.disable_depth from 1 to 2 so that
pm_runtime_enable() here leaves runtime PM disabled.

>  
>  	return 0;
>  
> @@ -308,6 +308,8 @@ static void nvjpg_remove(struct platform_device *pdev)
>  
>  	host1x_client_unregister(&nvjpg->client.base);
>  	falcon_exit(&nvjpg->falcon);
> +	pm_runtime_dont_use_autosuspend(&pdev->dev);
> +	pm_runtime_disable(&pdev->dev);

[Severity: Medium]
Does calling pm_runtime_disable() here after host1x_client_unregister()
disable runtime PM twice?

When the composite Host1x device is active, host1x_client_unregister()
calls host1x_device_exit() -> nvjpg_exit(), which already runs:

drivers/gpu/drm/tegra/nvjpg.c:nvjpg_exit() {
	...
	pm_runtime_dont_use_autosuspend(client->dev);
	pm_runtime_force_suspend(client->dev);
	...
}

pm_runtime_force_suspend() calls pm_runtime_disable() and leaves
dev->power.disable_depth at 1, so the second pm_runtime_disable() in
nvjpg_remove() increments disable_depth to 2 for a single
pm_runtime_enable() in nvjpg_probe().  Because pm_runtime_reinit() does not
reset disable_depth on unbind, a subsequent re-probe only decrements
disable_depth from 2 to 1, leaving runtime PM disabled and causing all
NVJPG submissions to fail with -EACCES.  As in ace01e2af387 ("drm/tegra:
gr2d/gr3d: Contain PM in the gr*d_probe/gr*d_remove"), runtime PM enable
and disable should be contained in probe and remove rather than mixed with
pm_runtime_force_suspend() in nvjpg_exit().

[Severity: Medium]
Should pm_runtime_dont_use_autosuspend() and pm_runtime_disable() also run
before falcon_exit(), matching vic_remove() and nvdec_remove()?

__device_release_driver() calls pm_runtime_get_sync() and
pm_runtime_put_sync() right before nvjpg_remove(), which leaves the device
RPM_ACTIVE while the 500 ms autosuspend timer is pending.  When
nvjpg_exit() has not force-suspended the device, falcon_exit() tears down
the Falcon firmware while runtime PM is still active, and
pm_runtime_dont_use_autosuspend() can then trigger nvjpg_runtime_suspend()
after falcon_exit() has already run.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/tencent_A7D12B6489AE96132560FAEF56E5517D5106@qq.com?part=1

      reply	other threads:[~2026-11-29 14:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29 13:44 [PATCH] drm/tegra: nvjpg: fix runtime PM setup in probe Jiawen Liu
2026-11-29 14:00 ` sashiko-bot [this message]

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-239667@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=1298662399@qq.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 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.