Skip to contentSkip to conversation

drm/amd: Disable S/G for APUs when 64GB or more host memory

PATCH Superseded Mario Limonciello 2 participants 4 messages Jul 27, 2023

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/amd: Disable S/G for APUs when 64GB or more host memory

Users report a white flickering screen on multiple systems that is tied to having 64GB or more memory. When S/G is enabled pages will get pinned to both VRAM carve out and system RAM leading to this.

Until it can be fixed properly, disable S/G when 64GB of memory or more is detected. This will force pages to be pinned into VRAM. This should fix white screen flickers but if VRAM pressure is encountered may lead to black screens. It's a trade-off for now.

Fixes 81d0bcf990093 ("drm/amdgpu: make display pinning more flexible (v2)")
Cc Hamza Mahfooz <[email protected]>
Cc Roman Li <[email protected]>
Cc <[email protected]> # 6.1.y: bf0207e172703 ("drm/amdgpu: add S/G display parameter")
Cc <[email protected]> # 6.4.y

---
v1->v2:
* Fix updating mode_info as well

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h           |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    | 25 +++++++++++++++++++
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  5 ++--
 3 files changed, 28 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index 93d0f4c7b560e..2e3c7c15cb8e3 100644
@@ -1313,6 +1313,7 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
 void amdgpu_device_pci_config_reset(struct amdgpu_device *adev);
 int amdgpu_device_pci_reset(struct amdgpu_device *adev);
 bool amdgpu_device_need_post(struct amdgpu_device *adev);
+bool amdgpu_sg_display_supported(struct amdgpu_device *adev);
 bool amdgpu_device_pcie_dynamic_switching_supported(void);
 bool amdgpu_device_should_use_aspm(struct amdgpu_device *adev);
 bool amdgpu_device_aspm_support_quirk(void);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +25 -0
index dc0e5227119b1..a4e36b178d86c 100644
@@ -1296,6 +1296,31 @@ bool amdgpu_device_need_post(struct amdgpu_device *adev)
 	return true;
 }
 
