[PATCH 19/23] drm/i915: populate ttm_placement on demand
Matthew Auld
matthew.auld at intel.com
Thu May 27 18:22:50 UTC 2021
We need to be able set the place.flags per object, in the next patch.
Signed-off-by: Matthew Auld <matthew.auld at intel.com>
---
drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 43 ++++++++++++++++++++-----
1 file changed, 35 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
index 3748098b42d5..292984548cb8 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
@@ -56,13 +56,6 @@ static const struct ttm_place lmem0_sys_placement_flags[] = {
}
};
-static struct ttm_placement i915_lmem0_placement = {
- .num_placement = 1,
- .placement = &lmem0_sys_placement_flags[0],
- .num_busy_placement = 1,
- .busy_placement = &lmem0_sys_placement_flags[0],
-};
-
static struct ttm_placement i915_sys_placement = {
.num_placement = 1,
.placement = &lmem0_sys_placement_flags[1],
@@ -406,6 +399,36 @@ struct ttm_device_funcs *i915_ttm_driver(void)
return &i915_ttm_bo_driver;
}
+
+static void i915_ttm_placement(struct drm_i915_gem_object *obj,
+ struct ttm_placement *placement,
+ struct ttm_place *place)
+{
+ struct intel_memory_region *mr = obj->mm.region;
+
+ /*
+ * XXX: for now just support lmem, also we need to consider the
+ * mm.placements here at some point.
+ */
+ switch (mr->type) {
+ case INTEL_MEMORY_LOCAL:
+ place->fpfn = 0;
+ place->lpfn = 0;
+ place->mem_type = I915_PL_LMEM0;
+ place->flags = 0;
+ if (obj->flags & I915_BO_ALLOC_CONTIGUOUS)
+ place->flags = TTM_PL_FLAG_CONTIGUOUS;
+ break;
+ default:
+ GEM_BUG_ON(1);
+ }
+
+ placement->num_placement = 1;
+ placement->placement = place;
+ placement->num_busy_placement = 1;
+ placement->busy_placement = place;
+}
+
static int i915_ttm_get_pages(struct drm_i915_gem_object *obj)
{
struct ttm_buffer_object *bo = i915_gem_to_ttm(obj);
@@ -413,11 +436,15 @@ static int i915_ttm_get_pages(struct drm_i915_gem_object *obj)
.interruptible = true,
.no_wait_gpu = false,
};
+ struct ttm_placement placement;
+ struct ttm_place place;
struct sg_table *st;
int ret;
+ i915_ttm_placement(obj, &placement, &place);
+
/* Move to the requested placement. */
- ret = ttm_bo_validate(bo, &i915_lmem0_placement, &ctx);
+ ret = ttm_bo_validate(bo, &placement, &ctx);
if (ret)
return ret == -ENOSPC ? -ENXIO : ret;
--
2.26.3
More information about the Intel-gfx-trybot
mailing list