diff options
author | Christian König <christian.koenig@amd.com> | 2016-05-06 15:31:19 +0200 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2016-05-11 13:30:30 -0400 |
commit | f153d2867bf74f84d47f67c377a8e3a34865e562 (patch) | |
tree | 22a99ad8bd91d3526880318e2a284f5e896a1f92 /drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | |
parent | 9f8fb5a2b339ba83493991ca8f1173a939a696d3 (diff) | |
download | lwn-f153d2867bf74f84d47f67c377a8e3a34865e562.tar.gz lwn-f153d2867bf74f84d47f67c377a8e3a34865e562.zip |
drm/amdgpu: move context switch handling into common code v2
It was a source of bugs to repeat that in each IP version.
v2: rename parameter
Signed-off-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>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c index d6f85923edcd..88b8fda7340f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c @@ -121,18 +121,16 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, { struct amdgpu_device *adev = ring->adev; struct amdgpu_ib *ib = &ibs[0]; - uint64_t ctx, old_ctx; struct fence *hwf; struct amdgpu_vm *vm = NULL; unsigned i, patch_offset = ~0; - bool skip_preamble; + bool skip_preamble, need_ctx_switch; int r = 0; if (num_ibs == 0) return -EINVAL; - ctx = ibs->ctx; if (job) /* for domain0 job like ring test, ibs->job is not assigned */ vm = job->vm; @@ -156,7 +154,6 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, patch_offset = amdgpu_ring_init_cond_exec(ring); if (vm) { - /* do context switch */ r = amdgpu_vm_flush(ring, ib->vm_id, ib->vm_pd_addr, ib->gds_base, ib->gds_size, ib->gws_base, ib->gws_size, @@ -173,16 +170,17 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, /* always set cond_exec_polling to CONTINUE */ *ring->cond_exe_cpu_addr = 1; - skip_preamble = ring->current_ctx == ctx; - old_ctx = ring->current_ctx; + skip_preamble = ring->current_ctx == ib->ctx; + need_ctx_switch = ring->current_ctx != ib->ctx; for (i = 0; i < num_ibs; ++i) { + ib = &ibs[i]; /* drop preamble IBs if we don't have a context switch */ if ((ib->flags & AMDGPU_IB_FLAG_PREAMBLE) && skip_preamble) continue; - amdgpu_ring_emit_ib(ring, ib); - ring->current_ctx = ctx; + amdgpu_ring_emit_ib(ring, ib, need_ctx_switch); + need_ctx_switch = false; } if (ring->funcs->emit_hdp_invalidate) @@ -191,7 +189,6 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, r = amdgpu_fence_emit(ring, &hwf); if (r) { dev_err(adev->dev, "failed to emit fence (%d)\n", r); - ring->current_ctx = old_ctx; if (ib->vm_id) amdgpu_vm_reset_id(adev, ib->vm_id); amdgpu_ring_undo(ring); @@ -212,6 +209,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, if (patch_offset != ~0 && ring->funcs->patch_cond_exec) amdgpu_ring_patch_cond_exec(ring, patch_offset); + ring->current_ctx = ibs->ctx; amdgpu_ring_commit(ring); return 0; } |