diff options
Diffstat (limited to 'meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/2979-drm-amdgpu-move-fw_reserve-functions-to-amdgpu_ttm.c.patch')
-rw-r--r-- | meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/2979-drm-amdgpu-move-fw_reserve-functions-to-amdgpu_ttm.c.patch | 273 |
1 files changed, 273 insertions, 0 deletions
diff --git a/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/2979-drm-amdgpu-move-fw_reserve-functions-to-amdgpu_ttm.c.patch b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/2979-drm-amdgpu-move-fw_reserve-functions-to-amdgpu_ttm.c.patch new file mode 100644 index 00000000..54467fe8 --- /dev/null +++ b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/2979-drm-amdgpu-move-fw_reserve-functions-to-amdgpu_ttm.c.patch @@ -0,0 +1,273 @@ +From 7a726dd756af73a112ac685ecdf5087e68791648 Mon Sep 17 00:00:00 2001 +From: Alex Deucher <alexander.deucher@amd.com> +Date: Thu, 14 Dec 2017 16:39:02 -0500 +Subject: [PATCH 2979/4131] drm/amdgpu: move fw_reserve functions to + amdgpu_ttm.c +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +It's the only place they are used. + +Acked-by: Christian König <christian.koenig@amd.com> +Signed-off-by: Alex Deucher <alexander.deucher@amd.com> + + Conflicts: + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c + drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c + +Change-Id: Id4c44964567b71eb105f39378450e1d38e74788d +--- + drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 - + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 96 ----------------------------- + drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 99 +++++++++++++++++++++++++++++- + 3 files changed, 97 insertions(+), 101 deletions(-) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h +index 4be9e18..e28c685 100755 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h +@@ -1428,9 +1428,6 @@ struct amdgpu_fw_vram_usage { + void *va; + }; + +-int amdgpu_fw_reserve_vram_init(struct amdgpu_device *adev); +-void amdgpu_fw_reserve_vram_fini(struct amdgpu_device *adev); +- + /* + * CGS + */ +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +index 545f4cf..a640aef 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +@@ -596,102 +596,6 @@ void amdgpu_device_gart_location(struct amdgpu_device *adev, + mc->gart_size >> 20, mc->gart_start, mc->gart_end); + } + +-/* +- * Firmware Reservation functions +- */ +-/** +- * amdgpu_fw_reserve_vram_fini - free fw reserved vram +- * +- * @adev: amdgpu_device pointer +- * +- * free fw reserved vram if it has been reserved. +- */ +-void amdgpu_fw_reserve_vram_fini(struct amdgpu_device *adev) +-{ +- amdgpu_bo_free_kernel(&adev->fw_vram_usage.reserved_bo, +- NULL, &adev->fw_vram_usage.va); +-} +- +-/** +- * amdgpu_fw_reserve_vram_init - create bo vram reservation from fw +- * +- * @adev: amdgpu_device pointer +- * +- * create bo vram reservation from fw. +- */ +-int amdgpu_fw_reserve_vram_init(struct amdgpu_device *adev) +-{ +- struct ttm_operation_ctx ctx = { false, false }; +- int r = 0; +- int i; +- u64 vram_size = adev->mc.visible_vram_size; +- u64 offset = adev->fw_vram_usage.start_offset; +- u64 size = adev->fw_vram_usage.size; +- struct amdgpu_bo *bo; +- +- adev->fw_vram_usage.va = NULL; +- adev->fw_vram_usage.reserved_bo = NULL; +- +- if (adev->fw_vram_usage.size > 0 && +- adev->fw_vram_usage.size <= vram_size) { +- +- r = amdgpu_bo_create(adev, adev->fw_vram_usage.size, +- PAGE_SIZE, true, AMDGPU_GEM_DOMAIN_VRAM, +- AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | +- AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS, NULL, NULL, 0, +- &adev->fw_vram_usage.reserved_bo); +- if (r) +- goto error_create; +- +- r = amdgpu_bo_reserve(adev->fw_vram_usage.reserved_bo, false); +- if (r) +- goto error_reserve; +- +- /* remove the original mem node and create a new one at the +- * request position +- */ +- bo = adev->fw_vram_usage.reserved_bo; +- offset = ALIGN(offset, PAGE_SIZE); +- for (i = 0; i < bo->placement.num_placement; ++i) { +- bo->placements[i].fpfn = offset >> PAGE_SHIFT; +- bo->placements[i].lpfn = (offset + size) >> PAGE_SHIFT; +- } +- +- ttm_bo_mem_put(&bo->tbo, &bo->tbo.mem); +- r = ttm_bo_mem_space(&bo->tbo, &bo->placement, +- &bo->tbo.mem, false, false); +- if (r) +- goto error_pin; +- +- r = amdgpu_bo_pin_restricted(adev->fw_vram_usage.reserved_bo, +- AMDGPU_GEM_DOMAIN_VRAM, +- adev->fw_vram_usage.start_offset, +- (adev->fw_vram_usage.start_offset + +- adev->fw_vram_usage.size), NULL); +- if (r) +- goto error_pin; +- r = amdgpu_bo_kmap(adev->fw_vram_usage.reserved_bo, +- &adev->fw_vram_usage.va); +- if (r) +- goto error_kmap; +- +- amdgpu_bo_unreserve(adev->fw_vram_usage.reserved_bo); +- } +- return r; +- +-error_kmap: +- amdgpu_bo_unpin(adev->fw_vram_usage.reserved_bo); +-error_pin: +- amdgpu_bo_unreserve(adev->fw_vram_usage.reserved_bo); +-error_reserve: +- amdgpu_bo_unref(&adev->fw_vram_usage.reserved_bo); +-error_create: +- adev->fw_vram_usage.va = NULL; +- adev->fw_vram_usage.reserved_bo = NULL; +- return r; +-} +- +- + #if !defined(BUILD_AS_DKMS) || LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) + /** + * amdgpu_device_resize_fb_bar - try to resize FB BAR +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +index 2b163be..d05ba9e 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +@@ -1507,6 +1507,101 @@ static void amdgpu_ssg_fini(struct amdgpu_device *adev) + } + #endif + ++/* ++ * Firmware Reservation functions ++ */ ++/** ++ * amdgpu_ttm_fw_reserve_vram_fini - free fw reserved vram ++ * ++ * @adev: amdgpu_device pointer ++ * ++ * free fw reserved vram if it has been reserved. ++ */ ++static void amdgpu_ttm_fw_reserve_vram_fini(struct amdgpu_device *adev) ++{ ++ amdgpu_bo_free_kernel(&adev->fw_vram_usage.reserved_bo, ++ NULL, &adev->fw_vram_usage.va); ++} ++ ++/** ++ * amdgpu_ttm_fw_reserve_vram_init - create bo vram reservation from fw ++ * ++ * @adev: amdgpu_device pointer ++ * ++ * create bo vram reservation from fw. ++ */ ++static int amdgpu_ttm_fw_reserve_vram_init(struct amdgpu_device *adev) ++{ ++ struct ttm_operation_ctx ctx = { false, false }; ++ int r = 0; ++ int i; ++ u64 vram_size = adev->mc.visible_vram_size; ++ u64 offset = adev->fw_vram_usage.start_offset; ++ u64 size = adev->fw_vram_usage.size; ++ struct amdgpu_bo *bo; ++ ++ adev->fw_vram_usage.va = NULL; ++ adev->fw_vram_usage.reserved_bo = NULL; ++ ++ if (adev->fw_vram_usage.size > 0 && ++ adev->fw_vram_usage.size <= vram_size) { ++ ++ r = amdgpu_bo_create(adev, adev->fw_vram_usage.size, ++ PAGE_SIZE, true, AMDGPU_GEM_DOMAIN_VRAM, ++ AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | ++ AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS, NULL, NULL, 0, ++ &adev->fw_vram_usage.reserved_bo); ++ if (r) ++ goto error_create; ++ ++ r = amdgpu_bo_reserve(adev->fw_vram_usage.reserved_bo, false); ++ if (r) ++ goto error_reserve; ++ ++ /* remove the original mem node and create a new one at the ++ * request position ++ */ ++ bo = adev->fw_vram_usage.reserved_bo; ++ offset = ALIGN(offset, PAGE_SIZE); ++ for (i = 0; i < bo->placement.num_placement; ++i) { ++ bo->placements[i].fpfn = offset >> PAGE_SHIFT; ++ bo->placements[i].lpfn = (offset + size) >> PAGE_SHIFT; ++ } ++ ++ ttm_bo_mem_put(&bo->tbo, &bo->tbo.mem); ++ r = ttm_bo_mem_space(&bo->tbo, &bo->placement, ++ &bo->tbo.mem, &ctx); ++ if (r) ++ goto error_pin; ++ ++ r = amdgpu_bo_pin_restricted(adev->fw_vram_usage.reserved_bo, ++ AMDGPU_GEM_DOMAIN_VRAM, ++ adev->fw_vram_usage.start_offset, ++ (adev->fw_vram_usage.start_offset + ++ adev->fw_vram_usage.size), NULL); ++ if (r) ++ goto error_pin; ++ r = amdgpu_bo_kmap(adev->fw_vram_usage.reserved_bo, ++ &adev->fw_vram_usage.va); ++ if (r) ++ goto error_kmap; ++ ++ amdgpu_bo_unreserve(adev->fw_vram_usage.reserved_bo); ++ } ++ return r; ++ ++error_kmap: ++ amdgpu_bo_unpin(adev->fw_vram_usage.reserved_bo); ++error_pin: ++ amdgpu_bo_unreserve(adev->fw_vram_usage.reserved_bo); ++error_reserve: ++ amdgpu_bo_unref(&adev->fw_vram_usage.reserved_bo); ++error_create: ++ adev->fw_vram_usage.va = NULL; ++ adev->fw_vram_usage.reserved_bo = NULL; ++ return r; ++} ++ + int amdgpu_ttm_init(struct amdgpu_device *adev) + { + uint64_t gtt_size; +@@ -1549,7 +1644,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) + *The reserved vram for firmware must be pinned to the specified + *place on the VRAM, so reserve it early. + */ +- r = amdgpu_fw_reserve_vram_init(adev); ++ r = amdgpu_ttm_fw_reserve_vram_init(adev); + if (r) { + return r; + } +@@ -1643,7 +1738,7 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev) + amdgpu_ttm_debugfs_fini(adev); + + amdgpu_bo_free_kernel(&adev->stolen_vga_memory, NULL, NULL); +- amdgpu_fw_reserve_vram_fini(adev); ++ amdgpu_ttm_fw_reserve_vram_fini(adev); + + amdgpu_ssg_fini(adev); + amdgpu_direct_gma_fini(adev); +-- +2.7.4 + |