Signed-off-by: Philip Yang <Philip.Yang@xxxxxxx>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
index 82a3299e53c0..67a454f4c37a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
@@ -369,7 +369,7 @@ static int amdgpu_vram_mgr_new(struct
ttm_mem_type_manager *man,
spin_lock(&mgr->lock);
for (i = 0; pages_left >= pages_per_node; ++i) {
- unsigned long pages = rounddown_pow_of_two(pages_left);
+ unsigned long pages = rounddown_pow_of_two(pages_per_node);
r = drm_mm_insert_node_in_range(mm, &nodes[i], pages,
pages_per_node, 0,
@@ -383,15 +383,11 @@ static int amdgpu_vram_mgr_new(struct
ttm_mem_type_manager *man,
pages_left -= pages;
}
- for (; pages_left; ++i) {
- unsigned long pages = min(pages_left, pages_per_node);
+ if (pages_left) {
uint32_t alignment = mem->page_alignment;
- if (pages == pages_per_node)
- alignment = pages_per_node;
-
r = drm_mm_insert_node_in_range(mm, &nodes[i],
- pages, alignment, 0,
+ pages_left, alignment, 0,
place->fpfn, lpfn,
mode);
if (unlikely(r))
@@ -399,7 +395,6 @@ static int amdgpu_vram_mgr_new(struct
ttm_mem_type_manager *man,
vis_usage += amdgpu_vram_mgr_vis_size(adev, &nodes[i]);
amdgpu_vram_mgr_virt_start(mem, &nodes[i]);
- pages_left -= pages;
}
spin_unlock(&mgr->lock);