Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/xe/lrc: Fix uninitialized new_ts when capturing context timestamp
@ 2026-03-12 12:53 Umesh Nerlige Ramappa
  2026-03-12 13:00 ` ✓ CI.KUnit: success for drm/xe/lrc: Fix uninitialized new_ts when capturing context timestamp (rev2) Patchwork
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Umesh Nerlige Ramappa @ 2026-03-12 12:53 UTC (permalink / raw)
  To: intel-xe

Getting engine specific CTX TIMESTAMP register can fail. In that case,
if the context is active, new_ts is uninitialized. Fix that case by
initializing new_ts to the last value that was sampled in SW -
lrc->ctx_timestamp.

Flagged by static analysis.

v2: Fix new_ts initialization (Ashutosh)

Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
---
 drivers/gpu/drm/xe/xe_lrc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_lrc.c b/drivers/gpu/drm/xe/xe_lrc.c
index aa26c71ae34f..04304dff45b0 100644
--- a/drivers/gpu/drm/xe/xe_lrc.c
+++ b/drivers/gpu/drm/xe/xe_lrc.c
@@ -2563,14 +2563,14 @@ static int get_ctx_timestamp(struct xe_lrc *lrc, u32 engine_id, u64 *reg_ctx_ts)
  * @lrc: Pointer to the lrc.
  *
  * Return latest ctx timestamp. With support for active contexts, the
- * calculation may bb slightly racy, so follow a read-again logic to ensure that
+ * calculation may be slightly racy, so follow a read-again logic to ensure that
  * the context is still active before returning the right timestamp.
  *
  * Returns: New ctx timestamp value
  */
 u64 xe_lrc_timestamp(struct xe_lrc *lrc)
 {
-	u64 lrc_ts, reg_ts, new_ts;
+	u64 lrc_ts, reg_ts, new_ts = lrc->ctx_timestamp;
 	u32 engine_id;
 
 	lrc_ts = xe_lrc_ctx_timestamp(lrc);
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [PATCH] drm/xe/lrc: Fix uninitialized new_ts when capturing context timestamp
@ 2026-03-11 10:49 Umesh Nerlige Ramappa
  2026-03-11 23:43 ` Dixit, Ashutosh
  0 siblings, 1 reply; 8+ messages in thread
From: Umesh Nerlige Ramappa @ 2026-03-11 10:49 UTC (permalink / raw)
  To: intel-xe

Getting engine specific CTX TIMESTAMP register can fail. In that case,
if the context is active, new_ts is uninitialized. Fix that case by
initializing new_ts to lrc_ts.

Flagged by static analysis.

Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
---
 drivers/gpu/drm/xe/xe_lrc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_lrc.c b/drivers/gpu/drm/xe/xe_lrc.c
index aa26c71ae34f..9d766ef414ed 100644
--- a/drivers/gpu/drm/xe/xe_lrc.c
+++ b/drivers/gpu/drm/xe/xe_lrc.c
@@ -2563,7 +2563,7 @@ static int get_ctx_timestamp(struct xe_lrc *lrc, u32 engine_id, u64 *reg_ctx_ts)
  * @lrc: Pointer to the lrc.
  *
  * Return latest ctx timestamp. With support for active contexts, the
- * calculation may bb slightly racy, so follow a read-again logic to ensure that
+ * calculation may be slightly racy, so follow a read-again logic to ensure that
  * the context is still active before returning the right timestamp.
  *
  * Returns: New ctx timestamp value
@@ -2584,6 +2584,8 @@ u64 xe_lrc_timestamp(struct xe_lrc *lrc)
 		engine_id = xe_lrc_engine_id(lrc);
 		if (!get_ctx_timestamp(lrc, engine_id, &reg_ts))
 			new_ts = reg_ts;
+		else
+			new_ts = lrc_ts;
 
 		/* read lrc again to ensure context is still active */
 		lrc_ts = xe_lrc_ctx_timestamp(lrc);
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-03-13 12:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-12 12:53 [PATCH] drm/xe/lrc: Fix uninitialized new_ts when capturing context timestamp Umesh Nerlige Ramappa
2026-03-12 13:00 ` ✓ CI.KUnit: success for drm/xe/lrc: Fix uninitialized new_ts when capturing context timestamp (rev2) Patchwork
2026-03-12 14:01 ` ✓ Xe.CI.BAT: " Patchwork
2026-03-12 22:04 ` [PATCH] drm/xe/lrc: Fix uninitialized new_ts when capturing context timestamp Dixit, Ashutosh
2026-03-13 12:11 ` ✓ Xe.CI.FULL: success for drm/xe/lrc: Fix uninitialized new_ts when capturing context timestamp (rev2) Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2026-03-11 10:49 [PATCH] drm/xe/lrc: Fix uninitialized new_ts when capturing context timestamp Umesh Nerlige Ramappa
2026-03-11 23:43 ` Dixit, Ashutosh
2026-03-12 12:35   ` Umesh Nerlige Ramappa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox