void __shmem_writeback(size_t size, struct address_space
*mapping);
#ifdef CONFIG_MMU_NOTIFIER
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
index a4b69a43b898..604ed5ad77f5 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
@@ -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;
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
index 01f332d8dbde..67c6bee695c7 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
@@ -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_free_st_table(struct sg_table *st, struct address_space
*mapping,
+ bool dirty, bool backup)
{
struct sgt_iter sgt_iter;
struct pagevec pvec;
@@ -49,7 +49,6 @@ 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,
@@ -171,7 +170,8 @@ struct sg_table *shmem_alloc_st(struct
drm_i915_private *i915,
err_sg:
sg_mark_end(sg);
if (sg != st->sgl) {
- shmem_free_st(st, mapping, false, false);
+ shmem_free_st_table(st, mapping, false, false);
+ kfree(st);
} else {
mapping_clear_unevictable(mapping);
sg_free_table(st);
@@ -254,7 +254,8 @@ static int shmem_get_pages(struct
drm_i915_gem_object *obj)
return 0;
err_pages:
- shmem_free_st(st, mapping, false, false);
+ shmem_free_st_table(st, mapping, false, false);
+ kfree(st);
/*
* shmemfs first checks if there is enough memory to
allocate the page
* and reports ENOSPC should there be insufficient, along
with the usual
@@ -374,8 +375,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_free_st_table(pages, file_inode(obj->base.filp)-
i_mapping,
+ obj->mm.dirty, obj->mm.madv ==
I915_MADV_WILLNEED);
+ kfree(pages);
obj->mm.dirty = false;
}
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
index 4fd2edb20dd9..6826e3859e18 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
@@ -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;
@@ -221,14 +221,10 @@ static int i915_ttm_tt_shmem_populate(struct
ttm_device *bdev,
if (IS_ERR(st))
return PTR_ERR(st);
- 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 +233,15 @@ 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;
+ i915_tt->cached_rsgt.table = *st;
+ kfree(st);