Skip to contentSkip to conversation

drm/amd: Fail initialization earlier when DC is disabled

PATCH In review Mario Limonciello 2 participants 2 messages Mar 6, 2025 – Mar 7, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 drm/amd: Fail initialization earlier when DC is disabled

Modern APU and dGPU require DC support to be able to light up the display. If DC support has been disabled either by kernel config or by kernel command line the screen will visibly freeze when the driver finishes early init.

As it's known before early init is done whether DC support is required detect this during discovery and bail if DC support was disabled for any reason. This will ensure that the existing framebuffer provided by efifb or simpledrm keeps working.

---
v3:
* Use amdgpu_device_asic_has_dc_support() instead to cover virtual displays and bringup
v2:
* Update commit message justification
* Add correct "default" handling

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 49 ++++++++++++++-----
 1 file changed, 36 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +36 -13
index a4258127083d0..ddd10e6345601 100644
@@ -2134,15 +2134,14 @@ static void amdgpu_discovery_set_sriov_display(struct amdgpu_device *adev)
 
 static int amdgpu_discovery_set_display_ip_blocks(struct amdgpu_device *adev)
 {
+	bool asic_support;
+
 	if (adev->enable_virtual_display) {
 		amdgpu_device_ip_block_add(adev, &amdgpu_vkms_ip_block);
 		return 0;
 	}
 
-	if (!amdgpu_device_has_dc_support(adev))
-		return 0;
-
-#if defined(CONFIG_DRM_AMD_DC)
+	asic_support = amdgpu_device_asic_has_dc_support(adev->asic_type);
 	if (amdgpu_ip_version(adev, DCE_HWIP, 0)) {
 		switch (amdgpu_ip_version(adev, DCE_HWIP, 0)) {
 		case IP_VERSION(1, 0, 0):
@@ -2166,39 +2165,63 @@ static int amdgpu_discovery_set_display_ip_blocks(struct amdgpu_device *adev)
 		case IP_VERSION(3, 5, 1):
 		case IP_VERSION(3, 6, 0):
 		case IP_VERSION(4, 1, 0):
+			if (!asic_support) {
+				dev_err(adev->dev,
+					"DC support is required for dm ip block(DCE_HWIP:0x%x)\n",
+					amdgpu_ip_version(adev, DCE_HWIP, 0));
+				return -EINVAL;
+			}
+
 			/* TODO: Fix IP version. DC code expects version 4.0.1 */
 			if (adev->ip_versions[DCE_HWIP][0] == IP_VERSION(4, 1, 0))
 				adev->ip_versions[DCE_HWIP][0] = IP_VERSION(4, 0, 1);
 
+#if defined(CONFIG_DRM_AMD_DC)
 			if (amdgpu_sriov_vf(adev))
 				amdgpu_discovery_set_sriov_display(adev);
 			else
 				amdgpu_device_ip_block_add(adev, &dm_ip_block);
 			break;
+#endif
 		default:
-			dev_err(adev->dev,
-				"Failed to add dm ip block(DCE_HWIP:0x%x)\n",
-				amdgpu_ip_version(adev, DCE_HWIP, 0));
-			return -EINVAL;
+			if (asic_support) {
+				dev_err(adev->dev,
+					"Failed to add dm ip block(DCE_HWIP:0x%x)\n",
+					amdgpu_ip_version(adev, DCE_HWIP, 0));
+				return -EINVAL;
+			}
+			return 0;
 		}
 	} else if (amdgpu_ip_version(adev, DCI_HWIP, 0)) {
 		switch (amdgpu_ip_version(adev, DCI_HWIP, 0)) {
 		case IP_VERSION(12, 0, 0):
 		case IP_VERSION(12, 0, 1):
 		case IP_VERSION(12, 1, 0):
+
+			if (!asic_support) {
+				dev_err(adev->dev,
+					"DC support is required for dm ip block(DCI_HWIP:0x%x)\n",
+					amdgpu_ip_version(adev, DCI_HWIP, 0));
+				return -EINVAL;
+			}
+
+#if defined(CONFIG_DRM_AMD_DC)
 			if (amdgpu_sriov_vf(adev))
 				amdgpu_discovery_set_sriov_display(adev);
 			else
 				amdgpu_device_ip_block_add(adev, &dm_ip_block);
 			break;
+#endif
 		default:
-			dev_err(adev->dev,
-				"Failed to add dm ip block(DCI_HWIP:0x%x)\n",
-				amdgpu_ip_version(adev, DCI_HWIP, 0));
-			return -EINVAL;
+			if (asic_support) {
+				dev_err(adev->dev,
+					"Failed to add dm ip block(DCI_HWIP:0x%x)\n",
+					amdgpu_ip_version(adev, DCI_HWIP, 0));
+				return -EINVAL;
+			}
+			return 0;
 		}
 	}
-#endif
 	return 0;
 }
 
Signature · 1 line
2.43.0
#1 lore raw
Quoted 28 lines · Mario Limonciello

