Commit 8f9a9a09 authored by Ma Jun's avatar Ma Jun Committed by Alex Deucher

drm/amd: Simplify the bo size check funciton

Simplify the code logic of size check function amdgpu_bo_validate_size
Signed-off-by: default avatarMa Jun <Jun.Ma2@amd.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent d30279a9
...@@ -459,7 +459,7 @@ void amdgpu_bo_free_kernel(struct amdgpu_bo **bo, u64 *gpu_addr, ...@@ -459,7 +459,7 @@ void amdgpu_bo_free_kernel(struct amdgpu_bo **bo, u64 *gpu_addr,
*cpu_addr = NULL; *cpu_addr = NULL;
} }
/* Validate bo size is bit bigger then the request domain */ /* Validate bo size is bit bigger than the request domain */
static bool amdgpu_bo_validate_size(struct amdgpu_device *adev, static bool amdgpu_bo_validate_size(struct amdgpu_device *adev,
unsigned long size, u32 domain) unsigned long size, u32 domain)
{ {
...@@ -469,29 +469,24 @@ static bool amdgpu_bo_validate_size(struct amdgpu_device *adev, ...@@ -469,29 +469,24 @@ static bool amdgpu_bo_validate_size(struct amdgpu_device *adev,
* If GTT is part of requested domains the check must succeed to * If GTT is part of requested domains the check must succeed to
* allow fall back to GTT. * allow fall back to GTT.
*/ */
if (domain & AMDGPU_GEM_DOMAIN_GTT) { if (domain & AMDGPU_GEM_DOMAIN_GTT)
man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT); man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
else if (domain & AMDGPU_GEM_DOMAIN_VRAM)
if (man && size < man->size)
return true;
else if (!man)
WARN_ON_ONCE("GTT domain requested but GTT mem manager uninitialized");
goto fail;
} else if (domain & AMDGPU_GEM_DOMAIN_VRAM) {
man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM); man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM);
else
return true;
if (man && size < man->size) if (!man) {
return true; if (domain & AMDGPU_GEM_DOMAIN_GTT)
goto fail; WARN_ON_ONCE("GTT domain requested but GTT mem manager uninitialized");
return false;
} }
/* TODO add more domains checks, such as AMDGPU_GEM_DOMAIN_CPU, _DOMAIN_DOORBELL */ /* TODO add more domains checks, such as AMDGPU_GEM_DOMAIN_CPU, _DOMAIN_DOORBELL */
return true; if (size < man->size)
return true;
fail: DRM_DEBUG("BO size %lu > total memory in domain: %llu\n", size, man->size);
if (man)
DRM_DEBUG("BO size %lu > total memory in domain: %llu\n", size,
man->size);
return false; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment