From 69aba669115d422d72c8c0d869bd5519b998efaa Mon Sep 17 00:00:00 2001 From: Jerome Glisse Date: Mon, 15 Feb 2010 11:56:37 +0100 Subject: [PATCH] drm/radeon/kms: add free flag for ib !! HACK DO NOT COMMIT !! --- drivers/gpu/drm/radeon/radeon.h | 3 ++- drivers/gpu/drm/radeon/radeon_ring.c | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index 993cdf2..b65f0e6 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h @@ -374,8 +374,9 @@ struct radeon_ib { unsigned long idx; uint64_t gpu_addr; struct radeon_fence *fence; - uint32_t *ptr; + uint32_t *ptr; uint32_t length_dw; + bool free; }; /* diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c index e3bee59..a82698c 100644 --- a/drivers/gpu/drm/radeon/radeon_ring.c +++ b/drivers/gpu/drm/radeon/radeon_ring.c @@ -86,6 +86,7 @@ int radeon_ib_get(struct radeon_device *rdev, struct radeon_ib **ib) set_bit(i, rdev->ib_pool.alloc_bm); rdev->ib_pool.ibs[i].length_dw = 0; *ib = &rdev->ib_pool.ibs[i]; + rdev->ib_pool.ibs[i].free = false; mutex_unlock(&rdev->ib_pool.mutex); goto out; } @@ -97,8 +98,18 @@ int radeon_ib_get(struct radeon_device *rdev, struct radeon_ib **ib) goto out; } /* get the first ib on the scheduled list */ - nib = list_entry(rdev->ib_pool.scheduled_ibs.next, - struct radeon_ib, list); + for (i = 0, nib = NULL; i < RADEON_IB_POOL_SIZE; i++) { + if (rdev->ib_pool.ibs[i].free) { + nib = &rdev->ib_pool.ibs[i]; + break; + } + } + if (nib == NULL) { + mutex_unlock(&rdev->ib_pool.mutex); + DRM_ERROR("no free IB\n"); + r = -EINVAL; + goto out; + } if (nib->fence == NULL) { /* we go do nothings here */ mutex_unlock(&rdev->ib_pool.mutex); @@ -121,6 +132,7 @@ int radeon_ib_get(struct radeon_device *rdev, struct radeon_ib **ib) /* scheduled list is accessed here */ mutex_lock(&rdev->ib_pool.mutex); + nib->free = false; list_del(&nib->list); INIT_LIST_HEAD(&nib->list); mutex_unlock(&rdev->ib_pool.mutex); @@ -144,6 +156,7 @@ void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib **ib) return; } mutex_lock(&rdev->ib_pool.mutex); + tmp->free = true; if (!list_empty(&tmp->list) && !radeon_fence_signaled(tmp->fence)) { /* IB is scheduled & not signaled don't do anythings */ mutex_unlock(&rdev->ib_pool.mutex); @@ -226,6 +239,7 @@ int radeon_ib_pool_init(struct radeon_device *rdev) rdev->ib_pool.ibs[i].ptr = ptr + offset; rdev->ib_pool.ibs[i].idx = i; rdev->ib_pool.ibs[i].length_dw = 0; + rdev->ib_pool.ibs[i].free = true; INIT_LIST_HEAD(&rdev->ib_pool.ibs[i].list); } bitmap_zero(rdev->ib_pool.alloc_bm, RADEON_IB_POOL_SIZE); -- 1.6.6