Modern APU and dGPU require DC support to be able to light up the display. If DC support has been disabled either by kernel config or by kernel command line the screen will visibly freeze when the driver finishes early init.

As it's known before early init is done whether DC support is required detect this during discovery and bail if DC support was disabled for any reason. This will ensure that the existing framebuffer provided by efifb or simpledrm keeps working.

---
v3:
* Use amdgpu_device_asic_has_dc_support() instead to cover virtual displays and bringup
v2:
* Update commit message justification
* Add correct "default" handling

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 49 ++++++++++++++-----
 1 file changed, 36 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +0 -0
index a4258127083d0..ddd10e6345601 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c static void amdgpu_discovery_set_sriov_display(struct amdgpu_device *adev) · line 2142

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +2 -0
@@ -2134,15 +2134,14 @@ static void amdgpu_discovery_set_sriov_display(struct amdgpu_device *adev)
 
 static int amdgpu_discovery_set_display_ip_blocks(struct amdgpu_device *adev)
 {
+       bool asic_support;
+
        if (adev->enable_virtual_display) {
                amdgpu_device_ip_block_add(adev, &amdgpu_vkms_ip_block);
                return 0;
        }

I think this will break for chips with harvested DCN blocks. I think you need to return early here in that case. E.g.,

if (adev->harvest_ip_mask & AMD_HARVEST_IP_DMU_MASK)

    return 0;

Alex

Quoted 85 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +34 -14
-       if (!amdgpu_device_has_dc_support(adev))
-               return 0;
-
-#if defined(CONFIG_DRM_AMD_DC)
+       asic_support = amdgpu_device_asic_has_dc_support(adev->asic_type);
        if (amdgpu_ip_version(adev, DCE_HWIP, 0)) {
                switch (amdgpu_ip_version(adev, DCE_HWIP, 0)) {
                case IP_VERSION(1, 0, 0):
@@ -2166,39 +2165,63 @@ static int amdgpu_discovery_set_display_ip_blocks(struct amdgpu_device *adev)
                case IP_VERSION(3, 5, 1):
                case IP_VERSION(3, 6, 0):
                case IP_VERSION(4, 1, 0):
+                       if (!asic_support) {
+                               dev_err(adev->dev,
+                                       "DC support is required for dm ip block(DCE_HWIP:0x%x)\n",
+                                       amdgpu_ip_version(adev, DCE_HWIP, 0));
+                               return -EINVAL;
+                       }
+
                        /* TODO: Fix IP version. DC code expects version 4.0.1 */
                        if (adev->ip_versions[DCE_HWIP][0] == IP_VERSION(4, 1, 0))
                                adev->ip_versions[DCE_HWIP][0] = IP_VERSION(4, 0, 1);
 
+#if defined(CONFIG_DRM_AMD_DC)
                        if (amdgpu_sriov_vf(adev))
                                amdgpu_discovery_set_sriov_display(adev);
                        else
                                amdgpu_device_ip_block_add(adev, &dm_ip_block);
                        break;
+#endif
                default:
-                       dev_err(adev->dev,
-                               "Failed to add dm ip block(DCE_HWIP:0x%x)\n",
-                               amdgpu_ip_version(adev, DCE_HWIP, 0));
-                       return -EINVAL;
+                       if (asic_support) {
+                               dev_err(adev->dev,
+                                       "Failed to add dm ip block(DCE_HWIP:0x%x)\n",
+                                       amdgpu_ip_version(adev, DCE_HWIP, 0));
+                               return -EINVAL;
+                       }
+                       return 0;
                }
        } else if (amdgpu_ip_version(adev, DCI_HWIP, 0)) {
                switch (amdgpu_ip_version(adev, DCI_HWIP, 0)) {
                case IP_VERSION(12, 0, 0):
                case IP_VERSION(12, 0, 1):
                case IP_VERSION(12, 1, 0):
+
+                       if (!asic_support) {
+                               dev_err(adev->dev,
+                                       "DC support is required for dm ip block(DCI_HWIP:0x%x)\n",
+                                       amdgpu_ip_version(adev, DCI_HWIP, 0));
+                               return -EINVAL;
+                       }
+
+#if defined(CONFIG_DRM_AMD_DC)
                        if (amdgpu_sriov_vf(adev))
                                amdgpu_discovery_set_sriov_display(adev);
                        else
                                amdgpu_device_ip_block_add(adev, &dm_ip_block);
                        break;
+#endif
                default:
-                       dev_err(adev->dev,
-                               "Failed to add dm ip block(DCI_HWIP:0x%x)\n",
-                               amdgpu_ip_version(adev, DCI_HWIP, 0));
-                       return -EINVAL;
+                       if (asic_support) {
+                               dev_err(adev->dev,
+                                       "Failed to add dm ip block(DCI_HWIP:0x%x)\n",
+                                       amdgpu_ip_version(adev, DCI_HWIP, 0));
+                               return -EINVAL;
+                       }
+                       return 0;
                }
        }
-#endif
        return 0;
 }
 
--

2.43.0