drm/amd/powerplay: implement smu update table function
authorKevin Wang <Kevin1.Wang@amd.com>
Mon, 7 Jan 2019 07:34:09 +0000 (15:34 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 19 Mar 2019 20:03:57 +0000 (15:03 -0500)
sometime, the driver need changed table data between driver and smu.
this function can help update table data

Signed-off-by: Kevin Wang <Kevin1.Wang@amd.com>
Reviewed-by: Huang Rui <ray.huang@amd.com>
Acked-by: Alex Deucher <alexander.deucher@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

index 172b844..56095a4 100644 (file)
 #include "smu_v11_0.h"
 #include "atom.h"
 
+int smu_update_table(struct smu_context *smu, uint32_t table_id,
+                    void *table_data, bool drv2smu)
+{
+       struct smu_table_context *smu_table = &smu->smu_table;
+       struct smu_table *table = NULL;
+       int ret = 0;
+
+       if (!table_data || table_id >= smu_table->table_count)
+               return -EINVAL;
+
+       table = &smu_table->tables[table_id];
+
+       if (drv2smu)
+               memcpy(table->cpu_addr, table_data, table->size);
+
+       ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetDriverDramAddrHigh,
+                                         upper_32_bits(table->mc_address));
+       if (ret)
+               return ret;
+       ret = smu_send_smc_msg_with_param(smu, SMU_MSG_SetDriverDramAddrLow,
+                                         lower_32_bits(table->mc_address));
+       if (ret)
+               return ret;
+       ret = smu_send_smc_msg_with_param(smu, drv2smu ?
+                                         SMU_MSG_TransferTableDram2Smu :
+                                         SMU_MSG_TransferTableSmu2Dram,
+                                         table_id);
+       if (ret)
+               return ret;
+
+       if (!drv2smu)
+               memcpy(table_data, table->cpu_addr, table->size);
+
+       return ret;
+}
+
 int smu_feature_init_dpm(struct smu_context *smu)
 {
        struct smu_feature *feature = &smu->smu_feature;
index fe86a7f..c159e4d 100644 (file)
@@ -364,4 +364,7 @@ extern int smu_feature_set_enabled(struct smu_context *smu, int feature_id, bool
 extern int smu_feature_is_supported(struct smu_context *smu, int feature_id);
 extern int smu_feature_set_supported(struct smu_context *smu, int feature_id, bool enable);
 
+int smu_update_table(struct smu_context *smu, uint32_t table_id,
+                    void *table_data, bool drv2smu);
+
 #endif