struct kgem_buffer,
base.list);
+ DBG(("%s: handle=%d, busy? %d [%d]\n",
+ __FUNCTION__, bo->base.handle, bo->base.rq != NULL, bo->base.exec != NULL));
+
+ assert(bo->base.exec == NULL || RQ(bo->base.rq) == kgem->next_request);
if (bo->base.rq)
break;
return true;
}
+#ifndef NDEBUG
+static void kgem_commit__check_buffers(struct kgem *kgem)
+{
+ struct kgem_buffer *bo;
+
+ list_for_each_entry(bo, &kgem->active_buffers, base.list)
+ assert(bo->base.exec == NULL);
+}
+#else
+#define kgem_commit__check_buffers(kgem)
+#endif
+
static void kgem_commit(struct kgem *kgem)
{
struct kgem_request *rq = kgem->next_request;
if (bo->proxy) {
/* proxies are not used for domain tracking */
- bo->exec = NULL;
__kgem_bo_clear_busy(bo);
}
}
kgem->next_request = NULL;
+
+ kgem_commit__check_buffers(kgem);
}
static void kgem_close_list(struct kgem *kgem, struct list *head)
assert(bo->base.io);
assert(bo->base.refcnt >= 1);
- if (!bo->base.exec) {
+ if (bo->base.refcnt > 1 && !bo->base.exec) {
DBG(("%s: skipping unattached handle=%d, used=%d\n",
__FUNCTION__, bo->base.handle, bo->used));
continue;
assert(bo->base.rq);
assert(used >= bo->used);
bo->used = used;
- list_move(&bo->base.list,
- &kgem->active_buffers);
+ if (bo->base.refcnt == 1) {
+ list_move(&bo->base.list,
+ &kgem->active_buffers);
+ }
kgem->need_retire = true;
continue;
}
batch_end = kgem_end_batch(kgem);
kgem_sna_flush(kgem);
- DBG(("batch[%d/%d, flags=%x]: %d %d %d %d, nreloc=%d, nexec=%d, nfence=%d, aperture=%d [fenced=%]\n",
+ DBG(("batch[%d/%d, flags=%x]: %d %d %d %d, nreloc=%d, nexec=%d, nfence=%d, aperture=%d [fenced=%d]\n",
kgem->mode, kgem->ring, kgem->batch_flags,
batch_end, kgem->nbatch, kgem->surface, kgem->batch_size,
kgem->nreloc, kgem->nexec, kgem->nfence, kgem->aperture, kgem->aperture_fenced));
#endif
}
}
-
- kgem_commit(kgem);
}
+ kgem_commit(kgem);
if (kgem->wedged)
kgem_cleanup(kgem);
list_for_each_entry(bo, &kgem->active_buffers, base.list) {
assert(bo->base.io);
assert(bo->base.refcnt >= 1);
+ assert(bo->base.exec == NULL);
assert(bo->mmapped);
assert(bo->mmapped == MMAPPED_GTT || kgem->has_llc || bo->base.snoop);
- assert(bo->base.rq);
if ((bo->write & ~flags) & KGEM_BUFFER_INPLACE && !bo->base.snoop) {
DBG(("%s: skip write %x buffer, need %x\n",
}
if (size <= bytes(&bo->base) &&
- !__kgem_busy(kgem, bo->base.handle)) {
+ (bo->base.rq == NULL ||
+ !__kgem_busy(kgem, bo->base.handle))) {
DBG(("%s: reusing whole buffer? size=%d, total=%d\n",
__FUNCTION__, size, bytes(&bo->base)));
__kgem_bo_clear_busy(&bo->base);
+ kgem_buffer_release(kgem, bo);
switch (bo->mmapped) {
case MMAPPED_CPU: