Skip to content

Commit

Permalink
i915: use the VMA iterator
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Alexandre Frade <kernel@xanmod.org>
  • Loading branch information
Matthew Wilcox (Oracle) authored and xanmod committed Oct 3, 2022
1 parent 07fa267 commit 011fd66
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions drivers/gpu/drm/i915/gem/i915_gem_userptr.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,29 +426,25 @@ 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;

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;
}

/*
Expand Down

0 comments on commit 011fd66

Please sign in to comment.