]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe/svm: Document how xe keeps drm_pagemap references
authorThomas Hellström <thomas.hellstrom@linux.intel.com>
Fri, 19 Dec 2025 11:33:14 +0000 (12:33 +0100)
committerThomas Hellström <thomas.hellstrom@linux.intel.com>
Tue, 23 Dec 2025 09:00:48 +0000 (10:00 +0100)
As an aid to understanding the lifetime of the drm_pagemaps used
by the xe driver, document how the xe driver keeps the
drm_pagemap references.

v3:
- Fix formatting (Matt Brost)

Suggested-by: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Link: https://patch.msgid.link/20251219113320.183860-19-thomas.hellstrom@linux.intel.com
drivers/gpu/drm/xe/xe_svm.c

index 43af813276b8059b4e108a4fc0b4cf349a3b71f4..68f30338abeeeec15c2e3677aa66089c281c69ae 100644 (file)
 #define XE_PEER_PAGEMAP ((void *)0ul)
 #define XE_PEER_VM ((void *)1ul)
 
+/**
+ * DOC: drm_pagemap reference-counting in xe:
+ *
+ * In addition to the drm_pagemap internal reference counting by its zone
+ * device data, the xe driver holds the following long-time references:
+ *
+ * - struct xe_pagemap:
+ *     The xe_pagemap struct derives from struct drm_pagemap and uses its
+ *     reference count.
+ * - SVM-enabled VMs:
+ *     SVM-enabled VMs look up and keeps a reference to all xe_pagemaps on
+ *     the same device.
+ * - VMAs:
+ *     vmas keep a reference on the drm_pagemap indicated by a gpu_madvise()
+ *     call.
+ *
+ * In addition, all drm_pagemap or xe_pagemap pointers where lifetime cannot
+ * be guaranteed by a vma reference under the vm lock should keep a reference.
+ * That includes the range->pages.dpagemap pointer.
+ */
+
 static int xe_svm_get_pagemaps(struct xe_vm *vm);
 
 void *xe_svm_private_page_owner(struct xe_vm *vm, bool force_smem)