Skip to contentSkip to conversation

drm/i915: Introduce refcounted sg-tables

PATCH Superseded Thomas Hellström 3 participants 7 messages Nov 1, 2021

Subsystems (2)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 drm/i915: Introduce refcounted sg-tables

As we start to introduce asynchronous failsafe object migration, where we update the object state and then submit asynchronous commands we need to record what memory resources are actually used by various part of the command stream. Initially for three purposes:

1) Error capture.
2) Asynchronous migration error recovery.
3) Asynchronous vma bind.

At the time where these happens, the object state may have been updated to be several migrations ahead and object sg-tables discarded.

In order to make it possible to keep sg-tables with memory resource information for these operations, introduce refcounted sg-tables that aren't freed until the last user is done with them.

The alternative would be to reference information sitting on the corresponding ttm_resources which typically have the same lifetime as these refcountes sg_tables, but that leads to other awkward constructs:
Due to the design direction chosen for ttm resource managers that would lead to diamond-style inheritance, the LMEM resources may sometimes be prematurely freed, and finally the subclassed struct ttm_resource would have to bleed into the asynchronous vma bind code.

v3:
- Address a number of style issues (Matthew Auld)
v4:
- Dont check for st->sgl being NULL in i915_ttm_tt__shmem_unpopulate(), that should never happen. (Matthew Auld)
v5:
- Fix a Potential double-free (Matthew Auld)

---
 drivers/gpu/drm/i915/gem/i915_gem_object.h    |  12 +-
 .../gpu/drm/i915/gem/i915_gem_object_types.h  |   3 +-
 drivers/gpu/drm/i915/gem/i915_gem_shmem.c     |  53 +++--
 drivers/gpu/drm/i915/gem/i915_gem_ttm.c       | 186 ++++++++++--------
 drivers/gpu/drm/i915/i915_scatterlist.c       |  62 ++++--
 drivers/gpu/drm/i915/i915_scatterlist.h       |  76 ++++++-
 drivers/gpu/drm/i915/intel_region_ttm.c       |  15 +-
 drivers/gpu/drm/i915/intel_region_ttm.h       |   5 +-
 drivers/gpu/drm/i915/selftests/mock_region.c  |  12 +-
 9 files changed, 277 insertions(+), 147 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_object.h +6 -6
index a5479ac7a4ad..ba224598ed69 100644
@@ -620,12 +620,12 @@ int i915_gem_object_wait_migration(struct drm_i915_gem_object *obj,
 bool i915_gem_object_placement_possible(struct drm_i915_gem_object *obj,
 					enum intel_memory_type type);
 
-struct sg_table *shmem_alloc_st(struct drm_i915_private *i915,
-				size_t size, struct intel_memory_region *mr,
-				struct address_space *mapping,
-				unsigned int max_segment);
-void shmem_free_st(struct sg_table *st, struct address_space *mapping,
-		   bool dirty, bool backup);
+int shmem_sg_alloc_table(struct drm_i915_private *i915, struct sg_table *st,
+			 size_t size, struct intel_memory_region *mr,
+			 struct address_space *mapping,
+			 unsigned int max_segment);
+void shmem_sg_free_table(struct sg_table *st, struct address_space *mapping,
+			 bool dirty, bool backup);
 void __shmem_writeback(size_t size, struct address_space *mapping);
 
 #ifdef CONFIG_MMU_NOTIFIER
drivers/gpu/drm/i915/gem/i915_gem_object_types.h +2 -1
index a4b69a43b898..604ed5ad77f5 100644
@@ -544,6 +544,7 @@ struct drm_i915_gem_object {
 		 */
 		struct list_head region_link;
 
+		struct i915_refct_sgt *rsgt;
 		struct sg_table *pages;
 		void *mapping;
 
@@ -597,7 +598,7 @@ struct drm_i915_gem_object {
 	} mm;
 
 	struct {
-		struct sg_table *cached_io_st;
+		struct i915_refct_sgt *cached_io_rsgt;
 		struct i915_gem_object_page_iter get_io_page;
 		struct drm_i915_gem_object *backup;
 		bool created:1;
drivers/gpu/drm/i915/gem/i915_gem_shmem.c +25 -28

120 lines not on this page · raw message

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +108 -78

410 lines not on this page · raw message

drivers/gpu/drm/i915/i915_scatterlist.c +46 -16

126 lines not on this page · raw message

drivers/gpu/drm/i915/i915_scatterlist.h +72 -4

82 lines not on this page · raw message

drivers/gpu/drm/i915/intel_region_ttm.c +8 -7
index 98c7339bf8ba..2e901a27e259 100644
@@ -115,8 +115,8 @@ void intel_region_ttm_fini(struct intel_memory_region *mem)
 }
 
 /**
- * intel_region_ttm_resource_to_st - Convert an opaque TTM resource manager resource
- * to an sg_table.
+ * intel_region_ttm_resource_to_rsgt -
+ * Convert an opaque TTM resource manager resource to a refcounted sg_table.
  * @mem: The memory region.
  * @res: The resource manager resource obtained from the TTM resource manager.
  *
@@ -126,17 +126,18 @@ void intel_region_ttm_fini(struct intel_memory_region *mem)
  *
  * Return: A malloced sg_table on success, an error pointer on failure.
  */
-struct sg_table *intel_region_ttm_resource_to_st(struct intel_memory_region *mem,
-						 struct ttm_resource *res)
+struct i915_refct_sgt *
+intel_region_ttm_resource_to_rsgt(struct intel_memory_region *mem,
+				  struct ttm_resource *res)
 {
 	if (mem->is_range_manager) {
 		struct ttm_range_mgr_node *range_node =
 			to_ttm_range_mgr_node(res);
 
-		return i915_sg_from_mm_node(&range_node->mm_nodes[0],
-					    mem->region.start);
+		return i915_rsgt_from_mm_node(&range_node->mm_nodes[0],
+					      mem->region.start);
 	} else {
-		return i915_sg_from_buddy_resource(res, mem->region.start);
+		return i915_rsgt_from_buddy_resource(res, mem->region.start);
 	}
 }
 
drivers/gpu/drm/i915/intel_region_ttm.h +3 -2
index 6f44075920f2..7bbe2b46b504 100644
@@ -22,8 +22,9 @@ int intel_region_ttm_init(struct intel_memory_region *mem);
 
 void intel_region_ttm_fini(struct intel_memory_region *mem);
 
-struct sg_table *intel_region_ttm_resource_to_st(struct intel_memory_region *mem,
-						 struct ttm_resource *res);
+struct i915_refct_sgt *
+intel_region_ttm_resource_to_rsgt(struct intel_memory_region *mem,
+				  struct ttm_resource *res);
 
 void intel_region_ttm_resource_free(struct intel_memory_region *mem,
 				    struct ttm_resource *res);
drivers/gpu/drm/i915/selftests/mock_region.c +7 -5
index 75793008c4ef..7ec5037eaa58 100644
@@ -15,9 +15,9 @@
 static void mock_region_put_pages(struct drm_i915_gem_object *obj,
 				  struct sg_table *pages)
 {
+	i915_refct_sgt_put(obj->mm.rsgt);
+	obj->mm.rsgt = NULL;
 	intel_region_ttm_resource_free(obj->mm.region, obj->mm.res);
-	sg_free_table(pages);
-	kfree(pages);
 }
 
 static int mock_region_get_pages(struct drm_i915_gem_object *obj)
@@ -36,12 +36,14 @@ static int mock_region_get_pages(struct drm_i915_gem_object *obj)
 	if (IS_ERR(obj->mm.res))
 		return PTR_ERR(obj->mm.res);
 
-	pages = intel_region_ttm_resource_to_st(obj->mm.region, obj->mm.res);
-	if (IS_ERR(pages)) {
-		err = PTR_ERR(pages);
+	obj->mm.rsgt = intel_region_ttm_resource_to_rsgt(obj->mm.region,
+							 obj->mm.res);
+	if (IS_ERR(obj->mm.rsgt)) {
+		err = PTR_ERR(obj->mm.rsgt);
 		goto err_free_resource;
 	}
 
+	pages = &obj->mm.rsgt->table;
 	__i915_gem_object_set_pages(obj, pages, i915_sg_dma_sizes(pages->sgl));
 
 	return 0;
Signature · 1 line
2.31.1
#1 lore raw
Quoted 8 lines · Thomas Hellström

As we start to introduce asynchronous failsafe object migration, where we update the object state and then submit asynchronous commands we need to record what memory resources are actually used by various part of the command stream. Initially for three purposes:

1) Error capture.
2) Asynchronous migration error recovery.
3) Asynchronous vma bind.

FWIW something like this may be interesting to me as well, although I haven't looked much into details yet, for the purpose of allowing delayed "put pages" via decoupling from the GEM bo. Two questions after glancing over:

1)
I do wonder if abstracting "sgt" away from the name would make sense? Like perhaps obj->mm.pages being the location of the new abstraction so naming it along the lines of i915_obj_pages or something.

2)
And how come obj->mm.pages remains? Does it go away later in follow up work?

Regards,

Tvrtko

Quoted 967 lines

At the time where these happens, the object state may have been updated to be several migrations ahead and object sg-tables discarded.

In order to make it possible to keep sg-tables with memory resource information for these operations, introduce refcounted sg-tables that aren't freed until the last user is done with them.

The alternative would be to reference information sitting on the corresponding ttm_resources which typically have the same lifetime as these refcountes sg_tables, but that leads to other awkward constructs:
Due to the design direction chosen for ttm resource managers that would lead to diamond-style inheritance, the LMEM resources may sometimes be prematurely freed, and finally the subclassed struct ttm_resource would have to bleed into the asynchronous vma bind code.

v3:
- Address a number of style issues (Matthew Auld)
v4:
- Dont check for st->sgl being NULL in i915_ttm_tt__shmem_unpopulate(), that should never happen. (Matthew Auld)
v5:
- Fix a Potential double-free (Matthew Auld)

---
  drivers/gpu/drm/i915/gem/i915_gem_object.h    |  12 +-
  .../gpu/drm/i915/gem/i915_gem_object_types.h  |   3 +-
  drivers/gpu/drm/i915/gem/i915_gem_shmem.c     |  53 +++--
  drivers/gpu/drm/i915/gem/i915_gem_ttm.c       | 186 ++++++++++--------
  drivers/gpu/drm/i915/i915_scatterlist.c       |  62 ++++--
  drivers/gpu/drm/i915/i915_scatterlist.h       |  76 ++++++-
  drivers/gpu/drm/i915/intel_region_ttm.c       |  15 +-
  drivers/gpu/drm/i915/intel_region_ttm.h       |   5 +-
  drivers/gpu/drm/i915/selftests/mock_region.c  |  12 +-
  9 files changed, 277 insertions(+), 147 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_object.h +6 -6
