drm/radeon: rework ring syncing code
[deliverable/linux.git] / drivers / gpu / drm / radeon / radeon_cs.c
index 142f89462aa4ddab99030f7b285a8f6b2e883925..dd3e234294e443ea1f959af0f0f5053d3c0560e0 100644 (file)
@@ -115,36 +115,20 @@ static int radeon_cs_get_ring(struct radeon_cs_parser *p, u32 ring, s32 priority
        return 0;
 }
 
-static int radeon_cs_sync_rings(struct radeon_cs_parser *p)
+static void radeon_cs_sync_rings(struct radeon_cs_parser *p)
 {
-       bool sync_to_ring[RADEON_NUM_RINGS] = { };
-       bool need_sync = false;
-       int i, r;
+       int i;
 
        for (i = 0; i < p->nrelocs; i++) {
-               struct radeon_fence *fence;
+               struct radeon_fence *a, *b;
 
                if (!p->relocs[i].robj || !p->relocs[i].robj->tbo.sync_obj)
                        continue;
 
-               fence = p->relocs[i].robj->tbo.sync_obj;
-               if (fence->ring != p->ring && !radeon_fence_signaled(fence)) {
-                       sync_to_ring[fence->ring] = true;
-                       need_sync = true;
-               }
-       }
-
-       if (!need_sync) {
-               return 0;
-       }
-
-       r = radeon_semaphore_create(p->rdev, &p->ib.semaphore);
-       if (r) {
-               return r;
+               a = p->relocs[i].robj->tbo.sync_obj;
+               b = p->ib.sync_to[a->ring];
+               p->ib.sync_to[a->ring] = radeon_fence_later(a, b);
        }
-
-       return radeon_semaphore_sync_rings(p->rdev, p->ib.semaphore,
-                                          sync_to_ring, p->ring);
 }
 
 /* XXX: note that this is called from the legacy UMS CS ioctl as well */
@@ -368,10 +352,7 @@ static int radeon_cs_ib_chunk(struct radeon_device *rdev,
                DRM_ERROR("Invalid command stream !\n");
                return r;
        }
-       r = radeon_cs_sync_rings(parser);
-       if (r) {
-               DRM_ERROR("Failed to synchronize rings !\n");
-       }
+       radeon_cs_sync_rings(parser);
        parser->ib.vm_id = 0;
        r = radeon_ib_schedule(rdev, &parser->ib);
        if (r) {
@@ -468,10 +449,7 @@ static int radeon_cs_ib_vm_chunk(struct radeon_device *rdev,
        if (r) {
                goto out;
        }
-       r = radeon_cs_sync_rings(parser);
-       if (r) {
-               DRM_ERROR("Failed to synchronize rings !\n");
-       }
+       radeon_cs_sync_rings(parser);
 
        if ((rdev->family >= CHIP_TAHITI) &&
            (parser->chunk_const_ib_idx != -1)) {
This page took 0.04558 seconds and 5 git commands to generate.