From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 77585230BE9 for ; Wed, 17 Jun 2026 14:55:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781708152; cv=none; b=rvs1l6Y1RiDwt/w4fuz5lXGZIGVE2MUa/0Ubodj1iQ8J3+t9wMqlr56SffVlze2NKUj9+0irK7mTEr2rkIH7n+9dArvSczsr1yXp9a8AtD6U4w6Bi5UCBnmBJL4t2XYUHCf/QKLuFT176SWkN7c+QI1DlnyZCxWwAWtpJwRwPpU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781708152; c=relaxed/simple; bh=B8jGaMu50yEU36HgLLLq39nKxPfO0ebufp/+vz+TlPM=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EYR8cn2SuvsnNaQ5h3zdFjPv4naDwwYORcJZcbaspIaQe+MA3O+R1OwjLO6N4qZFSIl7BNbNC9jJ2lVtNrcfD1vGQ+eTn05njUId8YpnHsRCzZqfjj8Shzq3ulSh71fLYcz3nM245pNKqo3RM444DTxf3WA8R3c2/nRa/xj7jqk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=gzpokZJT; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="gzpokZJT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1781708149; bh=B8jGaMu50yEU36HgLLLq39nKxPfO0ebufp/+vz+TlPM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=gzpokZJTbMMowhbK2YnQVaU2HEnwVsCMj7WVbSmWz9FKrclvMP8Tgf2csaGfnLuff F2VWzVjnYPfYPl7sCl1Z5eFr5S/Dx7KvkQkFl298rRMeBhHHAmxHj64ezyV1L7KHy4 XDShN9syeabVdznKsL9ZDlNWT6mNQdoE9loa5e5GWUG4t2rvTHL/OrA0LZJ/FK4v87 tVZM3tMlOI3bOnD9Tm9/qwte61BO+urZicehZYujsK/Zvs0K6sywyFtVi8yNqT2m6q 7cX14GB23dI5SfAfH2A/6/LIQFFiItfdfBc8TVb4kW4qMRbUX6bw0u14kkkBW2DTIC ioKd41KZLU5hw== Received: from fedora-2.home (unknown [100.64.0.11]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbrezillon) by bali.collaboradmins.com (Postfix) with ESMTPSA id D889017E091C; Wed, 17 Jun 2026 16:55:48 +0200 (CEST) Date: Wed, 17 Jun 2026 16:55:46 +0200 From: Boris Brezillon To: =?UTF-8?B?QWRyacOhbg==?= Larumbe Cc: Rob Herring , Steven Price , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Faith Ekstrand , "Marty E. Plummer" , Tomeu Vizoso , Eric Anholt , Alyssa Rosenzweig , Robin Murphy , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Collabora Kernel Team , Neil Armstrong Subject: Re: [PATCH v2 6/7] drm/panfrost: Fix PM usage_count mishandling Message-ID: <20260617165546.4777de33@fedora-2.home> In-Reply-To: References: <20260604-claude-fixes-v2-0-57c6bd4c1655@collabora.com> <20260604-claude-fixes-v2-6-57c6bd4c1655@collabora.com> <20260604203631.20e76f5f@fedora-2.home> Organization: Collabora X-Mailer: Claws Mail 4.4.0 (GTK 3.24.52; x86_64-redhat-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, 16 Jun 2026 21:17:53 +0100 Adri=C3=A1n Larumbe wrote: > On 04.06.2026 20:36, Boris Brezillon wrote: > > On Thu, 04 Jun 2026 18:35:25 +0100 > > Adri=C3=A1n Larumbe wrote: > > =20 > > > During device probe(), failure to do a PM get() will leave the usage_= count > > > set to 0, which is the value assigned at device creation time. That m= eans > > > when the autosuspend delay expires, runtime suspend callback won't be > > > invoked, so the device will remain powered on forever. > > >=20 > > > On top of that, failure to call PM put() during device unplug means > > > Panfrost device's PM usage_count increases monotonically for every new > > > module reload. > > >=20 > > > The combined outcome of both of the above was that devfreq OPP transi= tion > > > notifications would be printed all the time, even when no jobs are be= ing > > > submitted. This quickly fills the kernel ring buffer with junk. > > >=20 > > > Even direr than that was the fact MMU interrupts are only enabled when > > > the device is reset, so after device probe() the very first job targe= ting > > > the tiler heap BO would always time out, because the driver's PM runt= ime > > > resume callback would not be invoked. > > >=20 > > > Signed-off-by: Adri=C3=A1n Larumbe > > > Fixes: 635430797d3f ("drm/panfrost: Rework runtime PM initialization") > > > Fixes: 876b15d2c88d ("drm/panfrost: Fix module unload") > > > --- > > > drivers/gpu/drm/panfrost/panfrost_drv.c | 6 +++++- > > > 1 file changed, 5 insertions(+), 1 deletion(-) > > >=20 > > > diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/dr= m/panfrost/panfrost_drv.c > > > index 2d4b6aa95c66..545fbf2c8d0c 100644 > > > --- a/drivers/gpu/drm/panfrost/panfrost_drv.c > > > +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c > > > @@ -989,6 +989,7 @@ static int panfrost_probe(struct platform_device = *pdev) > > > pm_runtime_set_active(pfdev->base.dev); > > > pm_runtime_mark_last_busy(pfdev->base.dev); > > > pm_runtime_enable(pfdev->base.dev); > > > + pm_runtime_get_noresume(pfdev->base.dev); > > > pm_runtime_set_autosuspend_delay(pfdev->base.dev, 50); /* ~3 frames= */ > > > pm_runtime_use_autosuspend(pfdev->base.dev); > > > =20 > > > @@ -1000,10 +1001,12 @@ static int panfrost_probe(struct platform_dev= ice *pdev) > > > if (err < 0) > > > goto err_out1; > > > =20 > > > + pm_runtime_put_autosuspend(pfdev->base.dev); > > > =20 > > > return 0; > > > =20 > > > err_out1: > > > + pm_runtime_put_noidle(pfdev->base.dev); =20 > >=20 > > Do we really need this get_noresume/put_noidle dance, can't use call > > pm_runtime_dont_use_autosuspend() instead like is done in panthor, or > > is panthor broken too? =20 >=20 > We need get_noresume() because after panfrost_device_init(), the device i= s powered > up but that is not reflected in the device's PM refcnt. Then pm_runtime_p= ut_autosuspend() > will decrement the refcnt back to 0 and let the autosuspend window expire= before > suspending the device, unless someone starts using it immediately. That's more or less what I'm questioning. Can't we make it so panfrost_clk_init() doesn't call clk_prepare_enable() on its clks, and then have a pm_runtime_resume_and_get() in panfrost_device_init() just before we start interacting with the HW components (so basically before panfrost_gpu_init()). Then you don't need this get_noresume/put_noidle() dance, because the init path is just considered like any other path that needs to interact with the HW. >=20 > pm_runtime_dont_use_autosuspend() is not mandatory if we manually call pm= _runtime_disable() > at device unplug time or when probe() fails. pm_runtime_use_autosuspend()= 's docs say: >=20 > pm_runtime_use_autosuspend - Allow autosuspend to be used for a device. > @dev: Target device. > Allow the runtime PM autosuspend mechanism to be used for @dev whenever > requested (or "autosuspend" will be handled as direct runtime-suspend for > it). > NOTE: It's important to undo this with pm_runtime_dont_use_autosuspend() > at driver exit time unless your driver initially enabled pm_runtime > with devm_pm_runtime_enable() (which handles it for you). >=20 > Panthor uses devm_pm_runtime_enable(), which makes me suspect perhaps it = doesn't need > to explicitly call pm_runtime_dont_use_autosuspend(). Yep, devm_pm_runtime_enable() takes care of that, indeed. >=20 > Panthor also manages PM refcnt fine at driver probe(), inside panthor_dev= ice_init(): >=20 > ``` c > ret =3D pm_runtime_resume_and_get(ptdev->base.dev); > if (ret) > return ret; >=20 > /* If PM is disabled, we need to call panthor_device_resume() manually. */ > if (!IS_ENABLED(CONFIG_PM)) { > ret =3D panthor_device_resume(ptdev->base.dev); > if (ret) > return ret; > } > ``` >=20 > If we want a similar thing in Panfrost, then we should move all clock and= devfreq enablement > into panfrost_device_runtime_resume() and do pm_runtime_resume_and_get() = right before > panfrost_gpu_init(). This ^. You probably want to keep clk_prepare() in the clk_init() path, since resume/suspend() only enable/disable the clks.