aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux-4.19/linux-yocto-4.19.8/0307-drm-amdgpu-try-allocating-VRAM-as-power-of-two.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-amd-bsp/recipes-kernel/linux-4.19/linux-yocto-4.19.8/0307-drm-amdgpu-try-allocating-VRAM-as-power-of-two.patch')
-rw-r--r--meta-amd-bsp/recipes-kernel/linux-4.19/linux-yocto-4.19.8/0307-drm-amdgpu-try-allocating-VRAM-as-power-of-two.patch99
1 files changed, 99 insertions, 0 deletions
diff --git a/meta-amd-bsp/recipes-kernel/linux-4.19/linux-yocto-4.19.8/0307-drm-amdgpu-try-allocating-VRAM-as-power-of-two.patch b/meta-amd-bsp/recipes-kernel/linux-4.19/linux-yocto-4.19.8/0307-drm-amdgpu-try-allocating-VRAM-as-power-of-two.patch
new file mode 100644
index 00000000..bae557f8
--- /dev/null
+++ b/meta-amd-bsp/recipes-kernel/linux-4.19/linux-yocto-4.19.8/0307-drm-amdgpu-try-allocating-VRAM-as-power-of-two.patch
@@ -0,0 +1,99 @@
+From 4a19ebbd28eb028edfebf534cbaf485380d2203d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Christian=20K=C3=B6nig?= <christian.koenig@amd.com>
+Date: Fri, 7 Sep 2018 14:27:05 +0200
+Subject: [PATCH 0307/2940] drm/amdgpu: try allocating VRAM as power of two
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Try to allocate VRAM in power of two sizes and only fallback to vram
+split sizes if that fails.
+
+Signed-off-by: Christian König <christian.koenig@amd.com>
+Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
+---
+ drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 52 +++++++++++++++-----
+ 1 file changed, 40 insertions(+), 12 deletions(-)
+
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
+index 9cfa8a9ada92..3f9d5d00c9b3 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
+@@ -124,6 +124,28 @@ u64 amdgpu_vram_mgr_bo_visible_size(struct amdgpu_bo *bo)
+ return usage;
+ }
+
++/**
++ * amdgpu_vram_mgr_virt_start - update virtual start address
++ *
++ * @mem: ttm_mem_reg to update
++ * @node: just allocated node
++ *
++ * Calculate a virtual BO start address to easily check if everything is CPU
++ * accessible.
++ */
++static void amdgpu_vram_mgr_virt_start(struct ttm_mem_reg *mem,
++ struct drm_mm_node *node)
++{
++ unsigned long start;
++
++ start = node->start + node->size;
++ if (start > mem->num_pages)
++ start -= mem->num_pages;
++ else
++ start = 0;
++ mem->start = max(mem->start, start);
++}
++
+ /**
+ * amdgpu_vram_mgr_new - allocate new ranges
+ *
+@@ -176,10 +198,25 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man,
+ pages_left = mem->num_pages;
+
+ spin_lock(&mgr->lock);
+- for (i = 0; i < num_nodes; ++i) {
++ for (i = 0; pages_left >= pages_per_node; ++i) {
++ unsigned long pages = rounddown_pow_of_two(pages_left);
++
++ r = drm_mm_insert_node_in_range(mm, &nodes[i], pages,
++ pages_per_node, 0,
++ place->fpfn, lpfn,
++ mode);
++ if (unlikely(r))
++ break;
++
++ usage += nodes[i].size << PAGE_SHIFT;
++ vis_usage += amdgpu_vram_mgr_vis_size(adev, &nodes[i]);
++ amdgpu_vram_mgr_virt_start(mem, &nodes[i]);
++ pages_left -= pages;
++ }
++
++ for (; pages_left; ++i) {
+ unsigned long pages = min(pages_left, pages_per_node);
+ uint32_t alignment = mem->page_alignment;
+- unsigned long start;
+
+ if (pages == pages_per_node)
+ alignment = pages_per_node;
+@@ -193,16 +230,7 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man,
+
+ usage += nodes[i].size << PAGE_SHIFT;
+ vis_usage += amdgpu_vram_mgr_vis_size(adev, &nodes[i]);
+-
+- /* Calculate a virtual BO start address to easily check if
+- * everything is CPU accessible.
+- */
+- start = nodes[i].start + nodes[i].size;
+- if (start > mem->num_pages)
+- start -= mem->num_pages;
+- else
+- start = 0;
+- mem->start = max(mem->start, start);
++ amdgpu_vram_mgr_virt_start(mem, &nodes[i]);
+ pages_left -= pages;
+ }
+ spin_unlock(&mgr->lock);
+--
+2.17.1
+