Use smu vram copy wrapper function for vram copy operations in
SMUv13.0.6 and SMUv13.0.12.

Signed-off-by: Lijo Lazar <[email protected]>
---
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_12_ppt.c |  9 +++++++--
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c  | 19 ++++++++++++-------
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_12_ppt.c 
b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_12_ppt.c
index 67cd186bd263..7193e3e4946a 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_12_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_12_ppt.c
@@ -479,9 +479,14 @@ static int smu_v13_0_12_get_system_metrics_table(struct 
smu_context *smu)
        }
 
        amdgpu_hdp_invalidate(smu->adev, NULL);
+
+       ret = smu_cmn_vram_cpy(smu, sys_table->cache.buffer,
+                              table->cpu_addr,
+                              smu_v13_0_12_get_system_metrics_size());
+       if (ret)
+               return ret;
+
        smu_table_cache_update_time(sys_table, jiffies);
-       memcpy(sys_table->cache.buffer, table->cpu_addr,
-              smu_v13_0_12_get_system_metrics_size());
 
        return 0;
 }
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c 
b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
index a5c2509bf673..03a4a3513228 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
@@ -778,7 +778,10 @@ int smu_v13_0_6_get_metrics_table(struct smu_context *smu, 
void *metrics_table,
                }
 
                amdgpu_hdp_invalidate(smu->adev, NULL);
-               memcpy(smu_table->metrics_table, table->cpu_addr, table_size);
+               ret = smu_cmn_vram_cpy(smu, smu_table->metrics_table,
+                                      table->cpu_addr, table_size);
+               if (ret)
+                       return ret;
 
                smu_table->metrics_time = jiffies;
        }
@@ -857,9 +860,9 @@ int smu_v13_0_6_get_static_metrics_table(struct smu_context 
*smu)
        }
 
        amdgpu_hdp_invalidate(smu->adev, NULL);
-       memcpy(smu_table->metrics_table, table->cpu_addr, table_size);
 
-       return 0;
+       return smu_cmn_vram_cpy(smu, smu_table->metrics_table,
+                               table->cpu_addr, table_size);
 }
 
 static void smu_v13_0_6_update_caps(struct smu_context *smu)
@@ -2404,13 +2407,15 @@ static int smu_v13_0_6_request_i2c_xfer(struct 
smu_context *smu,
 
        table_size = smu_table->tables[SMU_TABLE_I2C_COMMANDS].size;
 
-       memcpy(table->cpu_addr, table_data, table_size);
+       ret = smu_cmn_vram_cpy(smu, table->cpu_addr, table_data, table_size);
+       if (ret)
+               return ret;
+
        /* Flush hdp cache */
        amdgpu_hdp_flush(adev, NULL);
-       ret = smu_cmn_send_smc_msg(smu, SMU_MSG_RequestI2cTransaction,
-                                         NULL);
 
-       return ret;
+       return smu_cmn_send_smc_msg(smu, SMU_MSG_RequestI2cTransaction,
+                                   NULL);
 }
 
 static int smu_v13_0_6_i2c_xfer(struct i2c_adapter *i2c_adap,
-- 
2.49.0

Reply via email to