.. | .. |
---|
22 | 22 | * Authors: Christian König <christian.koenig@amd.com> |
---|
23 | 23 | */ |
---|
24 | 24 | |
---|
| 25 | +#include <linux/delay.h> |
---|
25 | 26 | #include <linux/firmware.h> |
---|
26 | | -#include <drm/drmP.h> |
---|
| 27 | + |
---|
27 | 28 | #include "amdgpu.h" |
---|
28 | 29 | #include "amdgpu_uvd.h" |
---|
29 | 30 | #include "vid.h" |
---|
.. | .. |
---|
105 | 106 | int r; |
---|
106 | 107 | |
---|
107 | 108 | /* UVD TRAP */ |
---|
108 | | - r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_UVD_SYSTEM_MESSAGE, &adev->uvd.inst->irq); |
---|
| 109 | + r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_UVD_SYSTEM_MESSAGE, &adev->uvd.inst->irq); |
---|
109 | 110 | if (r) |
---|
110 | 111 | return r; |
---|
111 | 112 | |
---|
.. | .. |
---|
115 | 116 | |
---|
116 | 117 | ring = &adev->uvd.inst->ring; |
---|
117 | 118 | sprintf(ring->name, "uvd"); |
---|
118 | | - r = amdgpu_ring_init(adev, ring, 512, &adev->uvd.inst->irq, 0); |
---|
| 119 | + r = amdgpu_ring_init(adev, ring, 512, &adev->uvd.inst->irq, 0, |
---|
| 120 | + AMDGPU_RING_PRIO_DEFAULT); |
---|
119 | 121 | if (r) |
---|
120 | 122 | return r; |
---|
121 | 123 | |
---|
.. | .. |
---|
158 | 160 | uvd_v5_0_set_clockgating_state(adev, AMD_CG_STATE_UNGATE); |
---|
159 | 161 | uvd_v5_0_enable_mgcg(adev, true); |
---|
160 | 162 | |
---|
161 | | - ring->ready = true; |
---|
162 | | - r = amdgpu_ring_test_ring(ring); |
---|
163 | | - if (r) { |
---|
164 | | - ring->ready = false; |
---|
| 163 | + r = amdgpu_ring_test_helper(ring); |
---|
| 164 | + if (r) |
---|
165 | 165 | goto done; |
---|
166 | | - } |
---|
167 | 166 | |
---|
168 | 167 | r = amdgpu_ring_alloc(ring, 10); |
---|
169 | 168 | if (r) { |
---|
.. | .. |
---|
210 | 209 | static int uvd_v5_0_hw_fini(void *handle) |
---|
211 | 210 | { |
---|
212 | 211 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
---|
213 | | - struct amdgpu_ring *ring = &adev->uvd.inst->ring; |
---|
214 | 212 | |
---|
215 | 213 | if (RREG32(mmUVD_STATUS) != 0) |
---|
216 | 214 | uvd_v5_0_stop(adev); |
---|
217 | | - |
---|
218 | | - ring->ready = false; |
---|
219 | 215 | |
---|
220 | 216 | return 0; |
---|
221 | 217 | } |
---|
.. | .. |
---|
257 | 253 | uint64_t offset; |
---|
258 | 254 | uint32_t size; |
---|
259 | 255 | |
---|
260 | | - /* programm memory controller bits 0-27 */ |
---|
| 256 | + /* program memory controller bits 0-27 */ |
---|
261 | 257 | WREG32(mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW, |
---|
262 | 258 | lower_32_bits(adev->uvd.inst->gpu_addr)); |
---|
263 | 259 | WREG32(mmUVD_LMI_VCPU_CACHE_64BIT_BAR_HIGH, |
---|
.. | .. |
---|
408 | 404 | /* set the wb address */ |
---|
409 | 405 | WREG32(mmUVD_RBC_RB_RPTR_ADDR, (upper_32_bits(ring->gpu_addr) >> 2)); |
---|
410 | 406 | |
---|
411 | | - /* programm the RB_BASE for ring buffer */ |
---|
| 407 | + /* program the RB_BASE for ring buffer */ |
---|
412 | 408 | WREG32(mmUVD_LMI_RBC_RB_64BIT_BAR_LOW, |
---|
413 | 409 | lower_32_bits(ring->gpu_addr)); |
---|
414 | 410 | WREG32(mmUVD_LMI_RBC_RB_64BIT_BAR_HIGH, |
---|
.. | .. |
---|
500 | 496 | |
---|
501 | 497 | WREG32(mmUVD_CONTEXT_ID, 0xCAFEDEAD); |
---|
502 | 498 | r = amdgpu_ring_alloc(ring, 3); |
---|
503 | | - if (r) { |
---|
504 | | - DRM_ERROR("amdgpu: cp failed to lock ring %d (%d).\n", |
---|
505 | | - ring->idx, r); |
---|
| 499 | + if (r) |
---|
506 | 500 | return r; |
---|
507 | | - } |
---|
508 | 501 | amdgpu_ring_write(ring, PACKET0(mmUVD_CONTEXT_ID, 0)); |
---|
509 | 502 | amdgpu_ring_write(ring, 0xDEADBEEF); |
---|
510 | 503 | amdgpu_ring_commit(ring); |
---|
.. | .. |
---|
512 | 505 | tmp = RREG32(mmUVD_CONTEXT_ID); |
---|
513 | 506 | if (tmp == 0xDEADBEEF) |
---|
514 | 507 | break; |
---|
515 | | - DRM_UDELAY(1); |
---|
| 508 | + udelay(1); |
---|
516 | 509 | } |
---|
517 | 510 | |
---|
518 | | - if (i < adev->usec_timeout) { |
---|
519 | | - DRM_DEBUG("ring test on %d succeeded in %d usecs\n", |
---|
520 | | - ring->idx, i); |
---|
521 | | - } else { |
---|
522 | | - DRM_ERROR("amdgpu: ring %d test failed (0x%08X)\n", |
---|
523 | | - ring->idx, tmp); |
---|
524 | | - r = -EINVAL; |
---|
525 | | - } |
---|
| 511 | + if (i >= adev->usec_timeout) |
---|
| 512 | + r = -ETIMEDOUT; |
---|
| 513 | + |
---|
526 | 514 | return r; |
---|
527 | 515 | } |
---|
528 | 516 | |
---|
.. | .. |
---|
535 | 523 | * Write ring commands to execute the indirect buffer |
---|
536 | 524 | */ |
---|
537 | 525 | static void uvd_v5_0_ring_emit_ib(struct amdgpu_ring *ring, |
---|
| 526 | + struct amdgpu_job *job, |
---|
538 | 527 | struct amdgpu_ib *ib, |
---|
539 | | - unsigned vmid, bool ctx_switch) |
---|
| 528 | + uint32_t flags) |
---|
540 | 529 | { |
---|
541 | 530 | amdgpu_ring_write(ring, PACKET0(mmUVD_LMI_RBC_IB_64BIT_BAR_LOW, 0)); |
---|
542 | 531 | amdgpu_ring_write(ring, lower_32_bits(ib->gpu_addr)); |
---|
.. | .. |
---|
772 | 761 | enum amd_clockgating_state state) |
---|
773 | 762 | { |
---|
774 | 763 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
---|
775 | | - bool enable = (state == AMD_CG_STATE_GATE) ? true : false; |
---|
| 764 | + bool enable = (state == AMD_CG_STATE_GATE); |
---|
776 | 765 | |
---|
777 | 766 | if (enable) { |
---|
778 | 767 | /* wait for STATUS to clear */ |
---|
.. | .. |
---|
859 | 848 | .type = AMDGPU_RING_TYPE_UVD, |
---|
860 | 849 | .align_mask = 0xf, |
---|
861 | 850 | .support_64bit_ptrs = false, |
---|
| 851 | + .no_user_fence = true, |
---|
862 | 852 | .get_rptr = uvd_v5_0_ring_get_rptr, |
---|
863 | 853 | .get_wptr = uvd_v5_0_ring_get_wptr, |
---|
864 | 854 | .set_wptr = uvd_v5_0_ring_set_wptr, |
---|