mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: ryan.zhang@oss.nxp.com
To: boris.brezillon@collabora.com, steven.price@arm.com, liviu.dudau@arm.com
Cc: maarten.lankhorst@linux.intel.com, mripard@kernel.org,
	tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	Ryan Zhang <ryan.zhang@oss.nxp.com>
Subject: [PATCH v2] drm/panthor: dummy read to discard the stale first GPU_TIMESTAMP read
Date: Wed, 23 Sep 2026 18:24:48 +0800	[thread overview]
Message-ID: <20260923102448.2279852-1-ryan.zhang@oss.nxp.com> (raw)
In-Reply-To: <20260921102957.1024029-1-ryan.zhang@oss.nxp.com>

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>
---
v2:
 - Added the r-b in commit msg.
 - Rebased on drm-misc-next to resolve conflict.
 - Moved the dummy read into panthor_gpu_get_timestamp() to align with
   the refactored timestamp query code on drm-misc-next.
Note: The original v1 patch was based on v6.18 and applied cleanly there.
Could we also port v1 into 6.18?

 drivers/gpu/drm/panthor/panthor_gpu.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/panthor/panthor_gpu.c b/drivers/gpu/drm/panthor/panthor_gpu.c
index a383b04f101e..b8df5663f04e 100644
--- a/drivers/gpu/drm/panthor/panthor_gpu.c
+++ b/drivers/gpu/drm/panthor/panthor_gpu.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 */
 
 #include <linux/bitfield.h>
 #include <linux/bitmap.h>
@@ -470,6 +471,9 @@ void panthor_gpu_resume(struct panthor_device *ptdev)
 
 u64 panthor_gpu_get_timestamp(struct panthor_device *ptdev)
 {
+	/* Dummy read to avoid stale values. */
+	gpu_read64_counter(ptdev->gpu->iomem, GPU_TIMESTAMP);
+
 	return gpu_read64_counter(ptdev->gpu->iomem, GPU_TIMESTAMP);
 }
 
-- 
2.43.0


      parent reply	other threads:[~2026-09-23 10:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-21 10:29 [PATCH] " ryan.zhang
2026-09-21 16:36 ` Liviu Dudau
2026-09-23 10:24 ` ryan.zhang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260923102448.2279852-1-ryan.zhang@oss.nxp.com \
    --to=ryan.zhang@oss.nxp.com \
    --cc=airlied@gmail.com \
    --cc=boris.brezillon@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liviu.dudau@arm.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=steven.price@arm.com \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®