drm/amdgpu: use clamp() in amdgpu_vm_adjust_size()
authorLi Zetao <lizetao1@huawei.com>
Fri, 30 Aug 2024 01:22:15 +0000 (09:22 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 6 Sep 2024 21:38:57 +0000 (17:38 -0400)
When it needs to get a value within a certain interval, using clamp()
makes the code easier to understand than min(max()).

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Li Zetao <lizetao1@huawei.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

index 75740e0..9eca247 100644 (file)
@@ -2244,7 +2244,7 @@ void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint32_t min_vm_size,
                phys_ram_gb = ((uint64_t)si.totalram * si.mem_unit +
                               (1 << 30) - 1) >> 30;
                vm_size = roundup_pow_of_two(
-                       min(max(phys_ram_gb * 3, min_vm_size), max_size));
+                       clamp(phys_ram_gb * 3, min_vm_size, max_size));
        }
 
        adev->vm_manager.max_pfn = (uint64_t)vm_size << 18;