drm/radeon: fix const IB handling v2
authorChristian König <deathsimple@vodafone.de>
Fri, 13 Jul 2012 11:06:00 +0000 (13:06 +0200)
committerChristian König <deathsimple@vodafone.de>
Wed, 18 Jul 2012 11:17:49 +0000 (13:17 +0200)
Const IBs are executed on the CE not the CP, so we can't
fence them in the normal way.

So submit them directly before the IB instead, just as
the documentation says.

v2: keep the extra documentation

Signed-off-by: Christian König <deathsimple@vodafone.de>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/r100.c
drivers/gpu/drm/radeon/r600.c
drivers/gpu/drm/radeon/radeon.h
drivers/gpu/drm/radeon/radeon_cs.c
drivers/gpu/drm/radeon/radeon_ring.c

index e0f5ae895f0743142ae8cf47294fa0b30df8b027..4ee5a74dac2261a9a3c4bc498f1477a68e07d191 100644 (file)
@@ -3693,7 +3693,7 @@ int r100_ib_test(struct radeon_device *rdev, struct radeon_ring *ring)
        ib.ptr[6] = PACKET2(0);
        ib.ptr[7] = PACKET2(0);
        ib.length_dw = 8;
-       r = radeon_ib_schedule(rdev, &ib);
+       r = radeon_ib_schedule(rdev, &ib, NULL);
        if (r) {
                radeon_scratch_free(rdev, scratch);
                radeon_ib_free(rdev, &ib);
index 3156d251b3c298961a33245f4fd59d21578cead0..c2e5069199953f9c85bbbd2c17edaa31b76a8060 100644 (file)
@@ -2619,7 +2619,7 @@ int r600_ib_test(struct radeon_device *rdev, struct radeon_ring *ring)
        ib.ptr[1] = ((scratch - PACKET3_SET_CONFIG_REG_OFFSET) >> 2);
        ib.ptr[2] = 0xDEADBEEF;
        ib.length_dw = 3;
-       r = radeon_ib_schedule(rdev, &ib);
+       r = radeon_ib_schedule(rdev, &ib, NULL);
        if (r) {
                radeon_scratch_free(rdev, scratch);
                radeon_ib_free(rdev, &ib);
index 2cb355bf272504d8167e8ea1f8681d8dc794dbf1..2d7f06c853369da57467c88c9c10b48e7ff7e127 100644 (file)
@@ -751,7 +751,8 @@ struct si_rlc {
 int radeon_ib_get(struct radeon_device *rdev, int ring,
                  struct radeon_ib *ib, unsigned size);
 void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib *ib);
-int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib);
+int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib,
+                      struct radeon_ib *const_ib);
 int radeon_ib_pool_init(struct radeon_device *rdev);
 void radeon_ib_pool_fini(struct radeon_device *rdev);
 int radeon_ib_ring_tests(struct radeon_device *rdev);
index 553da67a4cdd8a8b51f6b832be30545bbd24543e..8a4c49ef0cc4e40170b3300aa7ad9cffeea2bc72 100644 (file)
@@ -354,7 +354,7 @@ static int radeon_cs_ib_chunk(struct radeon_device *rdev,
        }
        radeon_cs_sync_rings(parser);
        parser->ib.vm_id = 0;
-       r = radeon_ib_schedule(rdev, &parser->ib);
+       r = radeon_ib_schedule(rdev, &parser->ib, NULL);
        if (r) {
                DRM_ERROR("Failed to schedule IB !\n");
        }
@@ -452,25 +452,24 @@ static int radeon_cs_ib_vm_chunk(struct radeon_device *rdev,
        }
        radeon_cs_sync_rings(parser);
 
+       parser->ib.vm_id = vm->id;
+       /* ib pool is bind at 0 in virtual address space,
+        * so gpu_addr is the offset inside the pool bo
+        */
+       parser->ib.gpu_addr = parser->ib.sa_bo->soffset;
+
        if ((rdev->family >= CHIP_TAHITI) &&
            (parser->chunk_const_ib_idx != -1)) {
                parser->const_ib.vm_id = vm->id;
-               /* ib pool is bind at 0 in virtual address space to gpu_addr is the
-                * offset inside the pool bo
+               /* ib pool is bind at 0 in virtual address space,
+                * so gpu_addr is the offset inside the pool bo
                 */
                parser->const_ib.gpu_addr = parser->const_ib.sa_bo->soffset;
-               r = radeon_ib_schedule(rdev, &parser->const_ib);
-               if (r)
-                       goto out;
+               r = radeon_ib_schedule(rdev, &parser->ib, &parser->const_ib);
+       } else {
+               r = radeon_ib_schedule(rdev, &parser->ib, NULL);
        }
 
-       parser->ib.vm_id = vm->id;
-       /* ib pool is bind at 0 in virtual address space to gpu_addr is the
-        * offset inside the pool bo
-        */
-       parser->ib.gpu_addr = parser->ib.sa_bo->soffset;
-       parser->ib.is_const_ib = false;
-       r = radeon_ib_schedule(rdev, &parser->ib);
 out:
        if (!r) {
                if (vm->fence) {
index 75cbe46411387690623f360c705426c6f50c81ef..c48c35403774cc356b57b3eb8a8fb77c9c5bc2dc 100644 (file)
@@ -74,7 +74,8 @@ void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib *ib)
        radeon_fence_unref(&ib->fence);
 }
 
-int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib)
+int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib,
+                      struct radeon_ib *const_ib)
 {
        struct radeon_ring *ring = &rdev->ring[ib->ring];
        bool need_sync = false;
@@ -105,6 +106,10 @@ int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib)
        if (!need_sync) {
                radeon_semaphore_free(rdev, &ib->semaphore, NULL);
        }
+       if (const_ib) {
+               radeon_ring_ib_execute(rdev, const_ib->ring, const_ib);
+               radeon_semaphore_free(rdev, &const_ib->semaphore, NULL);
+       }
        radeon_ring_ib_execute(rdev, ib->ring, ib);
        r = radeon_fence_emit(rdev, &ib->fence, ib->ring);
        if (r) {
@@ -112,6 +117,9 @@ int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib)
                radeon_ring_unlock_undo(rdev, ring);
                return r;
        }
+       if (const_ib) {
+               const_ib->fence = radeon_fence_ref(ib->fence);
+       }
        radeon_ring_unlock_commit(rdev, ring);
        return 0;
 }