Skip to content

Commit 9e304a1

Browse files
bgaffvsyrjala
authored andcommitted
drm/i915: Fix page cleanup on DMA remap failure
When converting to folios the cleanup path of shmem_get_pages() was missed. When a DMA remap fails and the max segment size is greater than PAGE_SIZE it will attempt to retry the remap with a PAGE_SIZEd segment size. The cleanup code isn't properly using the folio apis and as a result isn't handling compound pages correctly. v2 -> v3: (Ville) Just use shmem_sg_free_table() as-is in the failure path of shmem_get_pages(). shmem_sg_free_table() will clear mapping unevictable but it will be reset when it retries in shmem_sg_alloc_table(). v1 -> v2: (Ville) Fixed locations where we were not clearing mapping unevictable. Cc: stable@vger.kernel.org Cc: Ville Syrjala <ville.syrjala@linux.intel.com> Cc: Vidya Srinivas <vidya.srinivas@intel.com> Link: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/13487 Link: https://lore.kernel.org/lkml/20250116135636.410164-1-bgeffon@google.com/ Fixes: 0b62af2 ("i915: convert shmem_sg_free_table() to use a folio_batch") Signed-off-by: Brian Geffon <bgeffon@google.com> Suggested-by: Tomasz Figa <tfiga@google.com> Link: https://patchwork.freedesktop.org/patch/msgid/20250127204332.336665-1-bgeffon@google.com Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel.com> Tested-by: Vidya Srinivas <vidya.srinivas@intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
1 parent 431b742 commit 9e304a1

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

drivers/gpu/drm/i915/gem/i915_gem_shmem.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,6 @@ static int shmem_get_pages(struct drm_i915_gem_object *obj)
209209
struct address_space *mapping = obj->base.filp->f_mapping;
210210
unsigned int max_segment = i915_sg_segment_size(i915->drm.dev);
211211
struct sg_table *st;
212-
struct sgt_iter sgt_iter;
213-
struct page *page;
214212
int ret;
215213

216214
/*
@@ -239,9 +237,7 @@ static int shmem_get_pages(struct drm_i915_gem_object *obj)
239237
* for PAGE_SIZE chunks instead may be helpful.
240238
*/
241239
if (max_segment > PAGE_SIZE) {
242-
for_each_sgt_page(page, sgt_iter, st)
243-
put_page(page);
244-
sg_free_table(st);
240+
shmem_sg_free_table(st, mapping, false, false);
245241
kfree(st);
246242

247243
max_segment = PAGE_SIZE;

0 commit comments

Comments
 (0)