From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796385055; b=Z7SnK+3UZOe5L+77SsutMzgFTxuHgzcYdGBiEaJS7gPsGv0w0Gkx8Wr/onkvr1C1CwCl W32ZgHABsgaRIzUq9jj0OMshD/4fL21Peku6n4H8E4muF9PI3r9dF1NOUr9aFc5b7WA2n 3J9/5us2WBhVr1MOiK1zO1DH6pWzNgGsLyfEikdkRyoJyr1Ey2eFZuMPA/0PN7Vf3V71p jHLGlft9s32HAQEnXeLvJYJzpeRAPYAtDmVi5f9JGX0ql0KbUT/a90iU1PTcXL/2hTQOR ofu+HQaTREj2iM6eJCaLU17Eh/3AMGny3h796CkLfBejB8NMLz/EnumAbwnjb8rbbYg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385055; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=8LKZyz22HhTvZqIVRmu+8gW1shrD4WhqQRMzhbDFEWs=; b=b1odmdLS9uZvXJkSt8Jgj8eg9L8mQUwdZwvt5Kh+pPULFcmrl9piDd9XQjYykaTPzHD9 bBuxZ0GZSz24ic0ifiTxmXUMbza5mIS8vLpXd7AGatIdF/+oSBdVprlpPjVgpB4MwW0uR ABSBZ3G6hsx+d1V7VaiPR0O2ml6HVB/l9ldtF8OkGey5OTpbI+xIpl10x4nVmwIIHgO+z 3mGqWhwFBzAGrVQYkn5sqFHnKpqHtycESVA5GcRzZXGoLrTRwrDl8jfPVPaEcMwHGVouZ 8X6dbU4oNRLQMkZlbXHGYM0sYSkBpVjU8BRsxA334rL/aeqmx8NkV03dhqFe2qs1zOQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=OtZdh6xq; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 19217606A322; Fri, 4 Dec 2026 11:50:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=OtZdh6xq Received: by smtp.kernel.org (Postfix) with ESMTPSA id 828341F000CE; Fri, 4 Dec 2026 11:50:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385055; bh=8LKZyz22HhTvZqIVRmu+8gW1shrD4WhqQRMzhbDFEWs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OtZdh6xq/poDhPuuvOjsuVUmEXhGL9xZgvnT7GJF7ck0yRpOJ/S6cuzwTlrXG8gjI /tAhPWsOp2IRk2rlHo9HfDwPGEPk1HNCTbY67ZGKojg9MuYygveQQpFZPrQjimiIBL kZ5Sgz695gJrRIwQQwHJ2INwN/ii99vpwmTxXN0k= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Boris Brezillon , Steven Price , =?UTF-8?q?Adri=C3=A1n=20Larumbe?= , Sasha Levin Subject: [PATCH 6.6 0399/1167] drm/panfrost: Fix PM refcnt and autosuspend issues at device probe/remove Date: Fri, 4 Dec 2026 18:57:06 +0900 Message-ID: <20261204100712.416999759@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Adrián Larumbe [ Upstream commit e9672bf9382ff80be21d586f88e50339b85f5766 ] 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 means when the autosuspend delay expires, runtime suspend callback won't be invoked, so the device will remain powered on forever. 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. The outcome of both of the above meant that: - Devfreq OPP transition notifications would be printed all the time, even when no jobs are being submitted. This quickly fills the kernel ring buffer with junk. - Because MMU interrupts are only enabled when the device is reset, the very first job targeting the tiler heap BO after device probe() would always time out, since the driver's PM runtime resume callback would not be invoked. To fix the above: - Manually adjust the PM refcnt at device probe and removal time. - Ensure pm_runtime_dont_use_autosuspend is called in the wind-down path. - Call pm_runtime_put_autosuspend() when device is ready to accept jobs Fixes: 635430797d3f ("drm/panfrost: Rework runtime PM initialization") Fixes: 876b15d2c88d ("drm/panfrost: Fix module unload") Reviewed-by: Boris Brezillon Reviewed-by: Steven Price Link: https://patch.msgid.link/20261012-claude-fixes-v15-6-bc0a6c498553@collabora.com Signed-off-by: Adrián Larumbe [ sashal: Replaced pfdev->base.dev with pfdev->dev and placed the new PM calls around this tree's existing shrinker init and drm_dev_put() code, since the upstream context differs. ] Signed-off-by: Sasha Levin --- drivers/gpu/drm/panfrost/panfrost_drv.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c index 0c30310da50e2..57f1d5f82a942 100644 --- a/drivers/gpu/drm/panfrost/panfrost_drv.c +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c @@ -589,6 +589,11 @@ static int panfrost_probe(struct platform_device *pdev) goto err_out0; } + /* The reason we must manually set the PM status and usage counter is + * we have just powered the device up but did not go through the PM + * runtime resume callback, so we need to update these ourselves. + */ + pm_runtime_get_noresume(pfdev->dev); pm_runtime_set_active(pfdev->dev); pm_runtime_mark_last_busy(pfdev->dev); pm_runtime_enable(pfdev->dev); @@ -605,12 +610,16 @@ static int panfrost_probe(struct platform_device *pdev) panfrost_gem_shrinker_init(ddev); + pm_runtime_put_autosuspend(pfdev->dev); + return 0; err_out1: + pm_runtime_dont_use_autosuspend(pfdev->dev); pm_runtime_disable(pfdev->dev); panfrost_device_fini(pfdev); pm_runtime_set_suspended(pfdev->dev); + pm_runtime_put_noidle(pfdev->dev); err_out0: drm_dev_put(ddev); return err; @@ -625,9 +634,11 @@ static void panfrost_remove(struct platform_device *pdev) panfrost_gem_shrinker_cleanup(ddev); pm_runtime_get_sync(pfdev->dev); + pm_runtime_dont_use_autosuspend(pfdev->dev); pm_runtime_disable(pfdev->dev); panfrost_device_fini(pfdev); pm_runtime_set_suspended(pfdev->dev); + pm_runtime_put_noidle(pfdev->dev); drm_dev_put(ddev); } -- 2.53.0