diff options
author | Christian König <christian.koenig@amd.com> | 2017-11-23 11:16:05 +0100 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-12-06 12:48:29 -0500 |
commit | 36539dcea3225fb603905fb884446f3173cc0198 (patch) | |
tree | e40a3ba68bb51aa777e79c47ea31bb2ff39f2ef0 | |
parent | b38f41ebb8d0395221e136677387c36bf03fd320 (diff) | |
download | lwn-36539dcea3225fb603905fb884446f3173cc0198.tar.gz lwn-36539dcea3225fb603905fb884446f3173cc0198.zip |
drm/amdgpu: choose number of VM levels based on VM size
This allows us limiting the VM size for testing even of Vega10.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index c942f6b4be1b..82a6f6c86aaf 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -2582,12 +2582,17 @@ static uint32_t amdgpu_vm_get_block_size(uint64_t vm_size) void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint32_t vm_size, uint32_t fragment_size_default, unsigned max_level) { - /* adjust vm size first, but only for two level setups for now */ - if (amdgpu_vm_size != -1 && max_level == 1) + uint64_t tmp; + + /* adjust vm size first */ + if (amdgpu_vm_size != -1) vm_size = amdgpu_vm_size; adev->vm_manager.max_pfn = (uint64_t)vm_size << 18; - adev->vm_manager.num_level = max_level; + + tmp = roundup_pow_of_two(adev->vm_manager.max_pfn); + tmp = DIV_ROUND_UP(fls64(tmp) - 1, 9) - 1; + adev->vm_manager.num_level = min(max_level, (unsigned)tmp); /* block size depends on vm size and hw setup*/ if (adev->vm_manager.num_level > 1) @@ -2604,8 +2609,9 @@ void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint32_t vm_size, else adev->vm_manager.fragment_size = amdgpu_vm_fragment_size; - DRM_INFO("vm size is %u GB, block size is %u-bit, fragment size is %u-bit\n", - vm_size, adev->vm_manager.block_size, + DRM_INFO("vm size is %u GB, %u levels, block size is %u-bit, fragment size is %u-bit\n", + vm_size, adev->vm_manager.num_level + 1, + adev->vm_manager.block_size, adev->vm_manager.fragment_size); } |