]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/xe/lrc: Fix uninitialized new_ts when capturing context timestamp
authorUmesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Thu, 12 Mar 2026 12:53:09 +0000 (05:53 -0700)
committerThomas Hellström <thomas.hellstrom@linux.intel.com>
Thu, 19 Mar 2026 13:23:04 +0000 (14:23 +0100)
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)

Fixes: bb63e7257e63 ("drm/xe: Avoid toggling schedule state to check LRC timestamp in TDR")
Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Link: https://patch.msgid.link/20260312125308.3126607-2-umesh.nerlige.ramappa@intel.com
(cherry picked from commit 466e75d48038af252187855058a7a9312db9d2f8)
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
drivers/gpu/drm/xe/xe_lrc.c

index b0f037bc227ff3bc109e0e243b53f350387313c9..7b70cc01fdb38795abb4f81d75583304d526388a 100644 (file)
@@ -2413,14 +2413,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);