aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c58
1 files changed, 42 insertions, 16 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
index a162d87ca0c8..311589e02d17 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
@@ -181,15 +181,18 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
181 } 181 }
182 } 182 }
183 183
184 if (ring->funcs->init_cond_exec) 184 if (job && ring->funcs->init_cond_exec)
185 patch_offset = amdgpu_ring_init_cond_exec(ring); 185 patch_offset = amdgpu_ring_init_cond_exec(ring);
186 186
187 if (ring->funcs->emit_hdp_flush
188#ifdef CONFIG_X86_64 187#ifdef CONFIG_X86_64
189 && !(adev->flags & AMD_IS_APU) 188 if (!(adev->flags & AMD_IS_APU))
190#endif 189#endif
191 ) 190 {
192 amdgpu_ring_emit_hdp_flush(ring); 191 if (ring->funcs->emit_hdp_flush)
192 amdgpu_ring_emit_hdp_flush(ring);
193 else
194 amdgpu_asic_flush_hdp(adev, ring);
195 }
193 196
194 skip_preamble = ring->current_ctx == fence_ctx; 197 skip_preamble = ring->current_ctx == fence_ctx;
195 need_ctx_switch = ring->current_ctx != fence_ctx; 198 need_ctx_switch = ring->current_ctx != fence_ctx;
@@ -219,12 +222,10 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
219 if (ring->funcs->emit_tmz) 222 if (ring->funcs->emit_tmz)
220 amdgpu_ring_emit_tmz(ring, false); 223 amdgpu_ring_emit_tmz(ring, false);
221 224
222 if (ring->funcs->emit_hdp_invalidate
223#ifdef CONFIG_X86_64 225#ifdef CONFIG_X86_64
224 && !(adev->flags & AMD_IS_APU) 226 if (!(adev->flags & AMD_IS_APU))
225#endif 227#endif
226 ) 228 amdgpu_asic_invalidate_hdp(adev, ring);
227 amdgpu_ring_emit_hdp_invalidate(ring);
228 229
229 r = amdgpu_fence_emit(ring, f); 230 r = amdgpu_fence_emit(ring, f);
230 if (r) { 231 if (r) {
@@ -278,11 +279,6 @@ int amdgpu_ib_pool_init(struct amdgpu_device *adev)
278 return r; 279 return r;
279 } 280 }
280 281
281 r = amdgpu_sa_bo_manager_start(adev, &adev->ring_tmp_bo);
282 if (r) {
283 return r;
284 }
285
286 adev->ib_pool_ready = true; 282 adev->ib_pool_ready = true;
287 if (amdgpu_debugfs_sa_init(adev)) { 283 if (amdgpu_debugfs_sa_init(adev)) {
288 dev_err(adev->dev, "failed to register debugfs file for SA\n"); 284 dev_err(adev->dev, "failed to register debugfs file for SA\n");
@@ -301,7 +297,6 @@ int amdgpu_ib_pool_init(struct amdgpu_device *adev)
301void amdgpu_ib_pool_fini(struct amdgpu_device *adev) 297void amdgpu_ib_pool_fini(struct amdgpu_device *adev)
302{ 298{
303 if (adev->ib_pool_ready) { 299 if (adev->ib_pool_ready) {
304 amdgpu_sa_bo_manager_suspend(adev, &adev->ring_tmp_bo);
305 amdgpu_sa_bo_manager_fini(adev, &adev->ring_tmp_bo); 300 amdgpu_sa_bo_manager_fini(adev, &adev->ring_tmp_bo);
306 adev->ib_pool_ready = false; 301 adev->ib_pool_ready = false;
307 } 302 }
@@ -321,14 +316,45 @@ int amdgpu_ib_ring_tests(struct amdgpu_device *adev)
321{ 316{
322 unsigned i; 317 unsigned i;
323 int r, ret = 0; 318 int r, ret = 0;
319 long tmo_gfx, tmo_mm;
320
321 tmo_mm = tmo_gfx = AMDGPU_IB_TEST_TIMEOUT;
322 if (amdgpu_sriov_vf(adev)) {
323 /* for MM engines in hypervisor side they are not scheduled together
324 * with CP and SDMA engines, so even in exclusive mode MM engine could
325 * still running on other VF thus the IB TEST TIMEOUT for MM engines
326 * under SR-IOV should be set to a long time. 8 sec should be enough
327 * for the MM comes back to this VF.
328 */
329 tmo_mm = 8 * AMDGPU_IB_TEST_TIMEOUT;
330 }
331
332 if (amdgpu_sriov_runtime(adev)) {
333 /* for CP & SDMA engines since they are scheduled together so
334 * need to make the timeout width enough to cover the time
335 * cost waiting for it coming back under RUNTIME only
336 */
337 tmo_gfx = 8 * AMDGPU_IB_TEST_TIMEOUT;
338 }
324 339
325 for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { 340 for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
326 struct amdgpu_ring *ring = adev->rings[i]; 341 struct amdgpu_ring *ring = adev->rings[i];
342 long tmo;
327 343
328 if (!ring || !ring->ready) 344 if (!ring || !ring->ready)
329 continue; 345 continue;
330 346
331 r = amdgpu_ring_test_ib(ring, AMDGPU_IB_TEST_TIMEOUT); 347 /* MM engine need more time */
348 if (ring->funcs->type == AMDGPU_RING_TYPE_UVD ||
349 ring->funcs->type == AMDGPU_RING_TYPE_VCE ||
350 ring->funcs->type == AMDGPU_RING_TYPE_UVD_ENC ||
351 ring->funcs->type == AMDGPU_RING_TYPE_VCN_DEC ||
352 ring->funcs->type == AMDGPU_RING_TYPE_VCN_ENC)
353 tmo = tmo_mm;
354 else
355 tmo = tmo_gfx;
356
357 r = amdgpu_ring_test_ib(ring, tmo);
332 if (r) { 358 if (r) {
333 ring->ready = false; 359 ring->ready = false;
334 360