]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/amd/powerplay: pre-check the SMU state before issuing message
authorEvan Quan <evan.quan@amd.com>
Wed, 4 Dec 2019 09:29:52 +0000 (17:29 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 9 Dec 2019 22:05:17 +0000 (17:05 -0500)
Abort the message issuing if the SMU was not in the right state.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Reviewed-by: Kenneth Feng <kenneth.feng@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/smu_v11_0.c
drivers/gpu/drm/amd/powerplay/smu_v12_0.c

index eae3657cf1f386921b4f21c3def5588fac8b4f07..f5469ad4392975011d23dac141ecaf1c6d1240f1 100644 (file)
@@ -80,15 +80,13 @@ static int smu_v11_0_wait_for_response(struct smu_context *smu)
        for (i = 0; i < timeout; i++) {
                cur_value = RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90);
                if ((cur_value & MP1_C2PMSG_90__CONTENT_MASK) != 0)
-                       break;
+                       return cur_value == 0x1 ? 0 : -EIO;
+
                udelay(1);
        }
 
        /* timeout means wrong logic */
-       if (i == timeout)
-               return -ETIME;
-
-       return RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90) == 0x1 ? 0 : -EIO;
+       return -ETIME;
 }
 
 int
@@ -104,9 +102,11 @@ smu_v11_0_send_msg_with_param(struct smu_context *smu,
                return index;
 
        ret = smu_v11_0_wait_for_response(smu);
-       if (ret)
-               pr_err("failed send message: %10s (%d) \tparam: 0x%08x response %#x\n",
-                      smu_get_message_name(smu, msg), index, param, ret);
+       if (ret) {
+               pr_err("Msg issuing pre-check failed and "
+                      "SMU may be not in the right state!\n");
+               return ret;
+       }
 
        WREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90, 0);
 
index 269a7d73b58d7ba5e108d5b41dabf19558a6d05e..951aa4570a04105c3f8af554e723567973fcb686 100644 (file)
@@ -66,15 +66,13 @@ int smu_v12_0_wait_for_response(struct smu_context *smu)
        for (i = 0; i < adev->usec_timeout; i++) {
                cur_value = RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90);
                if ((cur_value & MP1_C2PMSG_90__CONTENT_MASK) != 0)
-                       break;
+                       return cur_value == 0x1 ? 0 : -EIO;
+
                udelay(1);
        }
 
        /* timeout means wrong logic */
-       if (i == adev->usec_timeout)
-               return -ETIME;
-
-       return RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90) == 0x1 ? 0 : -EIO;
+       return -ETIME;
 }
 
 int
@@ -90,9 +88,11 @@ smu_v12_0_send_msg_with_param(struct smu_context *smu,
                return index;
 
        ret = smu_v12_0_wait_for_response(smu);
-       if (ret)
-               pr_err("Failed to send message 0x%x, response 0x%x, param 0x%x\n",
-                      index, ret, param);
+       if (ret) {
+               pr_err("Msg issuing pre-check failed and "
+                      "SMU may be not in the right state!\n");
+               return ret;
+       }
 
        WREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90, 0);