]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/xe: Rename lookup_vma function to xe_find_vma_by_addr
authorHimal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Tue, 13 May 2025 04:02:21 +0000 (09:32 +0530)
committerHimal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Wed, 14 May 2025 13:55:54 +0000 (19:25 +0530)
This update renames the lookup_vma function to xe_vm_find_vma_by_addr and
makes it accessible externally. The function, which looks up a VMA by
its address within a specified VM, will be utilized in upcoming patches.

v2
 - Fix doc

Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Acked-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Link: https://lore.kernel.org/r/20250513040228.470682-9-himal.prasad.ghimiray@intel.com
Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
drivers/gpu/drm/xe/xe_gt_pagefault.c
drivers/gpu/drm/xe/xe_vm.c
drivers/gpu/drm/xe/xe_vm.h

index 10622ca471a283d655b9877d02c39e8a79fbd6b3..7a8f87709e39c361056e37ae55d18d51dd3f5317 100644 (file)
@@ -72,28 +72,6 @@ static bool vma_is_valid(struct xe_tile *tile, struct xe_vma *vma)
                !(BIT(tile->id) & vma->tile_invalidated);
 }
 
-static bool vma_matches(struct xe_vma *vma, u64 page_addr)
-{
-       if (page_addr > xe_vma_end(vma) - 1 ||
-           page_addr + SZ_4K - 1 < xe_vma_start(vma))
-               return false;
-
-       return true;
-}
-
-static struct xe_vma *lookup_vma(struct xe_vm *vm, u64 page_addr)
-{
-       struct xe_vma *vma = NULL;
-
-       if (vm->usm.last_fault_vma) {   /* Fast lookup */
-               if (vma_matches(vm->usm.last_fault_vma, page_addr))
-                       vma = vm->usm.last_fault_vma;
-       }
-       if (!vma)
-               vma = xe_vm_find_overlapping_vma(vm, page_addr, SZ_4K);
-
-       return vma;
-}
 
 static int xe_pf_begin(struct drm_exec *exec, struct xe_vma *vma,
                       bool atomic, unsigned int id)
@@ -231,7 +209,7 @@ static int handle_pagefault(struct xe_gt *gt, struct pagefault *pf)
                goto unlock_vm;
        }
 
-       vma = lookup_vma(vm, pf->page_addr);
+       vma = xe_vm_find_vma_by_addr(vm, pf->page_addr);
        if (!vma) {
                err = -EINVAL;
                goto unlock_vm;
index 21564ecf876573659a925e2ae70dce0e7a82068d..cb79a37d2132bdcec5610f88366a8b51e98c5527 100644 (file)
@@ -2139,6 +2139,35 @@ int xe_vm_destroy_ioctl(struct drm_device *dev, void *data,
        return err;
 }
 
+static bool vma_matches(struct xe_vma *vma, u64 page_addr)
+{
+       if (page_addr > xe_vma_end(vma) - 1 ||
+           page_addr + SZ_4K - 1 < xe_vma_start(vma))
+               return false;
+
+       return true;
+}
+
+/**
+ * xe_vm_find_vma_by_addr() - Find a VMA by its address
+ *
+ * @vm: the xe_vm the vma belongs to
+ * @page_addr: address to look up
+ */
+struct xe_vma *xe_vm_find_vma_by_addr(struct xe_vm *vm, u64 page_addr)
+{
+       struct xe_vma *vma = NULL;
+
+       if (vm->usm.last_fault_vma) {   /* Fast lookup */
+               if (vma_matches(vm->usm.last_fault_vma, page_addr))
+                       vma = vm->usm.last_fault_vma;
+       }
+       if (!vma)
+               vma = xe_vm_find_overlapping_vma(vm, page_addr, SZ_4K);
+
+       return vma;
+}
+
 static const u32 region_to_mem_type[] = {
        XE_PL_TT,
        XE_PL_VRAM0,
index 0ef811fc2bdeeed5513c3df1efeae2f4a74206b4..99e164852f637fbfefd80d5039d862ac67a120d5 100644 (file)
@@ -169,6 +169,8 @@ static inline bool xe_vma_is_userptr(struct xe_vma *vma)
                !xe_vma_is_cpu_addr_mirror(vma);
 }
 
+struct xe_vma *xe_vm_find_vma_by_addr(struct xe_vm *vm, u64 page_addr);
+
 /**
  * to_userptr_vma() - Return a pointer to an embedding userptr vma
  * @vma: Pointer to the embedded struct xe_vma