diff options
author | Rex Zhu <Rex.Zhu@amd.com> | 2016-12-28 06:43:23 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-01-27 11:12:58 -0500 |
commit | 1c86380248467b99a0d9a9f7fdd0834fa0c6c5aa (patch) | |
tree | 45b21f37f3b7478c4c3e1e6cd654a2fb0c6769a9 /drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c | |
parent | ae6a58e4090365f0ed6b24e0a67b8a08f6b55856 (diff) |
drm/amd/powerplay: refine powerplay interface.
v2: add pp_check function to check pp_instance
valid.
1. powerplay export two new interface to amdgpu,
amd_powerplay_create/amd_powerplay_destroy.
2. create pp_instance/smumgr/hwmgr/eventmgr in
early init, destroy them when lata_fini.
3. in sw_init, create and init asic private smumgr
data, and free them when sw_fini.
4. in hw_init, create and init asic private hwmgr
data, and free them when hw_fini.
5. export powerplay state: PP_DPM_DISABLED.
when user disabled powerplay or hwmgr/eventmgr
init failed, powerplay return this state to amdgpu.
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c | 108 |
1 files changed, 52 insertions, 56 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c index b1921c7da36b..8856eccc37fa 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c | |||
@@ -34,63 +34,34 @@ | |||
34 | #include "cik_dpm.h" | 34 | #include "cik_dpm.h" |
35 | #include "vi_dpm.h" | 35 | #include "vi_dpm.h" |
36 | 36 | ||
37 | static int amdgpu_powerplay_init(struct amdgpu_device *adev) | 37 | static int amdgpu_create_pp_handle(struct amdgpu_device *adev) |
38 | { | 38 | { |
39 | int ret = 0; | 39 | struct amd_pp_init pp_init; |
40 | struct amd_powerplay *amd_pp; | 40 | struct amd_powerplay *amd_pp; |
41 | int ret; | ||
41 | 42 | ||
42 | amd_pp = &(adev->powerplay); | 43 | amd_pp = &(adev->powerplay); |
43 | 44 | pp_init.chip_family = adev->family; | |
44 | if (adev->pp_enabled) { | 45 | pp_init.chip_id = adev->asic_type; |
45 | struct amd_pp_init *pp_init; | 46 | pp_init.pm_en = amdgpu_dpm != 0 ? true : false; |
46 | 47 | pp_init.feature_mask = amdgpu_pp_feature_mask; | |
47 | pp_init = kzalloc(sizeof(struct amd_pp_init), GFP_KERNEL); | 48 | pp_init.device = amdgpu_cgs_create_device(adev); |
48 | 49 | ret = amd_powerplay_create(&pp_init, &(amd_pp->pp_handle)); | |
49 | if (pp_init == NULL) | 50 | if (ret) |
50 | return -ENOMEM; | 51 | return -EINVAL; |
51 | 52 | return 0; | |
52 | pp_init->chip_family = adev->family; | ||
53 | pp_init->chip_id = adev->asic_type; | ||
54 | pp_init->device = amdgpu_cgs_create_device(adev); | ||
55 | ret = amd_powerplay_init(pp_init, amd_pp); | ||
56 | kfree(pp_init); | ||
57 | } else { | ||
58 | amd_pp->pp_handle = (void *)adev; | ||
59 | |||
60 | switch (adev->asic_type) { | ||
61 | #ifdef CONFIG_DRM_AMDGPU_SI | ||
62 | case CHIP_TAHITI: | ||
63 | case CHIP_PITCAIRN: | ||
64 | case CHIP_VERDE: | ||
65 | case CHIP_OLAND: | ||
66 | case CHIP_HAINAN: | ||
67 | amd_pp->ip_funcs = &si_dpm_ip_funcs; | ||
68 | break; | ||
69 | #endif | ||
70 | #ifdef CONFIG_DRM_AMDGPU_CIK | ||
71 | case CHIP_BONAIRE: | ||
72 | case CHIP_HAWAII: | ||
73 | amd_pp->ip_funcs = &ci_dpm_ip_funcs; | ||
74 | break; | ||
75 | case CHIP_KABINI: | ||
76 | case CHIP_MULLINS: | ||
77 | case CHIP_KAVERI: | ||
78 | amd_pp->ip_funcs = &kv_dpm_ip_funcs; | ||
79 | break; | ||
80 | #endif | ||
81 | default: | ||
82 | ret = -EINVAL; | ||
83 | break; | ||
84 | } | ||
85 | } | ||
86 | return ret; | ||
87 | } | 53 | } |
88 | 54 | ||
89 | static int amdgpu_pp_early_init(void *handle) | 55 | static int amdgpu_pp_early_init(void *handle) |
90 | { | 56 | { |
91 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 57 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
58 | struct amd_powerplay *amd_pp; | ||
92 | int ret = 0; | 59 | int ret = 0; |
93 | 60 | ||
61 | amd_pp = &(adev->powerplay); | ||
62 | adev->pp_enabled = false; | ||
63 | amd_pp->pp_handle = (void *)adev; | ||
64 | |||
94 | switch (adev->asic_type) { | 65 | switch (adev->asic_type) { |
95 | case CHIP_POLARIS11: | 66 | case CHIP_POLARIS11: |
96 | case CHIP_POLARIS10: | 67 | case CHIP_POLARIS10: |
@@ -101,25 +72,45 @@ static int amdgpu_pp_early_init(void *handle) | |||
101 | case CHIP_CARRIZO: | 72 | case CHIP_CARRIZO: |
102 | case CHIP_STONEY: | 73 | case CHIP_STONEY: |
103 | adev->pp_enabled = true; | 74 | adev->pp_enabled = true; |
75 | if (amdgpu_create_pp_handle(adev)) | ||
76 | return -EINVAL; | ||
77 | amd_pp->ip_funcs = &pp_ip_funcs; | ||
78 | amd_pp->pp_funcs = &pp_dpm_funcs; | ||
104 | break; | 79 | break; |
105 | /* These chips don't have powerplay implemenations */ | 80 | /* These chips don't have powerplay implemenations */ |
81 | #ifdef CONFIG_DRM_AMDGPU_SI | ||
82 | case CHIP_TAHITI: | ||
83 | case CHIP_PITCAIRN: | ||
84 | case CHIP_VERDE: | ||
85 | case CHIP_OLAND: | ||
86 | case CHIP_HAINAN: | ||
87 | amd_pp->ip_funcs = &si_dpm_ip_funcs; | ||
88 | break; | ||
89 | #endif | ||
90 | #ifdef CONFIG_DRM_AMDGPU_CIK | ||
106 | case CHIP_BONAIRE: | 91 | case CHIP_BONAIRE: |
107 | case CHIP_HAWAII: | 92 | case CHIP_HAWAII: |
93 | amd_pp->ip_funcs = &ci_dpm_ip_funcs; | ||
94 | break; | ||
108 | case CHIP_KABINI: | 95 | case CHIP_KABINI: |
109 | case CHIP_MULLINS: | 96 | case CHIP_MULLINS: |
110 | case CHIP_KAVERI: | 97 | case CHIP_KAVERI: |
98 | amd_pp->ip_funcs = &kv_dpm_ip_funcs; | ||
99 | break; | ||
100 | #endif | ||
111 | default: | 101 | default: |
112 | adev->pp_enabled = false; | 102 | ret = -EINVAL; |
113 | break; | 103 | break; |
114 | } | 104 | } |
115 | 105 | ||
116 | ret = amdgpu_powerplay_init(adev); | ||
117 | if (ret) | ||
118 | return ret; | ||
119 | |||
120 | if (adev->powerplay.ip_funcs->early_init) | 106 | if (adev->powerplay.ip_funcs->early_init) |
121 | ret = adev->powerplay.ip_funcs->early_init( | 107 | ret = adev->powerplay.ip_funcs->early_init( |
122 | adev->powerplay.pp_handle); | 108 | adev->powerplay.pp_handle); |
109 | |||
110 | if (ret == PP_DPM_DISABLED) { | ||
111 | adev->pm.dpm_enabled = false; | ||
112 | return 0; | ||
113 | } | ||
123 | return ret; | 114 | return ret; |
124 | } | 115 | } |
125 | 116 | ||
@@ -179,6 +170,11 @@ static int amdgpu_pp_hw_init(void *handle) | |||
179 | ret = adev->powerplay.ip_funcs->hw_init( | 170 | ret = adev->powerplay.ip_funcs->hw_init( |
180 | adev->powerplay.pp_handle); | 171 | adev->powerplay.pp_handle); |
181 | 172 | ||
173 | if (ret == PP_DPM_DISABLED) { | ||
174 | adev->pm.dpm_enabled = false; | ||
175 | return 0; | ||
176 | } | ||
177 | |||
182 | if ((amdgpu_dpm != 0) && !amdgpu_sriov_vf(adev)) | 178 | if ((amdgpu_dpm != 0) && !amdgpu_sriov_vf(adev)) |
183 | adev->pm.dpm_enabled = true; | 179 | adev->pm.dpm_enabled = true; |
184 | 180 | ||
@@ -204,14 +200,14 @@ static void amdgpu_pp_late_fini(void *handle) | |||
204 | { | 200 | { |
205 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 201 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
206 | 202 | ||
207 | if (adev->pp_enabled) { | ||
208 | amdgpu_pm_sysfs_fini(adev); | ||
209 | amd_powerplay_fini(adev->powerplay.pp_handle); | ||
210 | } | ||
211 | |||
212 | if (adev->powerplay.ip_funcs->late_fini) | 203 | if (adev->powerplay.ip_funcs->late_fini) |
213 | adev->powerplay.ip_funcs->late_fini( | 204 | adev->powerplay.ip_funcs->late_fini( |
214 | adev->powerplay.pp_handle); | 205 | adev->powerplay.pp_handle); |
206 | |||
207 | if (adev->pp_enabled && adev->pm.dpm_enabled) | ||
208 | amdgpu_pm_sysfs_fini(adev); | ||
209 | |||
210 | amd_powerplay_destroy(adev->powerplay.pp_handle); | ||
215 | } | 211 | } |
216 | 212 | ||
217 | static int amdgpu_pp_suspend(void *handle) | 213 | static int amdgpu_pp_suspend(void *handle) |