[PATCH 0/7] drm/etnaviv: Report GPU clock changes to userspace

From: Christian Gmeiner

Date: Fri Nov 20 2026 - 05:40:39 EST


Userspace that converts GPU cycle counts to time, like Mesa, needs the
core clock rate a job ran at. The thermal cooling device can change
this rate at any time, and userspace has no way to learn about it.

This series adds a CLOCK_HISTORY ioctl that returns the last clock
rate changes of a GPU with their timestamps. Userspace compares them
with the fence timestamp of a job and knows the rate the job ran at.
A trace event reports the same changes.

For this a job must run at a single rate. Today the cooling device
changes the clock while a job is running, which can also hang the GPU.
On a GC7000 rev 6009 I toggled the cooling state every 200 ms during
glmark2 runs and got 25 hang recoveries in 24 runs. With this series I
got none in 34 runs. So the first patches fix the cooling device:

- Patch 1 fixes the GPU state after a failed init and after unbind.
Patch 4 uses this state to decide if the clock can be changed.
- Patches 2-4 change the order of the cooling device registration,
skip requests that keep the clock and close a race with runtime
suspend.
- Patch 5 makes a clock change wait for the queued jobs.
- Patch 6 adds the trace event.
- Patch 7 keeps the last 256 changes in a ring buffer and adds the
ioctl to read them.

Tested on GC7000 rev 6214 (i.MX8MQ), and with backports to 6.6 on
GC7000 rev 6009 (i.MX8QM) and to 6.12 on GC2000 rev 5108 (i.MX6Q,
FSCALE path).

Link to the Mesa MR implementing the userspace side:
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/46538

Signed-off-by: Christian Gmeiner <cgmeiner@xxxxxxxxxx>
---
Christian Gmeiner (7):
drm/etnaviv: Don't set up a GPU on resume that is not initialized
drm/etnaviv: Register the cooling device last and unregister it first
drm/etnaviv: Skip cooling requests that keep the clock
drm/etnaviv: Don't change the clock of a suspended GPU
drm/etnaviv: Change the GPU clock between jobs
drm/etnaviv: Add a GPU clock change trace event
drm/etnaviv: Add an ioctl to read back GPU clock changes

drivers/gpu/drm/etnaviv/Makefile | 5 +-
drivers/gpu/drm/etnaviv/etnaviv_drv.c | 20 ++-
drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 240 ++++++++++++++++++++++---
drivers/gpu/drm/etnaviv/etnaviv_gpu.h | 12 ++
drivers/gpu/drm/etnaviv/etnaviv_trace.h | 62 +++++++
drivers/gpu/drm/etnaviv/etnaviv_trace_points.c | 9 +
include/uapi/drm/etnaviv_drm.h | 62 ++++++-
7 files changed, 378 insertions(+), 32 deletions(-)
---
base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
change-id: 20261116-etnaviv-gpu-freq-trace-52e421b3f72d

Best regards,
--
Christian Gmeiner <cgmeiner@xxxxxxxxxx>