Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
To: iav@iav.lv, Detlev Casanova <detlev.casanova@collabora.com>,
	Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Cc: Hans Verkuil <hverkuil+cisco@kernel.org>,
	Mauro Carvalho Chehab	 <mchehab@kernel.org>,
	Heiko Stuebner <heiko@sntech.de>,
	Diederik de Haas	 <diederik@cknow-tech.com>,
	Jonas Karlman <jonas@kwiboo.se>,
	Francesco Saverio Pavone <pavone.lawyer@gmail.com>,
	linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org,
		linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, 	stable@vger.kernel.org
Subject: Re: [PATCH] media: rkvdec: Do not keep the clocks enabled from probe
Date: Fri, 30 Oct 2026 08:49:03 -0400	[thread overview]
Message-ID: <76e2e993fa5a8fd054bad97505907d3c4e88e11c.camel@collabora.com> (raw)
In-Reply-To: <20261030-rkvdec-runtime-pm-clocks-v1-1-fb2c5b629e79@iav.lv>

[-- Attachment #1: Type: text/plain, Size: 3231 bytes --]

Le vendredi 30 octobre 2026 à 03:33 +0200, Igor Velkov via B4 Relay a écrit :
> From: Igor Velkov <iav@iav.lv>
> 
> Since commit 6a846f7d72c7 ("media: rkvdec: Enable all clocks without
> naming them") the clocks are fetched with devm_clk_bulk_get_all_enabled(),
> which keeps them enabled from probe until unbind. rkvdec_runtime_suspend()
> disables them on top of that, so their enable count never drops to zero
> and the clock gates stay open while the decoder is idle.
> 
> On RK3399 this also breaks restore from hibernation when the boot kernel
> has not enabled these clocks, for example with rkvdec built as a module:
> the gates are closed when the restored kernel takes over, while it still
> counts the clocks as enabled. Powering on the vdu power domain then finds
> the count at 1 and leaves the gates closed, and the first QoS register
> write of the domain never returns.
> 
> Get the clocks without enabling them and let runtime PM enable them while
> the decoder is in use, as before that commit.
> 
> Fixes: 6a846f7d72c7 ("media: rkvdec: Enable all clocks without naming them")
> Cc: stable@vger.kernel.org # v7.0+
> Signed-off-by: Igor Velkov <iav@iav.lv>
> ---
> Tested on ROCK Pi 4A (RK3399) with v7.3, rkvdec and panfrost built as
> modules, panfrost not loaded:
> - idle decoder: the vdu clocks have enable_count 0 (1 without the patch);
> - hibernate, power cycle, restore: 3 of 3 (0 of 3 without the patch, the
>   restored kernel stops after bringing the secondary CPUs up);
> - H.264 decode with GStreamer v4l2slh264dec, 300 frames of 720p High
>   profile: output identical to avdec_h264 (md5 of all frames).
> The QoS hang was traced with debug prints in rockchip_pd_power() on a
> 7.3-based kernel.
> 
> This is separate from the unbind leak in Jonas's patch that Francesco
> posted [1]: here the extra enable comes from probe.
> 
> [1] https://lore.kernel.org/all/20260717154505.83935-1-pavone.lawyer@gmail.com/
> ---
>  drivers/media/platform/rockchip/rkvdec/rkvdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec.c b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
> index 061281f903f3..45c541ae3029 100644
> --- a/drivers/media/platform/rockchip/rkvdec/rkvdec.c
> +++ b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
> @@ -1788,7 +1788,7 @@ static int rkvdec_probe(struct platform_device *pdev)
>  	if (ret)
>  		return ret;
>  
> -	ret = devm_clk_bulk_get_all_enabled(&pdev->dev, &rkvdec->clocks);
> +	ret = devm_clk_bulk_get_all(&pdev->dev, &rkvdec->clocks);

With the explanation above, it seems pretty clear we have an issue. Now, the
problem with this is that PM ops are set with:

  #define pm_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM), (_ptr))

So if CONFIG_PM is not set, the initial resume will never occur, and first mmio
access will likely hang the CPU. We need a clean pattern to handle this, and
perhaps review other similar drivers while at it.

Nicolas

>  	if (ret < 0)
>  		return ret;
>  
> 
> ---
> base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222
> change-id: 20261030-rkvdec-runtime-pm-clocks-41adcf141271
> 
> Best regards,

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2026-10-30 12:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-30  1:33 [PATCH] media: rkvdec: Do not keep the clocks enabled from probe Igor Velkov via B4 Relay
2026-10-30 12:49 ` Nicolas Dufresne [this message]
2026-10-30 18:05   ` Igor Velkov

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=76e2e993fa5a8fd054bad97505907d3c4e88e11c.camel@collabora.com \
    --to=nicolas.dufresne@collabora.com \
    --cc=detlev.casanova@collabora.com \
    --cc=diederik@cknow-tech.com \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=heiko@sntech.de \
    --cc=hverkuil+cisco@kernel.org \
    --cc=iav@iav.lv \
    --cc=jonas@kwiboo.se \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=mchehab@kernel.org \
    --cc=pavone.lawyer@gmail.com \
    --cc=stable@vger.kernel.org \
    /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