Skip to contentSkip to conversation

drm/v3d: Enable Performance Counters before clearing them

PATCH In review Maíra Canal 2 participants 3 messages Dec 4, 2024 – Dec 5, 2024

Subsystems (3)
lore
Share & tools
lore

Maíra Canal

author maintainer
#0 lore raw

PATCH 1/1 drm/v3d: Enable Performance Counters before clearing them

On the Raspberry Pi 5, performance counters are not being cleared when v3d_perfmon_start() is called, even though we write to the CLR register. As a result, their values accumulate until they overflow.

The expected behavior is for performance counters to reset to zero at the start of a job. When the job finishes and the perfmon is stopped, the counters should accurately reflect the values for that specific job.

To ensure this behavior, the performance counters are now enabled before being cleared. This allows the CLR register to function as intended, zeroing the counter values when the job begins.

Fixes 26a4dc29b74a ("drm/v3d: Expose performance counters to userspace")
---
 drivers/gpu/drm/v3d/v3d_perfmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/v3d/v3d_perfmon.c +1 -1
index b4c3708ea781..c49abb90954d 100644
@@ -255,9 +255,9 @@ void v3d_perfmon_start(struct v3d_dev *v3d, struct v3d_perfmon *perfmon)
 		V3D_CORE_WRITE(0, V3D_V4_PCTR_0_SRC_X(source), channel);
 	}
 
+	V3D_CORE_WRITE(0, V3D_V4_PCTR_0_EN, mask);
 	V3D_CORE_WRITE(0, V3D_V4_PCTR_0_CLR, mask);
 	V3D_CORE_WRITE(0, V3D_PCTR_0_OVERFLOW, mask);
-	V3D_CORE_WRITE(0, V3D_V4_PCTR_0_EN, mask);
 
 	v3d->active_perfmon = perfmon;
 }
Signature · 1 line
2.39.5 (Apple Git-154)
Reviewed-by on v1 1/1
#1 lore raw
Quoted 39 lines · Maíra Canal

On the Raspberry Pi 5, performance counters are not being cleared when v3d_perfmon_start() is called, even though we write to the CLR register. As a result, their values accumulate until they overflow.

The expected behavior is for performance counters to reset to zero at the start of a job. When the job finishes and the perfmon is stopped, the counters should accurately reflect the values for that specific job.

To ensure this behavior, the performance counters are now enabled before being cleared. This allows the CLR register to function as intended, zeroing the counter values when the job begins.

Fixes 26a4dc29b74a ("drm/v3d: Expose performance counters to

userspace")

---
 drivers/gpu/drm/v3d/v3d_perfmon.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/v3d/v3d_perfmon.c +0 -0
index b4c3708ea781..c49abb90954d 100644
@@ -255,9 +255,9 @@ void v3d_perfmon_start(struct v3d_dev *v3d,
 struct v3d_perfmon *perfmon)
  		V3D_CORE_WRITE(0, V3D_V4_PCTR_0_SRC_X(source),
 channel);
  	}

drivers/gpu/drm/v3d/v3d_perfmon.c +1 -0
+	V3D_CORE_WRITE(0, V3D_V4_PCTR_0_EN, mask);

  V3D_CORE_WRITE(0, V3D_V4_PCTR_0_CLR, mask); V3D_CORE_WRITE(0, V3D_PCTR_0_OVERFLOW, mask);

drivers/gpu/drm/v3d/v3d_perfmon.c +0 -1
-	V3D_CORE_WRITE(0, V3D_V4_PCTR_0_EN, mask);


  v3d->active_perfmon = perfmon;
 }

author maintainer
#2 lore raw

Hi Iago,

Quoted 1 line · Iago Toral

Thanks for reviewing! Applied to misc/kernel.git (drm-misc-fixes).

Best Regards,
- Maíra

Quoted 42 lines · Maíra Canal
Quoted 39 lines

On the Raspberry Pi 5, performance counters are not being cleared when v3d_perfmon_start() is called, even though we write to the CLR register. As a result, their values accumulate until they overflow.

The expected behavior is for performance counters to reset to zero at the start of a job. When the job finishes and the perfmon is stopped, the counters should accurately reflect the values for that specific job.

To ensure this behavior, the performance counters are now enabled before being cleared. This allows the CLR register to function as intended, zeroing the counter values when the job begins.

Fixes 26a4dc29b74a ("drm/v3d: Expose performance counters to

userspace")

---
  drivers/gpu/drm/v3d/v3d_perfmon.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/v3d/v3d_perfmon.c +1 -1
index b4c3708ea781..c49abb90954d 100644
@@ -255,9 +255,9 @@ void v3d_perfmon_start(struct v3d_dev *v3d,
 struct v3d_perfmon *perfmon)
  		V3D_CORE_WRITE(0, V3D_V4_PCTR_0_SRC_X(source),
 channel);
  	}
 
+	V3D_CORE_WRITE(0, V3D_V4_PCTR_0_EN, mask);
  	V3D_CORE_WRITE(0, V3D_V4_PCTR_0_CLR, mask);
  	V3D_CORE_WRITE(0, V3D_PCTR_0_OVERFLOW, mask);
-	V3D_CORE_WRITE(0, V3D_V4_PCTR_0_EN, mask);
 

  v3d->active_perfmon = perfmon;
 }