aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/radeon/radeon_cs.c
diff options
context:
space:
mode:
authorChristian König <deathsimple@vodafone.de>2012-01-05 22:11:06 -0500
committerDave Airlie <airlied@redhat.com>2012-01-06 04:16:09 -0500
commit93504fce28b1a387ec01f81b26637d237dca2b36 (patch)
tree7544b4fd960cbcbbfc17dea87aadd129eecf7b45 /drivers/gpu/drm/radeon/radeon_cs.c
parent721604a15b934f0a8d1909acb8017f029128be2f (diff)
drm/radeon/kms: Add support for multi-ring sync in CS ioctl (v2)
Use semaphores to sync buffers across rings in the CS ioctl. Add a reloc flag to allow userspace to skip sync for buffers. agd5f: port to latest CS ioctl changes. v2: add ring lock/unlock to make sure changes hit the ring. Signed-off-by: Christian König <deathsimple@vodafone.de> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon_cs.c')
-rw-r--r--drivers/gpu/drm/radeon/radeon_cs.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
index 4d595403b50c..17af0e83c328 100644
--- a/drivers/gpu/drm/radeon/radeon_cs.c
+++ b/drivers/gpu/drm/radeon/radeon_cs.c
@@ -84,6 +84,13 @@ int radeon_cs_parser_relocs(struct radeon_cs_parser *p)
84 p->relocs[i].flags = r->flags; 84 p->relocs[i].flags = r->flags;
85 radeon_bo_list_add_object(&p->relocs[i].lobj, 85 radeon_bo_list_add_object(&p->relocs[i].lobj,
86 &p->validated); 86 &p->validated);
87
88 if (p->relocs[i].robj->tbo.sync_obj && !(r->flags & RADEON_RELOC_DONT_SYNC)) {
89 struct radeon_fence *fence = p->relocs[i].robj->tbo.sync_obj;
90 if (!radeon_fence_signaled(fence)) {
91 p->sync_to_ring[fence->ring] = true;
92 }
93 }
87 } else 94 } else
88 p->relocs[i].handle = 0; 95 p->relocs[i].handle = 0;
89 } 96 }
@@ -109,6 +116,36 @@ static int radeon_cs_get_ring(struct radeon_cs_parser *p, u32 ring, s32 priority
109 return 0; 116 return 0;
110} 117}
111 118
119static int radeon_cs_sync_rings(struct radeon_cs_parser *p)
120{
121 int i, r;
122
123 for (i = 0; i < RADEON_NUM_RINGS; ++i) {
124 /* no need to sync to our own or unused rings */
125 if (i == p->ring || !p->sync_to_ring[i] || !p->rdev->ring[i].ready)
126 continue;
127
128 if (!p->ib->fence->semaphore) {
129 r = radeon_semaphore_create(p->rdev, &p->ib->fence->semaphore);
130 if (r)
131 return r;
132 }
133
134 r = radeon_ring_lock(p->rdev, &p->rdev->ring[i], 3);
135 if (r)
136 return r;
137 radeon_semaphore_emit_signal(p->rdev, i, p->ib->fence->semaphore);
138 radeon_ring_unlock_commit(p->rdev, &p->rdev->ring[i]);
139
140 r = radeon_ring_lock(p->rdev, &p->rdev->ring[p->ring], 3);
141 if (r)
142 return r;
143 radeon_semaphore_emit_wait(p->rdev, p->ring, p->ib->fence->semaphore);
144 radeon_ring_unlock_commit(p->rdev, &p->rdev->ring[p->ring]);
145 }
146 return 0;
147}
148
112int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data) 149int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
113{ 150{
114 struct drm_radeon_cs *cs = data; 151 struct drm_radeon_cs *cs = data;
@@ -314,6 +351,10 @@ static int radeon_cs_ib_chunk(struct radeon_device *rdev,
314 DRM_ERROR("Invalid command stream !\n"); 351 DRM_ERROR("Invalid command stream !\n");
315 return r; 352 return r;
316 } 353 }
354 r = radeon_cs_sync_rings(parser);
355 if (r) {
356 DRM_ERROR("Failed to synchronize rings !\n");
357 }
317 parser->ib->vm_id = 0; 358 parser->ib->vm_id = 0;
318 r = radeon_ib_schedule(rdev, parser->ib); 359 r = radeon_ib_schedule(rdev, parser->ib);
319 if (r) { 360 if (r) {
@@ -384,6 +425,10 @@ static int radeon_cs_ib_vm_chunk(struct radeon_device *rdev,
384 if (r) { 425 if (r) {
385 goto out; 426 goto out;
386 } 427 }
428 r = radeon_cs_sync_rings(parser);
429 if (r) {
430 DRM_ERROR("Failed to synchronize rings !\n");
431 }
387 parser->ib->vm_id = vm->id; 432 parser->ib->vm_id = vm->id;
388 /* ib pool is bind at 0 in virtual address space to gpu_addr is the 433 /* ib pool is bind at 0 in virtual address space to gpu_addr is the
389 * offset inside the pool bo 434 * offset inside the pool bo