aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLikun Gao <Likun.Gao@amd.com>2019-01-28 06:12:10 -0500
committerAlex Deucher <alexander.deucher@amd.com>2019-03-19 16:04:01 -0400
commitc5bee44baa3c60c3d283c3348ef1b5bf1e8e2427 (patch)
tree6c9bf404d850f60fd2f0dbc61303d30095990dfe
parentbc0fcffd36baa1cbbf2a6e951e4f1acad3aa8c90 (diff)
drm/amd/powerplay: add function to get sclk and mclk
Add function to get sclk and mclk for smu11. Signed-off-by: Likun Gao <Likun.Gao@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>
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c16
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h10
-rw-r--r--drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h6
-rw-r--r--drivers/gpu/drm/amd/powerplay/smu_v11_0.c84
4 files changed, 110 insertions, 6 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c
index 344967df3137..523b8ab6b04e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c
@@ -904,3 +904,19 @@ amdgpu_get_vce_clock_state(void *handle, u32 idx)
904 904
905 return NULL; 905 return NULL;
906} 906}
907
908int amdgpu_dpm_get_sclk(struct amdgpu_device *adev, bool low)
909{
910 if (is_support_sw_smu(adev))
911 return smu_get_sclk(&adev->smu, low);
912 else
913 return (adev)->powerplay.pp_funcs->get_sclk((adev)->powerplay.pp_handle, (low));
914}
915
916int amdgpu_dpm_get_mclk(struct amdgpu_device *adev, bool low)
917{
918 if (is_support_sw_smu(adev))
919 return smu_get_mclk(&adev->smu, low);
920 else
921 return (adev)->powerplay.pp_funcs->get_mclk((adev)->powerplay.pp_handle, (low));
922}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h
index 5b1539e72101..2fda77fec930 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h
@@ -278,12 +278,6 @@ enum amdgpu_pcie_gen {
278#define amdgpu_dpm_set_fan_speed_rpm(adev, s) \ 278#define amdgpu_dpm_set_fan_speed_rpm(adev, s) \
279 ((adev)->powerplay.pp_funcs->set_fan_speed_rpm)((adev)->powerplay.pp_handle, (s)) 279 ((adev)->powerplay.pp_funcs->set_fan_speed_rpm)((adev)->powerplay.pp_handle, (s))
280 280
281#define amdgpu_dpm_get_sclk(adev, l) \
282 ((adev)->powerplay.pp_funcs->get_sclk((adev)->powerplay.pp_handle, (l)))
283
284#define amdgpu_dpm_get_mclk(adev, l) \
285 ((adev)->powerplay.pp_funcs->get_mclk((adev)->powerplay.pp_handle, (l)))
286
287#define amdgpu_dpm_force_performance_level(adev, l) \ 281#define amdgpu_dpm_force_performance_level(adev, l) \
288 ((adev)->powerplay.pp_funcs->force_performance_level((adev)->powerplay.pp_handle, (l))) 282 ((adev)->powerplay.pp_funcs->force_performance_level((adev)->powerplay.pp_handle, (l)))
289 283
@@ -509,4 +503,8 @@ enum amdgpu_pcie_gen amdgpu_get_pcie_gen_support(struct amdgpu_device *adev,
509struct amd_vce_state* 503struct amd_vce_state*
510amdgpu_get_vce_clock_state(void *handle, u32 idx); 504amdgpu_get_vce_clock_state(void *handle, u32 idx);
511 505
506extern int amdgpu_dpm_get_sclk(struct amdgpu_device *adev, bool low);
507
508extern int amdgpu_dpm_get_mclk(struct amdgpu_device *adev, bool low);
509
512#endif 510#endif
diff --git a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
index db050978020f..d7f26e178839 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
@@ -528,6 +528,8 @@ struct smu_funcs
528 uint32_t value); 528 uint32_t value);
529 int (*dpm_set_uvd_enable)(struct smu_context *smu, bool enable); 529 int (*dpm_set_uvd_enable)(struct smu_context *smu, bool enable);
530 int (*dpm_set_vce_enable)(struct smu_context *smu, bool enable); 530 int (*dpm_set_vce_enable)(struct smu_context *smu, bool enable);
531 uint32_t (*get_sclk)(struct smu_context *smu, bool low);
532 uint32_t (*get_mclk)(struct smu_context *smu, bool low);
531}; 533};
532 534
533#define smu_init_microcode(smu) \ 535#define smu_init_microcode(smu) \
@@ -693,6 +695,10 @@ struct smu_funcs
693 ((smu)->funcs->dpm_set_uvd_enable ? (smu)->funcs->dpm_set_uvd_enable((smu), (enable)) : 0) 695 ((smu)->funcs->dpm_set_uvd_enable ? (smu)->funcs->dpm_set_uvd_enable((smu), (enable)) : 0)
694#define smu_dpm_set_vce_enable(smu, enable) \ 696#define smu_dpm_set_vce_enable(smu, enable) \
695 ((smu)->funcs->dpm_set_vce_enable ? (smu)->funcs->dpm_set_vce_enable((smu), (enable)) : 0) 697 ((smu)->funcs->dpm_set_vce_enable ? (smu)->funcs->dpm_set_vce_enable((smu), (enable)) : 0)
698#define smu_get_sclk(smu, low) \
699 ((smu)->funcs->get_sclk ? (smu)->funcs->get_sclk((smu), (low)) : 0)
700#define smu_get_mclk(smu, low) \
701 ((smu)->funcs->get_mclk ? (smu)->funcs->get_mclk((smu), (low)) : 0)
696 702
697 703
698extern int smu_get_atom_data_table(struct smu_context *smu, uint32_t table, 704extern int smu_get_atom_data_table(struct smu_context *smu, uint32_t table,
diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
index 3ebf89b3f815..48174df19105 100644
--- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
+++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
@@ -1258,6 +1258,88 @@ smu_v11_0_set_watermarks_for_clock_ranges(struct smu_context *smu, struct
1258 return ret; 1258 return ret;
1259} 1259}
1260 1260
1261static int smu_v11_0_get_clock_ranges(struct smu_context *smu,
1262 uint32_t *clock,
1263 PPCLK_e clock_select,
1264 bool max)
1265{
1266 int ret;
1267 *clock = 0;
1268 if (max) {
1269 ret = smu_send_smc_msg_with_param(smu, SMU_MSG_GetMaxDpmFreq,
1270 (clock_select << 16));
1271 if (ret) {
1272 pr_err("[GetClockRanges] Failed to get max clock from SMC!\n");
1273 return ret;
1274 }
1275 smu_read_smc_arg(smu, clock);
1276 } else {
1277 ret = smu_send_smc_msg_with_param(smu, SMU_MSG_GetMinDpmFreq,
1278 (clock_select << 16));
1279 if (ret) {
1280 pr_err("[GetClockRanges] Failed to get min clock from SMC!\n");
1281 return ret;
1282 }
1283 smu_read_smc_arg(smu, clock);
1284 }
1285
1286 return 0;
1287}
1288
1289static uint32_t smu_v11_0_dpm_get_sclk(struct smu_context *smu, bool low)
1290{
1291 uint32_t gfx_clk;
1292 int ret;
1293
1294 if (!smu_feature_is_enabled(smu, FEATURE_DPM_GFXCLK_BIT)) {
1295 pr_err("[GetSclks]: gfxclk dpm not enabled!\n");
1296 return -EPERM;
1297 }
1298
1299 if (low) {
1300 ret = smu_v11_0_get_clock_ranges(smu, &gfx_clk, PPCLK_GFXCLK, false);
1301 if (ret) {
1302 pr_err("[GetSclks]: fail to get min PPCLK_GFXCLK\n");
1303 return ret;
1304 }
1305 } else {
1306 ret = smu_v11_0_get_clock_ranges(smu, &gfx_clk, PPCLK_GFXCLK, true);
1307 if (ret) {
1308 pr_err("[GetSclks]: fail to get max PPCLK_GFXCLK\n");
1309 return ret;
1310 }
1311 }
1312
1313 return (gfx_clk * 100);
1314}
1315
1316static uint32_t smu_v11_0_dpm_get_mclk(struct smu_context *smu, bool low)
1317{
1318 uint32_t mem_clk;
1319 int ret;
1320
1321 if (!smu_feature_is_enabled(smu, FEATURE_DPM_UCLK_BIT)) {
1322 pr_err("[GetMclks]: memclk dpm not enabled!\n");
1323 return -EPERM;
1324 }
1325
1326 if (low) {
1327 ret = smu_v11_0_get_clock_ranges(smu, &mem_clk, PPCLK_UCLK, false);
1328 if (ret) {
1329 pr_err("[GetMclks]: fail to get min PPCLK_UCLK\n");
1330 return ret;
1331 }
1332 } else {
1333 ret = smu_v11_0_get_clock_ranges(smu, &mem_clk, PPCLK_GFXCLK, true);
1334 if (ret) {
1335 pr_err("[GetMclks]: fail to get max PPCLK_UCLK\n");
1336 return ret;
1337 }
1338 }
1339
1340 return (mem_clk * 100);
1341}
1342
1261static int smu_v11_0_set_od8_default_settings(struct smu_context *smu) 1343static int smu_v11_0_set_od8_default_settings(struct smu_context *smu)
1262{ 1344{
1263 struct smu_table_context *table_context = &smu->smu_table; 1345 struct smu_table_context *table_context = &smu->smu_table;
@@ -1658,6 +1740,8 @@ static const struct smu_funcs smu_v11_0_funcs = {
1658 .set_deep_sleep_dcefclk = smu_v11_0_set_deep_sleep_dcefclk, 1740 .set_deep_sleep_dcefclk = smu_v11_0_set_deep_sleep_dcefclk,
1659 .display_clock_voltage_request = smu_v11_0_display_clock_voltage_request, 1741 .display_clock_voltage_request = smu_v11_0_display_clock_voltage_request,
1660 .set_watermarks_for_clock_ranges = smu_v11_0_set_watermarks_for_clock_ranges, 1742 .set_watermarks_for_clock_ranges = smu_v11_0_set_watermarks_for_clock_ranges,
1743 .get_sclk = smu_v11_0_dpm_get_sclk,
1744 .get_mclk = smu_v11_0_dpm_get_mclk,
1661 .set_od8_default_settings = smu_v11_0_set_od8_default_settings, 1745 .set_od8_default_settings = smu_v11_0_set_od8_default_settings,
1662 .get_activity_monitor_coeff = smu_v11_0_get_activity_monitor_coeff, 1746 .get_activity_monitor_coeff = smu_v11_0_get_activity_monitor_coeff,
1663 .set_activity_monitor_coeff = smu_v11_0_set_activity_monitor_coeff, 1747 .set_activity_monitor_coeff = smu_v11_0_set_activity_monitor_coeff,