From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7EE992E1C4E for ; Fri, 24 Oct 2025 13:42:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761313333; cv=none; b=o3UjWsxrJTwQwNteJmxXU2k7ssT12wY3NzubZyLSuzV4foxoJhZDvZlHD24PKwiHq58NJEQ+D6FZkWsTjIaeDW9YYM2TBH/CrgAoC2n/OFB7ZBRfzzFMrhiRhzyBCi5pvBZSoJtrRC8WTVYESDWazI21ps4TfBpnIWx9FcgCMOo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761313333; c=relaxed/simple; bh=sNw3TPY7h5Lf1Pmc2SxTChnVEwbwRps3QfP6fqLhcP4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ETnMQ634GcaKiy8Sb391h1B3Lh7Wl1u26eMoCj35l2/pMV4OB+EFM+Yjw44DXXhTvQaJT7VVoojH0xyW2LYDrkK3epSeZJOibAk6CYVEaWavEl31u4USoLI7Id29rpKSp0bc35SLzoksCcNlzf+RLmvwCTHQJwzRjzM4Bb9C4Zg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 127D2175A for ; Fri, 24 Oct 2025 06:42:03 -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 A47143F63F for ; Fri, 24 Oct 2025 06:42:10 -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> 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-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20251022103242.1083311-1-ketil.johnsen@arm.com> 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! / --------------- ¯\_(ツ)_/¯