diff options
| author | Shane Xiao <[email protected]> | 2023-02-18 03:58:45 +0000 |
|---|---|---|
| committer | Alex Deucher <[email protected]> | 2023-02-23 22:35:58 +0000 |
| commit | 2866cc09617991cb4f9f36fbebdbba966fe5a21a (patch) | |
| tree | 2f5c527bb62ac4c9c54f5c3f956e14dc72331a20 /drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | |
| parent | drm/amdgpu: remove TOPDOWN flags when allocating VRAM in large bar system (diff) | |
| download | kernel-2866cc09617991cb4f9f36fbebdbba966fe5a21a.tar.gz kernel-2866cc09617991cb4f9f36fbebdbba966fe5a21a.zip | |
drm/amdgpu: optimize VRAM allocation when using drm buddy
Since the VRAM manager changed from drm mm to drm buddy. It's
not necessary to allocate 2MB aligned VRAM for more than 2MB
unaligned size, and then do trim. This method improves the
allocation efficiency and reduces memory fragmentation.
v2: Correct the remainder operation
Signed-off-by: Shane Xiao <[email protected]>
Reviewed-by: Arunpravin Paneer Selvam <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c')
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c index 9fa1d814508a..43d6a9d6a538 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c @@ -453,7 +453,8 @@ static int amdgpu_vram_mgr_new(struct ttm_resource_manager *man, /* Limit maximum size to 2GiB due to SG table limitations */ size = min(remaining_size, 2ULL << 30); - if (size >= (u64)pages_per_block << PAGE_SHIFT) + if ((size >= (u64)pages_per_block << PAGE_SHIFT) && + !(size & (((u64)pages_per_block << PAGE_SHIFT) - 1))) min_block_size = (u64)pages_per_block << PAGE_SHIFT; cur_size = size; |
