iris: softpin some things
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 25 Jan 2018 09:19:58 +0000 (01:19 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:05 +0000 (10:26 -0800)
src/gallium/drivers/iris/iris_batch.c
src/gallium/drivers/iris/iris_program_cache.c

index 41a95a9e37e2c94a35ec15668fcef5a4cbbb8927..23cff4189606cd4fb682c5f0f03971c717ef9ff2 100644 (file)
@@ -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,
index 58e3b3c25e9d81f2cdf59c41ef265a2ae3a88737..acbfba0681a121b32f0c8b38eff51d5ff784280a 100644 (file)
@@ -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;