On 1/26/22 16:21, Matthew Auld wrote:
The end goal is to have userspace tell the kernel what buffers will
require CPU access, however if we ever reach the CPU fault handler, and
the current resource is not mappable, then we should attempt to migrate
the buffer to the mappable portion of LMEM, or even system memory, if the
allowable placements permit it.

Signed-off-by: Matthew Auld <matthew.a...@intel.com>
Cc: Thomas Hellström <thomas.hellst...@linux.intel.com>
---
  drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 58 ++++++++++++++++++++++---
  1 file changed, 52 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c 
b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
index 8376e4c3d290..7299053fb1ec 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
@@ -636,11 +636,25 @@ static void i915_ttm_swap_notify(struct ttm_buffer_object 
*bo)
                i915_ttm_purge(obj);
  }
+static bool i915_ttm_resource_mappable(struct ttm_resource *res)
+{
+       struct i915_ttm_buddy_resource *bman_res = to_ttm_buddy_resource(res);
+
+       if (!i915_ttm_cpu_maps_iomem(res))
+               return true;
+
+       return bman_res->used_visible_size == bman_res->base.num_pages;
+}
+
  static int i915_ttm_io_mem_reserve(struct ttm_device *bdev, struct 
ttm_resource *mem)
  {
+

Stray line.

Otherwise LGTM.

Reviewed-by: Thomas Hellström <thomas.hellst...@linux.intel.com>

Reply via email to