drm/amdgpu: move preamble IB handling into common code
authorChristian König <christian.koenig@amd.com>
Fri, 6 May 2016 12:52:57 +0000 (14:52 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 11 May 2016 17:30:30 +0000 (13:30 -0400)
This fixes the handling which was completely broken when you
ad more than one preamble IB.

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>
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c

index f670519efbbccd9e4602f896fe47782aff44c7f5..d6f85923edcd460838d56ab9602495ec7b4a848c 100644 (file)
@@ -125,6 +125,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
        struct fence *hwf;
        struct amdgpu_vm *vm = NULL;
        unsigned i, patch_offset = ~0;
+       bool skip_preamble;
 
        int r = 0;
 
@@ -172,9 +173,14 @@ 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;
        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;
        }
index f4068f753fbe909cfefd5d10d251f08bd1a03d4c..d82fa9641f0e0c4f85042601afd4da4fab954077 100644 (file)
@@ -2036,10 +2036,6 @@ static void gfx_v7_0_ring_emit_ib_gfx(struct amdgpu_ring *ring,
        u32 header, control = 0;
        u32 next_rptr = ring->wptr + 5;
 
-       /* drop the CE preamble IB for the same context */
-       if ((ib->flags & AMDGPU_IB_FLAG_PREAMBLE) && !need_ctx_switch)
-               return;
-
        if (need_ctx_switch)
                next_rptr += 2;
 
index 7886228b8318f98b2cfebfe0c617c8625495fd89..9a0b6df210c174eeed3fc64ab980ee25287eea24 100644 (file)
@@ -5652,10 +5652,6 @@ static void gfx_v8_0_ring_emit_ib_gfx(struct amdgpu_ring *ring,
        u32 header, control = 0;
        u32 next_rptr = ring->wptr + 5;
 
-       /* drop the CE preamble IB for the same context */
-       if ((ib->flags & AMDGPU_IB_FLAG_PREAMBLE) && !need_ctx_switch)
-               return;
-
        if (need_ctx_switch)
                next_rptr += 2;