| From ecfdf430e7d9547d71ec3773437b0d652c7df76e Mon Sep 17 00:00:00 2001 | |
| From: Sasha Levin <sashal@kernel.org> | |
| Date: Wed, 4 Nov 2026 19:51:53 +0000 | |
| Subject: drm/panfrost: Enable cycle counting when perfcnt is enabled | |
| MIME-Version: 1.0 | |
| Content-Type: text/plain; charset=UTF-8 | |
| Content-Transfer-Encoding: 8bit | |
| From: Boris Brezillon <boris.brezillon@collabora.com> | |
| [ Upstream commit 99a2e2b1690f48b074bf14a3b7d5d52f45d26ecc ] | |
| If we don't do that, we end up with invalid timestamps in the block | |
| headers. | |
| We also need to skip the warning on the cycle counter reference being | |
| other than 0 during device reset, because of perfcnt's lingering ref. | |
| Ideally this would be dealt with by splitting the reset sequence into | |
| pre and post stages, so that a hypothetical panfrost_perfcnt_pre_reset() | |
| would release the cycle counter reference. In the absence thereof, we | |
| just make do. | |
| Fixes: 7786fd108777 ("drm/panfrost: Expose performance counters through unstable ioctls") | |
| Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> | |
| Reviewed-by: Steven Price <steven.price@arm.com> | |
| Link: https://patch.msgid.link/20261104-panfrost-reset-races-fixes-v3-1-09868a88c351@collabora.com | |
| Signed-off-by: Adriรกn Larumbe <adrian.larumbe@collabora.com> | |
| Signed-off-by: Sasha Levin <sashal@kernel.org> | |
| --- | |
| drivers/gpu/drm/panfrost/panfrost_gpu.c | 7 +++---- | |
| drivers/gpu/drm/panfrost/panfrost_perfcnt.c | 3 +++ | |
| 2 files changed, 6 insertions(+), 4 deletions(-) | |
| diff --git a/drivers/gpu/drm/panfrost/panfrost_gpu.c b/drivers/gpu/drm/panfrost/panfrost_gpu.c | |
| index 8a15ccce08e9b..5ef6897fc05ed 100644 | |
| --- a/drivers/gpu/drm/panfrost/panfrost_gpu.c | |
| +++ b/drivers/gpu/drm/panfrost/panfrost_gpu.c | |
| @@ -94,11 +94,10 @@ int panfrost_gpu_soft_reset(struct panfrost_device *pfdev) | |
| GPU_IRQ_CLEAN_CACHES_COMPLETED); | |
| /* | |
| - * All in-flight jobs should have released their cycle | |
| - * counter references upon reset, but let us make sure | |
| + * Even though all in-flight jobs should have released their cycle counter | |
| + * references upon reset, perfcnt's might still hang about. | |
| */ | |
| - if (drm_WARN_ON(&pfdev->base, atomic_read(&pfdev->cycle_counter.use_count) != 0)) | |
| - atomic_set(&pfdev->cycle_counter.use_count, 0); | |
| + atomic_set(&pfdev->cycle_counter.use_count, 0); | |
| return 0; | |
| } | |
| diff --git a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c | |
| index 03a6dcd8da2f5..46b5141932ee8 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; | |
| } | |
| @@ -81,6 +83,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.53.0 | |