From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sender6-op-o11.zoho.com (sender6-op-o11.zoho.com [165.173.180.11]) (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 6F48945C70F for ; Wed, 23 Sep 2026 20:23:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=165.173.180.11 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790195017; cv=pass; b=A5xt3v3j++xh7pRDs7g4X1f8IVWoQOF4QP4/3gVwwP27BIZC2R9hdlZ7/AwwppXBGZFyr8iwRfGmpn86pFzBjXrU8myq0oadJODmocXY4vEVLj2tboExDXaeh1JYbTG0aYyA6jB4mm2dofPo3FT3vxdX7m0RdgLCy798pi3SS7c= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790195017; c=relaxed/simple; bh=6o6rafjvmkjvA0xw6ARscJMbF1kGXdIRN73/+HyeBzQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iqVIPK24jNyFl5FEVA7bE7ziLtDT2ZvfPYhUwoRTH8l7kRpqx1EAdJmmcFmvkL293kTMd12ZQyB43AH3KZbo1E8nBdC8rpGm2KCAyS6cseMIzlJ4bsQULXP8yepENemqz8j+422yRRMaGTe0xnVpGMXyIJczNQbHHZ+29VBxtoM= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=adrian.larumbe@collabora.com header.b=NSuW96iw; arc=pass smtp.client-ip=165.173.180.11 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 (1024-bit key) header.d=collabora.com header.i=adrian.larumbe@collabora.com header.b="NSuW96iw" ARC-Seal: i=1; a=rsa-sha256; t=1790194958; cv=none; d=zohomail.com; s=zohoarc; b=lLqx2yAUq6o+M8/7F+UMx8DvBUKS2Ma9FpNQBhh87qJE+JQSU3SdiYX5AMYXTqQiZWWx+7UhAUgzPA30uNx0q5rnUicPYdvqZkLiE5g0JR7WFUUUd/QhlH+xajoa1dEvwBfZxDHxg9LUUDur6VYtrl6dpBlAA9Va+Bh1RGWGTk4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790194958; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=g+YIuk+4WIpshSahF8eOV7IWdfFGOw6fxHq1Lq9U6Ao=; b=JfK7hLfSZz3pfankwaTwEop71ESoAiFtVaCdVsShUkJkOI3TQGcTPby3l+haIcyDcAYoT0nYweZQ0zotUjA+x6Nc+nr7McWYKROsWVZ0g3iaIav5LOVdiYOZf81aMHIXOk03KRw8/K4jtgNslGiuGVochgdkl0QNpS0lTEBqWaI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=adrian.larumbe@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1790194958; s=zohomail; d=collabora.com; i=adrian.larumbe@collabora.com; h=Date:Date:From:From:To:To:Cc:Cc:Subject:Subject:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:In-Reply-To:Message-Id:Reply-To; bh=g+YIuk+4WIpshSahF8eOV7IWdfFGOw6fxHq1Lq9U6Ao=; b=NSuW96iwCPwTSl4mcg+Hji4Z35UcW4wIQBUE9BPLfjxRSG64yoQ8y/yT/68As0fD ITGj1Y6P21HeucZ3XblOF0EYLnk/lof/+uIK7jbxJRJAGc2TtG7qfXkafx26pdpSCfH uh/eRg4HP972fL/NkLyhYdk1jhW9EOmn26kBD6k0= Received: by smtp.zohomail.com with SMTPS id 1790194957839653.7404759552567; Wed, 23 Sep 2026 13:22:37 -0700 (PDT) Date: Wed, 23 Sep 2026 21:22:32 +0100 From: =?utf-8?Q?Adri=C3=A1n?= Larumbe To: Boris Brezillon 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 , Philipp Zabel , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Collabora Kernel Team , Neil Armstrong Subject: Re: [PATCH v9 10/16] drm/panfrost: Add debugfs knob for manually triggering a GPU reset Message-ID: References: <20260912-claude-fixes-v9-0-e588feaa61ef@collabora.com> <20260912-claude-fixes-v9-10-e588feaa61ef@collabora.com> <20260914113946.69936104@fedora-21.home> <20260923091010.58b8e677@fedora-21.home> 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: <20260923091010.58b8e677@fedora-21.home> X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/290.183.46 > On 23.09.2026 09:10, Boris Brezillon wrote: > On Tue, 22 Sep 2026 20:54:11 +0100 > Adrián Larumbe wrote: > > > On 14.09.2026 11:39, Boris Brezillon wrote: > > > On Sat, 12 Sep 2026 00:28:11 +0100 > > > Adrián Larumbe wrote: > > > > > > > This will be of great help when testing potential races between the GPU > > > > reset sequence and other parts of the code accessing HW registers. > > > > > > > > Signed-off-by: Adrián Larumbe > > > > > > Reviewed-by: Boris Brezillon > > > > > > One comment below. > > > > > > > --- > > > > drivers/gpu/drm/panfrost/panfrost_device.c | 37 ++++++++++++++++++++++++++++++ > > > > 1 file changed, 37 insertions(+) > > > > > > > > diff --git a/drivers/gpu/drm/panfrost/panfrost_device.c b/drivers/gpu/drm/panfrost/panfrost_device.c > > > > index d75566a45392..0aee1d87a7ab 100644 > > > > --- a/drivers/gpu/drm/panfrost/panfrost_device.c > > > > +++ b/drivers/gpu/drm/panfrost/panfrost_device.c > > > > @@ -2,6 +2,7 @@ > > > > /* Copyright 2018 Marty E. Plummer */ > > > > /* Copyright 2019 Linaro, Ltd, Rob Herring */ > > > > > > > > +#include > > > > #include > > > > #include > > > > #include > > > > @@ -583,9 +584,45 @@ EXPORT_GPL_DEV_PM_OPS(panfrost_pm_ops) = { > > > > }; > > > > > > > > #ifdef CONFIG_DEBUG_FS > > > > +static int reset_get(void *data, u64 *val) > > > > +{ > > > > + struct panfrost_device *pfdev = > > > > + container_of(data, struct panfrost_device, base); > > > > + > > > > + *val = atomic_read(&pfdev->reset.pending); > > > > + return 0; > > > > +} > > > > + > > > > +static int reset_set(void *data, u64 val) > > > > +{ > > > > + struct panfrost_device *pfdev = > > > > + container_of(data, struct panfrost_device, base); > > > > + int ret = pm_runtime_get_if_active(pfdev->base.dev); > > > > + > > > > + if (ret) { > > > > + panfrost_device_schedule_reset(pfdev); > > > > > > It feels weird to schedule a reset if the device is suspended, because > > > a suspend/resume cycle already acts as a reset. Any particular reason > > > you'd want to do that? If not, I'd suggest going for: > > > > That's been my goal all along, for the knob to trigger a reset only when > > the device isn't suspended. pm_runtime_get_if_active() docs states that: > > > > """ > > Increment the runtime PM usage counter of @dev if its runtime PM status is > > %RPM_ACTIVE, in which case it returns 1. If the device is in a different > > state, 0 is returned. -EINVAL is returned if runtime PM is disabled for the > > device, in which case also the usage_count will remain unmodified. > > """ > > > > So (ret != 0) means the device either doesn't support RPM or else it > > was in the ACTIVE state. In both cases, that means the device is powered > > so we can proceed with the reset. However, I only decrement the usage > > counter when kernel RPM is enabled (ret > 1). > > Okay, I see. Can we have a comment explaining that? Also, I think I > prefer an early bail out over the extra indentation level added here. > > if (!ret) > return 0; Will do. > Oh, and we should probably make this knob inactive in the device removal > path (with a disable_work()?), otherwise -EINVAL will be returned as > soon as pm_runtime_disable() is called, and this might cause a reset to > be scheduled, which we probably don't want, since it would interfere > with our device_fini() logic. I think replacing cancel_work_sync() with disable_work_sync() in panfrost_jm_fini() should be enough to this end. In that case, both queue_work() and flush_work() will do nothing and no PM reference will be taken, so the whole thing effective becomes a NOP. > > > > > if (ret <= 0) > > > return ret; > > > > > > panfrost_device_schedule_reset(pfdev); > > > pm_runtime_put(pfdev->base.dev); > > > return 0; > > > > > > > + flush_work(&pfdev->reset.work); > > > > + if (ret > 0) > > > > + pm_runtime_put(pfdev->base.dev); > > > > + } > > > > + > > > > + return 0; > > > > +} > > > > + > > > > +DEFINE_DEBUGFS_ATTRIBUTE(panfrost_reset_debugfs_fops, > > > > + reset_get, reset_set, > > > > + "0x%08llx\n"); > > > > + > > > > +static void panfrost_reset_debugfs_init(struct drm_minor *minor) > > > > +{ > > > > + debugfs_create_file("reset", 0600, minor->debugfs_root, > > > > + minor->dev, &panfrost_reset_debugfs_fops); > > > > +} > > > > + > > > > void panfrost_device_debugfs_init(struct drm_minor *minor) > > > > { > > > > panfrost_gem_debugfs_init(minor); > > > > panfrost_sched_debugfs_init(minor); > > > > + panfrost_reset_debugfs_init(minor); > > > > } > > > > #endif // CONFIG_DEBUG_FS > > > > > > > > Adrian Larumbe Adrian Larumbe