drm/amd/powerplay: add helper function to get smu firmware & if version
authorKevin Wang <kevin1.wang@amd.com>
Mon, 29 Apr 2019 06:47:41 +0000 (14:47 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 24 May 2019 17:20:47 +0000 (12:20 -0500)
add this helper function to get smc version.

Signed-off-by: Kevin Wang <kevin1.wang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
drivers/gpu/drm/amd/powerplay/smu_v11_0.c

index c058c784180eecf8daab0840ec5ee8120fd6f296..52d919a8b70aae7f693997b6b920ee4cc2c73ada 100644 (file)
 #include "atom.h"
 #include "amd_pcie.h"
 
+int smu_get_smc_version(struct smu_context *smu, uint32_t *if_version, uint32_t *smu_version)
+{
+       int ret = 0;
+
+       if (!if_version && !smu_version)
+               return -EINVAL;
+
+       if (if_version) {
+               ret = smu_send_smc_msg(smu, SMU_MSG_GetDriverIfVersion);
+               if (ret)
+                       return ret;
+
+               ret = smu_read_smc_arg(smu, if_version);
+               if (ret)
+                       return ret;
+       }
+
+       if (smu_version) {
+               ret = smu_send_smc_msg(smu, SMU_MSG_GetSmuVersion);
+               if (ret)
+                       return ret;
+
+               ret = smu_read_smc_arg(smu, smu_version);
+               if (ret)
+                       return ret;
+       }
+
+       return ret;
+}
+
 int smu_dpm_set_power_gate(struct smu_context *smu, uint32_t block_type,
                           bool gate)
 {
index c8b168b3413b6d529d892d116b77edddbbb22132..89052414e9f1a533de9c6c0a79a12099f623d77a 100644 (file)
@@ -767,4 +767,5 @@ extern int smu_dpm_set_power_gate(struct smu_context *smu,uint32_t block_type, b
 extern int smu_handle_task(struct smu_context *smu,
                           enum amd_dpm_forced_level level,
                           enum amd_pp_task task_id);
+int smu_get_smc_version(struct smu_context *smu, uint32_t *if_version, uint32_t *smu_version);
 #endif
index 92903a4cc4d8f460f371d76c942c4cb04afdc2af..cd36c4272659cfd7da8536e549dc52f807825631 100644 (file)
@@ -223,20 +223,27 @@ static int smu_v11_0_check_fw_status(struct smu_context *smu)
 
 static int smu_v11_0_check_fw_version(struct smu_context *smu)
 {
-       uint32_t smu_version = 0xff;
+       uint32_t if_version = 0xff, smu_version = 0xff;
+       uint16_t smu_major;
+       uint8_t smu_minor, smu_debug;
        int ret = 0;
 
-       ret = smu_send_smc_msg(smu, SMU_MSG_GetDriverIfVersion);
+       ret = smu_get_smc_version(smu, &if_version, &smu_version);
        if (ret)
-               goto err;
+               return ret;
 
-       ret = smu_read_smc_arg(smu, &smu_version);
-       if (ret)
-               goto err;
+       smu_major = (smu_version >> 16) & 0xffff;
+       smu_minor = (smu_version >> 8) & 0xff;
+       smu_debug = (smu_version >> 0) & 0xff;
+
+       pr_info("SMU Driver IF Version = 0x%08x, SMU FW Version = 0x%08x (%d.%d.%d)\n",
+               if_version, smu_version, smu_major, smu_minor, smu_debug);
 
-       if (smu_version != smu->smc_if_version)
+       if (if_version != smu->smc_if_version) {
+               pr_err("SMU driver if version not matched\n");
                ret = -EINVAL;
-err:
+       }
+
        return ret;
 }