* [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; 6+ 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] 6+ 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-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
1 sibling, 2 replies; 6+ 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 [flat|nested] 6+ 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; 6+ 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 [flat|nested] 6+ 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-16 7:23 ` Boris Brezillon
2026-10-16 7:24 ` Boris Brezillon
1 sibling, 0 replies; 6+ 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] 6+ 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-16 7:23 ` Boris Brezillon
@ 2026-10-16 7:24 ` Boris Brezillon
1 sibling, 0 replies; 6+ 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] 6+ 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; 6+ 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] 6+ messages in thread
end of thread, other threads:[~2026-10-16 7:25 UTC | newest]
Thread overview: 6+ 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-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®