diff options
author | Rex Zhu <Rex.Zhu@amd.com> | 2017-01-26 03:25:05 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-02-08 17:22:27 -0500 |
commit | beeea9819d1b85ea4f4beb09d176de9889079c75 (patch) | |
tree | b521cb3f6828d641a42cc7b0b15e5e9b269b261c | |
parent | 28ed5504ab4b211a4e589e648e5ebd1e0caa7a6a (diff) |
drm/amdgpu: refine code for VCE2.0 and related dpm code.
v2: clean up vce cg function.
use sw cg when vce stoped.
1. implement vce_stop function.
2. not start vce when hw_init.
3. refine vce cg/pg code.
4. delete bypass mode.
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-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_pm.c | 12 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/ci_dpm.c | 9 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/kv_dpm.c | 39 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/vce_v2_0.c | 163 |
4 files changed, 111 insertions, 112 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c index a61882ddc804..95e026a4a2de 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | |||
@@ -1142,12 +1142,22 @@ void amdgpu_dpm_enable_vce(struct amdgpu_device *adev, bool enable) | |||
1142 | /* XXX select vce level based on ring/task */ | 1142 | /* XXX select vce level based on ring/task */ |
1143 | adev->pm.dpm.vce_level = AMD_VCE_LEVEL_AC_ALL; | 1143 | adev->pm.dpm.vce_level = AMD_VCE_LEVEL_AC_ALL; |
1144 | mutex_unlock(&adev->pm.mutex); | 1144 | mutex_unlock(&adev->pm.mutex); |
1145 | amdgpu_pm_compute_clocks(adev); | ||
1146 | amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCE, | ||
1147 | AMD_PG_STATE_UNGATE); | ||
1148 | amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_VCE, | ||
1149 | AMD_CG_STATE_UNGATE); | ||
1145 | } else { | 1150 | } else { |
1151 | amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCE, | ||
1152 | AMD_PG_STATE_GATE); | ||
1153 | amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_VCE, | ||
1154 | AMD_CG_STATE_GATE); | ||
1146 | mutex_lock(&adev->pm.mutex); | 1155 | mutex_lock(&adev->pm.mutex); |
1147 | adev->pm.dpm.vce_active = false; | 1156 | adev->pm.dpm.vce_active = false; |
1148 | mutex_unlock(&adev->pm.mutex); | 1157 | mutex_unlock(&adev->pm.mutex); |
1158 | amdgpu_pm_compute_clocks(adev); | ||
1149 | } | 1159 | } |
1150 | amdgpu_pm_compute_clocks(adev); | 1160 | |
1151 | } | 1161 | } |
1152 | } | 1162 | } |
1153 | 1163 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c index a947022bfee8..f97ecb49972e 100644 --- a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c +++ b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c | |||
@@ -4256,12 +4256,6 @@ static int ci_update_vce_dpm(struct amdgpu_device *adev, | |||
4256 | 4256 | ||
4257 | if (amdgpu_current_state->evclk != amdgpu_new_state->evclk) { | 4257 | if (amdgpu_current_state->evclk != amdgpu_new_state->evclk) { |
4258 | if (amdgpu_new_state->evclk) { | 4258 | if (amdgpu_new_state->evclk) { |
4259 | /* turn the clocks on when encoding */ | ||
4260 | ret = amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_VCE, | ||
4261 | AMD_CG_STATE_UNGATE); | ||
4262 | if (ret) | ||
4263 | return ret; | ||
4264 | |||
4265 | pi->smc_state_table.VceBootLevel = ci_get_vce_boot_level(adev); | 4259 | pi->smc_state_table.VceBootLevel = ci_get_vce_boot_level(adev); |
4266 | tmp = RREG32_SMC(ixDPM_TABLE_475); | 4260 | tmp = RREG32_SMC(ixDPM_TABLE_475); |
4267 | tmp &= ~DPM_TABLE_475__VceBootLevel_MASK; | 4261 | tmp &= ~DPM_TABLE_475__VceBootLevel_MASK; |
@@ -4273,9 +4267,6 @@ static int ci_update_vce_dpm(struct amdgpu_device *adev, | |||
4273 | ret = ci_enable_vce_dpm(adev, false); | 4267 | ret = ci_enable_vce_dpm(adev, false); |
4274 | if (ret) | 4268 | if (ret) |
4275 | return ret; | 4269 | return ret; |
4276 | /* turn the clocks off when not encoding */ | ||
4277 | ret = amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_VCE, | ||
4278 | AMD_CG_STATE_GATE); | ||
4279 | } | 4270 | } |
4280 | } | 4271 | } |
4281 | return ret; | 4272 | return ret; |
diff --git a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c index 8159a2dbe427..f5a343cb0010 100644 --- a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c +++ b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c | |||
@@ -1550,11 +1550,6 @@ static int kv_update_vce_dpm(struct amdgpu_device *adev, | |||
1550 | 1550 | ||
1551 | if (amdgpu_new_state->evclk > 0 && amdgpu_current_state->evclk == 0) { | 1551 | if (amdgpu_new_state->evclk > 0 && amdgpu_current_state->evclk == 0) { |
1552 | kv_dpm_powergate_vce(adev, false); | 1552 | kv_dpm_powergate_vce(adev, false); |
1553 | /* turn the clocks on when encoding */ | ||
1554 | ret = amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_VCE, | ||
1555 | AMD_CG_STATE_UNGATE); | ||
1556 | if (ret) | ||
1557 | return ret; | ||
1558 | if (pi->caps_stable_p_state) | 1553 | if (pi->caps_stable_p_state) |
1559 | pi->vce_boot_level = table->count - 1; | 1554 | pi->vce_boot_level = table->count - 1; |
1560 | else | 1555 | else |
@@ -1573,15 +1568,9 @@ static int kv_update_vce_dpm(struct amdgpu_device *adev, | |||
1573 | amdgpu_kv_send_msg_to_smc_with_parameter(adev, | 1568 | amdgpu_kv_send_msg_to_smc_with_parameter(adev, |
1574 | PPSMC_MSG_VCEDPM_SetEnabledMask, | 1569 | PPSMC_MSG_VCEDPM_SetEnabledMask, |
1575 | (1 << pi->vce_boot_level)); | 1570 | (1 << pi->vce_boot_level)); |
1576 | |||
1577 | kv_enable_vce_dpm(adev, true); | 1571 | kv_enable_vce_dpm(adev, true); |
1578 | } else if (amdgpu_new_state->evclk == 0 && amdgpu_current_state->evclk > 0) { | 1572 | } else if (amdgpu_new_state->evclk == 0 && amdgpu_current_state->evclk > 0) { |
1579 | kv_enable_vce_dpm(adev, false); | 1573 | kv_enable_vce_dpm(adev, false); |
1580 | /* turn the clocks off when not encoding */ | ||
1581 | ret = amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_VCE, | ||
1582 | AMD_CG_STATE_GATE); | ||
1583 | if (ret) | ||
1584 | return ret; | ||
1585 | kv_dpm_powergate_vce(adev, true); | 1574 | kv_dpm_powergate_vce(adev, true); |
1586 | } | 1575 | } |
1587 | 1576 | ||
@@ -1713,32 +1702,19 @@ static void kv_dpm_powergate_uvd(struct amdgpu_device *adev, bool gate) | |||
1713 | static void kv_dpm_powergate_vce(struct amdgpu_device *adev, bool gate) | 1702 | static void kv_dpm_powergate_vce(struct amdgpu_device *adev, bool gate) |
1714 | { | 1703 | { |
1715 | struct kv_power_info *pi = kv_get_pi(adev); | 1704 | struct kv_power_info *pi = kv_get_pi(adev); |
1716 | int ret; | ||
1717 | 1705 | ||
1718 | if (pi->vce_power_gated == gate) | 1706 | if (pi->vce_power_gated == gate) |
1719 | return; | 1707 | return; |
1720 | 1708 | ||
1721 | pi->vce_power_gated = gate; | 1709 | pi->vce_power_gated = gate; |
1722 | 1710 | ||
1723 | if (gate) { | 1711 | if (!pi->caps_vce_pg) |
1724 | if (pi->caps_vce_pg) { | 1712 | return; |
1725 | /* shutdown the VCE block */ | 1713 | |
1726 | ret = amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCE, | 1714 | if (gate) |
1727 | AMD_PG_STATE_GATE); | 1715 | amdgpu_kv_notify_message_to_smu(adev, PPSMC_MSG_VCEPowerOFF); |
1728 | /* XXX: check for errors */ | 1716 | else |
1729 | /* power off the VCE block */ | 1717 | amdgpu_kv_notify_message_to_smu(adev, PPSMC_MSG_VCEPowerON); |
1730 | amdgpu_kv_notify_message_to_smu(adev, PPSMC_MSG_VCEPowerOFF); | ||
1731 | } | ||
1732 | } else { | ||
1733 | if (pi->caps_vce_pg) { | ||
1734 | /* power on the VCE block */ | ||
1735 | amdgpu_kv_notify_message_to_smu(adev, PPSMC_MSG_VCEPowerON); | ||
1736 | /* re-init the VCE block */ | ||
1737 | ret = amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCE, | ||
1738 | AMD_PG_STATE_UNGATE); | ||
1739 | /* XXX: check for errors */ | ||
1740 | } | ||
1741 | } | ||
1742 | } | 1718 | } |
1743 | 1719 | ||
1744 | static void kv_dpm_powergate_samu(struct amdgpu_device *adev, bool gate) | 1720 | static void kv_dpm_powergate_samu(struct amdgpu_device *adev, bool gate) |
@@ -2996,7 +2972,6 @@ static int kv_dpm_late_init(void *handle) | |||
2996 | 2972 | ||
2997 | kv_dpm_powergate_acp(adev, true); | 2973 | kv_dpm_powergate_acp(adev, true); |
2998 | kv_dpm_powergate_samu(adev, true); | 2974 | kv_dpm_powergate_samu(adev, true); |
2999 | kv_dpm_powergate_vce(adev, true); | ||
3000 | 2975 | ||
3001 | return 0; | 2976 | return 0; |
3002 | } | 2977 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c index 38ed903dd6f8..13c794961073 100644 --- a/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c +++ b/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c | |||
@@ -46,6 +46,11 @@ static void vce_v2_0_mc_resume(struct amdgpu_device *adev); | |||
46 | static void vce_v2_0_set_ring_funcs(struct amdgpu_device *adev); | 46 | static void vce_v2_0_set_ring_funcs(struct amdgpu_device *adev); |
47 | static void vce_v2_0_set_irq_funcs(struct amdgpu_device *adev); | 47 | static void vce_v2_0_set_irq_funcs(struct amdgpu_device *adev); |
48 | static int vce_v2_0_wait_for_idle(void *handle); | 48 | static int vce_v2_0_wait_for_idle(void *handle); |
49 | static void vce_v2_0_init_cg(struct amdgpu_device *adev); | ||
50 | static void vce_v2_0_disable_cg(struct amdgpu_device *adev); | ||
51 | static void vce_v2_0_enable_mgcg(struct amdgpu_device *adev, bool enable, | ||
52 | bool sw_cg); | ||
53 | |||
49 | /** | 54 | /** |
50 | * vce_v2_0_ring_get_rptr - get read pointer | 55 | * vce_v2_0_ring_get_rptr - get read pointer |
51 | * | 56 | * |
@@ -152,11 +157,14 @@ static int vce_v2_0_start(struct amdgpu_device *adev) | |||
152 | struct amdgpu_ring *ring; | 157 | struct amdgpu_ring *ring; |
153 | int r; | 158 | int r; |
154 | 159 | ||
155 | vce_v2_0_mc_resume(adev); | ||
156 | |||
157 | /* set BUSY flag */ | 160 | /* set BUSY flag */ |
158 | WREG32_P(mmVCE_STATUS, 1, ~1); | 161 | WREG32_P(mmVCE_STATUS, 1, ~1); |
159 | 162 | ||
163 | vce_v2_0_init_cg(adev); | ||
164 | vce_v2_0_disable_cg(adev); | ||
165 | |||
166 | vce_v2_0_mc_resume(adev); | ||
167 | |||
160 | ring = &adev->vce.ring[0]; | 168 | ring = &adev->vce.ring[0]; |
161 | WREG32(mmVCE_RB_RPTR, ring->wptr); | 169 | WREG32(mmVCE_RB_RPTR, ring->wptr); |
162 | WREG32(mmVCE_RB_WPTR, ring->wptr); | 170 | WREG32(mmVCE_RB_WPTR, ring->wptr); |
@@ -189,6 +197,54 @@ static int vce_v2_0_start(struct amdgpu_device *adev) | |||
189 | return 0; | 197 | return 0; |
190 | } | 198 | } |
191 | 199 | ||
200 | static int vce_v2_0_stop(struct amdgpu_device *adev) | ||
201 | { | ||
202 | int i, j; | ||
203 | int status; | ||
204 | |||
205 | if (vce_v2_0_lmi_clean(adev)) { | ||
206 | DRM_INFO("vce is not idle \n"); | ||
207 | return 0; | ||
208 | } | ||
209 | /* | ||
210 | for (i = 0; i < 10; ++i) { | ||
211 | for (j = 0; j < 100; ++j) { | ||
212 | status = RREG32(mmVCE_FW_REG_STATUS); | ||
213 | if (!(status & 1)) | ||
214 | break; | ||
215 | mdelay(1); | ||
216 | } | ||
217 | break; | ||
218 | } | ||
219 | */ | ||
220 | if (vce_v2_0_wait_for_idle(adev)) { | ||
221 | DRM_INFO("VCE is busy, Can't set clock gateing"); | ||
222 | return 0; | ||
223 | } | ||
224 | |||
225 | /* Stall UMC and register bus before resetting VCPU */ | ||
226 | WREG32_P(mmVCE_LMI_CTRL2, 1 << 8, ~(1 << 8)); | ||
227 | |||
228 | for (i = 0; i < 10; ++i) { | ||
229 | for (j = 0; j < 100; ++j) { | ||
230 | status = RREG32(mmVCE_LMI_STATUS); | ||
231 | if (status & 0x240) | ||
232 | break; | ||
233 | mdelay(1); | ||
234 | } | ||
235 | break; | ||
236 | } | ||
237 | |||
238 | WREG32_P(mmVCE_VCPU_CNTL, 0, ~0x80001); | ||
239 | |||
240 | /* put LMI, VCPU, RBC etc... into reset */ | ||
241 | WREG32_P(mmVCE_SOFT_RESET, 1, ~0x1); | ||
242 | |||
243 | WREG32(mmVCE_STATUS, 0); | ||
244 | |||
245 | return 0; | ||
246 | } | ||
247 | |||
192 | static int vce_v2_0_early_init(void *handle) | 248 | static int vce_v2_0_early_init(void *handle) |
193 | { | 249 | { |
194 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 250 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
@@ -254,11 +310,8 @@ static int vce_v2_0_hw_init(void *handle) | |||
254 | int r, i; | 310 | int r, i; |
255 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 311 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
256 | 312 | ||
257 | r = vce_v2_0_start(adev); | 313 | amdgpu_asic_set_vce_clocks(adev, 10000, 10000); |
258 | /* this error mean vcpu not in running state, so just skip ring test, not stop driver initialize */ | 314 | vce_v2_0_enable_mgcg(adev, true, false); |
259 | if (r) | ||
260 | return 0; | ||
261 | |||
262 | for (i = 0; i < adev->vce.num_rings; i++) | 315 | for (i = 0; i < adev->vce.num_rings; i++) |
263 | adev->vce.ring[i].ready = false; | 316 | adev->vce.ring[i].ready = false; |
264 | 317 | ||
@@ -349,50 +402,40 @@ static void vce_v2_0_set_sw_cg(struct amdgpu_device *adev, bool gated) | |||
349 | 402 | ||
350 | static void vce_v2_0_set_dyn_cg(struct amdgpu_device *adev, bool gated) | 403 | static void vce_v2_0_set_dyn_cg(struct amdgpu_device *adev, bool gated) |
351 | { | 404 | { |
352 | if (vce_v2_0_wait_for_idle(adev)) { | 405 | u32 orig, tmp; |
353 | DRM_INFO("VCE is busy, Can't set clock gateing"); | ||
354 | return; | ||
355 | } | ||
356 | |||
357 | WREG32_P(mmVCE_LMI_CTRL2, 0x100, ~0x100); | ||
358 | 406 | ||
359 | if (vce_v2_0_lmi_clean(adev)) { | 407 | /* LMI_MC/LMI_UMC always set in dynamic, |
360 | DRM_INFO("LMI is busy, Can't set clock gateing"); | 408 | * set {CGC_*_GATE_MODE, CGC_*_SW_GATE} = {0, 0} |
361 | return; | 409 | */ |
362 | } | 410 | tmp = RREG32(mmVCE_CLOCK_GATING_B); |
363 | 411 | tmp &= ~0x00060006; | |
364 | WREG32_P(mmVCE_VCPU_CNTL, 0, ~VCE_VCPU_CNTL__CLK_EN_MASK); | ||
365 | WREG32_P(mmVCE_SOFT_RESET, | ||
366 | VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK, | ||
367 | ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK); | ||
368 | WREG32(mmVCE_STATUS, 0); | ||
369 | 412 | ||
370 | if (gated) | 413 | /* Exception for ECPU, IH, SEM, SYS blocks needs to be turned on/off by SW */ |
371 | WREG32(mmVCE_CGTT_CLK_OVERRIDE, 0); | ||
372 | /* LMI_MC/LMI_UMC always set in dynamic, set {CGC_*_GATE_MODE, CGC_*_SW_GATE} = {0, 0} */ | ||
373 | if (gated) { | 414 | if (gated) { |
374 | /* Force CLOCK OFF , set {CGC_*_GATE_MODE, CGC_*_SW_GATE} = {*, 1} */ | 415 | tmp |= 0xe10000; |
375 | WREG32(mmVCE_CLOCK_GATING_B, 0xe90010); | 416 | WREG32(mmVCE_CLOCK_GATING_B, tmp); |
376 | } else { | 417 | } else { |
377 | /* Force CLOCK ON, set {CGC_*_GATE_MODE, CGC_*_SW_GATE} = {1, 0} */ | 418 | tmp |= 0xe1; |
378 | WREG32(mmVCE_CLOCK_GATING_B, 0x800f1); | 419 | tmp &= ~0xe10000; |
420 | WREG32(mmVCE_CLOCK_GATING_B, tmp); | ||
379 | } | 421 | } |
380 | 422 | ||
381 | /* Set VCE_UENC_CLOCK_GATING always in dynamic mode {*_FORCE_ON, *_FORCE_OFF} = {0, 0}*/; | 423 | orig = tmp = RREG32(mmVCE_UENC_CLOCK_GATING); |
382 | WREG32(mmVCE_UENC_CLOCK_GATING, 0x40); | 424 | tmp &= ~0x1fe000; |
425 | tmp &= ~0xff000000; | ||
426 | if (tmp != orig) | ||
427 | WREG32(mmVCE_UENC_CLOCK_GATING, tmp); | ||
428 | |||
429 | orig = tmp = RREG32(mmVCE_UENC_REG_CLOCK_GATING); | ||
430 | tmp &= ~0x3fc; | ||
431 | if (tmp != orig) | ||
432 | WREG32(mmVCE_UENC_REG_CLOCK_GATING, tmp); | ||
383 | 433 | ||
384 | /* set VCE_UENC_REG_CLOCK_GATING always in dynamic mode */ | 434 | /* set VCE_UENC_REG_CLOCK_GATING always in dynamic mode */ |
385 | WREG32(mmVCE_UENC_REG_CLOCK_GATING, 0x00); | 435 | WREG32(mmVCE_UENC_REG_CLOCK_GATING, 0x00); |
386 | 436 | ||
387 | WREG32_P(mmVCE_LMI_CTRL2, 0, ~0x100); | 437 | if(gated) |
388 | if(!gated) { | 438 | WREG32(mmVCE_CGTT_CLK_OVERRIDE, 0); |
389 | WREG32_P(mmVCE_VCPU_CNTL, VCE_VCPU_CNTL__CLK_EN_MASK, ~VCE_VCPU_CNTL__CLK_EN_MASK); | ||
390 | mdelay(100); | ||
391 | WREG32_P(mmVCE_SOFT_RESET, 0, ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK); | ||
392 | |||
393 | vce_v2_0_firmware_loaded(adev); | ||
394 | WREG32_P(mmVCE_STATUS, 0, ~VCE_STATUS__JOB_BUSY_MASK); | ||
395 | } | ||
396 | } | 439 | } |
397 | 440 | ||
398 | static void vce_v2_0_disable_cg(struct amdgpu_device *adev) | 441 | static void vce_v2_0_disable_cg(struct amdgpu_device *adev) |
@@ -400,10 +443,9 @@ static void vce_v2_0_disable_cg(struct amdgpu_device *adev) | |||
400 | WREG32(mmVCE_CGTT_CLK_OVERRIDE, 7); | 443 | WREG32(mmVCE_CGTT_CLK_OVERRIDE, 7); |
401 | } | 444 | } |
402 | 445 | ||
403 | static void vce_v2_0_enable_mgcg(struct amdgpu_device *adev, bool enable) | 446 | static void vce_v2_0_enable_mgcg(struct amdgpu_device *adev, bool enable, |
447 | bool sw_cg) | ||
404 | { | 448 | { |
405 | bool sw_cg = false; | ||
406 | |||
407 | if (enable && (adev->cg_flags & AMD_CG_SUPPORT_VCE_MGCG)) { | 449 | if (enable && (adev->cg_flags & AMD_CG_SUPPORT_VCE_MGCG)) { |
408 | if (sw_cg) | 450 | if (sw_cg) |
409 | vce_v2_0_set_sw_cg(adev, true); | 451 | vce_v2_0_set_sw_cg(adev, true); |
@@ -473,8 +515,6 @@ static void vce_v2_0_mc_resume(struct amdgpu_device *adev) | |||
473 | 515 | ||
474 | WREG32_P(mmVCE_LMI_CTRL2, 0x0, ~0x100); | 516 | WREG32_P(mmVCE_LMI_CTRL2, 0x0, ~0x100); |
475 | WREG32_FIELD(VCE_SYS_INT_EN, VCE_SYS_INT_TRAP_INTERRUPT_EN, 1); | 517 | WREG32_FIELD(VCE_SYS_INT_EN, VCE_SYS_INT_TRAP_INTERRUPT_EN, 1); |
476 | |||
477 | vce_v2_0_init_cg(adev); | ||
478 | } | 518 | } |
479 | 519 | ||
480 | static bool vce_v2_0_is_idle(void *handle) | 520 | static bool vce_v2_0_is_idle(void *handle) |
@@ -539,33 +579,20 @@ static int vce_v2_0_process_interrupt(struct amdgpu_device *adev, | |||
539 | return 0; | 579 | return 0; |
540 | } | 580 | } |
541 | 581 | ||
542 | static void vce_v2_0_set_bypass_mode(struct amdgpu_device *adev, bool enable) | ||
543 | { | ||
544 | u32 tmp = RREG32_SMC(ixGCK_DFS_BYPASS_CNTL); | ||
545 | |||
546 | if (enable) | ||
547 | tmp |= GCK_DFS_BYPASS_CNTL__BYPASSECLK_MASK; | ||
548 | else | ||
549 | tmp &= ~GCK_DFS_BYPASS_CNTL__BYPASSECLK_MASK; | ||
550 | |||
551 | WREG32_SMC(ixGCK_DFS_BYPASS_CNTL, tmp); | ||
552 | } | ||
553 | |||
554 | |||
555 | static int vce_v2_0_set_clockgating_state(void *handle, | 582 | static int vce_v2_0_set_clockgating_state(void *handle, |
556 | enum amd_clockgating_state state) | 583 | enum amd_clockgating_state state) |
557 | { | 584 | { |
558 | bool gate = false; | 585 | bool gate = false; |
559 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 586 | bool sw_cg = false; |
560 | bool enable = (state == AMD_CG_STATE_GATE) ? true : false; | ||
561 | |||
562 | 587 | ||
563 | vce_v2_0_set_bypass_mode(adev, enable); | 588 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
564 | 589 | ||
565 | if (state == AMD_CG_STATE_GATE) | 590 | if (state == AMD_CG_STATE_GATE) { |
566 | gate = true; | 591 | gate = true; |
592 | sw_cg = true; | ||
593 | } | ||
567 | 594 | ||
568 | vce_v2_0_enable_mgcg(adev, gate); | 595 | vce_v2_0_enable_mgcg(adev, gate, sw_cg); |
569 | 596 | ||
570 | return 0; | 597 | return 0; |
571 | } | 598 | } |
@@ -582,12 +609,8 @@ static int vce_v2_0_set_powergating_state(void *handle, | |||
582 | */ | 609 | */ |
583 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 610 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
584 | 611 | ||
585 | if (!(adev->pg_flags & AMD_PG_SUPPORT_VCE)) | ||
586 | return 0; | ||
587 | |||
588 | if (state == AMD_PG_STATE_GATE) | 612 | if (state == AMD_PG_STATE_GATE) |
589 | /* XXX do we need a vce_v2_0_stop()? */ | 613 | return vce_v2_0_stop(adev); |
590 | return 0; | ||
591 | else | 614 | else |
592 | return vce_v2_0_start(adev); | 615 | return vce_v2_0_start(adev); |
593 | } | 616 | } |