summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-04-08 10:09:42 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2012-04-08 10:09:42 +0100
commit701473d20485a0557b4fb36efcbfbb8656e2f619 (patch)
tree8f43c1979a399ee900468bf38295ba76a7619e2c
parent1ecf17b2507f95e1fefea15833fa9f57ec256a2e (diff)
sna: Release cached upload buffers when reusing a write buffer for readback
References: https://bugs.freedesktop.org/show_bug.cgi?id=48400 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/kgem.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 27fa165f..de02e9d6 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -1234,6 +1234,24 @@ static void bubble_sort_partial(struct list *head, struct kgem_partial_bo *bo)
}
}
+static void kgem_partial_buffer_release(struct kgem *kgem,
+ struct kgem_partial_bo *bo)
+{
+ while (!list_is_empty(&bo->base.vma)) {
+ struct kgem_bo *cached;
+
+ cached = list_first_entry(&bo->base.vma, struct kgem_bo, vma);
+ assert(cached->proxy == &bo->base);
+ list_del(&cached->vma);
+
+ assert(*(struct kgem_bo **)cached->map == cached);
+ *(struct kgem_bo **)cached->map = NULL;
+ cached->map = NULL;
+
+ kgem_bo_destroy(kgem, cached);
+ }
+}
+
static void kgem_retire_partials(struct kgem *kgem)
{
struct kgem_partial_bo *bo, *next;
@@ -1247,19 +1265,7 @@ static void kgem_retire_partials(struct kgem *kgem)
DBG(("%s: releasing upload cache for handle=%d? %d\n",
__FUNCTION__, bo->base.handle, !list_is_empty(&bo->base.vma)));
- while (!list_is_empty(&bo->base.vma)) {
- struct kgem_bo *cached;
-
- cached = list_first_entry(&bo->base.vma, struct kgem_bo, vma);
- assert(cached->proxy == &bo->base);
- list_del(&cached->vma);
-
- assert(*(struct kgem_bo **)cached->map == cached);
- *(struct kgem_bo **)cached->map = NULL;
- cached->map = NULL;
-
- kgem_bo_destroy(kgem, cached);
- }
+ kgem_partial_buffer_release(kgem, bo);
assert(bo->base.refcnt > 0);
if (bo->base.refcnt != 1)
@@ -3519,6 +3525,7 @@ struct kgem_bo *kgem_create_buffer(struct kgem *kgem,
__FUNCTION__, size, bo->used, bytes(&bo->base)));
gem_write(kgem->fd, bo->base.handle,
0, bo->used, bo->mem);
+ kgem_partial_buffer_release(kgem, bo);
bo->need_io = 0;
bo->write = 0;
offset = 0;
@@ -3991,8 +3998,9 @@ void kgem_buffer_read_sync(struct kgem *kgem, struct kgem_bo *_bo)
assert(_bo->io);
assert(_bo->exec == &_kgem_dummy_exec);
assert(_bo->rq == NULL);
- if (_bo->proxy)
- _bo = _bo->proxy;
+ assert(_bo->proxy);
+
+ _bo = _bo->proxy;
assert(_bo->exec == NULL);
bo = (struct kgem_partial_bo *)_bo;