diff options
author | Eric Huang <JinHuiEric.Huang@amd.com> | 2017-03-06 13:13:48 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-03-29 23:54:54 -0400 |
commit | d018772748fc474b2265ce333a704620b17df3fd (patch) | |
tree | a773b67de0728b99b8f2ffc3f7c1ed090e788295 | |
parent | a2dd023a7788ba6eb67fc4f7666c08c1a2846e2f (diff) |
drm/amd/powerplay: add some display/powerplay interfaces
New interfaces needed to handle the new clock trees and
bandwidth requirements on vega10.
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Eric Huang <JinHuiEric.Huang@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Acked-by: Tony Cheng <tony.cheng@amd.com>
Acked-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 94 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c | 49 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h | 28 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h | 11 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | 10 |
5 files changed, 191 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c index 6e1e695f97c5..dfd4fe6f0578 100644 --- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c +++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c | |||
@@ -1349,6 +1349,100 @@ int amd_powerplay_get_clock_by_type(void *handle, enum amd_pp_clock_type type, s | |||
1349 | return ret; | 1349 | return ret; |
1350 | } | 1350 | } |
1351 | 1351 | ||
1352 | int amd_powerplay_get_clock_by_type_with_latency(void *handle, | ||
1353 | enum amd_pp_clock_type type, | ||
1354 | struct pp_clock_levels_with_latency *clocks) | ||
1355 | { | ||
1356 | struct pp_hwmgr *hwmgr; | ||
1357 | struct pp_instance *pp_handle = (struct pp_instance *)handle; | ||
1358 | int ret = 0; | ||
1359 | |||
1360 | ret = pp_check(pp_handle); | ||
1361 | if (ret != 0) | ||
1362 | return ret; | ||
1363 | |||
1364 | if (!clocks) | ||
1365 | return -EINVAL; | ||
1366 | |||
1367 | mutex_lock(&pp_handle->pp_lock); | ||
1368 | hwmgr = ((struct pp_instance *)handle)->hwmgr; | ||
1369 | ret = phm_get_clock_by_type_with_latency(hwmgr, type, clocks); | ||
1370 | mutex_unlock(&pp_handle->pp_lock); | ||
1371 | return ret; | ||
1372 | } | ||
1373 | |||
1374 | int amd_powerplay_get_clock_by_type_with_voltage(void *handle, | ||
1375 | enum amd_pp_clock_type type, | ||
1376 | struct pp_clock_levels_with_voltage *clocks) | ||
1377 | { | ||
1378 | struct pp_hwmgr *hwmgr; | ||
1379 | struct pp_instance *pp_handle = (struct pp_instance *)handle; | ||
1380 | int ret = 0; | ||
1381 | |||
1382 | ret = pp_check(pp_handle); | ||
1383 | if (ret != 0) | ||
1384 | return ret; | ||
1385 | |||
1386 | if (!clocks) | ||
1387 | return -EINVAL; | ||
1388 | |||
1389 | hwmgr = ((struct pp_instance *)handle)->hwmgr; | ||
1390 | |||
1391 | mutex_lock(&pp_handle->pp_lock); | ||
1392 | |||
1393 | ret = phm_get_clock_by_type_with_voltage(hwmgr, type, clocks); | ||
1394 | |||
1395 | mutex_unlock(&pp_handle->pp_lock); | ||
1396 | return ret; | ||
1397 | } | ||
1398 | |||
1399 | int amd_powerplay_set_watermarks_for_clocks_ranges(void *handle, | ||
1400 | struct pp_wm_sets_with_clock_ranges_soc15 *wm_with_clock_ranges) | ||
1401 | { | ||
1402 | struct pp_hwmgr *hwmgr; | ||
1403 | struct pp_instance *pp_handle = (struct pp_instance *)handle; | ||
1404 | int ret = 0; | ||
1405 | |||
1406 | ret = pp_check(pp_handle); | ||
1407 | if (ret != 0) | ||
1408 | return ret; | ||
1409 | |||
1410 | if (!wm_with_clock_ranges) | ||
1411 | return -EINVAL; | ||
1412 | |||
1413 | hwmgr = ((struct pp_instance *)handle)->hwmgr; | ||
1414 | |||
1415 | mutex_lock(&pp_handle->pp_lock); | ||
1416 | ret = phm_set_watermarks_for_clocks_ranges(hwmgr, | ||
1417 | wm_with_clock_ranges); | ||
1418 | mutex_unlock(&pp_handle->pp_lock); | ||
1419 | |||
1420 | return ret; | ||
1421 | } | ||
1422 | |||
1423 | int amd_powerplay_display_clock_voltage_request(void *handle, | ||
1424 | struct pp_display_clock_request *clock) | ||
1425 | { | ||
1426 | struct pp_hwmgr *hwmgr; | ||
1427 | struct pp_instance *pp_handle = (struct pp_instance *)handle; | ||
1428 | int ret = 0; | ||
1429 | |||
1430 | ret = pp_check(pp_handle); | ||
1431 | if (ret != 0) | ||
1432 | return ret; | ||
1433 | |||
1434 | if (!clock) | ||
1435 | return -EINVAL; | ||
1436 | |||
1437 | hwmgr = ((struct pp_instance *)handle)->hwmgr; | ||
1438 | |||
1439 | mutex_lock(&pp_handle->pp_lock); | ||
1440 | ret = phm_display_clock_voltage_request(hwmgr, clock); | ||
1441 | mutex_unlock(&pp_handle->pp_lock); | ||
1442 | |||
1443 | return ret; | ||
1444 | } | ||
1445 | |||
1352 | int amd_powerplay_get_display_mode_validation_clocks(void *handle, | 1446 | int amd_powerplay_get_display_mode_validation_clocks(void *handle, |
1353 | struct amd_pp_simple_clock_info *clocks) | 1447 | struct amd_pp_simple_clock_info *clocks) |
1354 | { | 1448 | { |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c b/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c index 6646e1402a13..23bba2c8b18e 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c | |||
@@ -443,6 +443,55 @@ int phm_get_clock_by_type(struct pp_hwmgr *hwmgr, enum amd_pp_clock_type type, s | |||
443 | 443 | ||
444 | } | 444 | } |
445 | 445 | ||
446 | int phm_get_clock_by_type_with_latency(struct pp_hwmgr *hwmgr, | ||
447 | enum amd_pp_clock_type type, | ||
448 | struct pp_clock_levels_with_latency *clocks) | ||
449 | { | ||
450 | PHM_FUNC_CHECK(hwmgr); | ||
451 | |||
452 | if (hwmgr->hwmgr_func->get_clock_by_type_with_latency == NULL) | ||
453 | return -EINVAL; | ||
454 | |||
455 | return hwmgr->hwmgr_func->get_clock_by_type_with_latency(hwmgr, type, clocks); | ||
456 | |||
457 | } | ||
458 | |||
459 | int phm_get_clock_by_type_with_voltage(struct pp_hwmgr *hwmgr, | ||
460 | enum amd_pp_clock_type type, | ||
461 | struct pp_clock_levels_with_voltage *clocks) | ||
462 | { | ||
463 | PHM_FUNC_CHECK(hwmgr); | ||
464 | |||
465 | if (hwmgr->hwmgr_func->get_clock_by_type_with_voltage == NULL) | ||
466 | return -EINVAL; | ||
467 | |||
468 | return hwmgr->hwmgr_func->get_clock_by_type_with_voltage(hwmgr, type, clocks); | ||
469 | |||
470 | } | ||
471 | |||
472 | int phm_set_watermarks_for_clocks_ranges(struct pp_hwmgr *hwmgr, | ||
473 | struct pp_wm_sets_with_clock_ranges_soc15 *wm_with_clock_ranges) | ||
474 | { | ||
475 | PHM_FUNC_CHECK(hwmgr); | ||
476 | |||
477 | if (!hwmgr->hwmgr_func->set_watermarks_for_clocks_ranges) | ||
478 | return -EINVAL; | ||
479 | |||
480 | return hwmgr->hwmgr_func->set_watermarks_for_clocks_ranges(hwmgr, | ||
481 | wm_with_clock_ranges); | ||
482 | } | ||
483 | |||
484 | int phm_display_clock_voltage_request(struct pp_hwmgr *hwmgr, | ||
485 | struct pp_display_clock_request *clock) | ||
486 | { | ||
487 | PHM_FUNC_CHECK(hwmgr); | ||
488 | |||
489 | if (!hwmgr->hwmgr_func->display_clock_voltage_request) | ||
490 | return -EINVAL; | ||
491 | |||
492 | return hwmgr->hwmgr_func->display_clock_voltage_request(hwmgr, clock); | ||
493 | } | ||
494 | |||
446 | int phm_get_max_high_clocks(struct pp_hwmgr *hwmgr, struct amd_pp_simple_clock_info *clocks) | 495 | int phm_get_max_high_clocks(struct pp_hwmgr *hwmgr, struct amd_pp_simple_clock_info *clocks) |
447 | { | 496 | { |
448 | PHM_FUNC_CHECK(hwmgr); | 497 | PHM_FUNC_CHECK(hwmgr); |
diff --git a/drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h b/drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h index c0bf3af6846d..4e39f35bb745 100644 --- a/drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h +++ b/drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/errno.h> | 28 | #include <linux/errno.h> |
29 | #include "amd_shared.h" | 29 | #include "amd_shared.h" |
30 | #include "cgs_common.h" | 30 | #include "cgs_common.h" |
31 | #include "dm_pp_interface.h" | ||
31 | 32 | ||
32 | extern const struct amd_ip_funcs pp_ip_funcs; | 33 | extern const struct amd_ip_funcs pp_ip_funcs; |
33 | extern const struct amd_powerplay_funcs pp_dpm_funcs; | 34 | extern const struct amd_powerplay_funcs pp_dpm_funcs; |
@@ -226,6 +227,8 @@ struct amd_pp_display_configuration { | |||
226 | * higher latency not allowed. | 227 | * higher latency not allowed. |
227 | */ | 228 | */ |
228 | uint32_t dce_tolerable_mclk_in_active_latency; | 229 | uint32_t dce_tolerable_mclk_in_active_latency; |
230 | uint32_t min_dcef_set_clk; | ||
231 | uint32_t min_dcef_deep_sleep_set_clk; | ||
229 | }; | 232 | }; |
230 | 233 | ||
231 | struct amd_pp_simple_clock_info { | 234 | struct amd_pp_simple_clock_info { |
@@ -266,7 +269,11 @@ struct amd_pp_clock_info { | |||
266 | enum amd_pp_clock_type { | 269 | enum amd_pp_clock_type { |
267 | amd_pp_disp_clock = 1, | 270 | amd_pp_disp_clock = 1, |
268 | amd_pp_sys_clock, | 271 | amd_pp_sys_clock, |
269 | amd_pp_mem_clock | 272 | amd_pp_mem_clock, |
273 | amd_pp_dcef_clock, | ||
274 | amd_pp_soc_clock, | ||
275 | amd_pp_pixel_clock, | ||
276 | amd_pp_phy_clock | ||
270 | }; | 277 | }; |
271 | 278 | ||
272 | #define MAX_NUM_CLOCKS 16 | 279 | #define MAX_NUM_CLOCKS 16 |
@@ -303,6 +310,11 @@ struct pp_gpu_power { | |||
303 | uint32_t average_gpu_power; | 310 | uint32_t average_gpu_power; |
304 | }; | 311 | }; |
305 | 312 | ||
313 | struct pp_display_clock_request { | ||
314 | enum amd_pp_clock_type clock_type; | ||
315 | uint32_t clock_freq_in_khz; | ||
316 | }; | ||
317 | |||
306 | #define PP_GROUP_MASK 0xF0000000 | 318 | #define PP_GROUP_MASK 0xF0000000 |
307 | #define PP_GROUP_SHIFT 28 | 319 | #define PP_GROUP_SHIFT 28 |
308 | 320 | ||
@@ -405,6 +417,20 @@ int amd_powerplay_get_clock_by_type(void *handle, | |||
405 | enum amd_pp_clock_type type, | 417 | enum amd_pp_clock_type type, |
406 | struct amd_pp_clocks *clocks); | 418 | struct amd_pp_clocks *clocks); |
407 | 419 | ||
420 | int amd_powerplay_get_clock_by_type_with_latency(void *handle, | ||
421 | enum amd_pp_clock_type type, | ||
422 | struct pp_clock_levels_with_latency *clocks); | ||
423 | |||
424 | int amd_powerplay_get_clock_by_type_with_voltage(void *handle, | ||
425 | enum amd_pp_clock_type type, | ||
426 | struct pp_clock_levels_with_voltage *clocks); | ||
427 | |||
428 | int amd_powerplay_set_watermarks_for_clocks_ranges(void *handle, | ||
429 | struct pp_wm_sets_with_clock_ranges_soc15 *wm_with_clock_ranges); | ||
430 | |||
431 | int amd_powerplay_display_clock_voltage_request(void *handle, | ||
432 | struct pp_display_clock_request *clock); | ||
433 | |||
408 | int amd_powerplay_get_display_mode_validation_clocks(void *handle, | 434 | int amd_powerplay_get_display_mode_validation_clocks(void *handle, |
409 | struct amd_pp_simple_clock_info *output); | 435 | struct amd_pp_simple_clock_info *output); |
410 | 436 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h b/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h index b485bec678fd..5345b50761f4 100644 --- a/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h +++ b/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h | |||
@@ -419,6 +419,17 @@ extern int phm_get_current_shallow_sleep_clocks(struct pp_hwmgr *hwmgr, const st | |||
419 | 419 | ||
420 | extern int phm_get_clock_by_type(struct pp_hwmgr *hwmgr, enum amd_pp_clock_type type, struct amd_pp_clocks *clocks); | 420 | extern int phm_get_clock_by_type(struct pp_hwmgr *hwmgr, enum amd_pp_clock_type type, struct amd_pp_clocks *clocks); |
421 | 421 | ||
422 | extern int phm_get_clock_by_type_with_latency(struct pp_hwmgr *hwmgr, | ||
423 | enum amd_pp_clock_type type, | ||
424 | struct pp_clock_levels_with_latency *clocks); | ||
425 | extern int phm_get_clock_by_type_with_voltage(struct pp_hwmgr *hwmgr, | ||
426 | enum amd_pp_clock_type type, | ||
427 | struct pp_clock_levels_with_voltage *clocks); | ||
428 | extern int phm_set_watermarks_for_clocks_ranges(struct pp_hwmgr *hwmgr, | ||
429 | struct pp_wm_sets_with_clock_ranges_soc15 *wm_with_clock_ranges); | ||
430 | extern int phm_display_clock_voltage_request(struct pp_hwmgr *hwmgr, | ||
431 | struct pp_display_clock_request *clock); | ||
432 | |||
422 | extern int phm_get_max_high_clocks(struct pp_hwmgr *hwmgr, struct amd_pp_simple_clock_info *clocks); | 433 | extern int phm_get_max_high_clocks(struct pp_hwmgr *hwmgr, struct amd_pp_simple_clock_info *clocks); |
423 | 434 | ||
424 | #endif /* _HARDWARE_MANAGER_H_ */ | 435 | #endif /* _HARDWARE_MANAGER_H_ */ |
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h index 02185d49ff8d..7de9beabb35d 100644 --- a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +++ b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | |||
@@ -347,6 +347,16 @@ struct pp_hwmgr_func { | |||
347 | int (*get_current_shallow_sleep_clocks)(struct pp_hwmgr *hwmgr, | 347 | int (*get_current_shallow_sleep_clocks)(struct pp_hwmgr *hwmgr, |
348 | const struct pp_hw_power_state *state, struct pp_clock_info *clock_info); | 348 | const struct pp_hw_power_state *state, struct pp_clock_info *clock_info); |
349 | int (*get_clock_by_type)(struct pp_hwmgr *hwmgr, enum amd_pp_clock_type type, struct amd_pp_clocks *clocks); | 349 | int (*get_clock_by_type)(struct pp_hwmgr *hwmgr, enum amd_pp_clock_type type, struct amd_pp_clocks *clocks); |
350 | int (*get_clock_by_type_with_latency)(struct pp_hwmgr *hwmgr, | ||
351 | enum amd_pp_clock_type type, | ||
352 | struct pp_clock_levels_with_latency *clocks); | ||
353 | int (*get_clock_by_type_with_voltage)(struct pp_hwmgr *hwmgr, | ||
354 | enum amd_pp_clock_type type, | ||
355 | struct pp_clock_levels_with_voltage *clocks); | ||
356 | int (*set_watermarks_for_clocks_ranges)(struct pp_hwmgr *hwmgr, | ||
357 | struct pp_wm_sets_with_clock_ranges_soc15 *wm_with_clock_ranges); | ||
358 | int (*display_clock_voltage_request)(struct pp_hwmgr *hwmgr, | ||
359 | struct pp_display_clock_request *clock); | ||
350 | int (*get_max_high_clocks)(struct pp_hwmgr *hwmgr, struct amd_pp_simple_clock_info *clocks); | 360 | int (*get_max_high_clocks)(struct pp_hwmgr *hwmgr, struct amd_pp_simple_clock_info *clocks); |
351 | int (*power_off_asic)(struct pp_hwmgr *hwmgr); | 361 | int (*power_off_asic)(struct pp_hwmgr *hwmgr); |
352 | int (*force_clock_level)(struct pp_hwmgr *hwmgr, enum pp_clock_type type, uint32_t mask); | 362 | int (*force_clock_level)(struct pp_hwmgr *hwmgr, enum pp_clock_type type, uint32_t mask); |