drm/amdgpu: Fix NULL pointer when ta is missing
authorxinhui pan <xinhui.pan@amd.com>
Mon, 11 Mar 2019 04:17:14 +0000 (12:17 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 19 Mar 2019 20:36:51 +0000 (15:36 -0500)
Ta is optional, so check if ta firmware is loaded or not.

Signed-off-by: xinhui pan <xinhui.pan@amd.com>
Reviewed-by: Evan Quan <evan.quan@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c

index 7e3e1d588d748552ef2252f0a7cffc5e0dfa22c8..32388b5218e90190acc00d85c59c728124f466cf 100644 (file)
@@ -707,10 +707,13 @@ static int psp_hw_start(struct psp_context *psp)
                                "XGMI: Failed to initialize XGMI session\n");
        }
 
-       ret = psp_ras_initialize(psp);
-       if (ret)
-               dev_err(psp->adev->dev,
-                               "RAS: Failed to initialize RAS\n");
+
+       if (psp->adev->psp.ta_fw) {
+               ret = psp_ras_initialize(psp);
+               if (ret)
+                       dev_err(psp->adev->dev,
+                                       "RAS: Failed to initialize RAS\n");
+       }
 
        return 0;
 }
@@ -963,7 +966,8 @@ static int psp_hw_fini(void *handle)
            psp->xgmi_context.initialized == 1)
                 psp_xgmi_terminate(psp);
 
-       psp_ras_terminate(psp);
+       if (psp->adev->psp.ta_fw)
+               psp_ras_terminate(psp);
 
        psp_ring_destroy(psp, PSP_RING_TYPE__KM);
 
@@ -998,10 +1002,12 @@ static int psp_suspend(void *handle)
                }
        }
 
-       ret = psp_ras_terminate(psp);
-       if (ret) {
-               DRM_ERROR("Failed to terminate ras ta\n");
-               return ret;
+       if (psp->adev->psp.ta_fw) {
+               ret = psp_ras_terminate(psp);
+               if (ret) {
+                       DRM_ERROR("Failed to terminate ras ta\n");
+                       return ret;
+               }
        }
 
        ret = psp_ring_stop(psp, PSP_RING_TYPE__KM);