summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-01-11 12:09:13 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2012-01-11 12:10:18 +0000
commit0a5313900ec9a7c499eb5051f3a5f078a9b0bbde (patch)
treee4c68410f3f0b8cb5d8071fe49883d1fd38f53ef
parent2add5991a7d186d8271cb79ae4f62dad7b4ca243 (diff)
sna: Explicitly retire the bo following a serialisation point
This is to keep the sanity checks in order, but conceptually should be useful as well. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/kgem.c46
-rw-r--r--src/sna/kgem.h1
-rw-r--r--src/sna/kgem_debug_gen3.c2
-rw-r--r--src/sna/kgem_debug_gen4.c4
-rw-r--r--src/sna/kgem_debug_gen5.c2
5 files changed, 36 insertions, 19 deletions
diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index aa98ceac..f7bf116a 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -284,6 +284,20 @@ kgem_busy(struct kgem *kgem, int handle)
return busy.busy;
}
+static void kgem_bo_retire(struct kgem *kgem, struct kgem_bo *bo)
+{
+ assert(!kgem_busy(kgem, bo->handle));
+
+ if (bo->domain == DOMAIN_GPU)
+ kgem_retire(kgem);
+
+ if (bo->exec == NULL) {
+ bo->rq = NULL;
+ list_del(&bo->request);
+ bo->needs_flush = bo->flush;
+ }
+}
+
Bool kgem_bo_write(struct kgem *kgem, struct kgem_bo *bo,
const void *data, int length)
{
@@ -295,9 +309,7 @@ Bool kgem_bo_write(struct kgem *kgem, struct kgem_bo *bo,
return FALSE;
DBG(("%s: flush=%d, domain=%d\n", __FUNCTION__, bo->flush, bo->domain));
- bo->needs_flush = bo->flush;
- if (bo->domain == DOMAIN_GPU)
- kgem_retire(kgem);
+ kgem_bo_retire(kgem, bo);
bo->domain = DOMAIN_NONE;
return TRUE;
}
@@ -2556,7 +2568,8 @@ void *kgem_bo_map(struct kgem *kgem, struct kgem_bo *bo, int prot)
{
void *ptr;
- assert(bo->refcnt || bo->exec); /* allow for debugging purposes */
+ assert(bo->refcnt);
+ assert(bo->exec == NULL);
assert(!bo->purged);
assert(list_is_empty(&bo->list));
@@ -2595,15 +2608,23 @@ void *kgem_bo_map(struct kgem *kgem, struct kgem_bo *bo, int prot)
set_domain.write_domain = I915_GEM_DOMAIN_GTT;
drmIoctl(kgem->fd, DRM_IOCTL_I915_GEM_SET_DOMAIN, &set_domain);
- bo->needs_flush = bo->flush;
- if (bo->domain == DOMAIN_GPU)
- kgem_retire(kgem);
+ kgem_bo_retire(kgem, bo);
bo->domain = DOMAIN_GTT;
}
return ptr;
}
+void *kgem_bo_map__debug(struct kgem *kgem, struct kgem_bo *bo)
+{
+ if (bo->map)
+ return bo->map;
+
+ kgem_trim_vma_cache(kgem, MAP_GTT, bo->bucket);
+ return bo->map = gem_mmap(kgem->fd, bo->handle, bo->size,
+ PROT_READ | PROT_WRITE);
+}
+
void *kgem_bo_map__cpu(struct kgem *kgem, struct kgem_bo *bo)
{
struct drm_i915_gem_mmap mmap_arg;
@@ -2753,10 +2774,8 @@ void kgem_bo_sync__cpu(struct kgem *kgem, struct kgem_bo *bo)
set_domain.write_domain = I915_GEM_DOMAIN_CPU;
drmIoctl(kgem->fd, DRM_IOCTL_I915_GEM_SET_DOMAIN, &set_domain);
- assert(!kgem_busy(kgem, bo->handle));
- bo->needs_flush = bo->flush;
- if (bo->domain == DOMAIN_GPU)
- kgem_retire(kgem);
+
+ kgem_bo_retire(kgem, bo);
bo->domain = DOMAIN_CPU;
}
}
@@ -3208,10 +3227,7 @@ void kgem_buffer_read_sync(struct kgem *kgem, struct kgem_bo *_bo)
gem_read(kgem->fd,
bo->base.handle, (char *)(bo+1)+offset,
offset, length);
- assert(!kgem_busy(kgem, bo->base.handle));
- bo->base.needs_flush = bo->base.flush;
- if (bo->base.domain == DOMAIN_GPU)
- kgem_retire(kgem);
+ kgem_bo_retire(kgem, &bo->base);
bo->base.domain = DOMAIN_NONE;
} else
kgem_bo_sync__cpu(kgem, &bo->base);
diff --git a/src/sna/kgem.h b/src/sna/kgem.h
index 1bc0d9b4..d6fdfbc9 100644
--- a/src/sna/kgem.h
+++ b/src/sna/kgem.h
@@ -344,6 +344,7 @@ uint32_t kgem_add_reloc(struct kgem *kgem,
uint32_t delta);
void *kgem_bo_map(struct kgem *kgem, struct kgem_bo *bo, int prot);
+void *kgem_bo_map__debug(struct kgem *kgem, struct kgem_bo *bo);
void *kgem_bo_map__cpu(struct kgem *kgem, struct kgem_bo *bo);
void kgem_bo_sync__cpu(struct kgem *kgem, struct kgem_bo *bo);
uint32_t kgem_bo_flink(struct kgem *kgem, struct kgem_bo *bo);
diff --git a/src/sna/kgem_debug_gen3.c b/src/sna/kgem_debug_gen3.c
index 213c69f6..969b1d19 100644
--- a/src/sna/kgem_debug_gen3.c
+++ b/src/sna/kgem_debug_gen3.c
@@ -97,7 +97,7 @@ static void gen3_update_vertex_buffer_addr(struct kgem *kgem,
if (bo->handle == handle)
break;
assert(&bo->request != &kgem->next_request->buffers);
- base = kgem_bo_map(kgem, bo, PROT_READ);
+ base = kgem_bo_map__debug(kgem, bo);
}
ptr = (char *)base + kgem->reloc[i].delta;
diff --git a/src/sna/kgem_debug_gen4.c b/src/sna/kgem_debug_gen4.c
index 0004ecf5..53c350b8 100644
--- a/src/sna/kgem_debug_gen4.c
+++ b/src/sna/kgem_debug_gen4.c
@@ -84,7 +84,7 @@ static void gen4_update_vertex_buffer(struct kgem *kgem, const uint32_t *data)
if (bo->handle == reloc)
break;
assert(&bo->request != &kgem->next_request->buffers);
- base = kgem_bo_map(kgem, bo, PROT_READ);
+ base = kgem_bo_map__debug(kgem, bo);
}
ptr = (char *)base + kgem->reloc[i].delta;
@@ -405,7 +405,7 @@ get_reloc(struct kgem *kgem,
if (bo->handle == handle)
break;
assert(&bo->request != &kgem->next_request->buffers);
- base = kgem_bo_map(kgem, bo, PROT_READ);
+ base = kgem_bo_map__debug(kgem, bo);
r->bo = bo;
r->base = base;
}
diff --git a/src/sna/kgem_debug_gen5.c b/src/sna/kgem_debug_gen5.c
index 7912cc91..f21220f3 100644
--- a/src/sna/kgem_debug_gen5.c
+++ b/src/sna/kgem_debug_gen5.c
@@ -78,7 +78,7 @@ static void gen5_update_vertex_buffer(struct kgem *kgem, const uint32_t *data)
size = kgem->nbatch * sizeof(uint32_t);
} else {
bo = kgem_debug_get_bo_for_reloc_entry(kgem, reloc);
- base = kgem_bo_map(kgem, bo, PROT_READ);
+ base = kgem_bo_map__debug(kgem, bo);
size = bo->size;
}
ptr = (char *)base + reloc->delta;