diff options
author | Rex Zhu <Rex.Zhu@amd.com> | 2018-03-22 03:12:59 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-04-11 14:07:48 -0400 |
commit | b61e54cb1881c7cb74787da6a5d39d8d48dcc075 (patch) | |
tree | ed8730cabfd6a5cabb3ca55e555c39b023c91235 | |
parent | ba8ab90e6ac9322f39ab8368941b38b5bb12477c (diff) |
drm/amd/pp: Lock pm_funcs when set pp table
unlock mutex until set pp table completely to avoid
conflict if other pp functions were called simultaneously.
use hwmgr_handle_task instand of pp_dpm_dispatch_tasks.
It is not make sense that call pp_functions in ip_functions.
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c index 6503bbfdc76e..9ada102e253c 100644 --- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c +++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c | |||
@@ -31,8 +31,6 @@ | |||
31 | #include "amdgpu.h" | 31 | #include "amdgpu.h" |
32 | #include "hwmgr.h" | 32 | #include "hwmgr.h" |
33 | 33 | ||
34 | static int pp_dpm_dispatch_tasks(void *handle, enum amd_pp_task task_id, | ||
35 | enum amd_pm_state_type *user_state); | ||
36 | 34 | ||
37 | static const struct amd_pm_funcs pp_dpm_funcs; | 35 | static const struct amd_pm_funcs pp_dpm_funcs; |
38 | 36 | ||
@@ -146,10 +144,12 @@ static int pp_late_init(void *handle) | |||
146 | struct amdgpu_device *adev = handle; | 144 | struct amdgpu_device *adev = handle; |
147 | struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle; | 145 | struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle; |
148 | 146 | ||
149 | if (hwmgr && hwmgr->pm_en) | 147 | if (hwmgr && hwmgr->pm_en) { |
150 | pp_dpm_dispatch_tasks(hwmgr, | 148 | mutex_lock(&hwmgr->smu_lock); |
149 | hwmgr_handle_task(hwmgr, | ||
151 | AMD_PP_TASK_COMPLETE_INIT, NULL); | 150 | AMD_PP_TASK_COMPLETE_INIT, NULL); |
152 | 151 | mutex_unlock(&hwmgr->smu_lock); | |
152 | } | ||
153 | return 0; | 153 | return 0; |
154 | } | 154 | } |
155 | 155 | ||
@@ -620,7 +620,7 @@ static int amd_powerplay_reset(void *handle) | |||
620 | static int pp_dpm_set_pp_table(void *handle, const char *buf, size_t size) | 620 | static int pp_dpm_set_pp_table(void *handle, const char *buf, size_t size) |
621 | { | 621 | { |
622 | struct pp_hwmgr *hwmgr = handle; | 622 | struct pp_hwmgr *hwmgr = handle; |
623 | int ret = 0; | 623 | int ret = -ENOMEM; |
624 | 624 | ||
625 | if (!hwmgr || !hwmgr->pm_en) | 625 | if (!hwmgr || !hwmgr->pm_en) |
626 | return -EINVAL; | 626 | return -EINVAL; |
@@ -630,28 +630,28 @@ static int pp_dpm_set_pp_table(void *handle, const char *buf, size_t size) | |||
630 | hwmgr->hardcode_pp_table = kmemdup(hwmgr->soft_pp_table, | 630 | hwmgr->hardcode_pp_table = kmemdup(hwmgr->soft_pp_table, |
631 | hwmgr->soft_pp_table_size, | 631 | hwmgr->soft_pp_table_size, |
632 | GFP_KERNEL); | 632 | GFP_KERNEL); |
633 | if (!hwmgr->hardcode_pp_table) { | 633 | if (!hwmgr->hardcode_pp_table) |
634 | mutex_unlock(&hwmgr->smu_lock); | 634 | goto err; |
635 | return -ENOMEM; | ||
636 | } | ||
637 | } | 635 | } |
638 | 636 | ||
639 | memcpy(hwmgr->hardcode_pp_table, buf, size); | 637 | memcpy(hwmgr->hardcode_pp_table, buf, size); |
640 | 638 | ||
641 | hwmgr->soft_pp_table = hwmgr->hardcode_pp_table; | 639 | hwmgr->soft_pp_table = hwmgr->hardcode_pp_table; |
642 | mutex_unlock(&hwmgr->smu_lock); | ||
643 | 640 | ||
644 | ret = amd_powerplay_reset(handle); | 641 | ret = amd_powerplay_reset(handle); |
645 | if (ret) | 642 | if (ret) |
646 | return ret; | 643 | goto err; |
647 | 644 | ||
648 | if (hwmgr->hwmgr_func->avfs_control) { | 645 | if (hwmgr->hwmgr_func->avfs_control) { |
649 | ret = hwmgr->hwmgr_func->avfs_control(hwmgr, false); | 646 | ret = hwmgr->hwmgr_func->avfs_control(hwmgr, false); |
650 | if (ret) | 647 | if (ret) |
651 | return ret; | 648 | goto err; |
652 | } | 649 | } |
653 | 650 | mutex_unlock(&hwmgr->smu_lock); | |
654 | return 0; | 651 | return 0; |
652 | err: | ||
653 | mutex_unlock(&hwmgr->smu_lock); | ||
654 | return ret; | ||
655 | } | 655 | } |
656 | 656 | ||
657 | static int pp_dpm_force_clock_level(void *handle, | 657 | static int pp_dpm_force_clock_level(void *handle, |