[PATCH v9 0/3] drm/xe: make CTX_TIMESTAMP TOCTOU-safe and handle sentinels

Gajendra Uttamchand <[email protected]> Fri, 31 Jul 2026 04:00:05 +0000
Newsgroups org.freedesktop.lists.intel-xe
Message-ID <[email protected]>
Fix timestamp handling for Xe LRC contexts to avoid races and false
timeout detection. This patch documents and centralises the
CONTEXT_ACTIVE sentinel and makes MMIO reads of CTX_TIMESTAMP TOCTOU-
safe by verifying the LRC-stored timestamp before and after the MMIO
read.

Fixes: d243ef6a39c6 ("drm/xe/lrc: Refactor xe_lrc_timestamp to simplify logic")

v2:
Dropped the redundant second patch (Matt Brost)

v3:
Added the Fixes tag for the original commit (Umesh Nerlige)

v4:
Added Reviewed-by for the original commit (Umesh Nerlige)
Added Acked-by for the original commit (Matt Brost)

v5:
Fix incorrect 'From:' username in commit header (Kamil)"

v6:
Fix AI review comments from sashiko.dev
 - Fix torn read of CTX_TIMESTAMP from LRC
 - Fix ABA race on engine migration in context timestamp read

v7:
Fix review comments (Vivi Rodrigo)
 - Added Assisted-by coding assistant used
 - Removed extra comments
Added ldw check additionally to avoid torn read (sashiko.dev)

v8:
Fix git am merge issue with v7 patch series

v9:
Fix AI review comments from sashiko.dev

Gajendra Uttamchand (3):
  drm/xe/lrc: document sentinel and make CTX_TIMESTAMP read TOCTOU-safe
  drm/xe/lrc: Fix torn read of CTX_TIMESTAMP from LRC
  drm/xe/lrc: Fix ABA race on engine migration in context timestamp read

 drivers/gpu/drm/xe/xe_lrc.c | 69 ++++++++++++++++++++++++++++---------
 drivers/gpu/drm/xe/xe_lrc.h |  7 ++++
 2 files changed, 60 insertions(+), 16 deletions(-)

--
2.43.0