* [PATCH] drm/panthor: dummy read to discard the stale first GPU_TIMESTAMP read
@ 2026-09-21 10:29 ryan.zhang
2026-09-21 16:36 ` Liviu Dudau
0 siblings, 1 reply; 2+ messages in thread
From: ryan.zhang @ 2026-09-21 10:29 UTC (permalink / raw)
To: boris.brezillon, steven.price, liviu.dudau
Cc: maarten.lankhorst, mripard, tzimmermann, airlied, simona,
dri-devel, linux-kernel, Ryan Zhang
From: Ryan Zhang <ryan.zhang@oss.nxp.com>
The first read of GPU_TIMESTAMP after the GPU has been idle can return a
value that lags the real counter, while a read issued immediately after is
accurate.
Userspace correlates this timestamp with the host clock, so a stale value
shows up as skew between the device and host time domains and makes
dEQP-VK.pipeline.monolithic.timestamp.calibrated.calibration_test fail
whenever a query happens to hit a large first-read error.
Signed-off-by: Ryan Zhang <ryan.zhang@oss.nxp.com>
---
drivers/gpu/drm/panthor/panthor_drv.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
index 720bf889096d..956a147dc282 100644
--- a/drivers/gpu/drm/panthor/panthor_drv.c
+++ b/drivers/gpu/drm/panthor/panthor_drv.c
@@ -2,6 +2,7 @@
/* Copyright 2018 Marty E. Plummer <hanetzer@startmail.com> */
/* Copyright 2019 Linaro, Ltd., Rob Herring <robh@kernel.org> */
/* Copyright 2019 Collabora ltd. */
+/* Copyright 2026 NXP */
#ifdef CONFIG_ARM_ARCH_TIMER
#include <asm/arch_timer.h>
@@ -772,6 +773,10 @@ static int panthor_query_timestamp_info(struct panthor_device *ptdev,
#else
arg->timestamp_frequency = 0;
#endif
+
+ /* Dummy read to avoid stale values. */
+ gpu_read64_counter(ptdev, GPU_TIMESTAMP);
+
arg->current_timestamp = gpu_read64_counter(ptdev, GPU_TIMESTAMP);
arg->timestamp_offset = gpu_read64(ptdev, GPU_TIMESTAMP_OFFSET);
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/panthor: dummy read to discard the stale first GPU_TIMESTAMP read
2026-09-21 10:29 [PATCH] drm/panthor: dummy read to discard the stale first GPU_TIMESTAMP read ryan.zhang
@ 2026-09-21 16:36 ` Liviu Dudau
0 siblings, 0 replies; 2+ messages in thread
From: Liviu Dudau @ 2026-09-21 16:36 UTC (permalink / raw)
To: ryan.zhang
Cc: boris.brezillon, steven.price, maarten.lankhorst, mripard,
tzimmermann, airlied, simona, dri-devel, linux-kernel
On Mon, Sep 21, 2026 at 06:29:57PM +0800, ryan.zhang@oss.nxp.com wrote:
> From: Ryan Zhang <ryan.zhang@oss.nxp.com>
>
> The first read of GPU_TIMESTAMP after the GPU has been idle can return a
> value that lags the real counter, while a read issued immediately after is
> accurate.
>
> Userspace correlates this timestamp with the host clock, so a stale value
> shows up as skew between the device and host time domains and makes
> dEQP-VK.pipeline.monolithic.timestamp.calibrated.calibration_test fail
> whenever a query happens to hit a large first-read error.
>
> Signed-off-by: Ryan Zhang <ryan.zhang@oss.nxp.com>
Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
Best regards,
Liviu
> ---
> drivers/gpu/drm/panthor/panthor_drv.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
> index 720bf889096d..956a147dc282 100644
> --- a/drivers/gpu/drm/panthor/panthor_drv.c
> +++ b/drivers/gpu/drm/panthor/panthor_drv.c
> @@ -2,6 +2,7 @@
> /* Copyright 2018 Marty E. Plummer <hanetzer@startmail.com> */
> /* Copyright 2019 Linaro, Ltd., Rob Herring <robh@kernel.org> */
> /* Copyright 2019 Collabora ltd. */
> +/* Copyright 2026 NXP */
>
> #ifdef CONFIG_ARM_ARCH_TIMER
> #include <asm/arch_timer.h>
> @@ -772,6 +773,10 @@ static int panthor_query_timestamp_info(struct panthor_device *ptdev,
> #else
> arg->timestamp_frequency = 0;
> #endif
> +
> + /* Dummy read to avoid stale values. */
> + gpu_read64_counter(ptdev, GPU_TIMESTAMP);
> +
> arg->current_timestamp = gpu_read64_counter(ptdev, GPU_TIMESTAMP);
> arg->timestamp_offset = gpu_read64(ptdev, GPU_TIMESTAMP_OFFSET);
>
> --
> 2.43.0
>
--
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-21 16:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-21 10:29 [PATCH] drm/panthor: dummy read to discard the stale first GPU_TIMESTAMP read ryan.zhang
2026-09-21 16:36 ` Liviu Dudau
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®