Skip to contentSkip to conversation

drm/amdgpu: Use vma_lookup() in amdgpu_ttm_tt_get_user_pages()

PATCH In review Liam Howlett 3 participants 3 messages Jun 3, 2021 – Jun 4, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: Use vma_lookup() in amdgpu_ttm_tt_get_user_pages()

Use vma_lookup() to find the VMA at a specific address. As vma_lookup() will return NULL if the address is not within any VMA, the start address no longer needs to be validated.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -2
index 7cb7ffdd1900..dfb5ca3f8da8 100644
@@ -680,9 +680,9 @@ int amdgpu_ttm_tt_get_user_pages(struct amdgpu_bo *bo, struct page **pages)
 		return -ESRCH;
 
 	mmap_read_lock(mm);
-	vma = find_vma(mm, start);
+	vma = vma_lookup(mm, start);
 	mmap_read_unlock(mm);
-	if (unlikely(!vma || start < vma->vm_start)) {
+	if (unlikely(!vma)) {
 		r = -EFAULT;
 		goto out_putmm;
 	}
Signature · 1 line
2.30.2
Reviewed-by on v1 1/1
#1 lore raw

Am 03.06.21 um 18:09 schrieb Liam Howlett:

Quoted 5 lines

Use vma_lookup() to find the VMA at a specific address. As vma_lookup() will return NULL if the address is not within any VMA, the start address no longer needs to be validated.

Quoted 20 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -2
index 7cb7ffdd1900..dfb5ca3f8da8 100644
@@ -680,9 +680,9 @@ int amdgpu_ttm_tt_get_user_pages(struct amdgpu_bo *bo, struct page **pages)
  		return -ESRCH;
 
  	mmap_read_lock(mm);
-	vma = find_vma(mm, start);
+	vma = vma_lookup(mm, start);
  	mmap_read_unlock(mm);
-	if (unlikely(!vma || start < vma->vm_start)) {
+	if (unlikely(!vma)) {
  		r = -EFAULT;
  		goto out_putmm;
  	}
Acked-by
#2 lore raw
Quoted 10 lines · Christian König

Am 03.06.21 um 18:09 schrieb Liam Howlett:

Quoted 5 lines

Use vma_lookup() to find the VMA at a specific address. As vma_lookup() will return NULL if the address is not within any VMA, the start address no longer needs to be validated.

I'm fine to have this go through whatever tree makes sense.

Quoted 11 lines
Quoted 11 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
index 7cb7ffdd1900..dfb5ca3f8da8 100644
@@ -680,9 +680,9 @@ int amdgpu_ttm_tt_get_user_pages(struct amdgpu_bo *bo, struct page **pages)
              return -ESRCH;
 
Quoted 10 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_tt_get_user_pages(struct amdgpu_bo *bo, struct page **pages) · line 688

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -2
      mmap_read_lock(mm);
-     vma = find_vma(mm, start);
+     vma = vma_lookup(mm, start);
      mmap_read_unlock(mm);
-     if (unlikely(!vma || start < vma->vm_start)) {
+     if (unlikely(!vma)) {
              r = -EFAULT;
              goto out_putmm;
      }

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx