diff options
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c index aeeeb72ebbc4..6b49d406daf6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | |||
@@ -85,8 +85,6 @@ int amdgpu_vce_sw_init(struct amdgpu_device *adev, unsigned long size) | |||
85 | unsigned ucode_version, version_major, version_minor, binary_id; | 85 | unsigned ucode_version, version_major, version_minor, binary_id; |
86 | int i, r; | 86 | int i, r; |
87 | 87 | ||
88 | INIT_DELAYED_WORK(&adev->vce.idle_work, amdgpu_vce_idle_work_handler); | ||
89 | |||
90 | switch (adev->asic_type) { | 88 | switch (adev->asic_type) { |
91 | #ifdef CONFIG_DRM_AMDGPU_CIK | 89 | #ifdef CONFIG_DRM_AMDGPU_CIK |
92 | case CHIP_BONAIRE: | 90 | case CHIP_BONAIRE: |
@@ -197,6 +195,9 @@ int amdgpu_vce_sw_init(struct amdgpu_device *adev, unsigned long size) | |||
197 | adev->vce.filp[i] = NULL; | 195 | adev->vce.filp[i] = NULL; |
198 | } | 196 | } |
199 | 197 | ||
198 | INIT_DELAYED_WORK(&adev->vce.idle_work, amdgpu_vce_idle_work_handler); | ||
199 | mutex_init(&adev->vce.idle_mutex); | ||
200 | |||
200 | return 0; | 201 | return 0; |
201 | } | 202 | } |
202 | 203 | ||
@@ -220,6 +221,7 @@ int amdgpu_vce_sw_fini(struct amdgpu_device *adev) | |||
220 | amdgpu_ring_fini(&adev->vce.ring[1]); | 221 | amdgpu_ring_fini(&adev->vce.ring[1]); |
221 | 222 | ||
222 | release_firmware(adev->vce.fw); | 223 | release_firmware(adev->vce.fw); |
224 | mutex_destroy(&adev->vce.idle_mutex); | ||
223 | 225 | ||
224 | return 0; | 226 | return 0; |
225 | } | 227 | } |
@@ -315,19 +317,19 @@ static void amdgpu_vce_idle_work_handler(struct work_struct *work) | |||
315 | } | 317 | } |
316 | 318 | ||
317 | /** | 319 | /** |
318 | * amdgpu_vce_note_usage - power up VCE | 320 | * amdgpu_vce_ring_begin_use - power up VCE |
319 | * | 321 | * |
320 | * @adev: amdgpu_device pointer | 322 | * @ring: amdgpu ring |
321 | * | 323 | * |
322 | * Make sure VCE is powerd up when we want to use it | 324 | * Make sure VCE is powerd up when we want to use it |
323 | */ | 325 | */ |
324 | static void amdgpu_vce_note_usage(struct amdgpu_device *adev) | 326 | void amdgpu_vce_ring_begin_use(struct amdgpu_ring *ring) |
325 | { | 327 | { |
326 | bool set_clocks = !cancel_delayed_work_sync(&adev->vce.idle_work); | 328 | struct amdgpu_device *adev = ring->adev; |
327 | 329 | bool set_clocks; | |
328 | set_clocks &= schedule_delayed_work(&adev->vce.idle_work, | ||
329 | VCE_IDLE_TIMEOUT); | ||
330 | 330 | ||
331 | mutex_lock(&adev->vce.idle_mutex); | ||
332 | set_clocks = !cancel_delayed_work_sync(&adev->vce.idle_work); | ||
331 | if (set_clocks) { | 333 | if (set_clocks) { |
332 | if (adev->pm.dpm_enabled) { | 334 | if (adev->pm.dpm_enabled) { |
333 | amdgpu_dpm_enable_vce(adev, true); | 335 | amdgpu_dpm_enable_vce(adev, true); |
@@ -335,6 +337,19 @@ static void amdgpu_vce_note_usage(struct amdgpu_device *adev) | |||
335 | amdgpu_asic_set_vce_clocks(adev, 53300, 40000); | 337 | amdgpu_asic_set_vce_clocks(adev, 53300, 40000); |
336 | } | 338 | } |
337 | } | 339 | } |
340 | mutex_unlock(&adev->vce.idle_mutex); | ||
341 | } | ||
342 | |||
343 | /** | ||
344 | * amdgpu_vce_ring_end_use - power VCE down | ||
345 | * | ||
346 | * @ring: amdgpu ring | ||
347 | * | ||
348 | * Schedule work to power VCE down again | ||
349 | */ | ||
350 | void amdgpu_vce_ring_end_use(struct amdgpu_ring *ring) | ||
351 | { | ||
352 | schedule_delayed_work(&ring->adev->vce.idle_work, VCE_IDLE_TIMEOUT); | ||
338 | } | 353 | } |
339 | 354 | ||
340 | /** | 355 | /** |
@@ -355,8 +370,6 @@ void amdgpu_vce_free_handles(struct amdgpu_device *adev, struct drm_file *filp) | |||
355 | if (!handle || adev->vce.filp[i] != filp) | 370 | if (!handle || adev->vce.filp[i] != filp) |
356 | continue; | 371 | continue; |
357 | 372 | ||
358 | amdgpu_vce_note_usage(adev); | ||
359 | |||
360 | r = amdgpu_vce_get_destroy_msg(ring, handle, false, NULL); | 373 | r = amdgpu_vce_get_destroy_msg(ring, handle, false, NULL); |
361 | if (r) | 374 | if (r) |
362 | DRM_ERROR("Error destroying VCE handle (%d)!\n", r); | 375 | DRM_ERROR("Error destroying VCE handle (%d)!\n", r); |
@@ -622,8 +635,6 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, uint32_t ib_idx) | |||
622 | uint32_t *size = &tmp; | 635 | uint32_t *size = &tmp; |
623 | int i, r = 0, idx = 0; | 636 | int i, r = 0, idx = 0; |
624 | 637 | ||
625 | amdgpu_vce_note_usage(p->adev); | ||
626 | |||
627 | while (idx < ib->length_dw) { | 638 | while (idx < ib->length_dw) { |
628 | uint32_t len = amdgpu_get_ib_value(p, ib_idx, idx); | 639 | uint32_t len = amdgpu_get_ib_value(p, ib_idx, idx); |
629 | uint32_t cmd = amdgpu_get_ib_value(p, ib_idx, idx + 1); | 640 | uint32_t cmd = amdgpu_get_ib_value(p, ib_idx, idx + 1); |