Commit 7554886d authored by Luben Tuikov's avatar Luben Tuikov Committed by Alex Deucher

drm/amdgpu: Fix size validation for non-exclusive domains (v4)

Fix amdgpu_bo_validate_size() to check whether the TTM domain manager for the
requested memory exists, else we get a kernel oops when dereferencing "man".

v2: Make the patch standalone, i.e. not dependent on local patches.
v3: Preserve old behaviour and just check that the manager pointer is not
    NULL.
v4: Complain if GTT domain requested and it is uninitialized--most likely a
    bug.

Cc: Alex Deucher <Alexander.Deucher@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: AMD Graphics <amd-gfx@lists.freedesktop.org>
Signed-off-by: default avatarLuben Tuikov <luben.tuikov@amd.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 28afcb0a
...@@ -448,27 +448,24 @@ static bool amdgpu_bo_validate_size(struct amdgpu_device *adev, ...@@ -448,27 +448,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);
if (size < man->size) if (man && size < man->size)
return true; return true;
else else if (!man)
goto fail; WARN_ON_ONCE("GTT domain requested but GTT mem manager uninitialized");
} goto fail;
} else if (domain & AMDGPU_GEM_DOMAIN_VRAM) {
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);
if (size < man->size) if (man && size < man->size)
return true; return true;
else goto fail;
goto fail;
} }
/* TODO add more domains checks, such as AMDGPU_GEM_DOMAIN_CPU */ /* TODO add more domains checks, such as AMDGPU_GEM_DOMAIN_CPU */
return true; return true;
......
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