[RFC 00/15] drm/xe: Access counter consumer layer

Himal Prasad Ghimiray
2026-03-18T07:10:14Z

This series implements the Xe access counter consumer layer for discrete
Intel GPUs. Access counters track GPU memory access patterns and emit
notifications when a threshold is exceeded; the KMD uses these as hints
to migrate BOs and SVM ranges to tile-local VRAM.

The series starts by factoring the identical circular buffer code shared
between page faults and access counters into a generic struct
xe_usm_queue, then wires both consumers to it. The access counter consumer reuses
pf_wq rather than allocating a new workqueue.

Two helpers are extracted from the page fault path for reuse:
xe_vma_lock_and_validate() and xe_device_asid_to_fault_vm(). The worker
handles both BO-backed VMAs (migrate + rebind) and SVM VMAs (via
xe_svm_range_setup()).

A new exec queue extension (DRM_XE_EXEC_QUEUE_EXTENSION_SET_ACC_PARAM)
lets userspace configure per-queue trigger/notify thresholds and
granularity, which are programmed into CTX_ACC_CTR_THOLD and CTX_ASID
during LRC init (Bspec: 59264, 59265).

Finally, xe_vma_supports_access_ctr() identifies VMAs ineligible for
access counting, and xe_pt_stage_bind() sets the NC PTE bit on them to
avoid wasting finite hardware counter slots (Bspec: 67095).

Suggested-by: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>

Himal Prasad Ghimiray (15):
drm/xe: Add xe_usm_queue generic USM circular buffer
drm/xe/pagefault: Use xe_usm_queue helpers
drm/xe: Stub out new access_counter layer
drm/xe: Implement xe_access_counter_init
drm/xe: Implement xe_access_counter_handler
drm/xe: Extract xe_vma_lock_and_validate helper
drm/xe: Move ASID to FAULT VM lookup to xe_device
drm/xe: Implement xe_access_counter_queue_work
drm/xe/trace: Add xe_vma_acc trace event for access counter
notifications
drm/xe/svm: Handle svm ranges on access ctr trigger
drm/xe: Add xe_guc_access_counter layer
drm/xe/uapi: Add access counter parameter extension for exec queue
drm/xe/lrc: Pass exec_queue to xe_lrc_create for access counter params
drm/xe/vm: Add xe_vma_supports_access_ctr() helper
drm/xe/pt: Set NC PTE bit for VMAs ineligible for access counting

drivers/gpu/drm/xe/Makefile | 4 +-
drivers/gpu/drm/xe/regs/xe_gtt_defs.h | 2 +-
drivers/gpu/drm/xe/regs/xe_lrc_layout.h | 10 +
drivers/gpu/drm/xe/xe_access_counter.c | 255 +++++++++++++++++++
drivers/gpu/drm/xe/xe_access_counter.h | 17 ++
drivers/gpu/drm/xe/xe_access_counter_types.h | 123 +++++++++
drivers/gpu/drm/xe/xe_device.c | 30 +++
drivers/gpu/drm/xe/xe_device.h | 1 +
drivers/gpu/drm/xe/xe_device_types.h | 6 +-
drivers/gpu/drm/xe/xe_exec_queue.c | 29 ++-
drivers/gpu/drm/xe/xe_exec_queue_types.h | 9 +
drivers/gpu/drm/xe/xe_execlist.c | 2 +-
drivers/gpu/drm/xe/xe_guc_access_counter.c | 62 +++++
drivers/gpu/drm/xe/xe_guc_access_counter.h | 15 ++
drivers/gpu/drm/xe/xe_guc_ct.c | 4 +
drivers/gpu/drm/xe/xe_lrc.c | 35 ++-
drivers/gpu/drm/xe/xe_lrc.h | 5 +-
drivers/gpu/drm/xe/xe_pagefault.c | 79 +-----
drivers/gpu/drm/xe/xe_pagefault_types.h | 27 +-
drivers/gpu/drm/xe/xe_pt.c | 11 +
drivers/gpu/drm/xe/xe_svm.c | 59 +++--
drivers/gpu/drm/xe/xe_svm.h | 4 +
drivers/gpu/drm/xe/xe_trace_bo.h | 32 ++-
drivers/gpu/drm/xe/xe_usm_queue.h | 100 ++++++++
drivers/gpu/drm/xe/xe_vm.c | 72 ++++++
drivers/gpu/drm/xe/xe_vm.h | 6 +
include/uapi/drm/xe_drm.h | 39 +++
27 files changed, 910 insertions(+), 128 deletions(-)
create mode 100644 drivers/gpu/drm/xe/xe_access_counter.c
create mode 100644 drivers/gpu/drm/xe/xe_access_counter.h
create mode 100644 drivers/gpu/drm/xe/xe_access_counter_types.h
create mode 100644 drivers/gpu/drm/xe/xe_guc_access_counter.c
create mode 100644 drivers/gpu/drm/xe/xe_guc_access_counter.h
create mode 100644 drivers/gpu/drm/xe/xe_usm_queue.h

--
2.34.1