[PATCH v2 0/4] drm/msm/adreno: keep the GPU timestamp monotonic across power collapse
From: Dmitry Baryshkov
Date: Sat Oct 31 2026 - 12:12:22 EST
Before a750 the always-on counter behind MSM_PARAM_TIMESTAMP, which the
GPU also writes for its own timestamps, restarts whenever the GPU powers
up. This is the case on the GMU-less a5xx and a6xx parts, and also on
the GMU parts before a750. GL_TIMESTAMP, Vulkan calibrated timestamps
and clGetDeviceAndHostTimer() go backwards after every runtime suspend.
The counter can't be written back, so keep an offset that makes it
continuous, advancing it by the CLOCK_MONOTONIC time the counter was
stopped. Publish the offset in a new page that every context's command
streams can read, so that userspace can add it to the timestamps the
GPU writes, and report the counter with the offset already added as the
new MSM_PARAM_TIMESTAMP_MONOTONIC. The page isn't mapped to the CPU, so
it needs no sequence count. MSM_PARAM_TIMESTAMP stays raw. Where the
counter doesn't restart the offset stays zero, so userspace takes the
same path everywhere.
Tested on a512, a530, a540, a610, a630, a643, a650, a660, a702 and
a730: the corrected counter stays monotonic and tracks CLOCK_MONOTONIC
across runtime suspend, and the GPU can read the page but not write it.
With the Mesa changes GL and Vulkan timestamps stay monotonic, and the
OpenCL CTS device_timer test, which failed before, passes.
For the corresponding Mesa changes see [1].
[1] https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/45806
---
Changes in v2:
- Left MSM_PARAM_TIMESTAMP raw and let userspace add the offset, so
that it keeps matching the timestamps the GPU writes (Connor, Rob).
- Added a GPU-readable page for kernel state, MSM_PARAM_VDSO_IOVA (Rob).
- Added MSM_PARAM_TIMESTAMP_MONOTONIC for the CPU side.
- Covered the a6xx GMU parts before a750, whose counter restarts too.
- Dropped a4xx, whose get_timestamp counts GPU cycles, not 19.2 MHz ticks.
- Split the change into four patches.
- Link to v1: https://patch.msgid.link/20260828-b4-adreno-timestamp-v1-1-273525da144c@xxxxxxxxxxxxxxxx
---
Dmitry Baryshkov (4):
drm/msm: share a page of kernel state with the GPU
drm/msm/adreno: add a timestamp offset for counters that restart
drm/msm/a5xx: keep the timestamp offset
drm/msm/a6xx: keep the timestamp offset before a750
drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 13 ++++++-
drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 21 ++++++++++-
drivers/gpu/drm/msm/adreno/adreno_gpu.c | 66 +++++++++++++++++++++++++++++++++
drivers/gpu/drm/msm/adreno/adreno_gpu.h | 10 +++++
drivers/gpu/drm/msm/msm_gpu.c | 15 ++++++++
drivers/gpu/drm/msm/msm_gpu.h | 5 +++
include/uapi/drm/msm_drm.h | 25 +++++++++++++
7 files changed, 153 insertions(+), 2 deletions(-)
---
base-commit: d024361c631b3f020a26c07d683e5103404b0fbf
change-id: 20260828-b4-adreno-timestamp-f4c846391b97
Best regards,
--
With best wishes
Dmitry