diff options
Diffstat (limited to 'meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/2176-drm-amdgpu-Implement-BO-size-validation-V2.patch')
-rw-r--r-- | meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/2176-drm-amdgpu-Implement-BO-size-validation-V2.patch | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/2176-drm-amdgpu-Implement-BO-size-validation-V2.patch b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/2176-drm-amdgpu-Implement-BO-size-validation-V2.patch new file mode 100644 index 00000000..404c6b8a --- /dev/null +++ b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/2176-drm-amdgpu-Implement-BO-size-validation-V2.patch @@ -0,0 +1,82 @@ +From d623ea5ab8945ff2a0c7a9f654d970dcfd673882 Mon Sep 17 00:00:00 2001 +From: Andrey Grodzovsky <andrey.grodzovsky@amd.com> +Date: Fri, 10 Nov 2017 18:35:56 -0500 +Subject: [PATCH 2176/4131] drm/amdgpu: Implement BO size validation V2 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Validates BO size against each requested domain's total memory. + +v2: +Make GTT size check a MUST to allow fall back to GTT. +Rmove redundant NULL check. + +Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com> +Reviewed-by: Christian König <christian.koenig@amd.com> +--- + drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 41 ++++++++++++++++++++++++++++++ + 1 file changed, 41 insertions(+) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +index 8b8684b..9c62925 100755 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +@@ -307,6 +307,44 @@ void amdgpu_bo_free_kernel(struct amdgpu_bo **bo, u64 *gpu_addr, + *cpu_addr = NULL; + } + ++/* Validate bo size is bit bigger then the request domain */ ++static bool amdgpu_bo_validate_size(struct amdgpu_device *adev, ++ unsigned long size, u32 domain) ++{ ++ struct ttm_mem_type_manager *man = NULL; ++ ++ /* ++ * If GTT is part of requested domains the check must succeed to ++ * allow fall back to GTT ++ */ ++ if (domain & AMDGPU_GEM_DOMAIN_GTT) { ++ man = &adev->mman.bdev.man[TTM_PL_TT]; ++ ++ if (size < (man->size << PAGE_SHIFT)) ++ return true; ++ else ++ goto fail; ++ } ++ ++ if (domain & AMDGPU_GEM_DOMAIN_VRAM) { ++ man = &adev->mman.bdev.man[TTM_PL_VRAM]; ++ ++ if (size < (man->size << PAGE_SHIFT)) ++ return true; ++ else ++ goto fail; ++ } ++ ++ ++ /* TODO add more domains checks, such as AMDGPU_GEM_DOMAIN_CPU */ ++ return true; ++ ++fail: ++ DRM_ERROR("BO size %lu > total memory in domain: %llu\n", size, ++ man->size << PAGE_SHIFT); ++ return false; ++} ++ + static int amdgpu_bo_do_create(struct amdgpu_device *adev, + unsigned long size, int byte_align, + bool kernel, u32 domain, u64 flags, +@@ -325,6 +363,9 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, + page_align = roundup(byte_align, PAGE_SIZE) >> PAGE_SHIFT; + size = ALIGN(size, PAGE_SIZE); + ++ if (!amdgpu_bo_validate_size(adev, size, domain)) ++ return -ENOMEM; ++ + if (kernel) { + type = ttm_bo_type_kernel; + } else if (sg) { +-- +2.7.4 + |