Skip to content

Commit 9ae587f

Browse files
arunpravin24alexdeucher
authored andcommitted
drm/amdgpu: Fix the vram base start address
If the size returned by drm buddy allocator is higher than the required size, we take the higher size to calculate the buffer start address. This is required if we couldn't trim the buffer to the requested size. This will fix the display corruption issue on APU's which has limited VRAM size. Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2859 Fixes: 0a1844b ("drm/buddy: Improve contiguous memory allocation") Signed-off-by: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com> Acked-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent d539b0a commit 9ae587f

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,16 @@ static inline bool amdgpu_is_vram_mgr_blocks_contiguous(struct list_head *head)
7777
return true;
7878
}
7979

80+
static inline u64 amdgpu_vram_mgr_blocks_size(struct list_head *head)
81+
{
82+
struct drm_buddy_block *block;
83+
u64 size = 0;
8084

85+
list_for_each_entry(block, head, link)
86+
size += amdgpu_vram_mgr_block_size(block);
87+
88+
return size;
89+
}
8190

8291
/**
8392
* DOC: mem_info_vram_total
@@ -516,15 +525,17 @@ static int amdgpu_vram_mgr_new(struct ttm_resource_manager *man,
516525
mutex_unlock(&mgr->lock);
517526

518527
vres->base.start = 0;
528+
size = max_t(u64, amdgpu_vram_mgr_blocks_size(&vres->blocks),
529+
vres->base.size);
519530
list_for_each_entry(block, &vres->blocks, link) {
520531
unsigned long start;
521532

522533
start = amdgpu_vram_mgr_block_start(block) +
523534
amdgpu_vram_mgr_block_size(block);
524535
start >>= PAGE_SHIFT;
525536

526-
if (start > PFN_UP(vres->base.size))
527-
start -= PFN_UP(vres->base.size);
537+
if (start > PFN_UP(size))
538+
start -= PFN_UP(size);
528539
else
529540
start = 0;
530541
vres->base.start = max(vres->base.start, start);

0 commit comments

Comments
 (0)