]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
drm/amd/powerplay: using valid mapping check for rn
authorAaron Liu <aaron.liu@amd.com>
Wed, 21 Aug 2019 21:45:52 +0000 (16:45 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 22 Aug 2019 22:37:53 +0000 (17:37 -0500)
Check whether the message mapping is valid

Signed-off-by: Aaron Liu <aaron.liu@amd.com>
Reviewed-by: Kenneth Feng <kenneth.feng@amd.com>
Reviewed-by: Evan Quan <evan.quan@amd.com>
Reviewed-by: Kevin Wang <kevin1.wang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/inc/smu_v12_0.h
drivers/gpu/drm/amd/powerplay/renoir_ppt.c

index 278cdc2c0d47a25e729670e2e717dbe9c0277e91..acf3db12f59f84abf66ba47a8a9e5fdcf6d3a049 100644 (file)
 #define MP1_SRAM                       0x03c00004
 
 
+struct smu_12_0_cmn2aisc_mapping {
+       int     valid_mapping;
+       int     map_to;
+};
+
 void smu_v12_0_set_smu_funcs(struct smu_context *smu);
 
 #endif
index af8bb1cc5d9acb1cce85921ffa2234d82ce8352d..2580383ff49b0e44baa21e0c4346085ae674ea64 100644 (file)
 #include "soc15_common.h"
 #include "smu_v12_0_ppsmc.h"
 #include "smu12_driver_if.h"
+#include "smu_v12_0.h"
 #include "renoir_ppt.h"
 
 
 #define MSG_MAP(msg, index) \
-       [SMU_MSG_##msg] = index
+       [SMU_MSG_##msg] = {1, (index)}
 
-static int renoir_message_map[SMU_MSG_MAX_COUNT] = {
+static struct smu_12_0_cmn2aisc_mapping renoir_message_map[SMU_MSG_MAX_COUNT] = {
        MSG_MAP(TestMessage,                    PPSMC_MSG_TestMessage),
        MSG_MAP(GetSmuVersion,                  PPSMC_MSG_GetSmuVersion),
        MSG_MAP(GetDriverIfVersion,             PPSMC_MSG_GetDriverIfVersion),
@@ -98,16 +99,16 @@ static int renoir_message_map[SMU_MSG_MAX_COUNT] = {
 
 static int renoir_get_smu_msg_index(struct smu_context *smc, uint32_t index)
 {
-       int val;
+       struct smu_12_0_cmn2aisc_mapping mapping;
 
        if (index >= SMU_MSG_MAX_COUNT)
                return -EINVAL;
 
-       val = renoir_message_map[index];
-       if (val > PPSMC_Message_Count)
+       mapping = renoir_message_map[index];
+       if (!(mapping.valid_mapping))
                return -EINVAL;
 
-       return val;
+       return mapping.map_to;
 }