summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/vc4/vc4_simulator.c
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2015-06-12 12:47:47 -0700
committerEric Anholt <eric@anholt.net>2015-06-16 15:15:14 -0700
commit6dd55b49090da22d3a8e9226507a95e914eaf10f (patch)
treedf82a883e62f7b1b5468fe061d926ab9a8c473ea /src/gallium/drivers/vc4/vc4_simulator.c
parent731ac05cc4e444175288032a76a29c95059af038 (diff)
downloadexternal_mesa3d-6dd55b49090da22d3a8e9226507a95e914eaf10f.zip
external_mesa3d-6dd55b49090da22d3a8e9226507a95e914eaf10f.tar.gz
external_mesa3d-6dd55b49090da22d3a8e9226507a95e914eaf10f.tar.bz2
vc4: Handle refcounting the exec BO like we do in the kernel.
This reduces the diff to the kernel, and will be useful when I make the kernel allocate more BOs as part of validation.
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_simulator.c')
-rw-r--r--src/gallium/drivers/vc4/vc4_simulator.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/gallium/drivers/vc4/vc4_simulator.c b/src/gallium/drivers/vc4/vc4_simulator.c
index 2f72e72..2e4d879 100644
--- a/src/gallium/drivers/vc4/vc4_simulator.c
+++ b/src/gallium/drivers/vc4/vc4_simulator.c
@@ -39,10 +39,11 @@ vc4_wrap_bo_with_cma(struct drm_device *dev, struct vc4_bo *bo)
{
struct vc4_context *vc4 = dev->vc4;
struct vc4_screen *screen = vc4->screen;
- struct drm_gem_cma_object *obj = CALLOC_STRUCT(drm_gem_cma_object);
+ struct drm_vc4_bo *drm_bo = CALLOC_STRUCT(drm_vc4_bo);
+ struct drm_gem_cma_object *obj = &drm_bo->base;
uint32_t size = align(bo->size, 4096);
- obj->bo = bo;
+ drm_bo->bo = bo;
obj->base.size = size;
obj->vaddr = screen->simulator_mem_base + dev->simulator_mem_next;
obj->paddr = simpenrose_hw_addr(obj->vaddr);
@@ -94,7 +95,7 @@ vc4_simulator_unpin_bos(struct vc4_exec_info *exec)
{
for (int i = 0; i < exec->bo_count; i++) {
struct drm_gem_cma_object *obj = exec->bo[i].bo;
- struct vc4_bo *bo = obj->bo;
+ struct vc4_bo *bo = to_vc4_bo(&obj->base)->bo;
memcpy(bo->map, obj->vaddr, bo->size);
@@ -124,6 +125,7 @@ vc4_simulator_flush(struct vc4_context *vc4, struct drm_vc4_submit_cl *args)
int ret;
memset(&exec, 0, sizeof(exec));
+ list_inithead(&exec.unref_list);
if (ctex && ctex->bo->simulator_winsys_map) {
#if 0
@@ -176,8 +178,12 @@ vc4_simulator_flush(struct vc4_context *vc4, struct drm_vc4_submit_cl *args)
if (ret)
return ret;
- vc4_bo_unreference(&exec.exec_bo->bo);
- free(exec.exec_bo);
+ list_for_each_entry_safe(struct drm_vc4_bo, bo, &exec.unref_list,
+ unref_head) {
+ list_del(&bo->unref_head);
+ vc4_bo_unreference(&bo->bo);
+ free(bo);
+ }
if (ctex && ctex->bo->simulator_winsys_map) {
for (int y = 0; y < ctex->base.b.height0; y++) {