aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/linux-yocto-4.14.71/4194-drm-amdgpu-Free-VGA-stolen-memory-as-soon-as-possibl.patch
diff options
context:
space:
mode:
Diffstat (limited to 'common/recipes-kernel/linux/linux-yocto-4.14.71/4194-drm-amdgpu-Free-VGA-stolen-memory-as-soon-as-possibl.patch')
-rw-r--r--common/recipes-kernel/linux/linux-yocto-4.14.71/4194-drm-amdgpu-Free-VGA-stolen-memory-as-soon-as-possibl.patch200
1 files changed, 200 insertions, 0 deletions
diff --git a/common/recipes-kernel/linux/linux-yocto-4.14.71/4194-drm-amdgpu-Free-VGA-stolen-memory-as-soon-as-possibl.patch b/common/recipes-kernel/linux/linux-yocto-4.14.71/4194-drm-amdgpu-Free-VGA-stolen-memory-as-soon-as-possibl.patch
new file mode 100644
index 00000000..9844443d
--- /dev/null
+++ b/common/recipes-kernel/linux/linux-yocto-4.14.71/4194-drm-amdgpu-Free-VGA-stolen-memory-as-soon-as-possibl.patch
@@ -0,0 +1,200 @@
+From 529b33b4adb036be8b967661a21a34deb21b4c24 Mon Sep 17 00:00:00 2001
+From: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
+Date: Fri, 6 Apr 2018 14:54:10 -0500
+Subject: [PATCH 4194/5725] drm/amdgpu: Free VGA stolen memory as soon as
+ possible.
+
+Reserved VRAM is used to avoid overriding pre OS FB.
+Once our display stack takes over we don't need the reserved
+VRAM anymore.
+
+v2:
+Remove comment, we know actually why we need to reserve the stolen VRAM.
+Fix return type for amdgpu_ttm_late_init.
+v3:
+Return 0 in amdgpu_bo_late_init, rebase on changes to previous patch
+v4: rebase
+v5:
+For GMC9 reserve always just 9M and keep the stolem memory around
+until GART table curruption on S3 resume is resolved.
+
+Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
+Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
+Signed-off-by: Kalyan Alle <kalyan.alle@amd.com>
+---
+ drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 7 +++++++
+ drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 1 +
+ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 7 +++++--
+ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 1 +
+ drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | 2 ++
+ drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 2 ++
+ drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 2 ++
+ drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 26 ++++++++++++++++++++++++++
+ 8 files changed, 46 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+index 74d05cc..bdffe43 100755
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+@@ -894,6 +894,13 @@ int amdgpu_bo_init(struct amdgpu_device *adev)
+ return amdgpu_ttm_init(adev);
+ }
+
++int amdgpu_bo_late_init(struct amdgpu_device *adev)
++{
++ amdgpu_ttm_late_init(adev);
++
++ return 0;
++}
++
+ void amdgpu_bo_fini(struct amdgpu_device *adev)
+ {
+ amdgpu_ttm_fini(adev);
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+index 92873fa..291477d 100755
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+@@ -262,6 +262,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
+ int amdgpu_bo_unpin(struct amdgpu_bo *bo);
+ int amdgpu_bo_evict_vram(struct amdgpu_device *adev);
+ int amdgpu_bo_init(struct amdgpu_device *adev);
++int amdgpu_bo_late_init(struct amdgpu_device *adev);
+ void amdgpu_bo_fini(struct amdgpu_device *adev);
+ int amdgpu_bo_fbdev_mmap(struct amdgpu_bo *bo,
+ struct vm_area_struct *vma);
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+index 53b0fcc..2f8d89f 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+@@ -1724,14 +1724,17 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
+ return 0;
+ }
+
++void amdgpu_ttm_late_init(struct amdgpu_device *adev)
++{
++ amdgpu_bo_free_kernel(&adev->stolen_vga_memory, NULL, NULL);
++}
++
+ void amdgpu_ttm_fini(struct amdgpu_device *adev)
+ {
+ if (!adev->mman.initialized)
+ return;
+
+ amdgpu_ttm_debugfs_fini(adev);
+-
+- amdgpu_bo_free_kernel(&adev->stolen_vga_memory, NULL, NULL);
+ amdgpu_ttm_fw_reserve_vram_fini(adev);
+ if (adev->mman.aper_base_kaddr)
+ iounmap(adev->mman.aper_base_kaddr);
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
+index 9a364e7..265c3ed 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
+@@ -81,6 +81,7 @@ uint64_t amdgpu_vram_mgr_usage(struct ttm_mem_type_manager *man);
+ uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_mem_type_manager *man);
+
+ int amdgpu_ttm_init(struct amdgpu_device *adev);
++void amdgpu_ttm_late_init(struct amdgpu_device *adev);
+ void amdgpu_ttm_fini(struct amdgpu_device *adev);
+ void amdgpu_ttm_set_buffer_funcs_status(struct amdgpu_device *adev,
+ bool enable);
+diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
+index ef77f79..1170699 100644
+--- a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
++++ b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
+@@ -818,6 +818,8 @@ static int gmc_v6_0_late_init(void *handle)
+ {
+ struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+
++ amdgpu_bo_late_init(adev);
++
+ if (amdgpu_vm_fault_stop != AMDGPU_VM_FAULT_STOP_ALWAYS)
+ return amdgpu_irq_get(adev, &adev->gmc.vm_fault, 0);
+ else
+diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
+index cee1aec..22707a4 100644
+--- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
++++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
+@@ -960,6 +960,8 @@ static int gmc_v7_0_late_init(void *handle)
+ {
+ struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+
++ amdgpu_bo_late_init(adev);
++
+ if (amdgpu_vm_fault_stop != AMDGPU_VM_FAULT_STOP_ALWAYS)
+ return amdgpu_irq_get(adev, &adev->gmc.vm_fault, 0);
+ else
+diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
+index 67f9b74..2829ae8 100644
+--- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
++++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
+@@ -1055,6 +1055,8 @@ static int gmc_v8_0_late_init(void *handle)
+ {
+ struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+
++ amdgpu_bo_late_init(adev);
++
+ if (amdgpu_vm_fault_stop != AMDGPU_VM_FAULT_STOP_ALWAYS)
+ return amdgpu_irq_get(adev, &adev->gmc.vm_fault, 0);
+ else
+diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
+index 315045a..263d3ab 100644
+--- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
++++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
+@@ -664,6 +664,11 @@ static int gmc_v9_0_late_init(void *handle)
+ unsigned i;
+ int r;
+
++ /*
++ * TODO - Uncomment once GART corruption issue is fixed.
++ */
++ /* amdgpu_bo_late_init(adev); */
++
+ for(i = 0; i < adev->num_rings; ++i) {
+ struct amdgpu_ring *ring = adev->rings[i];
+ unsigned vmhub = ring->funcs->vmhub;
+@@ -804,6 +809,13 @@ static unsigned gmc_v9_0_get_vbios_fb_size(struct amdgpu_device *adev)
+ u32 d1vga_control = RREG32_SOC15(DCE, 0, mmD1VGA_CONTROL);
+ unsigned size;
+
++ /*
++ * TODO Remove once GART corruption is resolved
++ * Check related code in gmc_v9_0_sw_fini
++ * */
++ size = 9 * 1024 * 1024;
++
++#if 0
+ if (REG_GET_FIELD(d1vga_control, D1VGA_CONTROL, D1VGA_MODE_ENABLE)) {
+ size = 9 * 1024 * 1024; /* reserve 8MB for vga emulator and 1 MB for FB */
+ } else {
+@@ -831,6 +843,8 @@ static unsigned gmc_v9_0_get_vbios_fb_size(struct amdgpu_device *adev)
+ /* return 0 if the pre-OS buffer uses up most of vram */
+ if ((adev->gmc.real_vram_size - size) < (8 * 1024 * 1024))
+ return 0;
++
++#endif
+ return size;
+ }
+
+@@ -953,6 +967,18 @@ static int gmc_v9_0_sw_fini(void *handle)
+ amdgpu_gem_force_release(adev);
+ amdgpu_vm_manager_fini(adev);
+ gmc_v9_0_gart_fini(adev);
++
++ /*
++ * TODO:
++ * Currently there is a bug where some memory client outside
++ * of the driver writes to first 8M of VRAM on S3 resume,
++ * this overrides GART which by default gets placed in first 8M and
++ * causes VM_FAULTS once GTT is accessed.
++ * Keep the stolen memory reservation until the while this is not solved.
++ * Also check code in gmc_v9_0_get_vbios_fb_size and gmc_v9_0_late_init
++ */
++ amdgpu_bo_free_kernel(&adev->stolen_vga_memory, NULL, NULL);
++
+ amdgpu_bo_fini(adev);
+
+ return 0;
+--
+2.7.4
+