* [PATCH 0/2] Two small perfcnt fixes for Panfrost
@ 2026-10-15 18:22 Adrián Larumbe
2026-10-15 18:22 ` [PATCH 1/2] drm/panfrost: Enable cycle counting when perfcnt is enabled Adrián Larumbe
2026-10-15 18:22 ` [PATCH 2/2] drm/panfrost: Fix race when restoring reset state in perfcnt Adrián Larumbe
0 siblings, 2 replies; 7+ messages in thread
From: Adrián Larumbe @ 2026-10-15 18:22 UTC (permalink / raw)
To: Boris Brezillon, Rob Herring, Steven Price, Adrián Larumbe,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter
Cc: dri-devel, linux-kernel
To: Boris Brezillon <boris.brezillon@collabora.com>
To: Rob Herring <robh@kernel.org>
To: Steven Price <steven.price@arm.com>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: Maxime Ripard <mripard@kernel.org>
To: Thomas Zimmermann <tzimmermann@suse.de>
To: David Airlie <airlied@gmail.com>
To: Simona Vetter <simona@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>
First fix makes sure cycle counter is enabled when starting a new
session. This is required by some profiling frameworks like
Perfetto. Second fix deals with a recently-introduced race condition.
---
Adrián Larumbe (1):
drm/panfrost: Fix race when restoring reset state in perfcnt
Boris Brezillon (1):
drm/panfrost: Enable cycle counting when perfcnt is enabled
drivers/gpu/drm/panfrost/panfrost_perfcnt.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
---
base-commit: 9944dd07f3cf7b6c19d65c2585147887ca06677c
change-id: 20261014-panfrost-reset-races-fixes-6f5f2459dc9b
Best regards,
--
Adrián Larumbe <adrian.larumbe@collabora.com>
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 1/2] drm/panfrost: Enable cycle counting when perfcnt is enabled 2026-10-15 18:22 [PATCH 0/2] Two small perfcnt fixes for Panfrost Adrián Larumbe @ 2026-10-15 18:22 ` Adrián Larumbe 2026-10-15 18:36 ` sashiko-bot ` (2 more replies) 2026-10-15 18:22 ` [PATCH 2/2] drm/panfrost: Fix race when restoring reset state in perfcnt Adrián Larumbe 1 sibling, 3 replies; 7+ messages in thread From: Adrián Larumbe @ 2026-10-15 18:22 UTC (permalink / raw) To: Boris Brezillon, Rob Herring, Steven Price, Adrián Larumbe, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter Cc: dri-devel, linux-kernel From: Boris Brezillon <boris.brezillon@collabora.com> If we don't do that, we end up with invalid timestamps in the block headers. Fixes: 7786fd108777 ("drm/panfrost: Expose performance counters through unstable ioctls") Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> --- drivers/gpu/drm/panfrost/panfrost_perfcnt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c index a9def452d5ef..b26da057a1a0 100644 --- a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c +++ b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c @@ -17,6 +17,7 @@ #include "panfrost_device.h" #include "panfrost_features.h" #include "panfrost_gem.h" +#include "panfrost_gpu.h" #include "panfrost_issues.h" #include "panfrost_job.h" #include "panfrost_mmu.h" @@ -52,6 +53,7 @@ static void panfrost_perfcnt_hw_disable(struct panfrost_device *pfdev) gpu_write(pfdev, GPU_PRFCNT_TILER_EN, 0); if (perfcnt->owns_as_ref) { + panfrost_cycle_counter_put(pfdev); panfrost_mmu_as_put(pfdev, perfcnt->mapping->mmu); perfcnt->owns_as_ref = false; } @@ -84,6 +86,7 @@ static int panfrost_perfcnt_hw_enable(struct panfrost_device *pfdev) return ret; perfcnt->owns_as_ref = true; + panfrost_cycle_counter_get(pfdev); as = ret; cfg = GPU_PERFCNT_CFG_AS(as) | -- 2.55.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] drm/panfrost: Enable cycle counting when perfcnt is enabled 2026-10-15 18:22 ` [PATCH 1/2] drm/panfrost: Enable cycle counting when perfcnt is enabled Adrián Larumbe @ 2026-10-15 18:36 ` sashiko-bot 2026-10-16 7:23 ` Boris Brezillon 2026-10-16 7:24 ` Boris Brezillon 2 siblings, 0 replies; 7+ messages in thread From: sashiko-bot @ 2026-10-15 18:36 UTC (permalink / raw) To: Adrián Larumbe; +Cc: dri-devel Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] drm/panfrost: Spurious drm_WARN_ON during GPU reset with active perfcnt -- commit d9ae50cec3ff06c2a614193efb813114ed5ac709 Author: Boris Brezillon <boris.brezillon@collabora.com> Date: Thu Oct 15 18:22:31 2026 +0000 drm/panfrost: Enable cycle counting when perfcnt is enabled If we don't do that, we end up with invalid timestamps in the block headers. > diff --git a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c > index a9def452d5ef9..b26da057a1a01 100644 > --- a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c > +++ b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c [ ... ] > @@ -84,6 +86,7 @@ static int panfrost_perfcnt_hw_enable(struct panfrost_device *pfdev) > return ret; > > perfcnt->owns_as_ref = true; > + panfrost_cycle_counter_get(pfdev); [Severity: Medium] Will this cause a spurious drm_WARN_ON() during a GPU reset? When a GPU reset is triggered (e.g. by a job timeout), panfrost_device_reset() is called. This function calls panfrost_gpu_soft_reset() before it handles the perfcnt state via panfrost_perfcnt_reset(): drivers/gpu/drm/panfrost/panfrost_device.c:panfrost_device_reset() { ... panfrost_gpu_soft_reset(pfdev); ... panfrost_perfcnt_reset(pfdev); } Inside panfrost_gpu_soft_reset(), it expects all cycle counter references to be released: drivers/gpu/drm/panfrost/panfrost_gpu.c:panfrost_gpu_soft_reset() { ... /* * All in-flight jobs should have released their cycle * counter references upon reset, but let us make sure */ if (drm_WARN_ON(&pfdev->base, atomic_read(&pfdev->cycle_counter.use_count) != 0)) atomic_set(&pfdev->cycle_counter.use_count, 0); ... } Because the perfcnt still holds the reference when panfrost_gpu_soft_reset() is called, won't this trigger the drm_WARN_ON() and potentially panic the kernel if panic_on_warn is enabled? > > as = ret; > cfg = GPU_PERFCNT_CFG_AS(as) | -- Sashiko AI review · https://sashiko.dev/#/patchset/20261015-panfrost-reset-races-fixes-v1-0-bb74c1786a0b@collabora.com?part=1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] drm/panfrost: Enable cycle counting when perfcnt is enabled 2026-10-15 18:22 ` [PATCH 1/2] drm/panfrost: Enable cycle counting when perfcnt is enabled Adrián Larumbe 2026-10-15 18:36 ` sashiko-bot @ 2026-10-16 7:23 ` Boris Brezillon 2026-10-16 7:24 ` Boris Brezillon 2 siblings, 0 replies; 7+ messages in thread From: Boris Brezillon @ 2026-10-16 7:23 UTC (permalink / raw) To: Adrián Larumbe Cc: Rob Herring, Steven Price, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, dri-devel, linux-kernel On Thu, 15 Oct 2026 19:22:31 +0100 Adrián Larumbe <adrian.larumbe@collabora.com> wrote: > From: Boris Brezillon <boris.brezillon@collabora.com> > > If we don't do that, we end up with invalid timestamps in the block > headers. > > Fixes: 7786fd108777 ("drm/panfrost: Expose performance counters through unstable ioctls") > Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Let's make sure this is merged in the same release the perfcnt uAPI changes are in, so userspace can check the driver version to know if the fix is present or not (we have a workaround in mesa for that which we can drop when the fix is in). > --- > drivers/gpu/drm/panfrost/panfrost_perfcnt.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c > index a9def452d5ef..b26da057a1a0 100644 > --- a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c > +++ b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c > @@ -17,6 +17,7 @@ > #include "panfrost_device.h" > #include "panfrost_features.h" > #include "panfrost_gem.h" > +#include "panfrost_gpu.h" > #include "panfrost_issues.h" > #include "panfrost_job.h" > #include "panfrost_mmu.h" > @@ -52,6 +53,7 @@ static void panfrost_perfcnt_hw_disable(struct panfrost_device *pfdev) > gpu_write(pfdev, GPU_PRFCNT_TILER_EN, 0); > > if (perfcnt->owns_as_ref) { > + panfrost_cycle_counter_put(pfdev); > panfrost_mmu_as_put(pfdev, perfcnt->mapping->mmu); > perfcnt->owns_as_ref = false; > } > @@ -84,6 +86,7 @@ static int panfrost_perfcnt_hw_enable(struct panfrost_device *pfdev) > return ret; > > perfcnt->owns_as_ref = true; > + panfrost_cycle_counter_get(pfdev); > > as = ret; > cfg = GPU_PERFCNT_CFG_AS(as) | > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] drm/panfrost: Enable cycle counting when perfcnt is enabled 2026-10-15 18:22 ` [PATCH 1/2] drm/panfrost: Enable cycle counting when perfcnt is enabled Adrián Larumbe 2026-10-15 18:36 ` sashiko-bot 2026-10-16 7:23 ` Boris Brezillon @ 2026-10-16 7:24 ` Boris Brezillon 2 siblings, 0 replies; 7+ messages in thread From: Boris Brezillon @ 2026-10-16 7:24 UTC (permalink / raw) To: Adrián Larumbe Cc: Rob Herring, Steven Price, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, dri-devel, linux-kernel On Thu, 15 Oct 2026 19:22:31 +0100 Adrián Larumbe <adrian.larumbe@collabora.com> wrote: > From: Boris Brezillon <boris.brezillon@collabora.com> > > If we don't do that, we end up with invalid timestamps in the block > headers. > > Fixes: 7786fd108777 ("drm/panfrost: Expose performance counters through unstable ioctls") > Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Also, you need to add your SoB here. > --- > drivers/gpu/drm/panfrost/panfrost_perfcnt.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c > index a9def452d5ef..b26da057a1a0 100644 > --- a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c > +++ b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c > @@ -17,6 +17,7 @@ > #include "panfrost_device.h" > #include "panfrost_features.h" > #include "panfrost_gem.h" > +#include "panfrost_gpu.h" > #include "panfrost_issues.h" > #include "panfrost_job.h" > #include "panfrost_mmu.h" > @@ -52,6 +53,7 @@ static void panfrost_perfcnt_hw_disable(struct panfrost_device *pfdev) > gpu_write(pfdev, GPU_PRFCNT_TILER_EN, 0); > > if (perfcnt->owns_as_ref) { > + panfrost_cycle_counter_put(pfdev); > panfrost_mmu_as_put(pfdev, perfcnt->mapping->mmu); > perfcnt->owns_as_ref = false; > } > @@ -84,6 +86,7 @@ static int panfrost_perfcnt_hw_enable(struct panfrost_device *pfdev) > return ret; > > perfcnt->owns_as_ref = true; > + panfrost_cycle_counter_get(pfdev); > > as = ret; > cfg = GPU_PERFCNT_CFG_AS(as) | > ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2] drm/panfrost: Fix race when restoring reset state in perfcnt 2026-10-15 18:22 [PATCH 0/2] Two small perfcnt fixes for Panfrost Adrián Larumbe 2026-10-15 18:22 ` [PATCH 1/2] drm/panfrost: Enable cycle counting when perfcnt is enabled Adrián Larumbe @ 2026-10-15 18:22 ` Adrián Larumbe 2026-10-16 7:24 ` Boris Brezillon 1 sibling, 1 reply; 7+ messages in thread From: Adrián Larumbe @ 2026-10-15 18:22 UTC (permalink / raw) To: Boris Brezillon, Rob Herring, Steven Price, Adrián Larumbe, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter Cc: dri-devel, linux-kernel struct panfrost_perfcnt::state should always be updated atomically, both in the dump ioctl and the reset sequence. Fixes: 9944dd07f3cf ("drm/panfrost: Fix races between perfcnt and reset sequence") Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com> --- drivers/gpu/drm/panfrost/panfrost_perfcnt.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c index b26da057a1a0..d50b6cc2ecfa 100644 --- a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c +++ b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c @@ -148,18 +148,17 @@ static int panfrost_perfcnt_dump_locked(struct panfrost_device *pfdev, u32 *stat */ ret = wait_for_completion_interruptible_timeout(&pfdev->perfcnt->dump_comp, msecs_to_jiffies(1000)); - if (!ret) ret = -ETIMEDOUT; - /* We need to restore perfcnt state so the next successful dump can relay it to UM */ - if (ret < 0) { - perfcnt->state |= *state; - *state = 0; - return ret; - } - scoped_guard(rwsem_read, &pfdev->reset.lock) { + /* Restore perfcnt state so the next successful dump can relay it to UM */ + if (ret < 0) { + perfcnt->state |= *state; + *state = 0; + return ret; + } + *state |= perfcnt->state; /* UM must re-enable their session before requesting new dumps. */ -- 2.55.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] drm/panfrost: Fix race when restoring reset state in perfcnt 2026-10-15 18:22 ` [PATCH 2/2] drm/panfrost: Fix race when restoring reset state in perfcnt Adrián Larumbe @ 2026-10-16 7:24 ` Boris Brezillon 0 siblings, 0 replies; 7+ messages in thread From: Boris Brezillon @ 2026-10-16 7:24 UTC (permalink / raw) To: Adrián Larumbe Cc: Rob Herring, Steven Price, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter, dri-devel, linux-kernel On Thu, 15 Oct 2026 19:22:32 +0100 Adrián Larumbe <adrian.larumbe@collabora.com> wrote: > struct panfrost_perfcnt::state should always be updated atomically, both > in the dump ioctl and the reset sequence. > > Fixes: 9944dd07f3cf ("drm/panfrost: Fix races between perfcnt and reset sequence") > Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> > --- > drivers/gpu/drm/panfrost/panfrost_perfcnt.c | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) > > diff --git a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c > index b26da057a1a0..d50b6cc2ecfa 100644 > --- a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c > +++ b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c > @@ -148,18 +148,17 @@ static int panfrost_perfcnt_dump_locked(struct panfrost_device *pfdev, u32 *stat > */ > ret = wait_for_completion_interruptible_timeout(&pfdev->perfcnt->dump_comp, > msecs_to_jiffies(1000)); > - > if (!ret) > ret = -ETIMEDOUT; > > - /* We need to restore perfcnt state so the next successful dump can relay it to UM */ > - if (ret < 0) { > - perfcnt->state |= *state; > - *state = 0; > - return ret; > - } > - > scoped_guard(rwsem_read, &pfdev->reset.lock) { > + /* Restore perfcnt state so the next successful dump can relay it to UM */ > + if (ret < 0) { > + perfcnt->state |= *state; > + *state = 0; > + return ret; > + } > + > *state |= perfcnt->state; > > /* UM must re-enable their session before requesting new dumps. */ > ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-10-16 7:25 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-10-15 18:22 [PATCH 0/2] Two small perfcnt fixes for Panfrost Adrián Larumbe 2026-10-15 18:22 ` [PATCH 1/2] drm/panfrost: Enable cycle counting when perfcnt is enabled Adrián Larumbe 2026-10-15 18:36 ` sashiko-bot 2026-10-16 7:23 ` Boris Brezillon 2026-10-16 7:24 ` Boris Brezillon 2026-10-15 18:22 ` [PATCH 2/2] drm/panfrost: Fix race when restoring reset state in perfcnt Adrián Larumbe 2026-10-16 7:24 ` Boris Brezillon
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.