diff options
-rw-r--r-- | drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c | 6 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c | 146 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.h | 5 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c | 137 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.h | 13 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/powerplay/inc/smumgr.h | 6 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c | 6 |
11 files changed, 55 insertions, 274 deletions
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c b/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c index ce378bd21661..a3991c0dff2e 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c | |||
@@ -306,8 +306,10 @@ int phm_start_thermal_controller(struct pp_hwmgr *hwmgr, struct PP_TemperatureRa | |||
306 | range.min = temperature_range->min; | 306 | range.min = temperature_range->min; |
307 | } | 307 | } |
308 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, | 308 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, |
309 | PHM_PlatformCaps_ThermalController)) | 309 | PHM_PlatformCaps_ThermalController) |
310 | return phm_dispatch_table(hwmgr, &(hwmgr->start_thermal_controller), &range, NULL); | 310 | && hwmgr->hwmgr_func->start_thermal_controller != NULL) |
311 | return hwmgr->hwmgr_func->start_thermal_controller(hwmgr, &range); | ||
312 | |||
311 | return 0; | 313 | return 0; |
312 | } | 314 | } |
313 | 315 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c index 4f1b932361b2..387d0b62100c 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c | |||
@@ -73,6 +73,7 @@ int hwmgr_early_init(struct pp_instance *handle) | |||
73 | hwmgr->dpm_level = AMD_DPM_FORCED_LEVEL_AUTO; | 73 | hwmgr->dpm_level = AMD_DPM_FORCED_LEVEL_AUTO; |
74 | hwmgr_init_default_caps(hwmgr); | 74 | hwmgr_init_default_caps(hwmgr); |
75 | hwmgr_set_user_specify_caps(hwmgr); | 75 | hwmgr_set_user_specify_caps(hwmgr); |
76 | hwmgr->fan_ctrl_is_in_default_mode = true; | ||
76 | 77 | ||
77 | switch (hwmgr->chip_family) { | 78 | switch (hwmgr->chip_family) { |
78 | case AMDGPU_FAMILY_CZ: | 79 | case AMDGPU_FAMILY_CZ: |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c index dfe06d98304c..c631b1926be7 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | |||
@@ -2284,7 +2284,6 @@ static int smu7_hwmgr_backend_fini(struct pp_hwmgr *hwmgr) | |||
2284 | { | 2284 | { |
2285 | kfree(hwmgr->dyn_state.vddc_dep_on_dal_pwrl); | 2285 | kfree(hwmgr->dyn_state.vddc_dep_on_dal_pwrl); |
2286 | hwmgr->dyn_state.vddc_dep_on_dal_pwrl = NULL; | 2286 | hwmgr->dyn_state.vddc_dep_on_dal_pwrl = NULL; |
2287 | pp_smu7_thermal_fini(hwmgr); | ||
2288 | kfree(hwmgr->backend); | 2287 | kfree(hwmgr->backend); |
2289 | hwmgr->backend = NULL; | 2288 | hwmgr->backend = NULL; |
2290 | 2289 | ||
@@ -2301,8 +2300,6 @@ static int smu7_hwmgr_backend_init(struct pp_hwmgr *hwmgr) | |||
2301 | return -ENOMEM; | 2300 | return -ENOMEM; |
2302 | 2301 | ||
2303 | hwmgr->backend = data; | 2302 | hwmgr->backend = data; |
2304 | pp_smu7_thermal_initialize(hwmgr); | ||
2305 | |||
2306 | smu7_patch_voltage_workaround(hwmgr); | 2303 | smu7_patch_voltage_workaround(hwmgr); |
2307 | smu7_init_dpm_defaults(hwmgr); | 2304 | smu7_init_dpm_defaults(hwmgr); |
2308 | 2305 | ||
@@ -4661,6 +4658,7 @@ static const struct pp_hwmgr_func smu7_hwmgr_funcs = { | |||
4661 | .set_power_profile_state = smu7_set_power_profile_state, | 4658 | .set_power_profile_state = smu7_set_power_profile_state, |
4662 | .avfs_control = smu7_avfs_control, | 4659 | .avfs_control = smu7_avfs_control, |
4663 | .disable_smc_firmware_ctf = smu7_thermal_disable_alert, | 4660 | .disable_smc_firmware_ctf = smu7_thermal_disable_alert, |
4661 | .start_thermal_controller = smu7_start_thermal_controller, | ||
4664 | }; | 4662 | }; |
4665 | 4663 | ||
4666 | uint8_t smu7_get_sleep_divider_id_from_clock(uint32_t clock, | 4664 | uint8_t smu7_get_sleep_divider_id_from_clock(uint32_t clock, |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c index a457b884dd7d..10e12b2b4385 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c | |||
@@ -360,7 +360,7 @@ static int smu7_thermal_initialize(struct pp_hwmgr *hwmgr) | |||
360 | * | 360 | * |
361 | * @param hwmgr The address of the hardware manager. | 361 | * @param hwmgr The address of the hardware manager. |
362 | */ | 362 | */ |
363 | int smu7_thermal_enable_alert(struct pp_hwmgr *hwmgr) | 363 | static void smu7_thermal_enable_alert(struct pp_hwmgr *hwmgr) |
364 | { | 364 | { |
365 | uint32_t alert; | 365 | uint32_t alert; |
366 | 366 | ||
@@ -371,7 +371,7 @@ int smu7_thermal_enable_alert(struct pp_hwmgr *hwmgr) | |||
371 | CG_THERMAL_INT, THERM_INT_MASK, alert); | 371 | CG_THERMAL_INT, THERM_INT_MASK, alert); |
372 | 372 | ||
373 | /* send message to SMU to enable internal thermal interrupts */ | 373 | /* send message to SMU to enable internal thermal interrupts */ |
374 | return smum_send_msg_to_smc(hwmgr->smumgr, PPSMC_MSG_Thermal_Cntl_Enable); | 374 | smum_send_msg_to_smc(hwmgr->smumgr, PPSMC_MSG_Thermal_Cntl_Enable); |
375 | } | 375 | } |
376 | 376 | ||
377 | /** | 377 | /** |
@@ -416,8 +416,7 @@ int smu7_thermal_stop_thermal_controller(struct pp_hwmgr *hwmgr) | |||
416 | * @param Result the last failure code | 416 | * @param Result the last failure code |
417 | * @return result from set temperature range routine | 417 | * @return result from set temperature range routine |
418 | */ | 418 | */ |
419 | static int tf_smu7_thermal_start_smc_fan_control(struct pp_hwmgr *hwmgr, | 419 | static int smu7_thermal_start_smc_fan_control(struct pp_hwmgr *hwmgr) |
420 | void *input, void *output, void *storage, int result) | ||
421 | { | 420 | { |
422 | /* If the fantable setup has failed we could have disabled | 421 | /* If the fantable setup has failed we could have disabled |
423 | * PHM_PlatformCaps_MicrocodeFanControl even after | 422 | * PHM_PlatformCaps_MicrocodeFanControl even after |
@@ -432,108 +431,34 @@ static int tf_smu7_thermal_start_smc_fan_control(struct pp_hwmgr *hwmgr, | |||
432 | return 0; | 431 | return 0; |
433 | } | 432 | } |
434 | 433 | ||
435 | /** | 434 | int smu7_start_thermal_controller(struct pp_hwmgr *hwmgr, |
436 | * Set temperature range for high and low alerts | 435 | struct PP_TemperatureRange *range) |
437 | * @param hwmgr the address of the powerplay hardware manager. | ||
438 | * @param pInput the pointer to input data | ||
439 | * @param pOutput the pointer to output data | ||
440 | * @param pStorage the pointer to temporary storage | ||
441 | * @param Result the last failure code | ||
442 | * @return result from set temperature range routine | ||
443 | */ | ||
444 | static int tf_smu7_thermal_set_temperature_range(struct pp_hwmgr *hwmgr, | ||
445 | void *input, void *output, void *storage, int result) | ||
446 | { | 436 | { |
447 | struct PP_TemperatureRange *range = (struct PP_TemperatureRange *)input; | 437 | int ret = 0; |
448 | 438 | ||
449 | if (range == NULL) | 439 | if (range == NULL) |
450 | return -EINVAL; | 440 | return -EINVAL; |
451 | 441 | ||
452 | return smu7_thermal_set_temperature_range(hwmgr, range->min, range->max); | 442 | smu7_thermal_initialize(hwmgr); |
453 | } | 443 | ret = smu7_thermal_set_temperature_range(hwmgr, range->min, range->max); |
454 | 444 | if (ret) | |
455 | /** | 445 | return -EINVAL; |
456 | * Programs one-time setting registers | 446 | smu7_thermal_enable_alert(hwmgr); |
457 | * @param hwmgr the address of the powerplay hardware manager. | 447 | ret = smum_thermal_avfs_enable(hwmgr); |
458 | * @param pInput the pointer to input data | 448 | if (ret) |
459 | * @param pOutput the pointer to output data | 449 | return -EINVAL; |
460 | * @param pStorage the pointer to temporary storage | ||
461 | * @param Result the last failure code | ||
462 | * @return result from initialize thermal controller routine | ||
463 | */ | ||
464 | static int tf_smu7_thermal_initialize(struct pp_hwmgr *hwmgr, | ||
465 | void *input, void *output, void *storage, int result) | ||
466 | { | ||
467 | return smu7_thermal_initialize(hwmgr); | ||
468 | } | ||
469 | |||
470 | /** | ||
471 | * Enable high and low alerts | ||
472 | * @param hwmgr the address of the powerplay hardware manager. | ||
473 | * @param pInput the pointer to input data | ||
474 | * @param pOutput the pointer to output data | ||
475 | * @param pStorage the pointer to temporary storage | ||
476 | * @param Result the last failure code | ||
477 | * @return result from enable alert routine | ||
478 | */ | ||
479 | static int tf_smu7_thermal_enable_alert(struct pp_hwmgr *hwmgr, | ||
480 | void *input, void *output, void *storage, int result) | ||
481 | { | ||
482 | return smu7_thermal_enable_alert(hwmgr); | ||
483 | } | ||
484 | |||
485 | /** | ||
486 | * Disable high and low alerts | ||
487 | * @param hwmgr the address of the powerplay hardware manager. | ||
488 | * @param pInput the pointer to input data | ||
489 | * @param pOutput the pointer to output data | ||
490 | * @param pStorage the pointer to temporary storage | ||
491 | * @param Result the last failure code | ||
492 | * @return result from disable alert routine | ||
493 | */ | ||
494 | static int tf_smu7_thermal_disable_alert(struct pp_hwmgr *hwmgr, | ||
495 | void *input, void *output, void *storage, int result) | ||
496 | { | ||
497 | return smu7_thermal_disable_alert(hwmgr); | ||
498 | } | ||
499 | 450 | ||
500 | static const struct phm_master_table_item | ||
501 | phm_thermal_start_thermal_controller_master_list[] = { | ||
502 | { .tableFunction = tf_smu7_thermal_initialize }, | ||
503 | { .tableFunction = tf_smu7_thermal_set_temperature_range }, | ||
504 | { .tableFunction = tf_smu7_thermal_enable_alert }, | ||
505 | { .tableFunction = smum_thermal_avfs_enable }, | ||
506 | /* We should restrict performance levels to low before we halt the SMC. | 451 | /* We should restrict performance levels to low before we halt the SMC. |
507 | * On the other hand we are still in boot state when we do this | 452 | * On the other hand we are still in boot state when we do this |
508 | * so it would be pointless. | 453 | * so it would be pointless. |
509 | * If this assumption changes we have to revisit this table. | 454 | * If this assumption changes we have to revisit this table. |
510 | */ | 455 | */ |
511 | { .tableFunction = smum_thermal_setup_fan_table }, | 456 | smum_thermal_setup_fan_table(hwmgr); |
512 | { .tableFunction = tf_smu7_thermal_start_smc_fan_control }, | 457 | smu7_thermal_start_smc_fan_control(hwmgr); |
513 | { } | 458 | return 0; |
514 | }; | 459 | } |
515 | 460 | ||
516 | static const struct phm_master_table_header | 461 | |
517 | phm_thermal_start_thermal_controller_master = { | ||
518 | 0, | ||
519 | PHM_MasterTableFlag_None, | ||
520 | phm_thermal_start_thermal_controller_master_list | ||
521 | }; | ||
522 | |||
523 | static const struct phm_master_table_item | ||
524 | phm_thermal_set_temperature_range_master_list[] = { | ||
525 | { .tableFunction = tf_smu7_thermal_disable_alert }, | ||
526 | { .tableFunction = tf_smu7_thermal_set_temperature_range }, | ||
527 | { .tableFunction = tf_smu7_thermal_enable_alert }, | ||
528 | { } | ||
529 | }; | ||
530 | |||
531 | static const struct phm_master_table_header | ||
532 | phm_thermal_set_temperature_range_master = { | ||
533 | 0, | ||
534 | PHM_MasterTableFlag_None, | ||
535 | phm_thermal_set_temperature_range_master_list | ||
536 | }; | ||
537 | 462 | ||
538 | int smu7_thermal_ctrl_uninitialize_thermal_controller(struct pp_hwmgr *hwmgr) | 463 | int smu7_thermal_ctrl_uninitialize_thermal_controller(struct pp_hwmgr *hwmgr) |
539 | { | 464 | { |
@@ -542,34 +467,3 @@ int smu7_thermal_ctrl_uninitialize_thermal_controller(struct pp_hwmgr *hwmgr) | |||
542 | return 0; | 467 | return 0; |
543 | } | 468 | } |
544 | 469 | ||
545 | /** | ||
546 | * Initializes the thermal controller related functions in the Hardware Manager structure. | ||
547 | * @param hwmgr The address of the hardware manager. | ||
548 | * @exception Any error code from the low-level communication. | ||
549 | */ | ||
550 | int pp_smu7_thermal_initialize(struct pp_hwmgr *hwmgr) | ||
551 | { | ||
552 | int result; | ||
553 | |||
554 | result = phm_construct_table(hwmgr, | ||
555 | &phm_thermal_set_temperature_range_master, | ||
556 | &(hwmgr->set_temperature_range)); | ||
557 | |||
558 | if (!result) { | ||
559 | result = phm_construct_table(hwmgr, | ||
560 | &phm_thermal_start_thermal_controller_master, | ||
561 | &(hwmgr->start_thermal_controller)); | ||
562 | if (result) | ||
563 | phm_destroy_table(hwmgr, &(hwmgr->set_temperature_range)); | ||
564 | } | ||
565 | |||
566 | if (!result) | ||
567 | hwmgr->fan_ctrl_is_in_default_mode = true; | ||
568 | return result; | ||
569 | } | ||
570 | |||
571 | void pp_smu7_thermal_fini(struct pp_hwmgr *hwmgr) | ||
572 | { | ||
573 | phm_destroy_table(hwmgr, &(hwmgr->set_temperature_range)); | ||
574 | phm_destroy_table(hwmgr, &(hwmgr->start_thermal_controller)); | ||
575 | } | ||
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.h b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.h index ba71b608fa75..42c1ba0fad78 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.h +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.h | |||
@@ -46,14 +46,13 @@ extern int smu7_fan_ctrl_set_default_mode(struct pp_hwmgr *hwmgr); | |||
46 | extern int smu7_fan_ctrl_set_static_mode(struct pp_hwmgr *hwmgr, uint32_t mode); | 46 | extern int smu7_fan_ctrl_set_static_mode(struct pp_hwmgr *hwmgr, uint32_t mode); |
47 | extern int smu7_fan_ctrl_set_fan_speed_percent(struct pp_hwmgr *hwmgr, uint32_t speed); | 47 | extern int smu7_fan_ctrl_set_fan_speed_percent(struct pp_hwmgr *hwmgr, uint32_t speed); |
48 | extern int smu7_fan_ctrl_reset_fan_speed_to_default(struct pp_hwmgr *hwmgr); | 48 | extern int smu7_fan_ctrl_reset_fan_speed_to_default(struct pp_hwmgr *hwmgr); |
49 | extern int pp_smu7_thermal_initialize(struct pp_hwmgr *hwmgr); | ||
50 | extern void pp_smu7_thermal_fini(struct pp_hwmgr *hwmgr); | ||
51 | extern int smu7_thermal_ctrl_uninitialize_thermal_controller(struct pp_hwmgr *hwmgr); | 49 | extern int smu7_thermal_ctrl_uninitialize_thermal_controller(struct pp_hwmgr *hwmgr); |
52 | extern int smu7_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed); | 50 | extern int smu7_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed); |
53 | extern int smu7_fan_ctrl_get_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t *speed); | 51 | extern int smu7_fan_ctrl_get_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t *speed); |
54 | extern int smu7_fan_ctrl_stop_smc_fan_control(struct pp_hwmgr *hwmgr); | 52 | extern int smu7_fan_ctrl_stop_smc_fan_control(struct pp_hwmgr *hwmgr); |
55 | extern int smu7_thermal_enable_alert(struct pp_hwmgr *hwmgr); | ||
56 | extern int smu7_thermal_disable_alert(struct pp_hwmgr *hwmgr); | 53 | extern int smu7_thermal_disable_alert(struct pp_hwmgr *hwmgr); |
57 | extern int smu7_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr); | 54 | extern int smu7_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr); |
55 | extern int smu7_start_thermal_controller(struct pp_hwmgr *hwmgr, | ||
56 | struct PP_TemperatureRange *temperature_range); | ||
58 | #endif | 57 | #endif |
59 | 58 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c index 4d7bd9fc91a8..0eb3c2907de9 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c | |||
@@ -5060,6 +5060,6 @@ int vega10_hwmgr_init(struct pp_hwmgr *hwmgr) | |||
5060 | { | 5060 | { |
5061 | hwmgr->hwmgr_func = &vega10_hwmgr_funcs; | 5061 | hwmgr->hwmgr_func = &vega10_hwmgr_funcs; |
5062 | hwmgr->pptable_func = &vega10_pptable_funcs; | 5062 | hwmgr->pptable_func = &vega10_pptable_funcs; |
5063 | pp_vega10_thermal_initialize(hwmgr); | 5063 | |
5064 | return 0; | 5064 | return 0; |
5065 | } | 5065 | } |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c index 5b3c443d4e94..ce873e40a8fd 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c | |||
@@ -528,8 +528,7 @@ int vega10_thermal_stop_thermal_controller(struct pp_hwmgr *hwmgr) | |||
528 | * @param Result the last failure code | 528 | * @param Result the last failure code |
529 | * @return result from set temperature range routine | 529 | * @return result from set temperature range routine |
530 | */ | 530 | */ |
531 | int tf_vega10_thermal_setup_fan_table(struct pp_hwmgr *hwmgr, | 531 | int vega10_thermal_setup_fan_table(struct pp_hwmgr *hwmgr) |
532 | void *input, void *output, void *storage, int result) | ||
533 | { | 532 | { |
534 | int ret; | 533 | int ret; |
535 | struct vega10_hwmgr *data = (struct vega10_hwmgr *)(hwmgr->backend); | 534 | struct vega10_hwmgr *data = (struct vega10_hwmgr *)(hwmgr->backend); |
@@ -593,8 +592,7 @@ int tf_vega10_thermal_setup_fan_table(struct pp_hwmgr *hwmgr, | |||
593 | * @param Result the last failure code | 592 | * @param Result the last failure code |
594 | * @return result from set temperature range routine | 593 | * @return result from set temperature range routine |
595 | */ | 594 | */ |
596 | int tf_vega10_thermal_start_smc_fan_control(struct pp_hwmgr *hwmgr, | 595 | int vega10_thermal_start_smc_fan_control(struct pp_hwmgr *hwmgr) |
597 | void *input, void *output, void *storage, int result) | ||
598 | { | 596 | { |
599 | /* If the fantable setup has failed we could have disabled | 597 | /* If the fantable setup has failed we could have disabled |
600 | * PHM_PlatformCaps_MicrocodeFanControl even after | 598 | * PHM_PlatformCaps_MicrocodeFanControl even after |
@@ -607,107 +605,37 @@ int tf_vega10_thermal_start_smc_fan_control(struct pp_hwmgr *hwmgr, | |||
607 | return 0; | 605 | return 0; |
608 | } | 606 | } |
609 | 607 | ||
610 | /** | 608 | |
611 | * Set temperature range for high and low alerts | 609 | int vega10_start_thermal_controller(struct pp_hwmgr *hwmgr, |
612 | * @param hwmgr the address of the powerplay hardware manager. | 610 | struct PP_TemperatureRange *range) |
613 | * @param pInput the pointer to input data | ||
614 | * @param pOutput the pointer to output data | ||
615 | * @param pStorage the pointer to temporary storage | ||
616 | * @param Result the last failure code | ||
617 | * @return result from set temperature range routine | ||
618 | */ | ||
619 | int tf_vega10_thermal_set_temperature_range(struct pp_hwmgr *hwmgr, | ||
620 | void *input, void *output, void *storage, int result) | ||
621 | { | 611 | { |
622 | struct PP_TemperatureRange *range = (struct PP_TemperatureRange *)input; | 612 | int ret = 0; |
623 | 613 | ||
624 | if (range == NULL) | 614 | if (range == NULL) |
625 | return -EINVAL; | 615 | return -EINVAL; |
626 | 616 | ||
627 | return vega10_thermal_set_temperature_range(hwmgr, range); | 617 | vega10_thermal_initialize(hwmgr); |
628 | } | 618 | ret = vega10_thermal_set_temperature_range(hwmgr, range); |
629 | 619 | if (ret) | |
630 | /** | 620 | return -EINVAL; |
631 | * Programs one-time setting registers | ||
632 | * @param hwmgr the address of the powerplay hardware manager. | ||
633 | * @param pInput the pointer to input data | ||
634 | * @param pOutput the pointer to output data | ||
635 | * @param pStorage the pointer to temporary storage | ||
636 | * @param Result the last failure code | ||
637 | * @return result from initialize thermal controller routine | ||
638 | */ | ||
639 | int tf_vega10_thermal_initialize(struct pp_hwmgr *hwmgr, | ||
640 | void *input, void *output, void *storage, int result) | ||
641 | { | ||
642 | return vega10_thermal_initialize(hwmgr); | ||
643 | } | ||
644 | |||
645 | /** | ||
646 | * Enable high and low alerts | ||
647 | * @param hwmgr the address of the powerplay hardware manager. | ||
648 | * @param pInput the pointer to input data | ||
649 | * @param pOutput the pointer to output data | ||
650 | * @param pStorage the pointer to temporary storage | ||
651 | * @param Result the last failure code | ||
652 | * @return result from enable alert routine | ||
653 | */ | ||
654 | int tf_vega10_thermal_enable_alert(struct pp_hwmgr *hwmgr, | ||
655 | void *input, void *output, void *storage, int result) | ||
656 | { | ||
657 | return vega10_thermal_enable_alert(hwmgr); | ||
658 | } | ||
659 | |||
660 | /** | ||
661 | * Disable high and low alerts | ||
662 | * @param hwmgr the address of the powerplay hardware manager. | ||
663 | * @param pInput the pointer to input data | ||
664 | * @param pOutput the pointer to output data | ||
665 | * @param pStorage the pointer to temporary storage | ||
666 | * @param Result the last failure code | ||
667 | * @return result from disable alert routine | ||
668 | */ | ||
669 | static int tf_vega10_thermal_disable_alert(struct pp_hwmgr *hwmgr, | ||
670 | void *input, void *output, void *storage, int result) | ||
671 | { | ||
672 | return vega10_thermal_disable_alert(hwmgr); | ||
673 | } | ||
674 | 621 | ||
675 | static struct phm_master_table_item | 622 | vega10_thermal_enable_alert(hwmgr); |
676 | vega10_thermal_start_thermal_controller_master_list[] = { | ||
677 | { .tableFunction = tf_vega10_thermal_initialize }, | ||
678 | { .tableFunction = tf_vega10_thermal_set_temperature_range }, | ||
679 | { .tableFunction = tf_vega10_thermal_enable_alert }, | ||
680 | /* We should restrict performance levels to low before we halt the SMC. | 623 | /* We should restrict performance levels to low before we halt the SMC. |
681 | * On the other hand we are still in boot state when we do this | 624 | * On the other hand we are still in boot state when we do this |
682 | * so it would be pointless. | 625 | * so it would be pointless. |
683 | * If this assumption changes we have to revisit this table. | 626 | * If this assumption changes we have to revisit this table. |
684 | */ | 627 | */ |
685 | { .tableFunction = tf_vega10_thermal_setup_fan_table }, | 628 | ret = vega10_thermal_setup_fan_table(hwmgr); |
686 | { .tableFunction = tf_vega10_thermal_start_smc_fan_control }, | 629 | if (ret) |
687 | { } | 630 | return -EINVAL; |
688 | }; | ||
689 | 631 | ||
690 | static struct phm_master_table_header | 632 | vega10_thermal_start_smc_fan_control(hwmgr); |
691 | vega10_thermal_start_thermal_controller_master = { | ||
692 | 0, | ||
693 | PHM_MasterTableFlag_None, | ||
694 | vega10_thermal_start_thermal_controller_master_list | ||
695 | }; | ||
696 | 633 | ||
697 | static struct phm_master_table_item | 634 | return 0; |
698 | vega10_thermal_set_temperature_range_master_list[] = { | ||
699 | { .tableFunction = tf_vega10_thermal_disable_alert }, | ||
700 | { .tableFunction = tf_vega10_thermal_set_temperature_range }, | ||
701 | { .tableFunction = tf_vega10_thermal_enable_alert }, | ||
702 | { } | ||
703 | }; | 635 | }; |
704 | 636 | ||
705 | struct phm_master_table_header | 637 | |
706 | vega10_thermal_set_temperature_range_master = { | 638 | |
707 | 0, | ||
708 | PHM_MasterTableFlag_None, | ||
709 | vega10_thermal_set_temperature_range_master_list | ||
710 | }; | ||
711 | 639 | ||
712 | int vega10_thermal_ctrl_uninitialize_thermal_controller(struct pp_hwmgr *hwmgr) | 640 | int vega10_thermal_ctrl_uninitialize_thermal_controller(struct pp_hwmgr *hwmgr) |
713 | { | 641 | { |
@@ -717,32 +645,3 @@ int vega10_thermal_ctrl_uninitialize_thermal_controller(struct pp_hwmgr *hwmgr) | |||
717 | } | 645 | } |
718 | return 0; | 646 | return 0; |
719 | } | 647 | } |
720 | |||
721 | /** | ||
722 | * Initializes the thermal controller related functions | ||
723 | * in the Hardware Manager structure. | ||
724 | * @param hwmgr The address of the hardware manager. | ||
725 | * @exception Any error code from the low-level communication. | ||
726 | */ | ||
727 | int pp_vega10_thermal_initialize(struct pp_hwmgr *hwmgr) | ||
728 | { | ||
729 | int result; | ||
730 | |||
731 | result = phm_construct_table(hwmgr, | ||
732 | &vega10_thermal_set_temperature_range_master, | ||
733 | &(hwmgr->set_temperature_range)); | ||
734 | |||
735 | if (!result) { | ||
736 | result = phm_construct_table(hwmgr, | ||
737 | &vega10_thermal_start_thermal_controller_master, | ||
738 | &(hwmgr->start_thermal_controller)); | ||
739 | if (result) | ||
740 | phm_destroy_table(hwmgr, | ||
741 | &(hwmgr->set_temperature_range)); | ||
742 | } | ||
743 | |||
744 | if (!result) | ||
745 | hwmgr->fan_ctrl_is_in_default_mode = true; | ||
746 | return result; | ||
747 | } | ||
748 | |||
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.h b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.h index 776f3a2effc0..f34ce04cfd89 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.h +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.h | |||
@@ -50,13 +50,6 @@ struct vega10_temperature { | |||
50 | #define FDO_PWM_MODE_STATIC_RPM 5 | 50 | #define FDO_PWM_MODE_STATIC_RPM 5 |
51 | 51 | ||
52 | 52 | ||
53 | extern int tf_vega10_thermal_initialize(struct pp_hwmgr *hwmgr, | ||
54 | void *input, void *output, void *storage, int result); | ||
55 | extern int tf_vega10_thermal_set_temperature_range(struct pp_hwmgr *hwmgr, | ||
56 | void *input, void *output, void *storage, int result); | ||
57 | extern int tf_vega10_thermal_enable_alert(struct pp_hwmgr *hwmgr, | ||
58 | void *input, void *output, void *storage, int result); | ||
59 | |||
60 | extern int vega10_thermal_get_temperature(struct pp_hwmgr *hwmgr); | 53 | extern int vega10_thermal_get_temperature(struct pp_hwmgr *hwmgr); |
61 | extern int vega10_thermal_stop_thermal_controller(struct pp_hwmgr *hwmgr); | 54 | extern int vega10_thermal_stop_thermal_controller(struct pp_hwmgr *hwmgr); |
62 | extern int vega10_fan_ctrl_get_fan_speed_info(struct pp_hwmgr *hwmgr, | 55 | extern int vega10_fan_ctrl_get_fan_speed_info(struct pp_hwmgr *hwmgr, |
@@ -69,7 +62,6 @@ extern int vega10_fan_ctrl_set_static_mode(struct pp_hwmgr *hwmgr, | |||
69 | extern int vega10_fan_ctrl_set_fan_speed_percent(struct pp_hwmgr *hwmgr, | 62 | extern int vega10_fan_ctrl_set_fan_speed_percent(struct pp_hwmgr *hwmgr, |
70 | uint32_t speed); | 63 | uint32_t speed); |
71 | extern int vega10_fan_ctrl_reset_fan_speed_to_default(struct pp_hwmgr *hwmgr); | 64 | extern int vega10_fan_ctrl_reset_fan_speed_to_default(struct pp_hwmgr *hwmgr); |
72 | extern int pp_vega10_thermal_initialize(struct pp_hwmgr *hwmgr); | ||
73 | extern int vega10_thermal_ctrl_uninitialize_thermal_controller( | 65 | extern int vega10_thermal_ctrl_uninitialize_thermal_controller( |
74 | struct pp_hwmgr *hwmgr); | 66 | struct pp_hwmgr *hwmgr); |
75 | extern int vega10_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, | 67 | extern int vega10_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, |
@@ -77,9 +69,10 @@ extern int vega10_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, | |||
77 | extern int vega10_fan_ctrl_get_fan_speed_rpm(struct pp_hwmgr *hwmgr, | 69 | extern int vega10_fan_ctrl_get_fan_speed_rpm(struct pp_hwmgr *hwmgr, |
78 | uint32_t *speed); | 70 | uint32_t *speed); |
79 | extern int vega10_fan_ctrl_stop_smc_fan_control(struct pp_hwmgr *hwmgr); | 71 | extern int vega10_fan_ctrl_stop_smc_fan_control(struct pp_hwmgr *hwmgr); |
80 | extern uint32_t smu7_get_xclk(struct pp_hwmgr *hwmgr); | ||
81 | extern int vega10_thermal_disable_alert(struct pp_hwmgr *hwmgr); | 72 | extern int vega10_thermal_disable_alert(struct pp_hwmgr *hwmgr); |
82 | int vega10_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr); | 73 | extern int vega10_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr); |
74 | |||
75 | extern uint32_t smu7_get_xclk(struct pp_hwmgr *hwmgr); | ||
83 | 76 | ||
84 | #endif | 77 | #endif |
85 | 78 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h index 3bbe7d5cb6de..831add448614 100644 --- a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +++ b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | |||
@@ -380,6 +380,7 @@ struct pp_hwmgr_func { | |||
380 | int (*disable_smc_firmware_ctf)(struct pp_hwmgr *hwmgr); | 380 | int (*disable_smc_firmware_ctf)(struct pp_hwmgr *hwmgr); |
381 | int (*set_active_display_count)(struct pp_hwmgr *hwmgr, uint32_t count); | 381 | int (*set_active_display_count)(struct pp_hwmgr *hwmgr, uint32_t count); |
382 | int (*set_deep_sleep_dcefclk)(struct pp_hwmgr *hwmgr, uint32_t clock); | 382 | int (*set_deep_sleep_dcefclk)(struct pp_hwmgr *hwmgr, uint32_t clock); |
383 | int (*start_thermal_controller)(struct pp_hwmgr *hwmgr, struct PP_TemperatureRange *range); | ||
383 | }; | 384 | }; |
384 | 385 | ||
385 | struct pp_table_func { | 386 | struct pp_table_func { |
@@ -766,8 +767,6 @@ struct pp_hwmgr { | |||
766 | struct phm_runtime_table_header set_power_state; | 767 | struct phm_runtime_table_header set_power_state; |
767 | struct phm_runtime_table_header enable_clock_power_gatings; | 768 | struct phm_runtime_table_header enable_clock_power_gatings; |
768 | struct phm_runtime_table_header display_configuration_changed; | 769 | struct phm_runtime_table_header display_configuration_changed; |
769 | struct phm_runtime_table_header start_thermal_controller; | ||
770 | struct phm_runtime_table_header set_temperature_range; | ||
771 | const struct pp_hwmgr_func *hwmgr_func; | 770 | const struct pp_hwmgr_func *hwmgr_func; |
772 | const struct pp_table_func *pptable_func; | 771 | const struct pp_table_func *pptable_func; |
773 | struct pp_power_state *ps; | 772 | struct pp_power_state *ps; |
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smumgr.h b/drivers/gpu/drm/amd/powerplay/inc/smumgr.h index 5d61cc9d4554..eb6609116a7a 100644 --- a/drivers/gpu/drm/amd/powerplay/inc/smumgr.h +++ b/drivers/gpu/drm/amd/powerplay/inc/smumgr.h | |||
@@ -186,10 +186,8 @@ extern int smum_update_sclk_threshold(struct pp_hwmgr *hwmgr); | |||
186 | 186 | ||
187 | extern int smum_update_smc_table(struct pp_hwmgr *hwmgr, uint32_t type); | 187 | extern int smum_update_smc_table(struct pp_hwmgr *hwmgr, uint32_t type); |
188 | extern int smum_process_firmware_header(struct pp_hwmgr *hwmgr); | 188 | extern int smum_process_firmware_header(struct pp_hwmgr *hwmgr); |
189 | extern int smum_thermal_avfs_enable(struct pp_hwmgr *hwmgr, | 189 | extern int smum_thermal_avfs_enable(struct pp_hwmgr *hwmgr); |
190 | void *input, void *output, void *storage, int result); | 190 | extern int smum_thermal_setup_fan_table(struct pp_hwmgr *hwmgr); |
191 | extern int smum_thermal_setup_fan_table(struct pp_hwmgr *hwmgr, | ||
192 | void *input, void *output, void *storage, int result); | ||
193 | extern int smum_init_smc_table(struct pp_hwmgr *hwmgr); | 191 | extern int smum_init_smc_table(struct pp_hwmgr *hwmgr); |
194 | extern int smum_populate_all_graphic_levels(struct pp_hwmgr *hwmgr); | 192 | extern int smum_populate_all_graphic_levels(struct pp_hwmgr *hwmgr); |
195 | extern int smum_populate_all_memory_levels(struct pp_hwmgr *hwmgr); | 193 | extern int smum_populate_all_memory_levels(struct pp_hwmgr *hwmgr); |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c index e397349ce1c9..4527c07bc679 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c | |||
@@ -114,8 +114,7 @@ int smum_early_init(struct pp_instance *handle) | |||
114 | return 0; | 114 | return 0; |
115 | } | 115 | } |
116 | 116 | ||
117 | int smum_thermal_avfs_enable(struct pp_hwmgr *hwmgr, | 117 | int smum_thermal_avfs_enable(struct pp_hwmgr *hwmgr) |
118 | void *input, void *output, void *storage, int result) | ||
119 | { | 118 | { |
120 | if (NULL != hwmgr->smumgr->smumgr_funcs->thermal_avfs_enable) | 119 | if (NULL != hwmgr->smumgr->smumgr_funcs->thermal_avfs_enable) |
121 | return hwmgr->smumgr->smumgr_funcs->thermal_avfs_enable(hwmgr); | 120 | return hwmgr->smumgr->smumgr_funcs->thermal_avfs_enable(hwmgr); |
@@ -123,8 +122,7 @@ int smum_thermal_avfs_enable(struct pp_hwmgr *hwmgr, | |||
123 | return 0; | 122 | return 0; |
124 | } | 123 | } |
125 | 124 | ||
126 | int smum_thermal_setup_fan_table(struct pp_hwmgr *hwmgr, | 125 | int smum_thermal_setup_fan_table(struct pp_hwmgr *hwmgr) |
127 | void *input, void *output, void *storage, int result) | ||
128 | { | 126 | { |
129 | if (NULL != hwmgr->smumgr->smumgr_funcs->thermal_setup_fan_table) | 127 | if (NULL != hwmgr->smumgr->smumgr_funcs->thermal_setup_fan_table) |
130 | return hwmgr->smumgr->smumgr_funcs->thermal_setup_fan_table(hwmgr); | 128 | return hwmgr->smumgr->smumgr_funcs->thermal_setup_fan_table(hwmgr); |