aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux-4.19/linux-yocto-4.19.8/0310-drm-amdgpu-add-amdgpu_gmc_agp_location-v3.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-amd-bsp/recipes-kernel/linux-4.19/linux-yocto-4.19.8/0310-drm-amdgpu-add-amdgpu_gmc_agp_location-v3.patch')
-rw-r--r--meta-amd-bsp/recipes-kernel/linux-4.19/linux-yocto-4.19.8/0310-drm-amdgpu-add-amdgpu_gmc_agp_location-v3.patch96
1 files changed, 96 insertions, 0 deletions
diff --git a/meta-amd-bsp/recipes-kernel/linux-4.19/linux-yocto-4.19.8/0310-drm-amdgpu-add-amdgpu_gmc_agp_location-v3.patch b/meta-amd-bsp/recipes-kernel/linux-4.19/linux-yocto-4.19.8/0310-drm-amdgpu-add-amdgpu_gmc_agp_location-v3.patch
new file mode 100644
index 00000000..f4b5088c
--- /dev/null
+++ b/meta-amd-bsp/recipes-kernel/linux-4.19/linux-yocto-4.19.8/0310-drm-amdgpu-add-amdgpu_gmc_agp_location-v3.patch
@@ -0,0 +1,96 @@
+From 8d5ba61d37577ae73d7d8b6f8d83c4327529fcdd Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Christian=20K=C3=B6nig?= <christian.koenig@amd.com>
+Date: Fri, 24 Aug 2018 12:08:06 +0200
+Subject: [PATCH 0310/2940] drm/amdgpu: add amdgpu_gmc_agp_location v3
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Helper to figure out the location of the AGP BAR.
+
+v2: fix a couple of bugs
+v3: correctly add one to vram_end
+
+Signed-off-by: Christian König <christian.koenig@amd.com>
+Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>
+---
+ drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 43 +++++++++++++++++++++++++
+ drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 5 +++
+ 2 files changed, 48 insertions(+)
+
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
+index 068f0c69c5d6..0effe848c101 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
+@@ -143,3 +143,46 @@ void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc)
+ dev_info(adev->dev, "GART: %lluM 0x%016llX - 0x%016llX\n",
+ mc->gart_size >> 20, mc->gart_start, mc->gart_end);
+ }
++
++/**
++ * amdgpu_gmc_agp_location - try to find AGP location
++ * @adev: amdgpu device structure holding all necessary informations
++ * @mc: memory controller structure holding memory informations
++ *
++ * Function will place try to find a place for the AGP BAR in the MC address
++ * space.
++ *
++ * AGP BAR will be assigned the largest available hole in the address space.
++ * Should be called after VRAM and GART locations are setup.
++ */
++void amdgpu_gmc_agp_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc)
++{
++ const uint64_t sixteen_gb = 1ULL << 34;
++ const uint64_t sixteen_gb_mask = ~(sixteen_gb - 1);
++ u64 size_af, size_bf;
++
++ if (mc->vram_start > mc->gart_start) {
++ size_bf = (mc->vram_start & sixteen_gb_mask) -
++ ALIGN(mc->gart_end + 1, sixteen_gb);
++ size_af = mc->mc_mask + 1 - ALIGN(mc->vram_end + 1, sixteen_gb);
++ } else {
++ size_bf = mc->vram_start & sixteen_gb_mask;
++ size_af = (mc->gart_start & sixteen_gb_mask) -
++ ALIGN(mc->vram_end + 1, sixteen_gb);
++ }
++
++ if (size_bf > size_af) {
++ mc->agp_start = mc->vram_start > mc->gart_start ?
++ mc->gart_end + 1 : 0;
++ mc->agp_size = size_bf;
++ } else {
++ mc->agp_start = (mc->vram_start > mc->gart_start ?
++ mc->vram_end : mc->gart_end) + 1,
++ mc->agp_size = size_af;
++ }
++
++ mc->agp_start = ALIGN(mc->agp_start, sixteen_gb);
++ mc->agp_end = mc->agp_start + mc->agp_size - 1;
++ dev_info(adev->dev, "AGP: %lluM 0x%016llX - 0x%016llX\n",
++ mc->agp_size >> 20, mc->agp_start, mc->agp_end);
++}
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
+index 8d53cd0595b6..412105f9ef7a 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
+@@ -81,6 +81,9 @@ struct amdgpu_gmc {
+ * about vram size near mc fb location */
+ u64 mc_vram_size;
+ u64 visible_vram_size;
++ u64 agp_size;
++ u64 agp_start;
++ u64 agp_end;
+ u64 gart_size;
+ u64 gart_start;
+ u64 gart_end;
+@@ -140,5 +143,7 @@ void amdgpu_gmc_vram_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc,
+ u64 base);
+ void amdgpu_gmc_gart_location(struct amdgpu_device *adev,
+ struct amdgpu_gmc *mc);
++void amdgpu_gmc_agp_location(struct amdgpu_device *adev,
++ struct amdgpu_gmc *mc);
+
+ #endif
+--
+2.17.1
+