+/*
+ * On APUs with >= 64GB white flickering has been observed w/ SG enabled.
+ * Disable S/G on such systems until we have a proper fix.
+ * https://gitlab.freedesktop.org/drm/amd/-/issues/2354
+ * https://gitlab.freedesktop.org/drm/amd/-/issues/2735
+ */
+bool amdgpu_sg_display_supported(struct amdgpu_device *adev)
+{
+	switch (amdgpu_sg_display) {
+	case -1:
+		break;
+	case 0:
+		return false;
+	case 1:
+		return true;
+	default:
+		return false;
+	}
+	if (totalram_pages() << (PAGE_SHIFT - 10) >= 64000000) {
+		DRM_WARN("Disabling S/G due to >=64GB RAM\n");
+		return false;
+	}
+	return true;
+}
+
 /*
  * Intel hosts such as Raptor Lake and Sapphire Rapids don't support dynamic
  * speed switching. Until we have confirmation from Intel that a specific host
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -3
index 77d970a2ee693..26c3eb7a9f882 100644
@@ -1639,9 +1639,8 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
 		}
 		break;
 	}
-	if (init_data.flags.gpu_vm_support &&
-	    (amdgpu_sg_display == 0))
-		init_data.flags.gpu_vm_support = false;
+	if (init_data.flags.gpu_vm_support)
+		init_data.flags.gpu_vm_support = amdgpu_sg_display_supported(adev);
 
 	if (init_data.flags.gpu_vm_support)
 		adev->mode_info.gpu_vm_support = true;
Signature · 1 line
2.25.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 57 lines · Mario Limonciello

Users report a white flickering screen on multiple systems that is tied to having 64GB or more memory. When S/G is enabled pages will get pinned to both VRAM carve out and system RAM leading to this.

Until it can be fixed properly, disable S/G when 64GB of memory or more is detected. This will force pages to be pinned into VRAM. This should fix white screen flickers but if VRAM pressure is encountered may lead to black screens. It's a trade-off for now.

Fixes 81d0bcf990093 ("drm/amdgpu: make display pinning more flexible (v2)")
Cc Hamza Mahfooz <[email protected]>
Cc Roman Li <[email protected]>
Cc <[email protected]> # 6.1.y: bf0207e172703 ("drm/amdgpu: add S/G display parameter")
Cc <[email protected]> # 6.4.y

---
v1->v2:
* Fix updating mode_info as well

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h           |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    | 25 +++++++++++++++++++
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  5 ++--
 3 files changed, 28 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index 93d0f4c7b560e..2e3c7c15cb8e3 100644
@@ -1313,6 +1313,7 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
 void amdgpu_device_pci_config_reset(struct amdgpu_device *adev);
 int amdgpu_device_pci_reset(struct amdgpu_device *adev);
 bool amdgpu_device_need_post(struct amdgpu_device *adev);
+bool amdgpu_sg_display_supported(struct amdgpu_device *adev);
 bool amdgpu_device_pcie_dynamic_switching_supported(void);
 bool amdgpu_device_should_use_aspm(struct amdgpu_device *adev);
 bool amdgpu_device_aspm_support_quirk(void);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +9 -0
index dc0e5227119b1..a4e36b178d86c 100644
@@ -1296,6 +1296,31 @@ bool amdgpu_device_need_post(struct amdgpu_device *adev)
        return true;
 }
 
+/*
+ * On APUs with >= 64GB white flickering has been observed w/ SG enabled.
+ * Disable S/G on such systems until we have a proper fix.
+ * https://gitlab.freedesktop.org/drm/amd/-/issues/2354
+ * https://gitlab.freedesktop.org/drm/amd/-/issues/2735
+ */
+bool amdgpu_sg_display_supported(struct amdgpu_device *adev)
+{
+       switch (amdgpu_sg_display) {

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c bool amdgpu_device_need_post(struct amdgpu_device *adev) · line 1317

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +10 -0
+       case -1:
+               break;
+       case 0:
+               return false;
+       case 1:
+               return true;
+       default:
+               return false;
+       }
+       if (totalram_pages() << (PAGE_SHIFT - 10) >= 64000000) {

Does totalram_pages() return the amount of physical ram or the amount of usable ram (i.e., minus carveout, firmware reservations, etc.)? Assuming it does the right thing here:

Quoted 28 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -0
+               DRM_WARN("Disabling S/G due to >=64GB RAM\n");
+               return false;
+       }
+       return true;
+}
+
 /*
  * Intel hosts such as Raptor Lake and Sapphire Rapids don't support dynamic
  * speed switching. Until we have confirmation from Intel that a specific host
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -4
index 77d970a2ee693..26c3eb7a9f882 100644
@@ -1639,9 +1639,8 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
                }
                break;
        }
-       if (init_data.flags.gpu_vm_support &&
-           (amdgpu_sg_display == 0))
-               init_data.flags.gpu_vm_support = false;
+       if (init_data.flags.gpu_vm_support)
+               init_data.flags.gpu_vm_support = amdgpu_sg_display_supported(adev);
 
        if (init_data.flags.gpu_vm_support)
                adev->mode_info.gpu_vm_support = true;
--

2.25.1

#2 lore raw
Quoted 64 lines · Alex Deucher
Quoted 62 lines · Mario Limonciello

Users report a white flickering screen on multiple systems that is tied to having 64GB or more memory. When S/G is enabled pages will get pinned to both VRAM carve out and system RAM leading to this.

Until it can be fixed properly, disable S/G when 64GB of memory or more is detected. This will force pages to be pinned into VRAM. This should fix white screen flickers but if VRAM pressure is encountered may lead to black screens. It's a trade-off for now.

Fixes 81d0bcf990093 ("drm/amdgpu: make display pinning more flexible (v2)")
Cc Hamza Mahfooz <[email protected]>
Cc Roman Li <[email protected]>
Cc <[email protected]> # 6.1.y: bf0207e172703 ("drm/amdgpu: add S/G display parameter")
Cc <[email protected]> # 6.4.y

---
v1->v2:
* Fix updating mode_info as well

---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h           |  1 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    | 25 +++++++++++++++++++
  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  5 ++--
  3 files changed, 28 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index 93d0f4c7b560e..2e3c7c15cb8e3 100644
@@ -1313,6 +1313,7 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
  void amdgpu_device_pci_config_reset(struct amdgpu_device *adev);
  int amdgpu_device_pci_reset(struct amdgpu_device *adev);
  bool amdgpu_device_need_post(struct amdgpu_device *adev);
+bool amdgpu_sg_display_supported(struct amdgpu_device *adev);
  bool amdgpu_device_pcie_dynamic_switching_supported(void);
  bool amdgpu_device_should_use_aspm(struct amdgpu_device *adev);
  bool amdgpu_device_aspm_support_quirk(void);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +14 -0
index dc0e5227119b1..a4e36b178d86c 100644
@@ -1296,6 +1296,31 @@ bool amdgpu_device_need_post(struct amdgpu_device *adev)
         return true;
  }
 
+/*
+ * On APUs with >= 64GB white flickering has been observed w/ SG enabled.
+ * Disable S/G on such systems until we have a proper fix.
+ * https://gitlab.freedesktop.org/drm/amd/-/issues/2354
+ * https://gitlab.freedesktop.org/drm/amd/-/issues/2735
+ */
+bool amdgpu_sg_display_supported(struct amdgpu_device *adev)
+{
+       switch (amdgpu_sg_display) {
+       case -1:
+               break;
+       case 0:
+               return false;
+       case 1:
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c bool amdgpu_device_need_post(struct amdgpu_device *adev) · line 1317

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5 -0
+               return true;
+       default:
+               return false;
+       }
+       if (totalram_pages() << (PAGE_SHIFT - 10) >= 64000000) {

Does totalram_pages() return the amount of physical ram or the amount of usable ram (i.e., minus carveout, firmware reservations, etc.)?

It's a good question. I don't have a system w/ 64GB in front of me so I just double checked on a Phoenix system that has 16GB soldered down.

It returns 15520248, so it's missing the VRAM carveout. amdgpu does know this already via adev->gmc.real_vram_size. So I think the logic should be:

if ((totalram_pages() << (PAGE_SHIFT - 10)) + (adev->gmc.real_vram_size / 1024) >= 64000000)

That should bring it to ~16GB.

Quoted 32 lines

Assuming it does the right thing here:

Quoted 28 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -0
+               DRM_WARN("Disabling S/G due to >=64GB RAM\n");
+               return false;
+       }
+       return true;
+}
+
  /*
   * Intel hosts such as Raptor Lake and Sapphire Rapids don't support dynamic
   * speed switching. Until we have confirmation from Intel that a specific host
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -4
index 77d970a2ee693..26c3eb7a9f882 100644
@@ -1639,9 +1639,8 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
                 }
                 break;
         }
-       if (init_data.flags.gpu_vm_support &&
-           (amdgpu_sg_display == 0))
-               init_data.flags.gpu_vm_support = false;
+       if (init_data.flags.gpu_vm_support)
+               init_data.flags.gpu_vm_support = amdgpu_sg_display_supported(adev);
 
         if (init_data.flags.gpu_vm_support)
                 adev->mode_info.gpu_vm_support = true;
--

2.25.1

#3 lore raw
Quoted 78 lines · Mario Limonciello
Quoted 64 lines · Alex Deucher
Quoted 62 lines · Mario Limonciello

Users report a white flickering screen on multiple systems that is tied to having 64GB or more memory. When S/G is enabled pages will get pinned to both VRAM carve out and system RAM leading to this.

Until it can be fixed properly, disable S/G when 64GB of memory or more is detected. This will force pages to be pinned into VRAM. This should fix white screen flickers but if VRAM pressure is encountered may lead to black screens. It's a trade-off for now.

Fixes 81d0bcf990093 ("drm/amdgpu: make display pinning more flexible (v2)")
Cc Hamza Mahfooz <[email protected]>
Cc Roman Li <[email protected]>
Cc <[email protected]> # 6.1.y: bf0207e172703 ("drm/amdgpu: add S/G display parameter")
Cc <[email protected]> # 6.4.y

---
v1->v2:
* Fix updating mode_info as well

---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h           |  1 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    | 25 +++++++++++++++++++
  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  5 ++--
  3 files changed, 28 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index 93d0f4c7b560e..2e3c7c15cb8e3 100644
@@ -1313,6 +1313,7 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
  void amdgpu_device_pci_config_reset(struct amdgpu_device *adev);
  int amdgpu_device_pci_reset(struct amdgpu_device *adev);
  bool amdgpu_device_need_post(struct amdgpu_device *adev);
+bool amdgpu_sg_display_supported(struct amdgpu_device *adev);
  bool amdgpu_device_pcie_dynamic_switching_supported(void);
  bool amdgpu_device_should_use_aspm(struct amdgpu_device *adev);
  bool amdgpu_device_aspm_support_quirk(void);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +14 -0
index dc0e5227119b1..a4e36b178d86c 100644
@@ -1296,6 +1296,31 @@ bool amdgpu_device_need_post(struct amdgpu_device *adev)
         return true;
  }
 
+/*
+ * On APUs with >= 64GB white flickering has been observed w/ SG enabled.
+ * Disable S/G on such systems until we have a proper fix.
+ * https://gitlab.freedesktop.org/drm/amd/-/issues/2354
+ * https://gitlab.freedesktop.org/drm/amd/-/issues/2735
+ */
+bool amdgpu_sg_display_supported(struct amdgpu_device *adev)
+{
+       switch (amdgpu_sg_display) {
+       case -1:
+               break;
+       case 0:
+               return false;
+       case 1:
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c bool amdgpu_device_need_post(struct amdgpu_device *adev) · line 1317

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5 -0
+               return true;
+       default:
+               return false;
+       }
+       if (totalram_pages() << (PAGE_SHIFT - 10) >= 64000000) {

Does totalram_pages() return the amount of physical ram or the amount of usable ram (i.e., minus carveout, firmware reservations, etc.)?

It's a good question. I don't have a system w/ 64GB in front of me so I just double checked on a Phoenix system that has 16GB soldered down.

Quoted 8 lines

It returns 15520248, so it's missing the VRAM carveout. amdgpu does know this already via adev->gmc.real_vram_size.
So I think the logic should be:

if ((totalram_pages() << (PAGE_SHIFT - 10)) + (adev->gmc.real_vram_size / 1024) >= 64000000)

That should bring it to ~16GB.

Yeah, that's probably good enough.

Alex

Quoted 34 lines
Quoted 33 lines

Assuming it does the right thing here:

Quoted 28 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -0
+               DRM_WARN("Disabling S/G due to >=64GB RAM\n");
+               return false;
+       }
+       return true;
+}
+
  /*
   * Intel hosts such as Raptor Lake and Sapphire Rapids don't support dynamic
   * speed switching. Until we have confirmation from Intel that a specific host
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -4
index 77d970a2ee693..26c3eb7a9f882 100644
@@ -1639,9 +1639,8 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
                 }
                 break;
         }
-       if (init_data.flags.gpu_vm_support &&
-           (amdgpu_sg_display == 0))
-               init_data.flags.gpu_vm_support = false;
+       if (init_data.flags.gpu_vm_support)
+               init_data.flags.gpu_vm_support = amdgpu_sg_display_supported(adev);
 
         if (init_data.flags.gpu_vm_support)
                 adev->mode_info.gpu_vm_support = true;
--

2.25.1