drm/amdkfd: use vma_lookup() instead of find_vma()
Subsystems (3)
PATCH 1/1 drm/amdkfd: use vma_lookup() instead of find_vma()
Using vma_lookup() verifies the start address is contained in the found vma. This results in easier to read the code.
Signed-off-by Deming Wang <[email protected]>
--- drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +4 -4
@@ -529,8 +529,8 @@ svm_migrate_ram_to_vram(struct svm_range *prange, uint32_t best_loc,for (addr = start; addr < end;) {unsigned long next; - vma =find_vma (mm, addr); -if (!vma || addr < vma->vm_start) + vma =vma_lookup (mm, addr); +if (!vma)break ; next =min (vma->vm_end, end);
@@ -798,8 +798,8 @@ int svm_migrate_vram_to_ram(struct svm_range *prange, struct mm_struct *mm,for (addr = start; addr < end;) {unsigned long next; - vma =find_vma (mm, addr); -if (!vma || addr < vma->vm_start) { + vma = vma_lookup(mm, addr) +if (!vma) {pr_debug ("failed to find vma for prange %p\n" , prange); r = -EFAULT ;break ;
Signature · 1 line
2.27.0
Felix Kuehling
maintainerAm 2022-10-06 um 22:26 schrieb Deming Wang:
Quoted 24 lines
Using
vma_lookup()verifies the start address is contained in the found vma. This results in easier to read the code.Signed-off-by Deming Wang <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +2
-2@@ -529,8 +529,8 @@ svm_migrate_ram_to_vram(struct svm_range *prange, uint32_t best_loc,for (addr = start; addr < end;) {unsigned long next; - vma =find_vma (mm, addr); -if (!vma || addr < vma->vm_start) + vma =vma_lookup (mm, addr); +if (!vma)break ; next =min (vma->vm_end, end);
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c int svm_migrate_vram_to_ram(struct svm_range *prange, struct mm_struct *mm, · line 801
Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +1
-2@@ -798,8 +798,8 @@ int svm_migrate_vram_to_ram(struct svm_range *prange, struct mm_struct *mm,for (addr = start; addr < end;) {unsigned long next; - vma =find_vma (mm, addr); -if (!vma || addr < vma->vm_start) { + vma =vma_lookup (mm, addr)
There is a semicolon missing here. I will fix this before I submit the patch.
Please do at least a minimum amount of due diligence before posting patches. That would include a test to make sure your code compiles.
Regards,
Felix
Quoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +1
-0+if (!vma) {pr_debug ("failed to find vma for prange %p\n" , prange); r = -EFAULT ;break ;