OSDN Git Service

drm/amdgpu: only hw fini SMU fisrt for ASICs need that
authorLang Yu <lang.yu@amd.com>
Fri, 3 Dec 2021 06:30:16 +0000 (14:30 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 13 Dec 2021 21:32:35 +0000 (16:32 -0500)
We found some headaches on ASICs don't need that,
so remove that for them.

Suggested-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Lang Yu <lang.yu@amd.com>
Reviewed-by: Kevin Wang <kevinyang.wang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

index d9de928..15e3f44 100644 (file)
@@ -2657,6 +2657,36 @@ static int amdgpu_device_ip_late_init(struct amdgpu_device *adev)
        return 0;
 }
 
+/**
+ * amdgpu_device_smu_fini_early - smu hw_fini wrapper
+ *
+ * @adev: amdgpu_device pointer
+ *
+ * For ASICs need to disable SMC first
+ */
+static void amdgpu_device_smu_fini_early(struct amdgpu_device *adev)
+{
+       int i, r;
+
+       if (adev->ip_versions[GC_HWIP][0] > IP_VERSION(9, 0, 0))
+               return;
+
+       for (i = 0; i < adev->num_ip_blocks; i++) {
+               if (!adev->ip_blocks[i].status.hw)
+                       continue;
+               if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_SMC) {
+                       r = adev->ip_blocks[i].version->funcs->hw_fini((void *)adev);
+                       /* XXX handle errors */
+                       if (r) {
+                               DRM_DEBUG("hw_fini of IP block <%s> failed %d\n",
+                                         adev->ip_blocks[i].version->funcs->name, r);
+                       }
+                       adev->ip_blocks[i].status.hw = false;
+                       break;
+               }
+       }
+}
+
 static int amdgpu_device_ip_fini_early(struct amdgpu_device *adev)
 {
        int i, r;
@@ -2677,21 +2707,8 @@ static int amdgpu_device_ip_fini_early(struct amdgpu_device *adev)
        amdgpu_device_set_pg_state(adev, AMD_PG_STATE_UNGATE);
        amdgpu_device_set_cg_state(adev, AMD_CG_STATE_UNGATE);
 
-       /* need to disable SMC first */
-       for (i = 0; i < adev->num_ip_blocks; i++) {
-               if (!adev->ip_blocks[i].status.hw)
-                       continue;
-               if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_SMC) {
-                       r = adev->ip_blocks[i].version->funcs->hw_fini((void *)adev);
-                       /* XXX handle errors */
-                       if (r) {
-                               DRM_DEBUG("hw_fini of IP block <%s> failed %d\n",
-                                         adev->ip_blocks[i].version->funcs->name, r);
-                       }
-                       adev->ip_blocks[i].status.hw = false;
-                       break;
-               }
-       }
+       /* Workaroud for ASICs need to disable SMC first */
+       amdgpu_device_smu_fini_early(adev);
 
        for (i = adev->num_ip_blocks - 1; i >= 0; i--) {
                if (!adev->ip_blocks[i].status.hw)