From 876417f9e81ff7214017fa0896c29d845c8f9966 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 25 Jan 2018 01:19:58 -0800 Subject: [PATCH] iris: softpin some things --- src/gallium/drivers/iris/iris_batch.c | 11 ++++++++--- src/gallium/drivers/iris/iris_program_cache.c | 8 +++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/iris/iris_batch.c b/src/gallium/drivers/iris/iris_batch.c index 41a95a9e37e..23cff418960 100644 --- a/src/gallium/drivers/iris/iris_batch.c +++ b/src/gallium/drivers/iris/iris_batch.c @@ -626,6 +626,14 @@ emit_reloc(struct iris_batch *batch, { assert(target != NULL); + unsigned int index = add_exec_bo(batch, target); + struct drm_i915_gem_exec_object2 *entry = &batch->validation_list[index]; + + if (target->kflags & EXEC_OBJECT_PINNED) { + assert(entry->offset == target->gtt_offset); + return entry->offset + target_offset; + } + if (rlist->reloc_count == rlist->reloc_array_size) { rlist->reloc_array_size *= 2; rlist->relocs = realloc(rlist->relocs, @@ -633,9 +641,6 @@ emit_reloc(struct iris_batch *batch, sizeof(struct drm_i915_gem_relocation_entry)); } - unsigned int index = add_exec_bo(batch, target); - struct drm_i915_gem_exec_object2 *entry = &batch->validation_list[index]; - rlist->relocs[rlist->reloc_count++] = (struct drm_i915_gem_relocation_entry) { .offset = offset, diff --git a/src/gallium/drivers/iris/iris_program_cache.c b/src/gallium/drivers/iris/iris_program_cache.c index 58e3b3c25e9..acbfba0681a 100644 --- a/src/gallium/drivers/iris/iris_program_cache.c +++ b/src/gallium/drivers/iris/iris_program_cache.c @@ -150,7 +150,7 @@ recreate_cache_bo(struct iris_context *ice, uint32_t size) void *old_map = cache->map; cache->bo = iris_bo_alloc(screen->bufmgr, "program cache", size, 64); - cache->bo->kflags = EXEC_OBJECT_CAPTURE; + cache->bo->kflags = EXEC_OBJECT_CAPTURE | EXEC_OBJECT_PINNED; cache->map = iris_bo_map(&ice->dbg, cache->bo, MAP_READ | MAP_WRITE | MAP_ASYNC | MAP_PERSISTENT); @@ -161,10 +161,16 @@ recreate_cache_bo(struct iris_context *ice, uint32_t size) (unsigned) old_bo->size / 1024, (unsigned) cache->bo->size / 1024); + /* Put the new BO just past the old one */ + cache->bo->gtt_offset = ALIGN(old_bo->gtt_offset + old_bo->size, 4096); + memcpy(cache->map, old_map, cache->next_offset); iris_bo_unreference(old_bo); iris_bo_unmap(old_bo); + } else { + /* Put the initial cache BO...somewhere. */ + cache->bo->gtt_offset = 4096 * 10; } ice->state.dirty |= IRIS_DIRTY_STATE_BASE_ADDRESS; -- 2.30.2