From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 99AF9CCF9E3 for ; Fri, 24 Oct 2025 13:42:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 121CB10EA90; Fri, 24 Oct 2025 13:42:11 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by gabe.freedesktop.org (Postfix) with ESMTP id 05C8610EA90 for ; Fri, 24 Oct 2025 13:42:10 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DE02F175A for ; Fri, 24 Oct 2025 06:42:01 -0700 (PDT) Received: from e110455-lin.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7E8873F63F for ; Fri, 24 Oct 2025 06:42:09 -0700 (PDT) Date: Fri, 24 Oct 2025 14:41:57 +0100 From: Liviu Dudau To: Ketil Johnsen Cc: Boris Brezillon , Steven Price , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Heiko Stuebner , Grant Likely , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm/panthor: Fix race with suspend during unplug Message-ID: References: <20251022103242.1083311-1-ketil.johnsen@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20251022103242.1083311-1-ketil.johnsen@arm.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Wed, Oct 22, 2025 at 12:32:41PM +0200, Ketil Johnsen wrote: > There is a race between panthor_device_unplug() and > panthor_device_suspend() which can lead to IRQ handlers running on a > powered down GPU. This is how it can happen: > - unplug routine calls drm_dev_unplug() > - panthor_device_suspend() can now execute, and will skip a lot of > important work because the device is currently marked as unplugged. > - IRQs will remain active in this case and IRQ handlers can therefore > try to access a powered down GPU. > > The fix is simply to take the PM ref in panthor_device_unplug() a > little bit earlier, before drm_dev_unplug(). > > Signed-off-by: Ketil Johnsen > Fixes: 5fe909cae118a ("drm/panthor: Add the device logical block") Reviewed-by: Liviu Dudau Best regards, Liviu > --- > drivers/gpu/drm/panthor/panthor_device.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/panthor/panthor_device.c b/drivers/gpu/drm/panthor/panthor_device.c > index 81df49880bd87..962a10e00848e 100644 > --- a/drivers/gpu/drm/panthor/panthor_device.c > +++ b/drivers/gpu/drm/panthor/panthor_device.c > @@ -83,6 +83,8 @@ void panthor_device_unplug(struct panthor_device *ptdev) > return; > } > > + drm_WARN_ON(&ptdev->base, pm_runtime_get_sync(ptdev->base.dev) < 0); > + > /* Call drm_dev_unplug() so any access to HW blocks happening after > * that point get rejected. > */ > @@ -93,8 +95,6 @@ void panthor_device_unplug(struct panthor_device *ptdev) > */ > mutex_unlock(&ptdev->unplug.lock); > > - drm_WARN_ON(&ptdev->base, pm_runtime_get_sync(ptdev->base.dev) < 0); > - > /* Now, try to cleanly shutdown the GPU before the device resources > * get reclaimed. > */ > -- > 2.47.2 > -- ==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