drm/amd/powerplay: add function to parse pptable for smu11
authorLikun Gao <Likun.Gao@amd.com>
Tue, 18 Dec 2018 14:56:48 +0000 (22:56 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 19 Mar 2019 20:03:56 +0000 (15:03 -0500)
Add smu_v11_0_parse_pptable function for smu11.

Signed-off-by: Likun Gao <Likun.Gao@amd.com>
Reviewed-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Kevin Wang <Kevin1.Wang@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
drivers/gpu/drm/amd/powerplay/smu_v11_0.c
drivers/gpu/drm/amd/powerplay/vega20_ppt.c

index 437d0ada16b64e42c56f1a7a3dd8dfe9569c718c..c6774e35280ab24b996eab989aefb7fb98b9b1ce 100644 (file)
@@ -70,6 +70,7 @@ struct smu_table_context
        uint32_t                        power_play_table_size;
 
        struct smu_bios_boot_up_values  boot_values;
+       void                            *driver_pptable;
        struct smu_table                *tables;
        uint32_t                        table_count;
        struct smu_table                memory_pool;
@@ -177,6 +178,8 @@ struct smu_funcs
        ((smu)->funcs->send_smc_msg? (smu)->funcs->send_smc_msg((smu), (msg)) : 0)
 #define smu_send_smc_msg_with_param(smu, msg, param) \
        ((smu)->funcs->send_smc_msg_with_param? (smu)->funcs->send_smc_msg_with_param((smu), (msg), (param)) : 0)
+#define smu_store_powerplay_table(smu) \
+       ((smu)->ppt_funcs->store_powerplay_table ? (smu)->ppt_funcs->store_powerplay_table((smu)) : 0)
 
 extern int smu_get_atom_data_table(struct smu_context *smu, uint32_t table,
                                   uint16_t *size, uint8_t *frev, uint8_t *crev,
index 65e5641d5299e7b3353ff1c29ef3a700ac753483..826fd6e9b007f36427d112234863e39d8a414a91 100644 (file)
@@ -486,6 +486,25 @@ static int smu_v11_0_notify_memory_pool_location(struct smu_context *smu)
        return ret;
 }
 
+static int smu_v11_0_parse_pptable(struct smu_context *smu)
+{
+       int ret;
+
+       struct smu_table_context *table_context = &smu->smu_table;
+
+       if (table_context->driver_pptable)
+               return -EINVAL;
+
+       table_context->driver_pptable = kzalloc(sizeof(PPTable_t), GFP_KERNEL);
+
+       if (!table_context->driver_pptable)
+               return -ENOMEM;
+
+       ret = smu_store_powerplay_table(smu);
+
+       return ret;
+}
+
 static const struct smu_funcs smu_v11_0_funcs = {
        .init_microcode = smu_v11_0_init_microcode,
        .load_microcode = smu_v11_0_load_microcode,
@@ -501,6 +520,7 @@ static const struct smu_funcs smu_v11_0_funcs = {
        .get_vbios_bootup_values = smu_v11_0_get_vbios_bootup_values,
        .get_clk_info_from_vbios = smu_v11_0_get_clk_info_from_vbios,
        .notify_memory_pool_location = smu_v11_0_notify_memory_pool_location,
+       .parse_pptable = smu_v11_0_parse_pptable,
 };
 
 void smu_v11_0_set_smu_funcs(struct smu_context *smu)
index 7522cc7edd43646220169e6b7171756e8487fd70..292f18c0c90d3a6eaa1c51ce12d89daf0e429ac1 100644 (file)
 
 static int vega20_store_powerplay_table(struct smu_context *smu)
 {
+       ATOM_Vega20_POWERPLAYTABLE *powerplay_table = NULL;
+       struct smu_table_context *table_context = &smu->smu_table;
+
+       if (!table_context->power_play_table)
+               return -EINVAL;
+
+       powerplay_table = table_context->power_play_table;
+
+       memcpy(table_context->driver_pptable, &powerplay_table->smcPPTable,
+              sizeof(PPTable_t));
+
        return 0;
 }