index a5479ac7a4ad..ba224598ed69 100644
@@ -620,12 +620,12 @@ int i915_gem_object_wait_migration(struct drm_i915_gem_object *obj,
  bool i915_gem_object_placement_possible(struct drm_i915_gem_object *obj,
  					enum intel_memory_type type);
 
-struct sg_table *shmem_alloc_st(struct drm_i915_private *i915,
-				size_t size, struct intel_memory_region *mr,
-				struct address_space *mapping,
-				unsigned int max_segment);
-void shmem_free_st(struct sg_table *st, struct address_space *mapping,
-		   bool dirty, bool backup);
+int shmem_sg_alloc_table(struct drm_i915_private *i915, struct sg_table *st,
+			 size_t size, struct intel_memory_region *mr,
+			 struct address_space *mapping,
+			 unsigned int max_segment);
+void shmem_sg_free_table(struct sg_table *st, struct address_space *mapping,
+			 bool dirty, bool backup);
  void __shmem_writeback(size_t size, struct address_space *mapping);
 
  #ifdef CONFIG_MMU_NOTIFIER
drivers/gpu/drm/i915/gem/i915_gem_object_types.h +2 -1
index a4b69a43b898..604ed5ad77f5 100644
@@ -544,6 +544,7 @@ struct drm_i915_gem_object {
  		 */
  		struct list_head region_link;
 
+		struct i915_refct_sgt *rsgt;
  		struct sg_table *pages;
  		void *mapping;
 
@@ -597,7 +598,7 @@ struct drm_i915_gem_object {
  	} mm;
 
  	struct {
-		struct sg_table *cached_io_st;
+		struct i915_refct_sgt *cached_io_rsgt;
  		struct i915_gem_object_page_iter get_io_page;
  		struct drm_i915_gem_object *backup;
  		bool created:1;
drivers/gpu/drm/i915/gem/i915_gem_shmem.c +25 -28
index 01f332d8dbde..4a88c89b7a14 100644
@@ -25,8 +25,8 @@ static void check_release_pagevec(struct pagevec *pvec)
  	cond_resched();
  }
 
-void shmem_free_st(struct sg_table *st, struct address_space *mapping,
-		   bool dirty, bool backup)
+void shmem_sg_free_table(struct sg_table *st, struct address_space *mapping,
+			 bool dirty, bool backup)
  {
  	struct sgt_iter sgt_iter;
  	struct pagevec pvec;
@@ -49,17 +49,15 @@ void shmem_free_st(struct sg_table *st, struct address_space *mapping,
  		check_release_pagevec(&pvec);
 
  	sg_free_table(st);
-	kfree(st);
  }
 
-struct sg_table *shmem_alloc_st(struct drm_i915_private *i915,
-				size_t size, struct intel_memory_region *mr,
-				struct address_space *mapping,
-				unsigned int max_segment)
+int shmem_sg_alloc_table(struct drm_i915_private *i915, struct sg_table *st,
+			 size_t size, struct intel_memory_region *mr,
+			 struct address_space *mapping,
+			 unsigned int max_segment)
  {
  	const unsigned long page_count = size / PAGE_SIZE;
  	unsigned long i;
-	struct sg_table *st;
  	struct scatterlist *sg;
  	struct page *page;
  	unsigned long last_pfn = 0;	/* suppress gcc warning */
@@ -71,16 +69,10 @@ struct sg_table *shmem_alloc_st(struct drm_i915_private *i915,
  	 * object, bail early.
  	 */
  	if (size > resource_size(&mr->region))
-		return ERR_PTR(-ENOMEM);
-
-	st = kmalloc(sizeof(*st), GFP_KERNEL);
-	if (!st)
-		return ERR_PTR(-ENOMEM);
+		return -ENOMEM;
 
-	if (sg_alloc_table(st, page_count, GFP_KERNEL)) {
-		kfree(st);
-		return ERR_PTR(-ENOMEM);
-	}
+	if (sg_alloc_table(st, page_count, GFP_KERNEL))
+		return -ENOMEM;
 
  	/*
  	 * Get the list of pages out of our struct file.  They'll be pinned
@@ -167,15 +159,14 @@ struct sg_table *shmem_alloc_st(struct drm_i915_private *i915,
  	/* Trim unused sg entries to avoid wasting memory. */
  	i915_sg_trim(st);
 
-	return st;
+	return 0;
  err_sg:
  	sg_mark_end(sg);
  	if (sg != st->sgl) {
-		shmem_free_st(st, mapping, false, false);
+		shmem_sg_free_table(st, mapping, false, false);
  	} else {
  		mapping_clear_unevictable(mapping);
  		sg_free_table(st);
-		kfree(st);
  	}
 
  	/*
@@ -190,7 +181,7 @@ struct sg_table *shmem_alloc_st(struct drm_i915_private *i915,
  	if (ret == -ENOSPC)
  		ret = -ENOMEM;
 
-	return ERR_PTR(ret);
+	return ret;
  }
 
  static int shmem_get_pages(struct drm_i915_gem_object *obj)
@@ -214,11 +205,14 @@ static int shmem_get_pages(struct drm_i915_gem_object *obj)
  	GEM_BUG_ON(obj->write_domain & I915_GEM_GPU_DOMAINS);
 
  rebuild_st:
-	st = shmem_alloc_st(i915, obj->base.size, mem, mapping, max_segment);
-	if (IS_ERR(st)) {
-		ret = PTR_ERR(st);
+	st = kmalloc(sizeof(*st), GFP_KERNEL);
+	if (!st)
+		return -ENOMEM;
+
+	ret = shmem_sg_alloc_table(i915, st, obj->base.size, mem, mapping,
+				   max_segment);
+	if (ret)
  		goto err_st;
-	}
 
  	ret = i915_gem_gtt_prepare_pages(obj, st);
  	if (ret) {
@@ -254,7 +248,7 @@ static int shmem_get_pages(struct drm_i915_gem_object *obj)
  	return 0;
 
  err_pages:
-	shmem_free_st(st, mapping, false, false);
+	shmem_sg_free_table(st, mapping, false, false);
  	/*
  	 * shmemfs first checks if there is enough memory to allocate the page
  	 * and reports ENOSPC should there be insufficient, along with the usual
@@ -268,6 +262,8 @@ static int shmem_get_pages(struct drm_i915_gem_object *obj)
  	if (ret == -ENOSPC)
  		ret = -ENOMEM;
 
+	kfree(st);
+
  	return ret;
  }
 
@@ -374,8 +370,9 @@ void i915_gem_object_put_pages_shmem(struct drm_i915_gem_object *obj, struct sg_
  	if (i915_gem_object_needs_bit17_swizzle(obj))
  		i915_gem_object_save_bit_17_swizzle(obj, pages);
 
-	shmem_free_st(pages, file_inode(obj->base.filp)->i_mapping,
-		      obj->mm.dirty, obj->mm.madv == I915_MADV_WILLNEED);
+	shmem_sg_free_table(pages, file_inode(obj->base.filp)->i_mapping,
+			    obj->mm.dirty, obj->mm.madv == I915_MADV_WILLNEED);
+	kfree(pages);
  	obj->mm.dirty = false;
  }
 
drivers/gpu/drm/i915/gem/i915_gem_ttm.c +108 -78
index 4fd2edb20dd9..6a05369e2705 100644
@@ -34,7 +34,7 @@
   * struct i915_ttm_tt - TTM page vector with additional private information
   * @ttm: The base TTM page vector.
   * @dev: The struct device used for dma mapping and unmapping.
- * @cached_st: The cached scatter-gather table.
+ * @cached_rsgt: The cached scatter-gather table.
   * @is_shmem: Set if using shmem.
   * @filp: The shmem file, if using shmem backend.
   *
@@ -47,7 +47,7 @@
  struct i915_ttm_tt {
  	struct ttm_tt ttm;
  	struct device *dev;
-	struct sg_table *cached_st;
+	struct i915_refct_sgt cached_rsgt;
 
  	bool is_shmem;
  	struct file *filp;
@@ -217,18 +217,16 @@ static int i915_ttm_tt_shmem_populate(struct ttm_device *bdev,
  		i915_tt->filp = filp;
  	}
 
-	st = shmem_alloc_st(i915, size, mr, filp->f_mapping, max_segment);
-	if (IS_ERR(st))
-		return PTR_ERR(st);
+	st = &i915_tt->cached_rsgt.table;
+	err = shmem_sg_alloc_table(i915, st, size, mr, filp->f_mapping,
+				   max_segment);
+	if (err)
+		return err;
 
-	err = dma_map_sg_attrs(i915_tt->dev,
-			       st->sgl, st->nents,
-			       DMA_BIDIRECTIONAL,
-			       DMA_ATTR_SKIP_CPU_SYNC);
-	if (err <= 0) {
-		err = -EINVAL;
+	err = dma_map_sgtable(i915_tt->dev, st, DMA_BIDIRECTIONAL,
+			      DMA_ATTR_SKIP_CPU_SYNC);
+	if (err)
  		goto err_free_st;
-	}
 
  	i = 0;
  	for_each_sgt_page(page, sgt_iter, st)
@@ -237,11 +235,11 @@ static int i915_ttm_tt_shmem_populate(struct ttm_device *bdev,
  	if (ttm->page_flags & TTM_TT_FLAG_SWAPPED)
  		ttm->page_flags &= ~TTM_TT_FLAG_SWAPPED;
 
-	i915_tt->cached_st = st;
  	return 0;
 
  err_free_st:
-	shmem_free_st(st, filp->f_mapping, false, false);
+	shmem_sg_free_table(st, filp->f_mapping, false, false);
+
  	return err;
  }
 
@@ -249,16 +247,27 @@ static void i915_ttm_tt_shmem_unpopulate(struct ttm_tt *ttm)
  {
  	struct i915_ttm_tt *i915_tt = container_of(ttm, typeof(*i915_tt), ttm);
  	bool backup = ttm->page_flags & TTM_TT_FLAG_SWAPPED;
+	struct sg_table *st = &i915_tt->cached_rsgt.table;
+
+	shmem_sg_free_table(st, file_inode(i915_tt->filp)->i_mapping,
+			    backup, backup);
+}
 
-	dma_unmap_sg(i915_tt->dev, i915_tt->cached_st->sgl,
-		     i915_tt->cached_st->nents,
-		     DMA_BIDIRECTIONAL);
+static void i915_ttm_tt_release(struct kref *ref)
+{
+	struct i915_ttm_tt *i915_tt =
+		container_of(ref, typeof(*i915_tt), cached_rsgt.kref);
+	struct sg_table *st = &i915_tt->cached_rsgt.table;
 
-	shmem_free_st(fetch_and_zero(&i915_tt->cached_st),
-		      file_inode(i915_tt->filp)->i_mapping,
-		      backup, backup);
+	GEM_WARN_ON(st->sgl);
+
+	kfree(i915_tt);
  }
 
+static const struct i915_refct_sgt_ops tt_rsgt_ops = {
+	.release = i915_ttm_tt_release
+};
+
  static struct ttm_tt *i915_ttm_tt_create(struct ttm_buffer_object *bo,
  					 uint32_t page_flags)
  {
@@ -287,6 +296,9 @@ static struct ttm_tt *i915_ttm_tt_create(struct ttm_buffer_object *bo,
  	if (ret)
  		goto err_free;
 
+	__i915_refct_sgt_init(&i915_tt->cached_rsgt, bo->base.size,
+			      &tt_rsgt_ops);
+
  	i915_tt->dev = obj->base.dev->dev;
 
  	return &i915_tt->ttm;
@@ -311,17 +323,15 @@ static int i915_ttm_tt_populate(struct ttm_device *bdev,
  static void i915_ttm_tt_unpopulate(struct ttm_device *bdev, struct ttm_tt *ttm)
  {
  	struct i915_ttm_tt *i915_tt = container_of(ttm, typeof(*i915_tt), ttm);
+	struct sg_table *st = &i915_tt->cached_rsgt.table;
+
+	if (st->sgl)
+		dma_unmap_sgtable(i915_tt->dev, st, DMA_BIDIRECTIONAL, 0);
 
  	if (i915_tt->is_shmem) {
  		i915_ttm_tt_shmem_unpopulate(ttm);
  	} else {
-		if (i915_tt->cached_st) {
-			dma_unmap_sgtable(i915_tt->dev, i915_tt->cached_st,
-					  DMA_BIDIRECTIONAL, 0);
-			sg_free_table(i915_tt->cached_st);
-			kfree(i915_tt->cached_st);
-			i915_tt->cached_st = NULL;
-		}
+		sg_free_table(st);
  		ttm_pool_free(&bdev->pool, ttm);
  	}
  }
@@ -334,7 +344,7 @@ static void i915_ttm_tt_destroy(struct ttm_device *bdev, struct ttm_tt *ttm)
  		fput(i915_tt->filp);
 
  	ttm_tt_fini(ttm);
-	kfree(i915_tt);
+	i915_refct_sgt_put(&i915_tt->cached_rsgt);
  }
 
  static bool i915_ttm_eviction_valuable(struct ttm_buffer_object *bo,
@@ -376,12 +386,12 @@ static int i915_ttm_move_notify(struct ttm_buffer_object *bo)
  	return 0;
  }
 
-static void i915_ttm_free_cached_io_st(struct drm_i915_gem_object *obj)
+static void i915_ttm_free_cached_io_rsgt(struct drm_i915_gem_object *obj)
  {
  	struct radix_tree_iter iter;
  	void __rcu **slot;
 
-	if (!obj->ttm.cached_io_st)
+	if (!obj->ttm.cached_io_rsgt)
  		return;
 
  	rcu_read_lock();
@@ -389,9 +399,8 @@ static void i915_ttm_free_cached_io_st(struct drm_i915_gem_object *obj)
  		radix_tree_delete(&obj->ttm.get_io_page.radix, iter.index);
  	rcu_read_unlock();
 
-	sg_free_table(obj->ttm.cached_io_st);
-	kfree(obj->ttm.cached_io_st);
-	obj->ttm.cached_io_st = NULL;
+	i915_refct_sgt_put(obj->ttm.cached_io_rsgt);
+	obj->ttm.cached_io_rsgt = NULL;
  }
 
  static void
@@ -477,7 +486,7 @@ static int i915_ttm_purge(struct drm_i915_gem_object *obj)
  	obj->write_domain = 0;
  	obj->read_domains = 0;
  	i915_ttm_adjust_gem_after_move(obj);
-	i915_ttm_free_cached_io_st(obj);
+	i915_ttm_free_cached_io_rsgt(obj);
  	obj->mm.madv = __I915_MADV_PURGED;
  	return 0;
  }
@@ -532,7 +541,7 @@ static void i915_ttm_swap_notify(struct ttm_buffer_object *bo)
  	int ret = i915_ttm_move_notify(bo);
 
  	GEM_WARN_ON(ret);
-	GEM_WARN_ON(obj->ttm.cached_io_st);
+	GEM_WARN_ON(obj->ttm.cached_io_rsgt);
  	if (!ret && obj->mm.madv != I915_MADV_WILLNEED)
  		i915_ttm_purge(obj);
  }
@@ -543,7 +552,7 @@ static void i915_ttm_delete_mem_notify(struct ttm_buffer_object *bo)
 
  	if (likely(obj)) {
  		__i915_gem_object_pages_fini(obj);
-		i915_ttm_free_cached_io_st(obj);
+		i915_ttm_free_cached_io_rsgt(obj);
  	}
  }
 
@@ -563,40 +572,35 @@ i915_ttm_region(struct ttm_device *bdev, int ttm_mem_type)
  					  ttm_mem_type - I915_PL_LMEM0);
  }
 
-static struct sg_table *i915_ttm_tt_get_st(struct ttm_tt *ttm)
+static struct i915_refct_sgt *i915_ttm_tt_get_st(struct ttm_tt *ttm)
  {
  	struct i915_ttm_tt *i915_tt = container_of(ttm, typeof(*i915_tt), ttm);
  	struct sg_table *st;
  	int ret;
 
-	if (i915_tt->cached_st)
-		return i915_tt->cached_st;
-
-	st = kzalloc(sizeof(*st), GFP_KERNEL);
-	if (!st)
-		return ERR_PTR(-ENOMEM);
+	if (i915_tt->cached_rsgt.table.sgl)
+		return i915_refct_sgt_get(&i915_tt->cached_rsgt);
 
+	st = &i915_tt->cached_rsgt.table;
  	ret = sg_alloc_table_from_pages_segment(st,
  			ttm->pages, ttm->num_pages,
  			0, (unsigned long)ttm->num_pages << PAGE_SHIFT,
  			i915_sg_segment_size(), GFP_KERNEL);
  	if (ret) {
-		kfree(st);
+		st->sgl = NULL;
  		return ERR_PTR(ret);
  	}
 
  	ret = dma_map_sgtable(i915_tt->dev, st, DMA_BIDIRECTIONAL, 0);
  	if (ret) {
  		sg_free_table(st);
-		kfree(st);
  		return ERR_PTR(ret);
  	}
 
-	i915_tt->cached_st = st;
-	return st;
+	return i915_refct_sgt_get(&i915_tt->cached_rsgt);
  }
 
-static struct sg_table *
+static struct i915_refct_sgt *
  i915_ttm_resource_get_st(struct drm_i915_gem_object *obj,
  			 struct ttm_resource *res)
  {
@@ -610,7 +614,21 @@ i915_ttm_resource_get_st(struct drm_i915_gem_object *obj,
  	 * the resulting st. Might make sense for GGTT.
  	 */
  	GEM_WARN_ON(!cpu_maps_iomem(res));
-	return intel_region_ttm_resource_to_st(obj->mm.region, res);
+	if (bo->resource == res) {
+		if (!obj->ttm.cached_io_rsgt) {
+			struct i915_refct_sgt *rsgt;
+
+			rsgt = intel_region_ttm_resource_to_rsgt(obj->mm.region,
+								 res);
+			if (IS_ERR(rsgt))
+				return rsgt;
+
+			obj->ttm.cached_io_rsgt = rsgt;
+		}
+		return i915_refct_sgt_get(obj->ttm.cached_io_rsgt);
+	}
+
+	return intel_region_ttm_resource_to_rsgt(obj->mm.region, res);
  }
 
  static int i915_ttm_accel_move(struct ttm_buffer_object *bo,
@@ -621,10 +639,7 @@ static int i915_ttm_accel_move(struct ttm_buffer_object *bo,
  {
  	struct drm_i915_private *i915 = container_of(bo->bdev, typeof(*i915),
  						     bdev);
-	struct ttm_resource_manager *src_man =
-		ttm_manager_type(bo->bdev, bo->resource->mem_type);
  	struct drm_i915_gem_object *obj = i915_ttm_to_gem(bo);
-	struct sg_table *src_st;
  	struct i915_request *rq;
  	struct ttm_tt *src_ttm = bo->ttm;
  	enum i915_cache_level src_level, dst_level;
@@ -650,17 +665,22 @@ static int i915_ttm_accel_move(struct ttm_buffer_object *bo,
  		}
  		intel_engine_pm_put(i915->gt.migrate.context->engine);
  	} else {
-		src_st = src_man->use_tt ? i915_ttm_tt_get_st(src_ttm) :
-			obj->ttm.cached_io_st;
+		struct i915_refct_sgt *src_rsgt =
+			i915_ttm_resource_get_st(obj, bo->resource);
+
+		if (IS_ERR(src_rsgt))
+			return PTR_ERR(src_rsgt);
 
  		src_level = i915_ttm_cache_level(i915, bo->resource, src_ttm);
  		intel_engine_pm_get(i915->gt.migrate.context->engine);
  		ret = intel_context_migrate_copy(i915->gt.migrate.context,
-						 NULL, src_st->sgl, src_level,
+						 NULL, src_rsgt->table.sgl,
+						 src_level,
  						 gpu_binds_iomem(bo->resource),
  						 dst_st->sgl, dst_level,
  						 gpu_binds_iomem(dst_mem),
  						 &rq);
+		i915_refct_sgt_put(src_rsgt);
  		if (!ret && rq) {
  			i915_request_wait(rq, 0, MAX_SCHEDULE_TIMEOUT);
  			i915_request_put(rq);
@@ -674,13 +694,14 @@ static int i915_ttm_accel_move(struct ttm_buffer_object *bo,
  static void __i915_ttm_move(struct ttm_buffer_object *bo, bool clear,
  			    struct ttm_resource *dst_mem,
  			    struct ttm_tt *dst_ttm,
-			    struct sg_table *dst_st,
+			    struct i915_refct_sgt *dst_rsgt,
  			    bool allow_accel)
  {
  	int ret = -EINVAL;
 
  	if (allow_accel)
-		ret = i915_ttm_accel_move(bo, clear, dst_mem, dst_ttm, dst_st);
+		ret = i915_ttm_accel_move(bo, clear, dst_mem, dst_ttm,
+					  &dst_rsgt->table);
  	if (ret) {
  		struct drm_i915_gem_object *obj = i915_ttm_to_gem(bo);
  		struct intel_memory_region *dst_reg, *src_reg;
@@ -697,12 +718,13 @@ static void __i915_ttm_move(struct ttm_buffer_object *bo, bool clear,
  		dst_iter = !cpu_maps_iomem(dst_mem) ?
  			ttm_kmap_iter_tt_init(&_dst_iter.tt, dst_ttm) :
  			ttm_kmap_iter_iomap_init(&_dst_iter.io, &dst_reg->iomap,
-						 dst_st, dst_reg->region.start);
+						 &dst_rsgt->table,
+						 dst_reg->region.start);
 
  		src_iter = !cpu_maps_iomem(bo->resource) ?
  			ttm_kmap_iter_tt_init(&_src_iter.tt, bo->ttm) :
  			ttm_kmap_iter_iomap_init(&_src_iter.io, &src_reg->iomap,
-						 obj->ttm.cached_io_st,
+						 &obj->ttm.cached_io_rsgt->table,
  						 src_reg->region.start);
 
  		ttm_move_memcpy(clear, dst_mem->num_pages, dst_iter, src_iter);
@@ -718,7 +740,7 @@ static int i915_ttm_move(struct ttm_buffer_object *bo, bool evict,
  	struct ttm_resource_manager *dst_man =
  		ttm_manager_type(bo->bdev, dst_mem->mem_type);
  	struct ttm_tt *ttm = bo->ttm;
-	struct sg_table *dst_st;
+	struct i915_refct_sgt *dst_rsgt;
  	bool clear;
  	int ret;
 
@@ -744,22 +766,24 @@ static int i915_ttm_move(struct ttm_buffer_object *bo, bool evict,
  			return ret;
  	}
 
-	dst_st = i915_ttm_resource_get_st(obj, dst_mem);
-	if (IS_ERR(dst_st))
-		return PTR_ERR(dst_st);
+	dst_rsgt = i915_ttm_resource_get_st(obj, dst_mem);
+	if (IS_ERR(dst_rsgt))
+		return PTR_ERR(dst_rsgt);
 
  	clear = !cpu_maps_iomem(bo->resource) && (!ttm || !ttm_tt_is_populated(ttm));
  	if (!(clear && ttm && !(ttm->page_flags & TTM_TT_FLAG_ZERO_ALLOC)))
-		__i915_ttm_move(bo, clear, dst_mem, bo->ttm, dst_st, true);
+		__i915_ttm_move(bo, clear, dst_mem, bo->ttm, dst_rsgt, true);
 
  	ttm_bo_move_sync_cleanup(bo, dst_mem);
  	i915_ttm_adjust_domains_after_move(obj);
-	i915_ttm_free_cached_io_st(obj);
+	i915_ttm_free_cached_io_rsgt(obj);
 
  	if (gpu_binds_iomem(dst_mem) || cpu_maps_iomem(dst_mem)) {
-		obj->ttm.cached_io_st = dst_st;
-		obj->ttm.get_io_page.sg_pos = dst_st->sgl;
+		obj->ttm.cached_io_rsgt = dst_rsgt;
+		obj->ttm.get_io_page.sg_pos = dst_rsgt->table.sgl;
  		obj->ttm.get_io_page.sg_idx = 0;
+	} else {
+		i915_refct_sgt_put(dst_rsgt);
  	}
 
  	i915_ttm_adjust_lru(obj);
@@ -825,7 +849,6 @@ static int __i915_ttm_get_pages(struct drm_i915_gem_object *obj,
  		.interruptible = true,
  		.no_wait_gpu = false,
  	};
-	struct sg_table *st;
  	int real_num_busy;
  	int ret;
 
@@ -862,12 +885,16 @@ static int __i915_ttm_get_pages(struct drm_i915_gem_object *obj,
  	}
 
  	if (!i915_gem_object_has_pages(obj)) {
-		/* Object either has a page vector or is an iomem object */
-		st = bo->ttm ? i915_ttm_tt_get_st(bo->ttm) : obj->ttm.cached_io_st;
-		if (IS_ERR(st))
-			return PTR_ERR(st);
+		struct i915_refct_sgt *rsgt =
+			i915_ttm_resource_get_st(obj, bo->resource);
+
+		if (IS_ERR(rsgt))
+			return PTR_ERR(rsgt);
 
-		__i915_gem_object_set_pages(obj, st, i915_sg_dma_sizes(st->sgl));
+		GEM_BUG_ON(obj->mm.rsgt);
+		obj->mm.rsgt = rsgt;
+		__i915_gem_object_set_pages(obj, &rsgt->table,
+					    i915_sg_dma_sizes(rsgt->table.sgl));
  	}
 
  	i915_ttm_adjust_lru(obj);
@@ -941,6 +968,9 @@ static void i915_ttm_put_pages(struct drm_i915_gem_object *obj,
  	 * If the object is not destroyed next, The TTM eviction logic
  	 * and shrinkers will move it out if needed.
  	 */
+
+	if (obj->mm.rsgt)
+		i915_refct_sgt_put(fetch_and_zero(&obj->mm.rsgt));
  }
 
  static void i915_ttm_adjust_lru(struct drm_i915_gem_object *obj)
@@ -1278,7 +1308,7 @@ int i915_gem_obj_copy_ttm(struct drm_i915_gem_object *dst,
  	struct ttm_operation_ctx ctx = {
  		.interruptible = intr,
  	};
-	struct sg_table *dst_st;
+	struct i915_refct_sgt *dst_rsgt;
  	int ret;
 
  	assert_object_held(dst);
@@ -1293,11 +1323,11 @@ int i915_gem_obj_copy_ttm(struct drm_i915_gem_object *dst,
  	if (ret)
  		return ret;
 
-	dst_st = gpu_binds_iomem(dst_bo->resource) ?
-		dst->ttm.cached_io_st : i915_ttm_tt_get_st(dst_bo->ttm);
-
+	dst_rsgt = i915_ttm_resource_get_st(dst, dst_bo->resource);
  	__i915_ttm_move(src_bo, false, dst_bo->resource, dst_bo->ttm,
-			dst_st, allow_accel);
+			dst_rsgt, allow_accel);
+
+	i915_refct_sgt_put(dst_rsgt);
 
  	return 0;
  }
drivers/gpu/drm/i915/i915_scatterlist.c +46 -16
index 4a6712dca838..41f2adb6a583 100644
@@ -41,8 +41,32 @@ bool i915_sg_trim(struct sg_table *orig_st)
  	return true;
  }
 
+static void i915_refct_sgt_release(struct kref *ref)
+{
+	struct i915_refct_sgt *rsgt =
+		container_of(ref, typeof(*rsgt), kref);
+
+	sg_free_table(&rsgt->table);
+	kfree(rsgt);
+}
+
+static const struct i915_refct_sgt_ops rsgt_ops = {
+	.release = i915_refct_sgt_release
+};
+
+/**
+ * i915_refct_sgt_init - Initialize a struct i915_refct_sgt with default ops
+ * @rsgt: The struct i915_refct_sgt to initialize.
+ * size: The size of the underlying memory buffer.
+ */
+void i915_refct_sgt_init(struct i915_refct_sgt *rsgt, size_t size)
+{
+	__i915_refct_sgt_init(rsgt, size, &rsgt_ops);
+}
+
  /**
- * i915_sg_from_mm_node - Create an sg_table from a struct drm_mm_node
+ * i915_rsgt_from_mm_node - Create a refcounted sg_table from a struct
+ * drm_mm_node
   * @node: The drm_mm_node.
   * @region_start: An offset to add to the dma addresses of the sg list.
   *
@@ -50,25 +74,28 @@ bool i915_sg_trim(struct sg_table *orig_st)
   * taking a maximum segment length into account, splitting into segments
   * if necessary.
   *
- * Return: A pointer to a kmalloced struct sg_table on success, negative
+ * Return: A pointer to a kmalloced struct i915_refct_sgt on success, negative
   * error code cast to an error pointer on failure.
   */
-struct sg_table *i915_sg_from_mm_node(const struct drm_mm_node *node,
-				      u64 region_start)
+struct i915_refct_sgt *i915_rsgt_from_mm_node(const struct drm_mm_node *node,
+					      u64 region_start)
  {
  	const u64 max_segment = SZ_1G; /* Do we have a limit on this? */
  	u64 segment_pages = max_segment >> PAGE_SHIFT;
  	u64 block_size, offset, prev_end;
+	struct i915_refct_sgt *rsgt;
  	struct sg_table *st;
  	struct scatterlist *sg;
 
-	st = kmalloc(sizeof(*st), GFP_KERNEL);
-	if (!st)
+	rsgt = kmalloc(sizeof(*rsgt), GFP_KERNEL);
+	if (!rsgt)
  		return ERR_PTR(-ENOMEM);
 
+	i915_refct_sgt_init(rsgt, node->size << PAGE_SHIFT);
+	st = &rsgt->table;
  	if (sg_alloc_table(st, DIV_ROUND_UP(node->size, segment_pages),
  			   GFP_KERNEL)) {
-		kfree(st);
+		i915_refct_sgt_put(rsgt);
  		return ERR_PTR(-ENOMEM);
  	}
 
@@ -104,11 +131,11 @@ struct sg_table *i915_sg_from_mm_node(const struct drm_mm_node *node,
  	sg_mark_end(sg);
  	i915_sg_trim(st);
 
-	return st;
+	return rsgt;
  }
 
  /**
- * i915_sg_from_buddy_resource - Create an sg_table from a struct
+ * i915_rsgt_from_buddy_resource - Create a refcounted sg_table from a struct
   * i915_buddy_block list
   * @res: The struct i915_ttm_buddy_resource.
   * @region_start: An offset to add to the dma addresses of the sg list.
@@ -117,11 +144,11 @@ struct sg_table *i915_sg_from_mm_node(const struct drm_mm_node *node,
   * taking a maximum segment length into account, splitting into segments
   * if necessary.
   *
- * Return: A pointer to a kmalloced struct sg_table on success, negative
+ * Return: A pointer to a kmalloced struct i915_refct_sgts on success, negative
   * error code cast to an error pointer on failure.
   */
-struct sg_table *i915_sg_from_buddy_resource(struct ttm_resource *res,
-					     u64 region_start)
+struct i915_refct_sgt *i915_rsgt_from_buddy_resource(struct ttm_resource *res,
+						     u64 region_start)
  {
  	struct i915_ttm_buddy_resource *bman_res = to_ttm_buddy_resource(res);
  	const u64 size = res->num_pages << PAGE_SHIFT;
@@ -129,18 +156,21 @@ struct sg_table *i915_sg_from_buddy_resource(struct ttm_resource *res,
  	struct i915_buddy_mm *mm = bman_res->mm;
  	struct list_head *blocks = &bman_res->blocks;
  	struct i915_buddy_block *block;
+	struct i915_refct_sgt *rsgt;
  	struct scatterlist *sg;
  	struct sg_table *st;
  	resource_size_t prev_end;
 
  	GEM_BUG_ON(list_empty(blocks));
 
-	st = kmalloc(sizeof(*st), GFP_KERNEL);
-	if (!st)
+	rsgt = kmalloc(sizeof(*rsgt), GFP_KERNEL);
+	if (!rsgt)
  		return ERR_PTR(-ENOMEM);
 
+	i915_refct_sgt_init(rsgt, size);
+	st = &rsgt->table;
  	if (sg_alloc_table(st, res->num_pages, GFP_KERNEL)) {
-		kfree(st);
+		i915_refct_sgt_put(rsgt);
  		return ERR_PTR(-ENOMEM);
  	}
 
@@ -181,7 +211,7 @@ struct sg_table *i915_sg_from_buddy_resource(struct ttm_resource *res,
  	sg_mark_end(sg);
  	i915_sg_trim(st);
 
-	return st;
+	return rsgt;
  }
 
  #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
drivers/gpu/drm/i915/i915_scatterlist.h +72 -4
index b8bd5925b03f..12c6a1684081 100644
@@ -144,10 +144,78 @@ static inline unsigned int i915_sg_segment_size(void)
 
  bool i915_sg_trim(struct sg_table *orig_st);
 
-struct sg_table *i915_sg_from_mm_node(const struct drm_mm_node *node,
-				      u64 region_start);
+/**
+ * struct i915_refct_sgt_ops - Operations structure for struct i915_refct_sgt
+ */
+struct i915_refct_sgt_ops {
+	/**
+	 * release() - Free the memory of the struct i915_refct_sgt
+	 * @ref: struct kref that is embedded in the struct i915_refct_sgt
+	 */
+	void (*release)(struct kref *ref);
+};
+
+/**
+ * struct i915_refct_sgt - A refcounted scatter-gather table
+ * @kref: struct kref for refcounting
+ * @table: struct sg_table holding the scatter-gather table itself. Note that
+ * @table->sgl = NULL can be used to determine whether a scatter-gather table
+ * is present or not.
+ * @size: The size in bytes of the underlying memory buffer
+ * @ops: The operations structure.
+ */
+struct i915_refct_sgt {
+	struct kref kref;
+	struct sg_table table;
+	size_t size;
+	const struct i915_refct_sgt_ops *ops;
+};
+
+/**
+ * i915_refct_sgt_put - Put a refcounted sg-table
+ * @rsgt the struct i915_refct_sgt to put.
+ */
+static inline void i915_refct_sgt_put(struct i915_refct_sgt *rsgt)
+{
+	if (rsgt)
+		kref_put(&rsgt->kref, rsgt->ops->release);
+}
+
+/**
+ * i915_refct_sgt_get - Get a refcounted sg-table
+ * @rsgt the struct i915_refct_sgt to get.
+ */
+static inline struct i915_refct_sgt *
+i915_refct_sgt_get(struct i915_refct_sgt *rsgt)
+{
+	kref_get(&rsgt->kref);
+	return rsgt;
+}
+
+/**
+ * __i915_refct_sgt_init - Initialize a refcounted sg-list with a custom
+ * operations structure
+ * @rsgt The struct i915_refct_sgt to initialize.
+ * @size: Size in bytes of the underlying memory buffer.
+ * @ops: A customized operations structure in case the refcounted sg-list
+ * is embedded into another structure.
+ */
+static inline void __i915_refct_sgt_init(struct i915_refct_sgt *rsgt,
+					 size_t size,
+					 const struct i915_refct_sgt_ops *ops)
+{
+	kref_init(&rsgt->kref);
+	rsgt->table.sgl = NULL;
+	rsgt->size = size;
+	rsgt->ops = ops;
+}
+
+void i915_refct_sgt_init(struct i915_refct_sgt *rsgt, size_t size);
+
+struct i915_refct_sgt *i915_rsgt_from_mm_node(const struct drm_mm_node *node,
+					      u64 region_start);
 
-struct sg_table *i915_sg_from_buddy_resource(struct ttm_resource *res,
-					     u64 region_start);
+struct i915_refct_sgt *i915_rsgt_from_buddy_resource(struct ttm_resource *res,
+						     u64 region_start);
 
  #endif
drivers/gpu/drm/i915/intel_region_ttm.c +8 -7
index 98c7339bf8ba..2e901a27e259 100644
@@ -115,8 +115,8 @@ void intel_region_ttm_fini(struct intel_memory_region *mem)
  }
 
  /**
- * intel_region_ttm_resource_to_st - Convert an opaque TTM resource manager resource
- * to an sg_table.
+ * intel_region_ttm_resource_to_rsgt -
+ * Convert an opaque TTM resource manager resource to a refcounted sg_table.
   * @mem: The memory region.
   * @res: The resource manager resource obtained from the TTM resource manager.
   *
@@ -126,17 +126,18 @@ void intel_region_ttm_fini(struct intel_memory_region *mem)
   *
   * Return: A malloced sg_table on success, an error pointer on failure.
   */
-struct sg_table *intel_region_ttm_resource_to_st(struct intel_memory_region *mem,
-						 struct ttm_resource *res)
+struct i915_refct_sgt *
+intel_region_ttm_resource_to_rsgt(struct intel_memory_region *mem,
+				  struct ttm_resource *res)
  {
  	if (mem->is_range_manager) {
  		struct ttm_range_mgr_node *range_node =
  			to_ttm_range_mgr_node(res);
 
-		return i915_sg_from_mm_node(&range_node->mm_nodes[0],
-					    mem->region.start);
+		return i915_rsgt_from_mm_node(&range_node->mm_nodes[0],
+					      mem->region.start);
  	} else {
-		return i915_sg_from_buddy_resource(res, mem->region.start);
+		return i915_rsgt_from_buddy_resource(res, mem->region.start);
  	}
  }
 
drivers/gpu/drm/i915/intel_region_ttm.h +3 -2
index 6f44075920f2..7bbe2b46b504 100644
@@ -22,8 +22,9 @@ int intel_region_ttm_init(struct intel_memory_region *mem);
 
  void intel_region_ttm_fini(struct intel_memory_region *mem);
 
-struct sg_table *intel_region_ttm_resource_to_st(struct intel_memory_region *mem,
-						 struct ttm_resource *res);
+struct i915_refct_sgt *
+intel_region_ttm_resource_to_rsgt(struct intel_memory_region *mem,
+				  struct ttm_resource *res);
 
  void intel_region_ttm_resource_free(struct intel_memory_region *mem,
  				    struct ttm_resource *res);
drivers/gpu/drm/i915/selftests/mock_region.c +7 -5
index 75793008c4ef..7ec5037eaa58 100644
@@ -15,9 +15,9 @@
  static void mock_region_put_pages(struct drm_i915_gem_object *obj,
  				  struct sg_table *pages)
  {
+	i915_refct_sgt_put(obj->mm.rsgt);
+	obj->mm.rsgt = NULL;
  	intel_region_ttm_resource_free(obj->mm.region, obj->mm.res);
-	sg_free_table(pages);
-	kfree(pages);
  }
 
  static int mock_region_get_pages(struct drm_i915_gem_object *obj)
@@ -36,12 +36,14 @@ static int mock_region_get_pages(struct drm_i915_gem_object *obj)
  	if (IS_ERR(obj->mm.res))
  		return PTR_ERR(obj->mm.res);
 
-	pages = intel_region_ttm_resource_to_st(obj->mm.region, obj->mm.res);
-	if (IS_ERR(pages)) {
-		err = PTR_ERR(pages);
+	obj->mm.rsgt = intel_region_ttm_resource_to_rsgt(obj->mm.region,
+							 obj->mm.res);
+	if (IS_ERR(obj->mm.rsgt)) {
+		err = PTR_ERR(obj->mm.rsgt);
  		goto err_free_resource;
  	}
 
+	pages = &obj->mm.rsgt->table;
  	__i915_gem_object_set_pages(obj, pages, i915_sg_dma_sizes(pages->sgl));
 
  	return 0;
#2 lore raw

Hi, Tvrtko

Quoted 17 lines · Tvrtko Ursulin
Quoted 9 lines · Thomas Hellström

As we start to introduce asynchronous failsafe object migration, where we update the object state and then submit asynchronous commands we need to record what memory resources are actually used by various part of the command stream. Initially for three purposes:

1) Error capture.
2) Asynchronous migration error recovery.
3) Asynchronous vma bind.

FWIW something like this may be interesting to me as well, although I haven't looked much into details yet, for the purpose of allowing delayed "put pages" via decoupling from the GEM bo.
Two questions after glancing over:

Quoted 5 lines

1)
I do wonder if abstracting "sgt" away from the name would make sense? Like perhaps obj->mm.pages being the location of the new abstraction so
naming it along the lines of i915_obj_pages or something.

Well it's not yet clear how this will end up. Really this should develop into something along the lines of "struct i915_async_obj", on which the sg-list is a member only. Depending on how this turns out and if it remains an sg-list I think your suggestion makes sense, but is it something we can postpone for now?

Quoted 4 lines

2)
And how come obj->mm.pages remains? Does it go away later in follow up work?

For the non-ttm backends, it's not yet implemented, so once they are either moved to TTM or updated, we can completely replace obj-

Quoted 1 line

mm.pages.

/Thomas

Quoted 1,170 lines

Regards,

Tvrtko

Quoted 1,165 lines

At the time where these happens, the object state may have been updated
to be several migrations ahead and object sg-tables discarded.

In order to make it possible to keep sg-tables with memory resource information for these operations, introduce refcounted sg-tables that
aren't freed until the last user is done with them.

The alternative would be to reference information sitting on the corresponding ttm_resources which typically have the same lifetime as
these refcountes sg_tables, but that leads to other awkward constructs:
Due to the design direction chosen for ttm resource managers that would
lead to diamond-style inheritance, the LMEM resources may sometimes be
prematurely freed, and finally the subclassed struct ttm_resource would
have to bleed into the asynchronous vma bind code.

v3:
- Address a number of style issues (Matthew Auld)
v4:
- Dont check for st->sgl being NULL in
i915_ttm_tt__shmem_unpopulate(),
   that should never happen. (Matthew Auld)
v5:
- Fix a Potential double-free (Matthew Auld)

---
  drivers/gpu/drm/i915/gem/i915_gem_object.h    |  12 +- .../gpu/drm/i915/gem/i915_gem_object_types.h  |   3 +- drivers/gpu/drm/i915/gem/i915_gem_shmem.c     |  53 +++-- drivers/gpu/drm/i915/gem/i915_gem_ttm.c       | 186 ++++++++++---
-----

  drivers/gpu/drm/i915/i915_scatterlist.c       |  62 ++++--
  drivers/gpu/drm/i915/i915_scatterlist.h       |  76 ++++++-
  drivers/gpu/drm/i915/intel_region_ttm.c       |  15 +-
  drivers/gpu/drm/i915/intel_region_ttm.h       |   5 +-
  drivers/gpu/drm/i915/selftests/mock_region.c  |  12 +-
  9 files changed, 277 insertions(+), 147 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_object.h +0 -0
index a5479ac7a4ad..ba224598ed69 100644
@@ -620,12 +620,12 @@ int i915_gem_object_wait_migration(struct
 drm_i915_gem_object *obj,

  bool i915_gem_object_placement_possible(struct drm_i915_gem_object *obj,
                                        enum intel_memory_type type);

-struct sg_table *shmem_alloc_st(struct drm_i915_private *i915, -                               size_t size, struct intel_memory_region *mr,
-                               struct address_space *mapping, -                               unsigned int max_segment); -void shmem_free_st(struct sg_table *st, struct address_space *mapping,
-                  bool dirty, bool backup);
+int shmem_sg_alloc_table(struct drm_i915_private *i915, struct sg_table *st,
+                        size_t size, struct intel_memory_region *mr,
+                        struct address_space *mapping, +                        unsigned int max_segment); +void shmem_sg_free_table(struct sg_table *st, struct address_space *mapping,
+                        bool dirty, bool backup);
  void __shmem_writeback(size_t size, struct address_space *mapping);

  #ifdef CONFIG_MMU_NOTIFIER

drivers/gpu/drm/i915/gem/i915_gem_object_types.h +0 -0
index a4b69a43b898..604ed5ad77f5 100644
@@ -544,6 +544,7 @@ struct drm_i915_gem_object {
                  */
                 struct list_head region_link;


+               struct i915_refct_sgt *rsgt;
                struct sg_table *pages;
                void *mapping;

drivers/gpu/drm/i915/gem/i915_gem_object_types.h +0 -0
@@ -597,7 +598,7 @@ struct drm_i915_gem_object {
         } mm;


        struct {
-               struct sg_table *cached_io_st;
+               struct i915_refct_sgt *cached_io_rsgt; struct i915_gem_object_page_iter get_io_page; struct drm_i915_gem_object *backup; bool created:1;

drivers/gpu/drm/i915/gem/i915_gem_shmem.c +0 -0
index 01f332d8dbde..4a88c89b7a14 100644
@@ -25,8 +25,8 @@ static void check_release_pagevec(struct pagevec
 *pvec)
         cond_resched();
   }


-void shmem_free_st(struct sg_table *st, struct address_space *mapping,
-                  bool dirty, bool backup)
+void shmem_sg_free_table(struct sg_table *st, struct address_space *mapping,
+                        bool dirty, bool backup)
  {
        struct sgt_iter sgt_iter;
        struct pagevec pvec;

drivers/gpu/drm/i915/gem/i915_gem_shmem.c +0 -0
@@ -49,17 +49,15 @@ void shmem_free_st(struct sg_table *st, struct
 address_space *mapping,
                 check_release_pagevec(&pvec);


        sg_free_table(st);
-       kfree(st);
  }

-struct sg_table *shmem_alloc_st(struct drm_i915_private *i915, -                               size_t size, struct intel_memory_region *mr,
-                               struct address_space *mapping, -                               unsigned int max_segment) +int shmem_sg_alloc_table(struct drm_i915_private *i915, struct sg_table *st,
+                        size_t size, struct intel_memory_region *mr,
+                        struct address_space *mapping, +                        unsigned int max_segment)
  {
        const unsigned long page_count = size / PAGE_SIZE; unsigned long i;
-       struct sg_table *st;
        struct scatterlist *sg;
        struct page *page;
        unsigned long last_pfn = 0;     /* suppress gcc warning */

drivers/gpu/drm/i915/gem/i915_gem_shmem.c +1 -5
@@ -71,16 +69,10 @@ struct sg_table *shmem_alloc_st(struct
 drm_i915_private *i915,
          * object, bail early.
          */
         if (size > resource_size(&mr->region))
-               return ERR_PTR(-ENOMEM);
-
-       st = kmalloc(sizeof(*st), GFP_KERNEL);
-       if (!st)
-               return ERR_PTR(-ENOMEM);
+               return -ENOMEM;


-       if (sg_alloc_table(st, page_count, GFP_KERNEL)) { -               kfree(st);
-               return ERR_PTR(-ENOMEM);
-       }
+       if (sg_alloc_table(st, page_count, GFP_KERNEL)) +               return -ENOMEM;

        /*
         * Get the list of pages out of our struct file.  They'll be pinned

drivers/gpu/drm/i915/gem/i915_gem_shmem.c +0 -0
@@ -167,15 +159,14 @@ struct sg_table *shmem_alloc_st(struct
 drm_i915_private *i915,
         /* Trim unused sg entries to avoid wasting memory. */
         i915_sg_trim(st);


-       return st;
+       return 0;
  err_sg:
        sg_mark_end(sg);
        if (sg != st->sgl) {
-               shmem_free_st(st, mapping, false, false); +               shmem_sg_free_table(st, mapping, false, false); } else {
                mapping_clear_unevictable(mapping); sg_free_table(st);
-               kfree(st);
        }

        /*

drivers/gpu/drm/i915/gem/i915_gem_shmem.c +0 -0
@@ -190,7 +181,7 @@ struct sg_table *shmem_alloc_st(struct
 drm_i915_private *i915,
         if (ret == -ENOSPC)
                 ret = -ENOMEM;


-       return ERR_PTR(ret);
+       return ret;
  }

  static int shmem_get_pages(struct drm_i915_gem_object *obj)

drivers/gpu/drm/i915/gem/i915_gem_shmem.c +0 -0
@@ -214,11 +205,14 @@ static int shmem_get_pages(struct
 drm_i915_gem_object *obj)
         GEM_BUG_ON(obj->write_domain & I915_GEM_GPU_DOMAINS);


  rebuild_st:
-       st = shmem_alloc_st(i915, obj->base.size, mem, mapping, max_segment);
-       if (IS_ERR(st)) {
-               ret = PTR_ERR(st);
+       st = kmalloc(sizeof(*st), GFP_KERNEL);
+       if (!st)
+               return -ENOMEM;
+
+       ret = shmem_sg_alloc_table(i915, st, obj->base.size, mem, mapping,
+                                  max_segment);
+       if (ret)
                goto err_st;
-       }

        ret = i915_gem_gtt_prepare_pages(obj, st);
        if (ret) {

drivers/gpu/drm/i915/gem/i915_gem_shmem.c +0 -0
@@ -254,7 +248,7 @@ static int shmem_get_pages(struct
 drm_i915_gem_object *obj)
         return 0;


  err_pages:
-       shmem_free_st(st, mapping, false, false);
+       shmem_sg_free_table(st, mapping, false, false); /*
         * shmemfs first checks if there is enough memory to allocate the page
         * and reports ENOSPC should there be insufficient, along with the usual

drivers/gpu/drm/i915/gem/i915_gem_shmem.c +0 -0
@@ -268,6 +262,8 @@ static int shmem_get_pages(struct
 drm_i915_gem_object *obj)
         if (ret == -ENOSPC)
                 ret = -ENOMEM;


+       kfree(st);
+
        return ret;
  }

drivers/gpu/drm/i915/gem/i915_gem_shmem.c +0 -0
@@ -374,8 +370,9 @@ void i915_gem_object_put_pages_shmem(struct

drm_i915_gem_object *obj, struct sg_
        if (i915_gem_object_needs_bit17_swizzle(obj)) i915_gem_object_save_bit_17_swizzle(obj, pages);
-       shmem_free_st(pages, file_inode(obj->base.filp)->i_mapping, -                     obj->mm.dirty, obj->mm.madv == I915_MADV_WILLNEED);
+       shmem_sg_free_table(pages, file_inode(obj->base.filp)-

Quoted 1 line

i_mapping,

+                           obj->mm.dirty, obj->mm.madv == I915_MADV_WILLNEED);
+       kfree(pages);
        obj->mm.dirty = false;
  }

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0 -0
index 4fd2edb20dd9..6a05369e2705 100644
@@ -34,7 +34,7 @@
    * struct i915_ttm_tt - TTM page vector with additional private

information
   * @ttm: The base TTM page vector.
   * @dev: The struct device used for dma mapping and unmapping.
- * @cached_st: The cached scatter-gather table.
+ * @cached_rsgt: The cached scatter-gather table.
   * @is_shmem: Set if using shmem.
   * @filp: The shmem file, if using shmem backend.
   *

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +1 -1
@@ -47,7 +47,7 @@
   struct i915_ttm_tt {
         struct ttm_tt ttm;
         struct device *dev;
-       struct sg_table *cached_st;
+       struct i915_refct_sgt cached_rsgt;


        bool is_shmem;
        struct file *filp;

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0 -0
@@ -217,18 +217,16 @@ static int i915_ttm_tt_shmem_populate(struct
 ttm_device *bdev,
                 i915_tt->filp = filp;
         }


-       st = shmem_alloc_st(i915, size, mr, filp->f_mapping, max_segment);
-       if (IS_ERR(st))
-               return PTR_ERR(st);
+       st = &i915_tt->cached_rsgt.table;
+       err = shmem_sg_alloc_table(i915, st, size, mr, filp-

Quoted 1 line

f_mapping,

+                                  max_segment);
+       if (err)
+               return err;

-       err = dma_map_sg_attrs(i915_tt->dev,
-                              st->sgl, st->nents,
-                              DMA_BIDIRECTIONAL,
-                              DMA_ATTR_SKIP_CPU_SYNC); -       if (err <= 0) {
-               err = -EINVAL;
+       err = dma_map_sgtable(i915_tt->dev, st, DMA_BIDIRECTIONAL, +                             DMA_ATTR_SKIP_CPU_SYNC); +       if (err)
                goto err_free_st;
-       }

        i = 0;
        for_each_sgt_page(page, sgt_iter, st)

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0 -0
@@ -237,11 +235,11 @@ static int i915_ttm_tt_shmem_populate(struct
 ttm_device *bdev,
         if (ttm->page_flags & TTM_TT_FLAG_SWAPPED)
                 ttm->page_flags &= ~TTM_TT_FLAG_SWAPPED;


-       i915_tt->cached_st = st;
        return 0;

  err_free_st:
-       shmem_free_st(st, filp->f_mapping, false, false); +       shmem_sg_free_table(st, filp->f_mapping, false, false); +
        return err;
  }

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +5 -0
@@ -249,16 +247,27 @@ static void
 i915_ttm_tt_shmem_unpopulate(struct ttm_tt *ttm)
   {
         struct i915_ttm_tt *i915_tt = container_of(ttm,
 typeof(*i915_tt), ttm);
         bool backup = ttm->page_flags & TTM_TT_FLAG_SWAPPED;
+       struct sg_table *st = &i915_tt->cached_rsgt.table;
+
+       shmem_sg_free_table(st, file_inode(i915_tt->filp)-
 >i_mapping,
+                           backup, backup);
+}


-       dma_unmap_sg(i915_tt->dev, i915_tt->cached_st->sgl, -                    i915_tt->cached_st->nents,
-                    DMA_BIDIRECTIONAL);

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +4 -0
+static void i915_ttm_tt_release(struct kref *ref)
+{
+       struct i915_ttm_tt *i915_tt =
+               container_of(ref, typeof(*i915_tt),

cached_rsgt.kref);
+       struct sg_table *st = &i915_tt->cached_rsgt.table;
-       shmem_free_st(fetch_and_zero(&i915_tt->cached_st), -                     file_inode(i915_tt->filp)->i_mapping, -                     backup, backup);
+       GEM_WARN_ON(st->sgl);
+
+       kfree(i915_tt);
  }

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +4 -0
+static const struct i915_refct_sgt_ops tt_rsgt_ops = {
+       .release = i915_ttm_tt_release
+};
+

  static struct ttm_tt *i915_ttm_tt_create(struct ttm_buffer_object *bo,
                                         uint32_t page_flags) {

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0 -0
@@ -287,6 +296,9 @@ static struct ttm_tt *i915_ttm_tt_create(struct
 ttm_buffer_object *bo,
         if (ret)
                 goto err_free;


+       __i915_refct_sgt_init(&i915_tt->cached_rsgt, bo->base.size, +                             &tt_rsgt_ops);
+
        i915_tt->dev = obj->base.dev->dev;

        return &i915_tt->ttm;

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +4 -0
@@ -311,17 +323,15 @@ static int i915_ttm_tt_populate(struct
 ttm_device *bdev,
   static void i915_ttm_tt_unpopulate(struct ttm_device *bdev,
 struct ttm_tt *ttm)
   {
         struct i915_ttm_tt *i915_tt = container_of(ttm,
 typeof(*i915_tt), ttm);
+       struct sg_table *st = &i915_tt->cached_rsgt.table;
+
+       if (st->sgl)
+               dma_unmap_sgtable(i915_tt->dev, st,
 DMA_BIDIRECTIONAL, 0);


        if (i915_tt->is_shmem) { i915_ttm_tt_shmem_unpopulate(ttm);
        } else {
-               if (i915_tt->cached_st) {
-                       dma_unmap_sgtable(i915_tt->dev, i915_tt-

Quoted 1 line

cached_st,

-                                         DMA_BIDIRECTIONAL, 0); -                       sg_free_table(i915_tt->cached_st); -                       kfree(i915_tt->cached_st);
-                       i915_tt->cached_st = NULL;
-               }
+               sg_free_table(st); ttm_pool_free(&bdev->pool, ttm);
        }
  }

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0 -0
@@ -334,7 +344,7 @@ static void i915_ttm_tt_destroy(struct
 ttm_device *bdev, struct ttm_tt *ttm)
                 fput(i915_tt->filp);


        ttm_tt_fini(ttm);
-       kfree(i915_tt);
+       i915_refct_sgt_put(&i915_tt->cached_rsgt);
  }

  static bool i915_ttm_eviction_valuable(struct ttm_buffer_object *bo,

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0 -0
@@ -376,12 +386,12 @@ static int i915_ttm_move_notify(struct
 ttm_buffer_object *bo)
         return 0;
   }


-static void i915_ttm_free_cached_io_st(struct drm_i915_gem_object *obj)
+static void i915_ttm_free_cached_io_rsgt(struct drm_i915_gem_object *obj)
  {
        struct radix_tree_iter iter;
        void __rcu **slot;

-       if (!obj->ttm.cached_io_st)
+       if (!obj->ttm.cached_io_rsgt)
                return;

        rcu_read_lock();

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0 -0
@@ -389,9 +399,8 @@ static void i915_ttm_free_cached_io_st(struct
 drm_i915_gem_object *obj)
                 radix_tree_delete(&obj->ttm.get_io_page.radix,
 iter.index);
         rcu_read_unlock();


-       sg_free_table(obj->ttm.cached_io_st); -       kfree(obj->ttm.cached_io_st);
-       obj->ttm.cached_io_st = NULL;
+       i915_refct_sgt_put(obj->ttm.cached_io_rsgt); +       obj->ttm.cached_io_rsgt = NULL;
  }

  static void

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +1 -1
@@ -477,7 +486,7 @@ static int i915_ttm_purge(struct
 drm_i915_gem_object *obj)
         obj->write_domain = 0;
         obj->read_domains = 0;
         i915_ttm_adjust_gem_after_move(obj);
-       i915_ttm_free_cached_io_st(obj);
+       i915_ttm_free_cached_io_rsgt(obj);
         obj->mm.madv = __I915_MADV_PURGED;
         return 0;

  }

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0 -0
@@ -532,7 +541,7 @@ static void i915_ttm_swap_notify(struct
 ttm_buffer_object *bo)
         int ret = i915_ttm_move_notify(bo);


        GEM_WARN_ON(ret);
-       GEM_WARN_ON(obj->ttm.cached_io_st);
+       GEM_WARN_ON(obj->ttm.cached_io_rsgt); if (!ret && obj->mm.madv != I915_MADV_WILLNEED) i915_ttm_purge(obj);
  }

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0 -0
@@ -543,7 +552,7 @@ static void i915_ttm_delete_mem_notify(struct
 ttm_buffer_object *bo)


        if (likely(obj)) { __i915_gem_object_pages_fini(obj); -               i915_ttm_free_cached_io_st(obj); +               i915_ttm_free_cached_io_rsgt(obj); }
  }

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0 -0
@@ -563,40 +572,35 @@ i915_ttm_region(struct ttm_device *bdev, int
 ttm_mem_type)

                                          ttm_mem_type - I915_PL_LMEM0);
  }

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +1 -1
-static struct sg_table *i915_ttm_tt_get_st(struct ttm_tt *ttm)
+static struct i915_refct_sgt *i915_ttm_tt_get_st(struct ttm_tt

*ttm)
  {
        struct i915_ttm_tt *i915_tt = container_of(ttm, typeof(*i915_tt), ttm);
        struct sg_table *st;
        int ret;

-       if (i915_tt->cached_st)
-               return i915_tt->cached_st;
-
-       st = kzalloc(sizeof(*st), GFP_KERNEL);
-       if (!st)
-               return ERR_PTR(-ENOMEM);
+       if (i915_tt->cached_rsgt.table.sgl)
+               return i915_refct_sgt_get(&i915_tt->cached_rsgt);
+       st = &i915_tt->cached_rsgt.table;
        ret = sg_alloc_table_from_pages_segment(st, ttm->pages, ttm->num_pages,
                        0, (unsigned long)ttm->num_pages << PAGE_SHIFT,
                        i915_sg_segment_size(), GFP_KERNEL); if (ret) {
-               kfree(st);
+               st->sgl = NULL;
                return ERR_PTR(ret);
        }

        ret = dma_map_sgtable(i915_tt->dev, st, DMA_BIDIRECTIONAL, 0);
        if (ret) {
                sg_free_table(st);
-               kfree(st);
                return ERR_PTR(ret);
        }

-       i915_tt->cached_st = st;
-       return st;
+       return i915_refct_sgt_get(&i915_tt->cached_rsgt); }

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +1 -1
-static struct sg_table *
+static struct i915_refct_sgt *

  i915_ttm_resource_get_st(struct drm_i915_gem_object *obj, struct ttm_resource *res) {

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +6 -1
@@ -610,7 +614,21 @@ i915_ttm_resource_get_st(struct
 drm_i915_gem_object *obj,
          * the resulting st. Might make sense for GGTT.
          */
         GEM_WARN_ON(!cpu_maps_iomem(res));
-       return intel_region_ttm_resource_to_st(obj->mm.region,
 res);
+       if (bo->resource == res) {
+               if (!obj->ttm.cached_io_rsgt) {
+                       struct i915_refct_sgt *rsgt;
+
+                       rsgt =
 intel_region_ttm_resource_to_rsgt(obj->mm.region,
+                                                               

res);
+                       if (IS_ERR(rsgt))
+                               return rsgt;

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +7 -0
+
+                       obj->ttm.cached_io_rsgt = rsgt;
+               }
+               return i915_refct_sgt_get(obj->ttm.cached_io_rsgt);
+       }
+
+       return intel_region_ttm_resource_to_rsgt(obj->mm.region,

res);
  }

  static int i915_ttm_accel_move(struct ttm_buffer_object *bo,

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0 -3
@@ -621,10 +639,7 @@ static int i915_ttm_accel_move(struct
 ttm_buffer_object *bo,
   {
         struct drm_i915_private *i915 = container_of(bo->bdev,
 typeof(*i915),
                                                      bdev);
-       struct ttm_resource_manager *src_man =
-               ttm_manager_type(bo->bdev, bo->resource->mem_type);
         struct drm_i915_gem_object *obj = i915_ttm_to_gem(bo);
-       struct sg_table *src_st;
         struct i915_request *rq;

        struct ttm_tt *src_ttm = bo->ttm; enum i915_cache_level src_level, dst_level;

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0 -0
@@ -650,17 +665,22 @@ static int i915_ttm_accel_move(struct
 ttm_buffer_object *bo,
                 }

                intel_engine_pm_put(i915->gt.migrate.context-

Quoted 1 line

engine);

        } else {
-               src_st = src_man->use_tt ? i915_ttm_tt_get_st(src_ttm) :
-                       obj->ttm.cached_io_st;
+               struct i915_refct_sgt *src_rsgt = +                       i915_ttm_resource_get_st(obj, bo-

Quoted 1 line

resource);

+
+               if (IS_ERR(src_rsgt))
+                       return PTR_ERR(src_rsgt);
                src_level = i915_ttm_cache_level(i915, bo-

Quoted 1 line

resource, src_ttm);

                intel_engine_pm_get(i915->gt.migrate.context-

Quoted 1 line

engine);

                ret = intel_context_migrate_copy(i915-

Quoted 1 line

gt.migrate.context,

-                                                NULL, src_st->sgl, src_level,
+                                                NULL, src_rsgt-

Quoted 1 line

table.sgl,

+                                                src_level,
gpu_binds_iomem(bo->resource),
                                                 dst_st->sgl, dst_level,

gpu_binds_iomem(dst_mem),
                                                 &rq); +               i915_refct_sgt_put(src_rsgt);
                if (!ret && rq) { i915_request_wait(rq, 0, MAX_SCHEDULE_TIMEOUT);
                        i915_request_put(rq);

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0 -0
@@ -674,13 +694,14 @@ static int i915_ttm_accel_move(struct
 ttm_buffer_object *bo,

  static void __i915_ttm_move(struct ttm_buffer_object *bo, bool clear,
                            struct ttm_resource *dst_mem, struct ttm_tt *dst_ttm,
-                           struct sg_table *dst_st,
+                           struct i915_refct_sgt *dst_rsgt, bool allow_accel)
  {
        int ret = -EINVAL;

        if (allow_accel)
-               ret = i915_ttm_accel_move(bo, clear, dst_mem, dst_ttm, dst_st);
+               ret = i915_ttm_accel_move(bo, clear, dst_mem, dst_ttm,
+                                         &dst_rsgt->table); if (ret) {
                struct drm_i915_gem_object *obj = i915_ttm_to_gem(bo);
                struct intel_memory_region *dst_reg, *src_reg;

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0 -0
@@ -697,12 +718,13 @@ static void __i915_ttm_move(struct
 ttm_buffer_object *bo, bool clear,

                dst_iter = !cpu_maps_iomem(dst_mem) ? ttm_kmap_iter_tt_init(&_dst_iter.tt, dst_ttm) :
                        ttm_kmap_iter_iomap_init(&_dst_iter.io, &dst_reg->iomap,
-                                                dst_st, dst_reg-

Quoted 1 line

region.start);

+                                                &dst_rsgt->table, +                                                dst_reg-

Quoted 1 line

region.start);


                src_iter = !cpu_maps_iomem(bo->resource) ? ttm_kmap_iter_tt_init(&_src_iter.tt, bo-

Quoted 1 line

ttm) :

                        ttm_kmap_iter_iomap_init(&_src_iter.io, &src_reg->iomap,
-                                                obj-

Quoted 1 line

ttm.cached_io_st,

+                                                &obj-

Quoted 1 line

ttm.cached_io_rsgt->table,

                                                 src_reg-

Quoted 1 line

region.start);


                ttm_move_memcpy(clear, dst_mem->num_pages, dst_iter, src_iter);

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0 -0
@@ -718,7 +740,7 @@ static int i915_ttm_move(struct
 ttm_buffer_object *bo, bool evict,

        struct ttm_resource_manager *dst_man = ttm_manager_type(bo->bdev, dst_mem->mem_type); struct ttm_tt *ttm = bo->ttm;
-       struct sg_table *dst_st;
+       struct i915_refct_sgt *dst_rsgt;
        bool clear;
        int ret;

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0 -0
@@ -744,22 +766,24 @@ static int i915_ttm_move(struct
 ttm_buffer_object *bo, bool evict,
                         return ret;
         }


-       dst_st = i915_ttm_resource_get_st(obj, dst_mem); -       if (IS_ERR(dst_st))
-               return PTR_ERR(dst_st);
+       dst_rsgt = i915_ttm_resource_get_st(obj, dst_mem); +       if (IS_ERR(dst_rsgt))
+               return PTR_ERR(dst_rsgt);

        clear = !cpu_maps_iomem(bo->resource) && (!ttm || !ttm_tt_is_populated(ttm));
        if (!(clear && ttm && !(ttm->page_flags & TTM_TT_FLAG_ZERO_ALLOC)))
-               __i915_ttm_move(bo, clear, dst_mem, bo->ttm, dst_st, true);
+               __i915_ttm_move(bo, clear, dst_mem, bo->ttm, dst_rsgt, true);

        ttm_bo_move_sync_cleanup(bo, dst_mem); i915_ttm_adjust_domains_after_move(obj);
-       i915_ttm_free_cached_io_st(obj);
+       i915_ttm_free_cached_io_rsgt(obj);

        if (gpu_binds_iomem(dst_mem) || cpu_maps_iomem(dst_mem)) { -               obj->ttm.cached_io_st = dst_st;
-               obj->ttm.get_io_page.sg_pos = dst_st->sgl; +               obj->ttm.cached_io_rsgt = dst_rsgt;
+               obj->ttm.get_io_page.sg_pos = dst_rsgt->table.sgl; obj->ttm.get_io_page.sg_idx = 0;
+       } else {
+               i915_refct_sgt_put(dst_rsgt);
        }

        i915_ttm_adjust_lru(obj);

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0 -1
@@ -825,7 +849,6 @@ static int __i915_ttm_get_pages(struct
 drm_i915_gem_object *obj,
                 .interruptible = true,
                 .no_wait_gpu = false,
         };
-       struct sg_table *st;
         int real_num_busy;
         int ret;

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0 -0
@@ -862,12 +885,16 @@ static int __i915_ttm_get_pages(struct
 drm_i915_gem_object *obj,
         }


        if (!i915_gem_object_has_pages(obj)) {
-               /* Object either has a page vector or is an iomem object */
-               st = bo->ttm ? i915_ttm_tt_get_st(bo->ttm) : obj-

Quoted 1 line

ttm.cached_io_st;

-               if (IS_ERR(st))
-                       return PTR_ERR(st);
+               struct i915_refct_sgt *rsgt =
+                       i915_ttm_resource_get_st(obj, bo-

Quoted 1 line

resource);

+
+               if (IS_ERR(rsgt))
+                       return PTR_ERR(rsgt);

-               __i915_gem_object_set_pages(obj, st, i915_sg_dma_sizes(st->sgl));
+               GEM_BUG_ON(obj->mm.rsgt);
+               obj->mm.rsgt = rsgt;
+               __i915_gem_object_set_pages(obj, &rsgt->table, +                                           i915_sg_dma_sizes(rsgt-

Quoted 1 line

table.sgl));

        }

        i915_ttm_adjust_lru(obj);

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0 -0
@@ -941,6 +968,9 @@ static void i915_ttm_put_pages(struct
 drm_i915_gem_object *obj,
          * If the object is not destroyed next, The TTM eviction

logic
         * and shrinkers will move it out if needed.
         */
+
+       if (obj->mm.rsgt)
+               i915_refct_sgt_put(fetch_and_zero(&obj->mm.rsgt)); }

  static void i915_ttm_adjust_lru(struct drm_i915_gem_object *obj)

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +1 -1
@@ -1278,7 +1308,7 @@ int i915_gem_obj_copy_ttm(struct
 drm_i915_gem_object *dst,
         struct ttm_operation_ctx ctx = {
                 .interruptible = intr,
         };
-       struct sg_table *dst_st;
+       struct i915_refct_sgt *dst_rsgt;
         int ret;


        assert_object_held(dst);

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0 -0
@@ -1293,11 +1323,11 @@ int i915_gem_obj_copy_ttm(struct
 drm_i915_gem_object *dst,
         if (ret)
                 return ret;


-       dst_st = gpu_binds_iomem(dst_bo->resource) ?
-               dst->ttm.cached_io_st : i915_ttm_tt_get_st(dst_bo-

Quoted 1 line

ttm);

-
+       dst_rsgt = i915_ttm_resource_get_st(dst, dst_bo->resource); __i915_ttm_move(src_bo, false, dst_bo->resource, dst_bo-

Quoted 1 line

ttm,

-                       dst_st, allow_accel);
+                       dst_rsgt, allow_accel);
+
+       i915_refct_sgt_put(dst_rsgt);

        return 0;
  }

drivers/gpu/drm/i915/i915_scatterlist.c +0 -0
index 4a6712dca838..41f2adb6a583 100644
@@ -41,8 +41,32 @@ bool i915_sg_trim(struct sg_table *orig_st)
         return true;
   }

drivers/gpu/drm/i915/i915_scatterlist.c +15 -0
+static void i915_refct_sgt_release(struct kref *ref)
+{
+       struct i915_refct_sgt *rsgt =
+               container_of(ref, typeof(*rsgt), kref);
+
+       sg_free_table(&rsgt->table);
+       kfree(rsgt);
+}
+
+static const struct i915_refct_sgt_ops rsgt_ops = {
+       .release = i915_refct_sgt_release
+};
+
+/**
+ * i915_refct_sgt_init - Initialize a struct i915_refct_sgt with

default ops
+ * @rsgt: The struct i915_refct_sgt to initialize.
+ * size: The size of the underlying memory buffer.
+ */

drivers/gpu/drm/i915/i915_scatterlist.c +5 -0
+void i915_refct_sgt_init(struct i915_refct_sgt *rsgt, size_t size)
+{
+       __i915_refct_sgt_init(rsgt, size, &rsgt_ops);
+}
+

  /**
- * i915_sg_from_mm_node - Create an sg_table from a struct drm_mm_node
+ * i915_rsgt_from_mm_node - Create a refcounted sg_table from a struct
+ * drm_mm_node
   * @node: The drm_mm_node.
   * @region_start: An offset to add to the dma addresses of the sg list.
   *

drivers/gpu/drm/i915/i915_scatterlist.c +0 -0
@@ -50,25 +74,28 @@ bool i915_sg_trim(struct sg_table *orig_st)
    * taking a maximum segment length into account, splitting into

segments
   * if necessary.
   *
- * Return: A pointer to a kmalloced struct sg_table on success, negative
+ * Return: A pointer to a kmalloced struct i915_refct_sgt on success, negative
   * error code cast to an error pointer on failure. */
-struct sg_table *i915_sg_from_mm_node(const struct drm_mm_node *node,
-                                     u64 region_start) +struct i915_refct_sgt *i915_rsgt_from_mm_node(const struct drm_mm_node *node,
+                                             u64 region_start) {
        const u64 max_segment = SZ_1G; /* Do we have a limit on this? */
        u64 segment_pages = max_segment >> PAGE_SHIFT; u64 block_size, offset, prev_end;
+       struct i915_refct_sgt *rsgt;
        struct sg_table *st;
        struct scatterlist *sg;

-       st = kmalloc(sizeof(*st), GFP_KERNEL);
-       if (!st)
+       rsgt = kmalloc(sizeof(*rsgt), GFP_KERNEL);
+       if (!rsgt)
                return ERR_PTR(-ENOMEM);

+       i915_refct_sgt_init(rsgt, node->size << PAGE_SHIFT); +       st = &rsgt->table;
        if (sg_alloc_table(st, DIV_ROUND_UP(node->size, segment_pages),
                           GFP_KERNEL)) {
-               kfree(st);
+               i915_refct_sgt_put(rsgt);
                return ERR_PTR(-ENOMEM);
        }

drivers/gpu/drm/i915/i915_scatterlist.c +0 -0
@@ -104,11 +131,11 @@ struct sg_table *i915_sg_from_mm_node(const
 struct drm_mm_node *node,
         sg_mark_end(sg);
         i915_sg_trim(st);


-       return st;
+       return rsgt;
  }

  /**
- * i915_sg_from_buddy_resource - Create an sg_table from a struct
+ * i915_rsgt_from_buddy_resource - Create a refcounted sg_table from a struct
   * i915_buddy_block list
   * @res: The struct i915_ttm_buddy_resource.
   * @region_start: An offset to add to the dma addresses of the sg list.

drivers/gpu/drm/i915/i915_scatterlist.c +0 -0
@@ -117,11 +144,11 @@ struct sg_table *i915_sg_from_mm_node(const
 struct drm_mm_node *node,
    * taking a maximum segment length into account, splitting into

segments
   * if necessary.
   *
- * Return: A pointer to a kmalloced struct sg_table on success, negative
+ * Return: A pointer to a kmalloced struct i915_refct_sgts on success, negative
   * error code cast to an error pointer on failure.
   */
-struct sg_table *i915_sg_from_buddy_resource(struct ttm_resource *res,
-                                            u64 region_start) +struct i915_refct_sgt *i915_rsgt_from_buddy_resource(struct ttm_resource *res,
+                                                    u64 region_start)
  {
        struct i915_ttm_buddy_resource *bman_res = to_ttm_buddy_resource(res);
        const u64 size = res->num_pages << PAGE_SHIFT;

drivers/gpu/drm/i915/i915_scatterlist.c +1 -0
@@ -129,18 +156,21 @@ struct sg_table
 *i915_sg_from_buddy_resource(struct ttm_resource *res,
         struct i915_buddy_mm *mm = bman_res->mm;
         struct list_head *blocks = &bman_res->blocks;
         struct i915_buddy_block *block;
+       struct i915_refct_sgt *rsgt;
         struct scatterlist *sg;
         struct sg_table *st;
         resource_size_t prev_end;


        GEM_BUG_ON(list_empty(blocks));

-       st = kmalloc(sizeof(*st), GFP_KERNEL);
-       if (!st)
+       rsgt = kmalloc(sizeof(*rsgt), GFP_KERNEL); +       if (!rsgt)
                return ERR_PTR(-ENOMEM);

+       i915_refct_sgt_init(rsgt, size);
+       st = &rsgt->table;
        if (sg_alloc_table(st, res->num_pages, GFP_KERNEL)) { -               kfree(st);
+               i915_refct_sgt_put(rsgt);
                return ERR_PTR(-ENOMEM);
        }

drivers/gpu/drm/i915/i915_scatterlist.c +0 -0
@@ -181,7 +211,7 @@ struct sg_table
 *i915_sg_from_buddy_resource(struct ttm_resource *res,
         sg_mark_end(sg);
         i915_sg_trim(st);


-       return st;
+       return rsgt;
  }

  #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)

drivers/gpu/drm/i915/i915_scatterlist.h +0 -0
index b8bd5925b03f..12c6a1684081 100644
@@ -144,10 +144,78 @@ static inline unsigned int
 i915_sg_segment_size(void)


  bool i915_sg_trim(struct sg_table *orig_st);

-struct sg_table *i915_sg_from_mm_node(const struct drm_mm_node *node,
-                                     u64 region_start); +/**
+ * struct i915_refct_sgt_ops - Operations structure for struct i915_refct_sgt
+ */
+struct i915_refct_sgt_ops {
+       /**
+        * release() - Free the memory of the struct i915_refct_sgt +        * @ref: struct kref that is embedded in the struct i915_refct_sgt
+        */
+       void (*release)(struct kref *ref);

drivers/gpu/drm/i915/i915_scatterlist.h +6 -0
+};
+
+/**
+ * struct i915_refct_sgt - A refcounted scatter-gather table
+ * @kref: struct kref for refcounting
+ * @table: struct sg_table holding the scatter-gather table

itself. Note that
+ * @table->sgl = NULL can be used to determine whether a scatter- gather table
+ * is present or not.
+ * @size: The size in bytes of the underlying memory buffer
+ * @ops: The operations structure.
+ */

drivers/gpu/drm/i915/i915_scatterlist.h +30 -0
+struct i915_refct_sgt {
+       struct kref kref;
+       struct sg_table table;
+       size_t size;
+       const struct i915_refct_sgt_ops *ops;
+};
+
+/**
+ * i915_refct_sgt_put - Put a refcounted sg-table
+ * @rsgt the struct i915_refct_sgt to put.
+ */
+static inline void i915_refct_sgt_put(struct i915_refct_sgt *rsgt)
+{
+       if (rsgt)
+               kref_put(&rsgt->kref, rsgt->ops->release);
+}
+
+/**
+ * i915_refct_sgt_get - Get a refcounted sg-table
+ * @rsgt the struct i915_refct_sgt to get.
+ */
+static inline struct i915_refct_sgt *
+i915_refct_sgt_get(struct i915_refct_sgt *rsgt)
+{
+       kref_get(&rsgt->kref);
+       return rsgt;
+}
+
+/**
+ * __i915_refct_sgt_init - Initialize a refcounted sg-list with a

custom
+ * operations structure
+ * @rsgt The struct i915_refct_sgt to initialize.
+ * @size: Size in bytes of the underlying memory buffer.
+ * @ops: A customized operations structure in case the refcounted sg-list
+ * is embedded into another structure.
+ */
+static inline void __i915_refct_sgt_init(struct i915_refct_sgt *rsgt,
+                                        size_t size,
+                                        const struct i915_refct_sgt_ops *ops)

drivers/gpu/drm/i915/i915_scatterlist.h +8 -0
+{
+       kref_init(&rsgt->kref);
+       rsgt->table.sgl = NULL;
+       rsgt->size = size;
+       rsgt->ops = ops;
+}
+
+void i915_refct_sgt_init(struct i915_refct_sgt *rsgt, size_t

size);

drivers/gpu/drm/i915/i915_scatterlist.h +2 -0
+
+struct i915_refct_sgt *i915_rsgt_from_mm_node(const struct

drm_mm_node *node,
+                                             u64 region_start);
-struct sg_table *i915_sg_from_buddy_resource(struct ttm_resource *res,
-                                            u64 region_start); +struct i915_refct_sgt *i915_rsgt_from_buddy_resource(struct ttm_resource *res,
+                                                    u64 region_start);

  #endif

drivers/gpu/drm/i915/intel_region_ttm.c +0 -0
index 98c7339bf8ba..2e901a27e259 100644
@@ -115,8 +115,8 @@ void intel_region_ttm_fini(struct
 intel_memory_region *mem)
   }


  /**
- * intel_region_ttm_resource_to_st - Convert an opaque TTM resource manager resource
- * to an sg_table.
+ * intel_region_ttm_resource_to_rsgt -
+ * Convert an opaque TTM resource manager resource to a refcounted sg_table.
   * @mem: The memory region.
   * @res: The resource manager resource obtained from the TTM resource manager.
   *

drivers/gpu/drm/i915/intel_region_ttm.c +0 -0
@@ -126,17 +126,18 @@ void intel_region_ttm_fini(struct
 intel_memory_region *mem)
    *
    * Return: A malloced sg_table on success, an error pointer on

failure.
   */
-struct sg_table *intel_region_ttm_resource_to_st(struct intel_memory_region *mem,
-                                                struct ttm_resource *res)

drivers/gpu/drm/i915/intel_region_ttm.c +3 -0
+struct i915_refct_sgt *
+intel_region_ttm_resource_to_rsgt(struct intel_memory_region *mem,
+                                 struct ttm_resource *res)

  {
        if (mem->is_range_manager) {
                struct ttm_range_mgr_node *range_node = to_ttm_range_mgr_node(res);
-               return i915_sg_from_mm_node(&range_node-

Quoted 1 line

mm_nodes[0],

-                                           mem->region.start); +               return i915_rsgt_from_mm_node(&range_node-

Quoted 1 line

mm_nodes[0],

+                                             mem->region.start); } else {
-               return i915_sg_from_buddy_resource(res, mem-

Quoted 1 line

region.start);

+               return i915_rsgt_from_buddy_resource(res, mem-

Quoted 1 line

region.start);

        }
  }

drivers/gpu/drm/i915/intel_region_ttm.h +0 -0
index 6f44075920f2..7bbe2b46b504 100644
@@ -22,8 +22,9 @@ int intel_region_ttm_init(struct
 intel_memory_region *mem);


  void intel_region_ttm_fini(struct intel_memory_region *mem);
-struct sg_table *intel_region_ttm_resource_to_st(struct intel_memory_region *mem,
-                                                struct ttm_resource *res);

drivers/gpu/drm/i915/intel_region_ttm.h +3 -0
+struct i915_refct_sgt *
+intel_region_ttm_resource_to_rsgt(struct intel_memory_region *mem,
+                                 struct ttm_resource *res);


  void intel_region_ttm_resource_free(struct intel_memory_region *mem,
                                    struct ttm_resource *res);

drivers/gpu/drm/i915/selftests/mock_region.c +0 -0
index 75793008c4ef..7ec5037eaa58 100644
@@ -15,9 +15,9 @@

  static void mock_region_put_pages(struct drm_i915_gem_object *obj,
                                  struct sg_table *pages) {
+       i915_refct_sgt_put(obj->mm.rsgt);
+       obj->mm.rsgt = NULL; intel_region_ttm_resource_free(obj->mm.region, obj-

Quoted 1 line

mm.res);

-       sg_free_table(pages);
-       kfree(pages);
  }

  static int mock_region_get_pages(struct drm_i915_gem_object *obj)

drivers/gpu/drm/i915/selftests/mock_region.c +0 -0
@@ -36,12 +36,14 @@ static int mock_region_get_pages(struct
 drm_i915_gem_object *obj)
         if (IS_ERR(obj->mm.res))
                 return PTR_ERR(obj->mm.res);


-       pages = intel_region_ttm_resource_to_st(obj->mm.region, obj->mm.res);
-       if (IS_ERR(pages)) {
-               err = PTR_ERR(pages);
+       obj->mm.rsgt = intel_region_ttm_resource_to_rsgt(obj-

Quoted 1 line

mm.region,

+                                                        obj-

Quoted 1 line

mm.res);

+       if (IS_ERR(obj->mm.rsgt)) {
+               err = PTR_ERR(obj->mm.rsgt);
                goto err_free_resource;
        }

+       pages = &obj->mm.rsgt->table;
        __i915_gem_object_set_pages(obj, pages,
i915_sg_dma_sizes(pages->sgl));

        return 0;

#5 lore raw

[Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915: Introduce refcounted sg-tables

In reply to Thomas Hellström
== Series Details ==

== Series Details ==

Series: drm/i915: Introduce refcounted sg-tables
URL : https://patchwork.freedesktop.org/series/96459/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_10822 -> Patchwork_21495
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/index.html

Participating hosts (39 -> 37)
------------------------------

Additional (3): fi-tgl-1115g4 fi-icl-u2 fi-bdw-5557u
Missing (5): bat-dg1-6 fi-hsw-4200u fi-bsw-cyan bat-adlp-4 fi-ctg-p8600

Known issues
------------

Here are the changes found in Patchwork_21495 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@amdgpu/amd_basic@query-info:
- fi-tgl-1115g4: NOTRUN -> [SKIP][1] ([fdo#109315])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/fi-tgl-1115g4/igt@amdgpu/[email protected]

* igt@amdgpu/amd_cs_nop@fork-gfx0:
- fi-icl-u2: NOTRUN -> [SKIP][2] ([fdo#109315]) +17 similar issues
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/fi-icl-u2/igt@amdgpu/[email protected]

* igt@amdgpu/amd_cs_nop@nop-gfx0:
- fi-tgl-1115g4: NOTRUN -> [SKIP][3] ([fdo#109315] / [i915#2575]) +16 similar issues
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/fi-tgl-1115g4/igt@amdgpu/[email protected]

* igt@gem_exec_suspend@basic-s3:
- fi-tgl-1115g4: NOTRUN -> [FAIL][4] ([i915#1888])
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/fi-tgl-1115g4/igt@[email protected]

* igt@gem_huc_copy@huc-copy:
- fi-tgl-1115g4: NOTRUN -> [SKIP][5] ([i915#2190])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/fi-tgl-1115g4/igt@[email protected]
- fi-icl-u2: NOTRUN -> [SKIP][6] ([i915#2190])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/fi-icl-u2/igt@[email protected]

* igt@i915_pm_backlight@basic-brightness:
- fi-tgl-1115g4: NOTRUN -> [SKIP][7] ([i915#1155])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/fi-tgl-1115g4/igt@[email protected]

* igt@kms_chamelium@common-hpd-after-suspend:
- fi-tgl-1115g4: NOTRUN -> [SKIP][8] ([fdo#111827]) +8 similar issues
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/fi-tgl-1115g4/igt@[email protected]

* igt@kms_chamelium@hdmi-hpd-fast:
- fi-icl-u2: NOTRUN -> [SKIP][9] ([fdo#111827]) +8 similar issues
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/fi-icl-u2/igt@[email protected]

* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-atomic:
- fi-tgl-1115g4: NOTRUN -> [SKIP][10] ([i915#4103]) +1 similar issue
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/fi-tgl-1115g4/igt@[email protected]

* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy:
- fi-icl-u2: NOTRUN -> [SKIP][11] ([fdo#109278]) +2 similar issues
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/fi-icl-u2/igt@[email protected]

* igt@kms_force_connector_basic@force-load-detect:
- fi-tgl-1115g4: NOTRUN -> [SKIP][12] ([fdo#109285])
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/fi-tgl-1115g4/igt@[email protected]
- fi-icl-u2: NOTRUN -> [SKIP][13] ([fdo#109285])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/fi-icl-u2/igt@[email protected]

* igt@kms_psr@primary_mmap_gtt:
- fi-tgl-1115g4: NOTRUN -> [SKIP][14] ([i915#1072]) +3 similar issues
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/fi-tgl-1115g4/igt@kms_psr@primary_mmap_gtt.html

* igt@prime_vgem@basic-userptr:
- fi-icl-u2: NOTRUN -> [SKIP][15] ([i915#3301])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/fi-icl-u2/igt@[email protected]
- fi-tgl-1115g4: NOTRUN -> [SKIP][16] ([i915#3301])
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/fi-tgl-1115g4/igt@[email protected]

* igt@runner@aborted:
- fi-bdw-5557u: NOTRUN -> [FAIL][17] ([i915#1602] / [i915#2426] / [i915#4312])
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/fi-bdw-5557u/igt@[email protected]

#### Possible fixes ####

* igt@kms_frontbuffer_tracking@basic:
- fi-cml-u2: [DMESG-WARN][18] ([i915#4269]) -> [PASS][19]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/fi-cml-u2/igt@[email protected]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/fi-cml-u2/igt@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[fdo#109315]: https://bugs.freedesktop.org/show_bug.cgi?id=109315
[fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
[i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
[i915#1155]: https://gitlab.freedesktop.org/drm/intel/issues/1155
[i915#1602]: https://gitlab.freedesktop.org/drm/intel/issues/1602
[i915#1888]: https://gitlab.freedesktop.org/drm/intel/issues/1888
[i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
[i915#2426]: https://gitlab.freedesktop.org/drm/intel/issues/2426
[i915#2575]: https://gitlab.freedesktop.org/drm/intel/issues/2575
[i915#3301]: https://gitlab.freedesktop.org/drm/intel/issues/3301
[i915#3303]: https://gitlab.freedesktop.org/drm/intel/issues/3303
[i915#4103]: https://gitlab.freedesktop.org/drm/intel/issues/4103
[i915#4269]: https://gitlab.freedesktop.org/drm/intel/issues/4269
[i915#4312]: https://gitlab.freedesktop.org/drm/intel/issues/4312

Build changes
-------------

* Linux: CI_DRM_10822 -> Patchwork_21495

CI-20190529: 20190529
CI_DRM_10822: f30396864663555f800dd6cb7e390272b8d605a4 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_6264: 3458490c14afe3cb8aa873fa9e520e1c815ea068 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_21495: a7b080f3353a43acf0fe0412cd0e63229e19cb29 @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

a7b080f3353a drm/i915: Introduce refcounted sg-tables

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/index.html

#3 lore raw
In reply to Thomas Hellström
Quoted 20 lines · Thomas Hellström

Hi, Tvrtko

Quoted 17 lines · Tvrtko Ursulin
Quoted 9 lines · Thomas Hellström

As we start to introduce asynchronous failsafe object migration, where we update the object state and then submit asynchronous commands we need to record what memory resources are actually used by various part of the command stream. Initially for three purposes:

1) Error capture.
2) Asynchronous migration error recovery.
3) Asynchronous vma bind.

FWIW something like this may be interesting to me as well, although I haven't looked much into details yet, for the purpose of allowing delayed "put pages" via decoupling from the GEM bo.
Two questions after glancing over:

Quoted 8 lines
Quoted 5 lines

1)
I do wonder if abstracting "sgt" away from the name would make sense? Like perhaps obj->mm.pages being the location of the new abstraction so
naming it along the lines of i915_obj_pages or something.

Well it's not yet clear how this will end up. Really this should develop into something along the lines of "struct i915_async_obj", on

Whole gigantic object struct will be needed for async free or for something more than that?

Quoted 3 lines

which the sg-list is a member only. Depending on how this turns out and if it remains an sg-list I think your suggestion makes sense, but is it something we can postpone for now?

...

Quoted 9 lines
Quoted 5 lines

2)
And how come obj->mm.pages remains? Does it go away later in follow up work?

For the non-ttm backends, it's not yet implemented, so once they are either moved to TTM or updated, we can completely replace obj-

Quoted 1 line

mm.pages.

... sure, it's your project. I assume there is some time pressure then. I was just asking since it looked a bit outside of the usual patterns on a glance.

Oh one more question, how will it work for objects which migrate between system and local memory? Depending on current placement either obj->mm.pages or obj->mm.rsgt will be valid?

Regards,

Tvrtko

#4 lore raw

Hi,

Quoted 28 lines · Tvrtko Ursulin
Quoted 26 lines · Thomas Hellström

Hi, Tvrtko

Quoted 22 lines · Tvrtko Ursulin
Quoted 9 lines · Thomas Hellström

As we start to introduce asynchronous failsafe object migration, where we update the object state and then submit asynchronous commands we need to record what memory resources are actually used by various part of the command stream. Initially for three purposes:

1) Error capture.
2) Asynchronous migration error recovery.
3) Asynchronous vma bind.

FWIW something like this may be interesting to me as well, although I haven't looked much into details yet, for the purpose of allowing delayed "put pages" via decoupling from the GEM bo.
Two questions after glancing over:

1)
I do wonder if abstracting "sgt" away from the name would make sense? Like perhaps obj->mm.pages being the location of the new abstraction so
naming it along the lines of i915_obj_pages or something.

Quoted 4 lines
Quoted 2 lines

Well it's not yet clear how this will end up. Really this should develop into something along the lines of "struct i915_async_obj", on

Whole gigantic object struct will be needed for async free or for something more than that?

I guess it depends on how an async free is supposed to work. For the async migration, the plan is that when you migrate, for example between LMEM and sys, we first unbind async and get a fence that signals when unbinding is complete.  The pages sg list will then be updated immediately to point to sys, then the old memory in the form of a struct ttm_resource will be freed when fences expire. It's on that ttm resource we ideally would want the sg-table to sit, but we avoid that ATM due to the awkward way those ttm resources were designed. But it's not a super-huge object.

Quoted 13 lines
Quoted 4 lines

which the sg-list is a member only. Depending on how this turns out and if it remains an sg-list I think your suggestion makes sense, but is it something we can postpone for now?

...

Quoted 6 lines
Quoted 5 lines

2)
And how come obj->mm.pages remains? Does it go away later in follow up work?

Quoted 5 lines
Quoted 3 lines

For the non-ttm backends, it's not yet implemented, so once they are either moved to TTM or updated, we can completely replace obj-

Quoted 1 line

mm.pages.

... sure, it's your project. I assume there is some time pressure then.

Yes, initially.

Quoted 3 lines

I was just asking since it looked a bit outside of the usual patterns on a glance.

Oh one more question, how will it work for objects which migrate between system and local memory? Depending on current placement either obj->mm.pages or obj->mm.rsgt will be valid?

The contract currently is that obj->mm.pages is *always* valid. Sometimes it points to the sg_table embedded in obj->mm.rsgt.

For anything that requires awareness of async migration, like upcoming vma resources and error capture, they also need to be aware of obj->mm.rsgt and handle refcounting accordingly. If it's NULL they can safely assume async migration is not happening.

/Thomas

Quoted 4 lines

Regards,

Tvrtko

#6 lore raw

[Intel-gfx] ✓ Fi.CI.IGT: success for drm/i915: Introduce refcounted sg-tables

In reply to Thomas Hellström
== Series Details ==

== Series Details ==

Series: drm/i915: Introduce refcounted sg-tables
URL : https://patchwork.freedesktop.org/series/96459/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_10822_full -> Patchwork_21495_full
====================================================

Summary
-------

**SUCCESS**

No regressions found.

Participating hosts (10 -> 10)
------------------------------

No changes in participating hosts

Known issues
------------

Here are the changes found in Patchwork_21495_full that come from known issues:

### CI changes ###

#### Possible fixes ####

* boot:
- shard-glk: ([PASS][1], [PASS][2], [PASS][3], [PASS][4], [PASS][5], [PASS][6], [PASS][7], [PASS][8], [FAIL][9], [PASS][10], [PASS][11], [PASS][12], [PASS][13], [PASS][14], [PASS][15], [PASS][16], [PASS][17], [PASS][18], [PASS][19], [PASS][20], [PASS][21], [PASS][22], [PASS][23], [PASS][24], [PASS][25]) ([i915#4392]) -> ([PASS][26], [PASS][27], [PASS][28], [PASS][29], [PASS][30], [PASS][31], [PASS][32], [PASS][33], [PASS][34], [PASS][35], [PASS][36], [PASS][37], [PASS][38], [PASS][39], [PASS][40], [PASS][41], [PASS][42], [PASS][43], [PASS][44], [PASS][45], [PASS][46], [PASS][47], [PASS][48], [PASS][49], [PASS][50])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-glk9/boot.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-glk9/boot.html
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-glk9/boot.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-glk9/boot.html
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-glk1/boot.html
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-glk1/boot.html
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-glk1/boot.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-glk2/boot.html
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-glk2/boot.html
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-glk2/boot.html
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-glk3/boot.html
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-glk3/boot.html
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-glk4/boot.html
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-glk4/boot.html
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-glk5/boot.html
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-glk5/boot.html
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-glk6/boot.html
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-glk6/boot.html
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-glk6/boot.html
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-glk7/boot.html
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-glk7/boot.html
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-glk7/boot.html
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-glk8/boot.html
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-glk8/boot.html
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-glk8/boot.html
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk4/boot.html
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk3/boot.html
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk5/boot.html
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk5/boot.html
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk3/boot.html
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk5/boot.html
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk6/boot.html
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk2/boot.html
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk2/boot.html
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk2/boot.html
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk1/boot.html
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk6/boot.html
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk1/boot.html
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk6/boot.html
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk7/boot.html
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk7/boot.html
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk7/boot.html
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk8/boot.html
[44]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk8/boot.html
[45]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk8/boot.html
[46]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk1/boot.html
[47]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk8/boot.html
[48]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk9/boot.html
[49]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk9/boot.html
[50]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk4/boot.html

### IGT changes ###

#### Issues hit ####

* igt@gem_eio@in-flight-contexts-1us:
- shard-tglb: [PASS][51] -> [TIMEOUT][52] ([i915#3063])
[51]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-tglb3/igt@[email protected]
[52]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb3/igt@[email protected]

* igt@gem_eio@unwedge-stress:
- shard-iclb: [PASS][53] -> [TIMEOUT][54] ([i915#2369] / [i915#2481] / [i915#3070])
[53]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-iclb4/igt@[email protected]
[54]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-iclb8/igt@[email protected]

* igt@gem_exec_fair@basic-none-share@rcs0:
- shard-apl: [PASS][55] -> [SKIP][56] ([fdo#109271])
[55]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-apl8/igt@gem_exec_fair@[email protected]
[56]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-apl2/igt@gem_exec_fair@[email protected]

* igt@gem_exec_fair@basic-none@vcs0:
- shard-kbl: [PASS][57] -> [FAIL][58] ([i915#2842]) +2 similar issues
[57]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-kbl4/igt@gem_exec_fair@[email protected]
[58]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-kbl6/igt@gem_exec_fair@[email protected]

* igt@gem_exec_fair@basic-none@vcs1:
- shard-iclb: NOTRUN -> [FAIL][59] ([i915#2842])
[59]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-iclb4/igt@gem_exec_fair@[email protected]

* igt@gem_exec_fair@basic-throttle@rcs0:
- shard-iclb: [PASS][60] -> [FAIL][61] ([i915#2849])
[60]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-iclb3/igt@gem_exec_fair@[email protected]
[61]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-iclb1/igt@gem_exec_fair@[email protected]

* igt@gem_huc_copy@huc-copy:
- shard-skl: NOTRUN -> [SKIP][62] ([fdo#109271] / [i915#2190])
[62]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-skl9/igt@[email protected]

* igt@gem_pwrite@basic-exhaustion:
- shard-skl: NOTRUN -> [WARN][63] ([i915#2658])
[63]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-skl5/igt@[email protected]

* igt@gem_pxp@display-protected-crc:
- shard-tglb: NOTRUN -> [SKIP][64] ([i915#4270]) +2 similar issues
[64]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb6/igt@[email protected]

* igt@gem_softpin@evict-snoop-interruptible:
- shard-tglb: NOTRUN -> [SKIP][65] ([fdo#109312])
[65]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb6/igt@[email protected]

* igt@gem_userptr_blits@access-control:
- shard-tglb: NOTRUN -> [SKIP][66] ([i915#3297]) +1 similar issue
[66]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb1/igt@[email protected]

* igt@gem_userptr_blits@input-checking:
- shard-skl: NOTRUN -> [DMESG-WARN][67] ([i915#3002])
[67]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-skl7/igt@[email protected]
- shard-tglb: NOTRUN -> [DMESG-WARN][68] ([i915#3002])
[68]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb5/igt@[email protected]
- shard-glk: NOTRUN -> [DMESG-WARN][69] ([i915#3002])
[69]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk3/igt@[email protected]
- shard-iclb: NOTRUN -> [DMESG-WARN][70] ([i915#3002])
[70]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-iclb8/igt@[email protected]

* igt@gem_workarounds@suspend-resume-fd:
- shard-tglb: [PASS][71] -> [INCOMPLETE][72] ([i915#456])
[71]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-tglb6/igt@[email protected]
[72]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb7/igt@[email protected]

* igt@gen9_exec_parse@basic-rejected-ctx-param:
- shard-iclb: NOTRUN -> [SKIP][73] ([i915#2856])
[73]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-iclb8/igt@[email protected]

* igt@gen9_exec_parse@bb-secure:
- shard-tglb: NOTRUN -> [SKIP][74] ([i915#2856]) +2 similar issues
[74]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb8/igt@[email protected]

* igt@i915_pm_backlight@bad-brightness:
- shard-glk: NOTRUN -> [SKIP][75] ([fdo#109271]) +34 similar issues
[75]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk3/igt@[email protected]

* igt@i915_pm_rpm@dpms-mode-unset-non-lpsp:
- shard-tglb: NOTRUN -> [SKIP][76] ([fdo#111644] / [i915#1397] / [i915#2411])
[76]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb1/igt@[email protected]

* igt@i915_pm_rpm@drm-resources-equal:
- shard-kbl: [PASS][77] -> [DMESG-WARN][78] ([i915#1982])
[77]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-kbl1/igt@[email protected]
[78]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-kbl6/igt@[email protected]

* igt@i915_selftest@live@hangcheck:
- shard-snb: [PASS][79] -> [INCOMPLETE][80] ([i915#3921])
[79]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-snb5/igt@i915_selftest@[email protected]
[80]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-snb7/igt@i915_selftest@[email protected]

* igt@i915_suspend@fence-restore-tiled2untiled:
- shard-apl: [PASS][81] -> [DMESG-WARN][82] ([i915#180]) +2 similar issues
[81]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-apl8/igt@[email protected]
[82]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-apl1/igt@[email protected]

* igt@kms_big_fb@linear-32bpp-rotate-90:
- shard-iclb: NOTRUN -> [SKIP][83] ([fdo#110725] / [fdo#111614])
[83]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-iclb8/igt@[email protected]

* igt@kms_big_fb@linear-8bpp-rotate-90:
- shard-tglb: NOTRUN -> [SKIP][84] ([fdo#111614]) +5 similar issues
[84]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb1/igt@[email protected]

* igt@kms_big_fb@x-tiled-32bpp-rotate-180:
- shard-glk: [PASS][85] -> [DMESG-WARN][86] ([i915#118]) +2 similar issues
[85]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-glk4/igt@[email protected]
[86]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk8/igt@[email protected]

* igt@kms_big_fb@x-tiled-max-hw-stride-64bpp-rotate-0-hflip:
- shard-skl: NOTRUN -> [SKIP][87] ([fdo#109271] / [i915#3777])
[87]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-skl9/igt@[email protected]

* igt@kms_big_fb@x-tiled-max-hw-stride-64bpp-rotate-180-hflip:
- shard-kbl: NOTRUN -> [SKIP][88] ([fdo#109271] / [i915#3777])
[88]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-kbl2/igt@[email protected]

* igt@kms_big_fb@y-tiled-max-hw-stride-64bpp-rotate-180-hflip:
- shard-apl: NOTRUN -> [SKIP][89] ([fdo#109271] / [i915#3777])
[89]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-apl7/igt@[email protected]

* igt@kms_big_fb@yf-tiled-32bpp-rotate-270:
- shard-tglb: NOTRUN -> [SKIP][90] ([fdo#111615]) +4 similar issues
[90]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb8/igt@[email protected]

* igt@kms_ccs@pipe-a-missing-ccs-buffer-y_tiled_gen12_mc_ccs:
- shard-kbl: NOTRUN -> [SKIP][91] ([fdo#109271] / [i915#3886]) +2 similar issues
[91]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-kbl2/igt@kms_ccs@pipe-a-missing-ccs-buffer-y_tiled_gen12_mc_ccs.html

* igt@kms_ccs@pipe-b-crc-primary-rotation-180-y_tiled_gen12_rc_ccs_cc:
- shard-skl: NOTRUN -> [SKIP][92] ([fdo#109271] / [i915#3886]) +3 similar issues
[92]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-skl9/igt@kms_ccs@pipe-b-crc-primary-rotation-180-y_tiled_gen12_rc_ccs_cc.html

* igt@kms_ccs@pipe-c-bad-rotation-90-y_tiled_gen12_mc_ccs:
- shard-apl: NOTRUN -> [SKIP][93] ([fdo#109271] / [i915#3886])
[93]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-apl7/igt@kms_ccs@pipe-c-bad-rotation-90-y_tiled_gen12_mc_ccs.html

* igt@kms_ccs@pipe-c-ccs-on-another-bo-y_tiled_gen12_mc_ccs:
- shard-glk: NOTRUN -> [SKIP][94] ([fdo#109271] / [i915#3886]) +2 similar issues
[94]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk3/igt@kms_ccs@pipe-c-ccs-on-another-bo-y_tiled_gen12_mc_ccs.html

* igt@kms_ccs@pipe-d-random-ccs-data-y_tiled_gen12_mc_ccs:
- shard-tglb: NOTRUN -> [SKIP][95] ([i915#3689]) +11 similar issues
[95]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb6/igt@kms_ccs@pipe-d-random-ccs-data-y_tiled_gen12_mc_ccs.html

* igt@kms_chamelium@dp-hpd-for-each-pipe:
- shard-apl: NOTRUN -> [SKIP][96] ([fdo#109271] / [fdo#111827]) +1 similar issue
[96]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-apl7/igt@[email protected]

* igt@kms_chamelium@hdmi-hpd-after-suspend:
- shard-iclb: NOTRUN -> [SKIP][97] ([fdo#109284] / [fdo#111827]) +1 similar issue
[97]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-iclb8/igt@[email protected]

* igt@kms_chamelium@hdmi-hpd-storm-disable:
- shard-skl: NOTRUN -> [SKIP][98] ([fdo#109271] / [fdo#111827]) +12 similar issues
[98]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-skl9/igt@[email protected]

* igt@kms_chamelium@vga-hpd-for-each-pipe:
- shard-glk: NOTRUN -> [SKIP][99] ([fdo#109271] / [fdo#111827]) +3 similar issues
[99]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk3/igt@[email protected]

* igt@kms_color_chamelium@pipe-c-ctm-0-25:
- shard-kbl: NOTRUN -> [SKIP][100] ([fdo#109271] / [fdo#111827]) +1 similar issue
[100]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-kbl2/igt@[email protected]

* igt@kms_color_chamelium@pipe-d-ctm-limited-range:
- shard-tglb: NOTRUN -> [SKIP][101] ([fdo#109284] / [fdo#111827]) +9 similar issues
[101]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb1/igt@[email protected]

* igt@kms_content_protection@legacy:
- shard-apl: NOTRUN -> [TIMEOUT][102] ([i915#1319])
[102]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-apl7/igt@[email protected]

* igt@kms_content_protection@mei_interface:
- shard-tglb: NOTRUN -> [SKIP][103] ([fdo#111828])
[103]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb6/igt@kms_content_protection@mei_interface.html

* igt@kms_cursor_crc@pipe-c-cursor-512x512-random:
- shard-skl: NOTRUN -> [SKIP][104] ([fdo#109271]) +124 similar issues
[104]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-skl9/igt@[email protected]

* igt@kms_cursor_crc@pipe-c-cursor-max-size-offscreen:
- shard-tglb: NOTRUN -> [SKIP][105] ([i915#3359]) +4 similar issues
[105]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb1/igt@[email protected]

* igt@kms_cursor_crc@pipe-c-cursor-max-size-random:
- shard-iclb: NOTRUN -> [SKIP][106] ([fdo#109278]) +1 similar issue
[106]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-iclb8/igt@[email protected]

* igt@kms_cursor_crc@pipe-d-cursor-32x32-offscreen:
- shard-tglb: NOTRUN -> [SKIP][107] ([i915#3319]) +1 similar issue
[107]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb8/igt@[email protected]

* igt@kms_cursor_crc@pipe-d-cursor-512x170-offscreen:
- shard-tglb: NOTRUN -> [SKIP][108] ([fdo#109279] / [i915#3359]) +4 similar issues
[108]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb1/igt@[email protected]

* igt@kms_fbcon_fbt@fbc-suspend:
- shard-kbl: [PASS][109] -> [INCOMPLETE][110] ([i915#180] / [i915#636])
[109]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-kbl2/igt@[email protected]
[110]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-kbl4/igt@[email protected]

* igt@kms_fbcon_fbt@psr-suspend:
- shard-tglb: [PASS][111] -> [INCOMPLETE][112] ([i915#2411] / [i915#456])
[111]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-tglb5/igt@[email protected]
[112]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb7/igt@[email protected]

* igt@kms_flip@2x-flip-vs-modeset-vs-hang:
- shard-kbl: NOTRUN -> [SKIP][113] ([fdo#109271]) +29 similar issues
[113]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-kbl2/igt@[email protected]

* igt@kms_flip@flip-vs-expired-vblank@b-edp1:
- shard-skl: [PASS][114] -> [FAIL][115] ([i915#79])
[114]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-skl10/igt@kms_flip@[email protected]
[115]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-skl8/igt@kms_flip@[email protected]

* igt@kms_flip@flip-vs-suspend-interruptible@a-dp1:
- shard-kbl: [PASS][116] -> [DMESG-WARN][117] ([i915#180]) +3 similar issues
[116]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-kbl1/igt@kms_flip@[email protected]
[117]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-kbl1/igt@kms_flip@[email protected]

* igt@kms_flip@flip-vs-suspend-interruptible@c-edp1:
- shard-skl: [PASS][118] -> [INCOMPLETE][119] ([i915#198])
[118]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-skl9/igt@kms_flip@[email protected]
[119]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-skl1/igt@kms_flip@[email protected]

* igt@kms_flip@plain-flip-fb-recreate-interruptible@c-edp1:
- shard-skl: [PASS][120] -> [FAIL][121] ([i915#2122]) +1 similar issue
[120]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-skl10/igt@kms_flip@[email protected]
[121]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-skl7/igt@kms_flip@[email protected]

* igt@kms_flip_scaled_crc@flip-32bpp-ytile-to-32bpp-ytileccs:
- shard-skl: NOTRUN -> [INCOMPLETE][122] ([i915#3699])
[122]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-skl5/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbc-2p-primscrn-spr-indfb-onoff:
- shard-iclb: NOTRUN -> [SKIP][123] ([fdo#109280])
[123]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-iclb8/igt@[email protected]

* igt@kms_frontbuffer_tracking@psr-2p-pri-indfb-multidraw:
- shard-apl: NOTRUN -> [SKIP][124] ([fdo#109271]) +31 similar issues
[124]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-apl7/igt@[email protected]

* igt@kms_frontbuffer_tracking@psr-2p-scndscrn-pri-indfb-draw-mmap-gtt:
- shard-tglb: NOTRUN -> [SKIP][125] ([fdo#111825]) +22 similar issues
[125]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb1/igt@kms_frontbuffer_tracking@psr-2p-scndscrn-pri-indfb-draw-mmap-gtt.html

* igt@kms_invalid_mode@clock-too-high:
- shard-tglb: NOTRUN -> [SKIP][126] ([i915#4278])
[126]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb8/igt@[email protected]

* igt@kms_pipe_crc_basic@hang-read-crc-pipe-d:
- shard-skl: NOTRUN -> [SKIP][127] ([fdo#109271] / [i915#533])
[127]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-skl5/igt@[email protected]

* igt@kms_plane@plane-panning-bottom-right-suspend@pipe-b-planes:
- shard-snb: [PASS][128] -> [SKIP][129] ([fdo#109271])
[128]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-snb7/igt@kms_plane@[email protected]
[129]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-snb2/igt@kms_plane@[email protected]

* igt@kms_plane_alpha_blend@pipe-b-alpha-transparent-fb:
- shard-skl: NOTRUN -> [FAIL][130] ([i915#265])
[130]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-skl8/igt@[email protected]

* igt@kms_plane_alpha_blend@pipe-c-coverage-7efc:
- shard-skl: [PASS][131] -> [FAIL][132] ([fdo#108145] / [i915#265])
[131]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-skl6/igt@[email protected]
[132]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-skl7/igt@[email protected]

* igt@kms_plane_lowres@pipe-d-tiling-y:
- shard-tglb: NOTRUN -> [SKIP][133] ([i915#3536]) +1 similar issue
[133]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb6/igt@[email protected]

* igt@kms_plane_scaling@scaler-with-clipping-clamping@pipe-c-scaler-with-clipping-clamping:
- shard-skl: NOTRUN -> [SKIP][134] ([fdo#109271] / [i915#2733])
[134]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-skl9/igt@kms_plane_scaling@scaler-with-clipping-clamping@pipe-c-scaler-with-clipping-clamping.html

* igt@kms_psr2_sf@overlay-plane-update-sf-dmg-area-5:
- shard-tglb: NOTRUN -> [SKIP][135] ([i915#2920]) +1 similar issue
[135]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb1/igt@[email protected]

* igt@kms_psr2_sf@overlay-primary-update-sf-dmg-area-2:
- shard-skl: NOTRUN -> [SKIP][136] ([fdo#109271] / [i915#658])
[136]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-skl5/igt@[email protected]

* igt@kms_psr2_sf@overlay-primary-update-sf-dmg-area-3:
- shard-kbl: NOTRUN -> [SKIP][137] ([fdo#109271] / [i915#658])
[137]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-kbl2/igt@[email protected]

* igt@kms_psr2_sf@overlay-primary-update-sf-dmg-area-4:
- shard-apl: NOTRUN -> [SKIP][138] ([fdo#109271] / [i915#658])
[138]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-apl7/igt@[email protected]

* igt@kms_psr2_sf@primary-plane-update-sf-dmg-area-5:
- shard-glk: NOTRUN -> [SKIP][139] ([fdo#109271] / [i915#658])
[139]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk3/igt@[email protected]
- shard-iclb: NOTRUN -> [SKIP][140] ([i915#658])
[140]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-iclb8/igt@[email protected]

* igt@kms_psr@psr2_no_drrs:
- shard-iclb: [PASS][141] -> [SKIP][142] ([fdo#109441])
[141]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-iclb2/igt@kms_psr@psr2_no_drrs.html
[142]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-iclb3/igt@kms_psr@psr2_no_drrs.html

* igt@kms_psr@psr2_sprite_render:
- shard-tglb: NOTRUN -> [FAIL][143] ([i915#132] / [i915#3467]) +4 similar issues
[143]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb5/igt@kms_psr@psr2_sprite_render.html
- shard-iclb: NOTRUN -> [SKIP][144] ([fdo#109441])
[144]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-iclb8/igt@kms_psr@psr2_sprite_render.html

* igt@kms_writeback@writeback-invalid-parameters:
- shard-tglb: NOTRUN -> [SKIP][145] ([i915#2437]) +1 similar issue
[145]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb6/igt@[email protected]

* igt@kms_writeback@writeback-pixel-formats:
- shard-skl: NOTRUN -> [SKIP][146] ([fdo#109271] / [i915#2437]) +1 similar issue
[146]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-skl8/igt@[email protected]

* igt@nouveau_crc@ctx-flip-threshold-reset-after-capture:
- shard-tglb: NOTRUN -> [SKIP][147] ([i915#2530])
[147]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb8/igt@[email protected]

* igt@prime_nv_test@nv_write_i915_cpu_mmap_read:
- shard-tglb: NOTRUN -> [SKIP][148] ([fdo#109291]) +4 similar issues
[148]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb5/igt@prime_nv_test@nv_write_i915_cpu_mmap_read.html
- shard-iclb: NOTRUN -> [SKIP][149] ([fdo#109291])
[149]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-iclb8/igt@prime_nv_test@nv_write_i915_cpu_mmap_read.html

* igt@sysfs_clients@busy:
- shard-tglb: NOTRUN -> [SKIP][150] ([i915#2994]) +2 similar issues
[150]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb5/igt@[email protected]
- shard-iclb: NOTRUN -> [SKIP][151] ([i915#2994])
[151]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-iclb8/igt@[email protected]
- shard-glk: NOTRUN -> [SKIP][152] ([fdo#109271] / [i915#2994])
[152]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk3/igt@[email protected]

* igt@sysfs_clients@fair-0:
- shard-skl: NOTRUN -> [SKIP][153] ([fdo#109271] / [i915#2994]) +3 similar issues
[153]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-skl8/igt@[email protected]

* igt@tools_test@sysfs_l3_parity:
- shard-tglb: NOTRUN -> [SKIP][154] ([fdo#109307])
[154]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb8/igt@tools_test@sysfs_l3_parity.html

#### Possible fixes ####

* igt@gem_eio@in-flight-suspend:
- shard-kbl: [DMESG-WARN][155] ([i915#180]) -> [PASS][156] +1 similar issue
[155]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-kbl1/igt@[email protected]
[156]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-kbl2/igt@[email protected]

* igt@gem_eio@unwedge-stress:
- shard-tglb: [TIMEOUT][157] ([i915#2369] / [i915#3063] / [i915#3648]) -> [PASS][158]
[157]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-tglb2/igt@[email protected]
[158]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-tglb3/igt@[email protected]

* igt@gem_exec_fair@basic-none@rcs0:
- shard-glk: [FAIL][159] ([i915#2842]) -> [PASS][160]
[159]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10822/shard-glk8/igt@gem_exec_fair@[email protected]
[160]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/shard-glk5/igt@gem_exec_fair@[email protected]

* igt@gem_exec_fair@basic-pace@rc

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21495/index.html