]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
i915: use the VMA iterator
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 14 Apr 2022 06:07:23 +0000 (23:07 -0700)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Tue, 26 Apr 2022 14:36:41 +0000 (10:36 -0400)
Replace the linked list in probe_range() with the VMA iterator.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
drivers/gpu/drm/i915/gem/i915_gem_userptr.c

index 6d1a71d6404cb107b916aa2e958f5e570131f140..e20ee4b611fd94aee55ecc866de7ae831a29a0f3 100644 (file)
@@ -426,12 +426,11 @@ static const struct drm_i915_gem_object_ops i915_gem_userptr_ops = {
 static int
 probe_range(struct mm_struct *mm, unsigned long addr, unsigned long len)
 {
-       const unsigned long end = addr + len;
+       VMA_ITERATOR(vmi, mm, addr);
        struct vm_area_struct *vma;
-       int ret = -EFAULT;
 
        mmap_read_lock(mm);
-       for (vma = find_vma(mm, addr); vma; vma = vma->vm_next) {
+       for_each_vma_range(vmi, vma, addr + len) {
                /* Check for holes, note that we also update the addr below */
                if (vma->vm_start > addr)
                        break;
@@ -439,16 +438,13 @@ probe_range(struct mm_struct *mm, unsigned long addr, unsigned long len)
                if (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP))
                        break;
 
-               if (vma->vm_end >= end) {
-                       ret = 0;
-                       break;
-               }
-
                addr = vma->vm_end;
        }
        mmap_read_unlock(mm);
 
-       return ret;
+       if (vma)
+               return -EFAULT;
+       return 0;
 }
 
 /*