[PATCH 20/25] drm/i915: populate ttm_placement per object
Matthew Auld
matthew.auld at intel.com
Tue May 18 13:43:32 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>
---
.../gpu/drm/i915/gem/i915_gem_object_types.h | 4 ++
drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 37 ++++++++++++++++++-
2 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
index 828310802b9f..13b420090817 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
@@ -11,6 +11,7 @@
#include <drm/drm_gem.h>
#include <drm/ttm/ttm_bo_api.h>
+#include <drm/ttm/ttm_placement.h>
#include <uapi/drm/i915_drm.h>
#include "i915_active.h"
@@ -263,6 +264,9 @@ struct drm_i915_gem_object {
*/
void *st_mm_node;
+ struct ttm_place ttm_place;
+ struct ttm_placement ttm_placement;
+
/**
* Element within memory_region->objects or region->purgeable
* if the object is marked as DONTNEED. Access is protected by
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
index 1eaefb89e859..6e43025a5089 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
@@ -399,6 +399,40 @@ struct ttm_device_funcs i915_ttm_bo_driver = {
.io_mem_pfn = i915_ttm_io_mem_pfn,
};
+
+static void i915_gem_object_ttm_placement(struct drm_i915_gem_object *obj)
+{
+ struct ttm_placement *placement = &obj->mm.ttm_placement;
+ struct ttm_place *place = &obj->mm.ttm_place;
+
+ /* TODO: should loop through the mm.placements */
+ if (i915_gem_object_has_struct_page(obj)) {
+ place->fpfn = 0;
+ place->lpfn = 0;
+ place->mem_type = I915_PL_SYSTEM;
+ place->flags = 0;
+ } else if (i915_gem_object_is_stolen(obj)) {
+ place->fpfn = 0;
+ place->lpfn = 0;
+ place->mem_type = I915_PL_STOLEN;
+ place->flags = TTM_PL_FLAG_CONTIGUOUS;
+ } else if (i915_gem_object_is_lmem(obj)) {
+ 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;
+ } else {
+ 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);
@@ -417,7 +451,8 @@ static int i915_ttm_get_pages(struct drm_i915_gem_object *obj)
}
/* Move to the requested placement. */
- ret = ttm_bo_validate(bo, &i915_lmem0_placement, &ctx);
+ i915_gem_object_ttm_placement(obj);
+ ret = ttm_bo_validate(bo, &obj->mm.ttm_placement, &ctx);
if (ret)
return ret == -ENOSPC ? -ENXIO : ret;
--
2.26.3
More information about the Intel-gfx-trybot
mailing list