public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Brian Geffon <bgeffon@google.com>
Cc: intel-gfx@lists.freedesktop.org, chris.p.wilson@intel.com,
	jani.saarinen@intel.com, tomasz.mistat@intel.com,
	vidya.srinivas@intel.com, jani.nikula@linux.intel.com,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
	stable@vger.kernel.org, Tomasz Figa <tfiga@google.com>
Subject: Re: [PATCH v3] drm/i915: Fix page cleanup on DMA remap failure
Date: Tue, 28 Jan 2025 18:19:31 +0200	[thread overview]
Message-ID: <Z5kDk69SkeHgwnj2@intel.com> (raw)
In-Reply-To: <20250127204332.336665-1-bgeffon@google.com>

On Mon, Jan 27, 2025 at 03:43:32PM -0500, Brian Geffon wrote:
> 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: 0b62af28f249 ("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>

Thanks. Pushed to drm-intel-gt-next.

> ---
>  drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> index fe69f2c8527d..ae3343c81a64 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> @@ -209,8 +209,6 @@ static int shmem_get_pages(struct drm_i915_gem_object *obj)
>  	struct address_space *mapping = obj->base.filp->f_mapping;
>  	unsigned int max_segment = i915_sg_segment_size(i915->drm.dev);
>  	struct sg_table *st;
> -	struct sgt_iter sgt_iter;
> -	struct page *page;
>  	int ret;
>  
>  	/*
> @@ -239,9 +237,7 @@ static int shmem_get_pages(struct drm_i915_gem_object *obj)
>  		 * for PAGE_SIZE chunks instead may be helpful.
>  		 */
>  		if (max_segment > PAGE_SIZE) {
> -			for_each_sgt_page(page, sgt_iter, st)
> -				put_page(page);
> -			sg_free_table(st);
> +			shmem_sg_free_table(st, mapping, false, false);
>  			kfree(st);
>  
>  			max_segment = PAGE_SIZE;
> -- 
> 2.48.1.262.g85cc9f2d1e-goog

-- 
Ville Syrjälä
Intel

      parent reply	other threads:[~2025-01-28 16:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-27 20:43 [PATCH v3] drm/i915: Fix page cleanup on DMA remap failure Brian Geffon
2025-01-27 21:15 ` Cavitt, Jonathan
2025-01-28  3:42   ` Srinivas, Vidya
2025-01-28 16:19 ` Ville Syrjälä [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z5kDk69SkeHgwnj2@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=bgeffon@google.com \
    --cc=chris.p.wilson@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=jani.saarinen@intel.com \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tfiga@google.com \
    --cc=tomasz.mistat@intel.com \
    --cc=vidya.srinivas@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox