[PATCH 0/2] [SRU][B/OEM] drm/amdgpu: Fix screen corruption on Stoney Ridge

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 0/2] [SRU][B/OEM] drm/amdgpu: Fix screen corruption on Stoney Ridge

Timo Aaltonen-6
From: Timo Aaltonen <[hidden email]>

BugLink: https://launchpad.net/bugs/1818617

These backported commits fix screen corruption in certain scenarios on AMD Stoney Ridge,
and should be applied to bionic and OEM kernel.

Alex Deucher (1):
  drm/amdgpu/gmc: steal the appropriate amount of vram for fw hand-over
    (v3)

Andrey Grodzovsky (1):
  drm/amdgpu: Free VGA stolen memory as soon as possible.

 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    | 27 ++++----
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h    |  1 +
 drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c      | 25 ++++++-
 drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c      | 25 ++++++-
 drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c      | 25 ++++++-
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c      | 79 ++++++++++++++++++++--
 8 files changed, 164 insertions(+), 26 deletions(-)

--
2.20.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 1/2] drm/amdgpu/gmc: steal the appropriate amount of vram for fw hand-over (v3)

Timo Aaltonen-6
From: Alex Deucher <[hidden email]>

BugLink: https://launchpad.net/bugs/1818617

Steal 9 MB for vga emulation and fb if vga is enabled, otherwise,
steal enough to cover the current display size as set by the vbios.

If no memory is used (e.g., secondary or headless card), skip
stolen memory reserve.

v2: skip reservation if vram is limited, address Christian's comments
v3: squash in fix from Harry

Reviewed-and-Tested-by: Andrey Grodzovsky <[hidden email]> (v2)
Signed-off-by: Alex Deucher <[hidden email]>
(cherry picked from commit ebdef28ebbcf767d9fa687acb1d02d97d834c628)
Signed-off-by: Timo Aaltonen <[hidden email]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 14 ++++---
 drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c   | 23 ++++++++++-
 drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c   | 23 ++++++++++-
 drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c   | 23 ++++++++++-
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c   | 53 ++++++++++++++++++++++---
 5 files changed, 118 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index ad5bf86ee8a3..8383529f4296 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1339,12 +1339,14 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
  return r;
  }
 
- r = amdgpu_bo_create_kernel(adev, adev->mc.stolen_size, PAGE_SIZE,
-    AMDGPU_GEM_DOMAIN_VRAM,
-    &adev->stolen_vga_memory,
-    NULL, NULL);
- if (r)
- return r;
+ if (adev->mc.stolen_size) {
+ r = amdgpu_bo_create_kernel(adev, adev->mc.stolen_size, PAGE_SIZE,
+    AMDGPU_GEM_DOMAIN_VRAM,
+    &adev->stolen_vga_memory,
+    NULL, NULL);
+ if (r)
+ return r;
+ }
  DRM_INFO("amdgpu: %uM of VRAM memory ready\n",
  (unsigned) (adev->mc.real_vram_size / (1024 * 1024)));
 
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
index f4603a7c8ef3..53c8c7554504 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
@@ -809,6 +809,25 @@ static int gmc_v6_0_late_init(void *handle)
  return 0;
 }
 
+static unsigned gmc_v6_0_get_vbios_fb_size(struct amdgpu_device *adev)
+{
+ u32 d1vga_control = RREG32(mmD1VGA_CONTROL);
+ unsigned size;
+
+ 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 {
+ u32 viewport = RREG32(mmVIEWPORT_SIZE);
+ size = (REG_GET_FIELD(viewport, VIEWPORT_SIZE, VIEWPORT_HEIGHT) *
+ REG_GET_FIELD(viewport, VIEWPORT_SIZE, VIEWPORT_WIDTH) *
+ 4);
+ }
+ /* return 0 if the pre-OS buffer uses up most of vram */
+ if ((adev->mc.real_vram_size - size) < (8 * 1024 * 1024))
+ return 0;
+ return size;
+}
+
 static int gmc_v6_0_sw_init(void *handle)
 {
  int r;
@@ -836,8 +855,6 @@ static int gmc_v6_0_sw_init(void *handle)
 
  adev->mc.mc_mask = 0xffffffffffULL;
 
- adev->mc.stolen_size = 256 * 1024;
-
  adev->need_dma32 = false;
  dma_bits = adev->need_dma32 ? 32 : 40;
  r = pci_set_dma_mask(adev->pdev, DMA_BIT_MASK(dma_bits));
@@ -862,6 +879,8 @@ static int gmc_v6_0_sw_init(void *handle)
  if (r)
  return r;
 
+ adev->mc.stolen_size = gmc_v6_0_get_vbios_fb_size(adev);
+
  r = amdgpu_bo_init(adev);
  if (r)
  return r;
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
index b0528ca9207b..e257ae9f873f 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
@@ -944,6 +944,25 @@ static int gmc_v7_0_late_init(void *handle)
  return 0;
 }
 
+static unsigned gmc_v7_0_get_vbios_fb_size(struct amdgpu_device *adev)
+{
+ u32 d1vga_control = RREG32(mmD1VGA_CONTROL);
+ unsigned size;
+
+ 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 {
+ u32 viewport = RREG32(mmVIEWPORT_SIZE);
+ size = (REG_GET_FIELD(viewport, VIEWPORT_SIZE, VIEWPORT_HEIGHT) *
+ REG_GET_FIELD(viewport, VIEWPORT_SIZE, VIEWPORT_WIDTH) *
+ 4);
+ }
+ /* return 0 if the pre-OS buffer uses up most of vram */
+ if ((adev->mc.real_vram_size - size) < (8 * 1024 * 1024))
+ return 0;
+ return size;
+}
+
 static int gmc_v7_0_sw_init(void *handle)
 {
  int r;
@@ -979,8 +998,6 @@ static int gmc_v7_0_sw_init(void *handle)
  */
  adev->mc.mc_mask = 0xffffffffffULL; /* 40 bit MC */
 
- adev->mc.stolen_size = 256 * 1024;
-
  /* set DMA mask + need_dma32 flags.
  * PCIE - can handle 40-bits.
  * IGP - can handle 40-bits
@@ -1010,6 +1027,8 @@ static int gmc_v7_0_sw_init(void *handle)
  if (r)
  return r;
 
+ adev->mc.stolen_size = gmc_v7_0_get_vbios_fb_size(adev);
+
  /* Memory manager */
  r = amdgpu_bo_init(adev);
  if (r)
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
index f368cfe2f585..dd30741964db 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
@@ -1034,6 +1034,25 @@ static int gmc_v8_0_late_init(void *handle)
  return 0;
 }
 
+static unsigned gmc_v8_0_get_vbios_fb_size(struct amdgpu_device *adev)
+{
+ u32 d1vga_control = RREG32(mmD1VGA_CONTROL);
+ unsigned size;
+
+ 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 {
+ u32 viewport = RREG32(mmVIEWPORT_SIZE);
+ size = (REG_GET_FIELD(viewport, VIEWPORT_SIZE, VIEWPORT_HEIGHT) *
+ REG_GET_FIELD(viewport, VIEWPORT_SIZE, VIEWPORT_WIDTH) *
+ 4);
+ }
+ /* return 0 if the pre-OS buffer uses up most of vram */
+ if ((adev->mc.real_vram_size - size) < (8 * 1024 * 1024))
+ return 0;
+ return size;
+}
+
 #define mmMC_SEQ_MISC0_FIJI 0xA71
 
 static int gmc_v8_0_sw_init(void *handle)
@@ -1076,8 +1095,6 @@ static int gmc_v8_0_sw_init(void *handle)
  */
  adev->mc.mc_mask = 0xffffffffffULL; /* 40 bit MC */
 
- adev->mc.stolen_size = 256 * 1024;
-
  /* set DMA mask + need_dma32 flags.
  * PCIE - can handle 40-bits.
  * IGP - can handle 40-bits
@@ -1107,6 +1124,8 @@ static int gmc_v8_0_sw_init(void *handle)
  if (r)
  return r;
 
+ adev->mc.stolen_size = gmc_v8_0_get_vbios_fb_size(adev);
+
  /* Memory manager */
  r = amdgpu_bo_init(adev);
  if (r)
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
index 9737408b56f5..8a9b7e685033 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
@@ -56,6 +56,14 @@
 #define DF_CS_AON0_DramBaseAddress0__IntLvAddrSel_MASK                                                        0x00000700L
 #define DF_CS_AON0_DramBaseAddress0__DramBaseAddr_MASK                                                        0xFFFFF000L
 
+/* add these here since we already include dce12 headers and these are for DCN */
+#define mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION                                                          0x055d
+#define mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION_BASE_IDX                                                 2
+#define HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION__PRI_VIEWPORT_WIDTH__SHIFT                                        0x0
+#define HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION__PRI_VIEWPORT_HEIGHT__SHIFT                                       0x10
+#define HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION__PRI_VIEWPORT_WIDTH_MASK                                          0x00003FFFL
+#define HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION__PRI_VIEWPORT_HEIGHT_MASK                                         0x3FFF0000L
+
 /* XXX Move this macro to VEGA10 header file, which is like vid.h for VI.*/
 #define AMDGPU_NUM_OF_VMIDS 8
 
@@ -546,6 +554,43 @@ static int gmc_v9_0_gart_init(struct amdgpu_device *adev)
  return amdgpu_gart_table_vram_alloc(adev);
 }
 
+static unsigned gmc_v9_0_get_vbios_fb_size(struct amdgpu_device *adev)
+{
+#if 0
+ u32 d1vga_control = RREG32_SOC15(DCE, 0, mmD1VGA_CONTROL);
+#endif
+ unsigned size;
+
+ 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 {
+ u32 viewport;
+
+ switch (adev->asic_type) {
+ case CHIP_RAVEN:
+ viewport = RREG32_SOC15(DCE, 0, mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION);
+ size = (REG_GET_FIELD(viewport,
+      HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION, PRI_VIEWPORT_HEIGHT) *
+ REG_GET_FIELD(viewport,
+      HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION, PRI_VIEWPORT_WIDTH) *
+ 4);
+ break;
+ case CHIP_VEGA10:
+ case CHIP_VEGA12:
+ default:
+ viewport = RREG32_SOC15(DCE, 0, mmSCL0_VIEWPORT_SIZE);
+ size = (REG_GET_FIELD(viewport, SCL0_VIEWPORT_SIZE, VIEWPORT_HEIGHT) *
+ REG_GET_FIELD(viewport, SCL0_VIEWPORT_SIZE, VIEWPORT_WIDTH) *
+ 4);
+ break;
+ }
+ }
+ /* return 0 if the pre-OS buffer uses up most of vram */
+ if ((adev->mc.real_vram_size - size) < (8 * 1024 * 1024))
+ return 0;
+ return size;
+}
+
 static int gmc_v9_0_sw_init(void *handle)
 {
  int r;
@@ -610,12 +655,6 @@ static int gmc_v9_0_sw_init(void *handle)
  */
  adev->mc.mc_mask = 0xffffffffffffULL; /* 48 bit MC */
 
- /*
- * It needs to reserve 8M stolen memory for vega10
- * TODO: Figure out how to avoid that...
- */
- adev->mc.stolen_size = 8 * 1024 * 1024;
-
  /* set DMA mask + need_dma32 flags.
  * PCIE - can handle 44-bits.
  * IGP - can handle 44-bits
@@ -639,6 +678,8 @@ static int gmc_v9_0_sw_init(void *handle)
  if (r)
  return r;
 
+ adev->mc.stolen_size = gmc_v9_0_get_vbios_fb_size(adev);
+
  /* Memory manager */
  r = amdgpu_bo_init(adev);
  if (r)
--
2.20.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 2/2] drm/amdgpu: Free VGA stolen memory as soon as possible.

Timo Aaltonen-6
In reply to this post by Timo Aaltonen-6
From: Andrey Grodzovsky <[hidden email]>

BugLink: https://launchpad.net/bugs/1818617

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 <[hidden email]>
Signed-off-by: Andrey Grodzovsky <[hidden email]>
Signed-off-by: Alex Deucher <[hidden email]>
(backported from commit 6f752ec2c20c6a575da29d5b297980f376830e6b)
Signed-off-by: Timo Aaltonen <[hidden email]>
---
 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    | 13 +++++------
 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(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 032179c79ce5..db99abe2ad4f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -786,6 +786,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 428aae048f4b..738b832d4ca3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -230,6 +230,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 8383529f4296..a2c5ac753c6d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1410,6 +1410,11 @@ 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)
 {
  int r;
@@ -1417,14 +1422,6 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)
  if (!adev->mman.initialized)
  return;
  amdgpu_ttm_debugfs_fini(adev);
- if (adev->stolen_vga_memory) {
- r = amdgpu_bo_reserve(adev->stolen_vga_memory, true);
- if (r == 0) {
- amdgpu_bo_unpin(adev->stolen_vga_memory);
- amdgpu_bo_unreserve(adev->stolen_vga_memory);
- }
- amdgpu_bo_unref(&adev->stolen_vga_memory);
- }
  ttm_bo_clean_mm(&adev->mman.bdev, TTM_PL_VRAM);
  ttm_bo_clean_mm(&adev->mman.bdev, TTM_PL_TT);
  if (adev->gds.mem.total_size)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
index 402b08368ead..f3d7baa6511b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
@@ -74,6 +74,7 @@ u64 amdgpu_vram_mgr_bo_invisible_size(struct amdgpu_bo *bo);
 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);
 
+void amdgpu_ttm_late_init(struct amdgpu_device *adev);
 int amdgpu_copy_buffer(struct amdgpu_ring *ring, uint64_t src_offset,
        uint64_t dst_offset, uint32_t byte_count,
        struct reservation_object *resv,
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
index 53c8c7554504..99cb3d727183 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
@@ -803,6 +803,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->mc.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 e257ae9f873f..f75f1eea13a1 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
@@ -938,6 +938,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->mc.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 dd30741964db..d0ac1bd7ccf5 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
@@ -1028,6 +1028,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->mc.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 8a9b7e685033..1a6eef9b1b70 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
@@ -412,6 +412,11 @@ static int gmc_v9_0_late_init(void *handle)
  unsigned vm_inv_eng[AMDGPU_MAX_VMHUBS] = { 4, 4 };
  unsigned i;
 
+ /*
+ * 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;
@@ -561,6 +566,13 @@ static unsigned gmc_v9_0_get_vbios_fb_size(struct amdgpu_device *adev)
 #endif
  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 {
@@ -588,6 +600,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->mc.real_vram_size - size) < (8 * 1024 * 1024))
  return 0;
+
+#endif
  return size;
 }
 
@@ -723,6 +737,18 @@ static int gmc_v9_0_sw_fini(void *handle)
  amdgpu_vm_manager_fini(adev);
  gmc_v9_0_gart_fini(adev);
  amdgpu_gem_force_release(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.20.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 0/2] [SRU][B/OEM] drm/amdgpu: Fix screen corruption on Stoney Ridge

Kleber Souza
In reply to this post by Timo Aaltonen-6
On 3/7/19 7:51 AM, Timo Aaltonen wrote:

> From: Timo Aaltonen <[hidden email]>
>
> BugLink: https://launchpad.net/bugs/1818617
>
> These backported commits fix screen corruption in certain scenarios on AMD Stoney Ridge,
> and should be applied to bionic and OEM kernel.
>
> Alex Deucher (1):
>   drm/amdgpu/gmc: steal the appropriate amount of vram for fw hand-over
>     (v3)
>
> Andrey Grodzovsky (1):
>   drm/amdgpu: Free VGA stolen memory as soon as possible.
>
>  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    | 27 ++++----
>  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h    |  1 +
>  drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c      | 25 ++++++-
>  drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c      | 25 ++++++-
>  drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c      | 25 ++++++-
>  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c      | 79 ++++++++++++++++++++--
>  8 files changed, 164 insertions(+), 26 deletions(-)
>

Hi Timo,

Can you please add a SRU template to the bug report?

Is this fix needed for bionic/linux as well?


Thanks,
Kleber

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 0/2] [SRU][B/OEM] drm/amdgpu: Fix screen corruption on Stoney Ridge

Timo Aaltonen-6
On 7.3.2019 20.08, Kleber Souza wrote:

> On 3/7/19 7:51 AM, Timo Aaltonen wrote:
>> From: Timo Aaltonen <[hidden email]>
>>
>> BugLink: https://launchpad.net/bugs/1818617
>>
>> These backported commits fix screen corruption in certain scenarios on AMD Stoney Ridge,
>> and should be applied to bionic and OEM kernel.
>>
>> Alex Deucher (1):
>>   drm/amdgpu/gmc: steal the appropriate amount of vram for fw hand-over
>>     (v3)
>>
>> Andrey Grodzovsky (1):
>>   drm/amdgpu: Free VGA stolen memory as soon as possible.
>>
>>  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    | 27 ++++----
>>  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h    |  1 +
>>  drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c      | 25 ++++++-
>>  drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c      | 25 ++++++-
>>  drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c      | 25 ++++++-
>>  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c      | 79 ++++++++++++++++++++--
>>  8 files changed, 164 insertions(+), 26 deletions(-)
>>
>
> Hi Timo,
>
> Can you please add a SRU template to the bug report?

Done.

> Is this fix needed for bionic/linux as well?

Yes, that's what the 'B' stood for, though the bug didn't have 'linux'
listed, fixed that now.


--
t

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

APPLIED/OEM: Re: [PATCH 0/2] [SRU][B/OEM] drm/amdgpu: Fix screen corruption on Stoney Ridge

Timo Aaltonen-6
In reply to this post by Timo Aaltonen-6
On 7.3.2019 8.51, Timo Aaltonen wrote:
> From: Timo Aaltonen <[hidden email]>
>
> BugLink: https://launchpad.net/bugs/1818617
>
> These backported commits fix screen corruption in certain scenarios on AMD Stoney Ridge,
> and should be applied to bionic and OEM kernel.

no ack's for oem, but couldn't wait longer, applied to oem-next


--
t

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team