On 5/22/26 9:32 PM, Kuehling, Felix wrote:
On 2026-05-22 07:28, Donet Tom wrote:
amdgpu_gart_map_vram_range() expects the number of pages (num_pages) in
4K page units. However, in amdgpu_ttm_map_buffer(), the number of pages
is calculated based on the system page size. On systems with non-4K page
sizes, this results in an incorrect number of pages being passed to
amdgpu_gart_map_vram_range().
Fix this by calculating the number of pages correctly before passing it
to amdgpu_gart_map_vram_range().
Signed-off-by: Donet Tom <[email protected]>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 3d2e00efc741..2904a9400605 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -269,6 +269,7 @@ static int amdgpu_ttm_map_buffer(struct
amdgpu_ttm_buffer_entity *entity,
amdgpu_gart_map(adev, 0, num_pages, dma_addr, flags,
cpu_addr);
} else {
u64 pa = mm_cur->start + adev->vm_manager.vram_base_offset;
+ num_pages *= AMDGPU_GPU_PAGES_IN_CPU_PAGE;
amdgpu_gart_map_vram_range(adev, pa, 0, num_pages, flags,
cpu_addr);
IMO it would be cleaner to change the definition of
amdgpu_gart_map_vram_range to use the same page size as amdgpu_gart_map.
Thank you, Felix, for the review.
I will make the suggested changes in amdgpu_gart_map_vram_range() and
post a v2 patch.
-Donet
Regards,
Felix
}