aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/radeon
diff options
context:
space:
mode:
authorMatthew Garrett <mjg@redhat.com>2010-04-30 15:24:17 -0400
committerDave Airlie <airlied@redhat.com>2010-05-18 04:21:45 -0400
commit91700f3cac56a1998a56d41e4459a5cebdb4f752 (patch)
tree24d82df7ed2b7f23e49963b6aa7ae31adbebe8f2 /drivers/gpu/drm/radeon
parent78930b1c39dd4a5afd5aa873eec11b5bd7079866 (diff)
radeon: Split out ring locking and allocation
We need to handle the ring while we've already locked it, so split out the allocation and commit functions in order to allow them to be used. Signed-off-by: Matthew Garrett <mjg@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/radeon')
-rw-r--r--drivers/gpu/drm/radeon/radeon.h2
-rw-r--r--drivers/gpu/drm/radeon/radeon_ring.c27
2 files changed, 23 insertions, 6 deletions
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 93ac88eb6b3..e39e2b4ec97 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -471,7 +471,9 @@ int radeon_ib_test(struct radeon_device *rdev);
471extern void radeon_ib_bogus_add(struct radeon_device *rdev, struct radeon_ib *ib); 471extern void radeon_ib_bogus_add(struct radeon_device *rdev, struct radeon_ib *ib);
472/* Ring access between begin & end cannot sleep */ 472/* Ring access between begin & end cannot sleep */
473void radeon_ring_free_size(struct radeon_device *rdev); 473void radeon_ring_free_size(struct radeon_device *rdev);
474int radeon_ring_alloc(struct radeon_device *rdev, unsigned ndw);
474int radeon_ring_lock(struct radeon_device *rdev, unsigned ndw); 475int radeon_ring_lock(struct radeon_device *rdev, unsigned ndw);
476void radeon_ring_commit(struct radeon_device *rdev);
475void radeon_ring_unlock_commit(struct radeon_device *rdev); 477void radeon_ring_unlock_commit(struct radeon_device *rdev);
476void radeon_ring_unlock_undo(struct radeon_device *rdev); 478void radeon_ring_unlock_undo(struct radeon_device *rdev);
477int radeon_ring_test(struct radeon_device *rdev); 479int radeon_ring_test(struct radeon_device *rdev);
diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c
index f6e1e8d4d98..6cc42591abd 100644
--- a/drivers/gpu/drm/radeon/radeon_ring.c
+++ b/drivers/gpu/drm/radeon/radeon_ring.c
@@ -258,31 +258,41 @@ void radeon_ring_free_size(struct radeon_device *rdev)
258 } 258 }
259} 259}
260 260
261int radeon_ring_lock(struct radeon_device *rdev, unsigned ndw) 261int radeon_ring_alloc(struct radeon_device *rdev, unsigned ndw)
262{ 262{
263 int r; 263 int r;
264 264
265 /* Align requested size with padding so unlock_commit can 265 /* Align requested size with padding so unlock_commit can
266 * pad safely */ 266 * pad safely */
267 ndw = (ndw + rdev->cp.align_mask) & ~rdev->cp.align_mask; 267 ndw = (ndw + rdev->cp.align_mask) & ~rdev->cp.align_mask;
268 mutex_lock(&rdev->cp.mutex);
269 while (ndw > (rdev->cp.ring_free_dw - 1)) { 268 while (ndw > (rdev->cp.ring_free_dw - 1)) {
270 radeon_ring_free_size(rdev); 269 radeon_ring_free_size(rdev);
271 if (ndw < rdev->cp.ring_free_dw) { 270 if (ndw < rdev->cp.ring_free_dw) {
272 break; 271 break;
273 } 272 }
274 r = radeon_fence_wait_next(rdev); 273 r = radeon_fence_wait_next(rdev);
275 if (r) { 274 if (r)
276 mutex_unlock(&rdev->cp.mutex);
277 return r; 275 return r;
278 }
279 } 276 }
280 rdev->cp.count_dw = ndw; 277 rdev->cp.count_dw = ndw;
281 rdev->cp.wptr_old = rdev->cp.wptr; 278 rdev->cp.wptr_old = rdev->cp.wptr;
282 return 0; 279 return 0;
283} 280}
284 281
285void radeon_ring_unlock_commit(struct radeon_device *rdev) 282int radeon_ring_lock(struct radeon_device *rdev, unsigned ndw)
283{
284 int r;
285
286 mutex_lock(&rdev->cp.mutex);
287 r = radeon_ring_alloc(rdev, ndw);
288 if (r) {
289 mutex_unlock(&rdev->cp.mutex);
290 return r;
291 }
292 return 0;
293}
294
295void radeon_ring_commit(struct radeon_device *rdev)
286{ 296{
287 unsigned count_dw_pad; 297 unsigned count_dw_pad;
288 unsigned i; 298 unsigned i;
@@ -295,6 +305,11 @@ void radeon_ring_unlock_commit(struct radeon_device *rdev)
295 } 305 }
296 DRM_MEMORYBARRIER(); 306 DRM_MEMORYBARRIER();
297 radeon_cp_commit(rdev); 307 radeon_cp_commit(rdev);
308}
309
310void radeon_ring_unlock_commit(struct radeon_device *rdev)
311{
312 radeon_ring_commit(rdev);
298 mutex_unlock(&rdev->cp.mutex); 313 mutex_unlock(&rdev->cp.mutex);
299} 314}
300 315