All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 3/4] drm/i915: Make i915_gem_object_phys_attach() use obj->mm.lock more appropriately
Date: Fri, 30 Jun 2017 14:40:08 +0300	[thread overview]
Message-ID: <20170630114008.GQ12629@intel.com> (raw)
In-Reply-To: <20170615082509.23820-3-chris@chris-wilson.co.uk>

On Thu, Jun 15, 2017 at 09:25:08AM +0100, Chris Wilson wrote:
> Actually transferring from shmemfs to the physically contiguous set of
> pages should be wholly guarded by its obj->mm.lock!
> 
> v2: Remember to free the old pages.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/i915_gem.c | 44 +++++++++++++++++++++++++++--------------
>  1 file changed, 29 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 31cbe78171a9..7f3be5deeb5e 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -574,7 +574,8 @@ int
>  i915_gem_object_attach_phys(struct drm_i915_gem_object *obj,
>  			    int align)
>  {
> -	int ret;
> +	struct sg_table *pages;
> +	int err;
>  
>  	if (align > obj->base.size)
>  		return -EINVAL;
> @@ -582,32 +583,45 @@ i915_gem_object_attach_phys(struct drm_i915_gem_object *obj,
>  	if (obj->ops == &i915_gem_phys_ops)
>  		return 0;
>  
> -	if (obj->mm.madv != I915_MADV_WILLNEED)
> -		return -EFAULT;
> -
> -	if (obj->base.filp == NULL)
> +	if (obj->ops != &i915_gem_object_ops)
>  		return -EINVAL;
>  
> -	ret = i915_gem_object_unbind(obj);
> -	if (ret)
> -		return ret;
> +	err = i915_gem_object_unbind(obj);
> +	if (err)
> +		return err;
> +
> +	mutex_lock(&obj->mm.lock);
> +
> +	if (obj->mm.quirked) {
> +		err = -EFAULT;
> +		goto err_unlock;
> +	}
>  
> -	__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
> -	if (obj->mm.pages)
> -		return -EBUSY;
> +	if (obj->mm.mapping) {
> +		err = -EBUSY;
> +		goto err_unlock;
> +	}
>  
> -	GEM_BUG_ON(obj->ops != &i915_gem_object_ops);
> +	pages = obj->mm.pages;
>  	obj->ops = &i915_gem_phys_ops;
>  
> -	ret = i915_gem_object_pin_pages(obj);
> -	if (ret)
> +	err = __i915_gem_object_get_pages(obj);
> +	if (err)
>  		goto err_xfer;
>  
> +	/* Perma-pin (until release) the physical set of pages */
> +	__i915_gem_object_pin_pages(obj);
> +
> +	i915_gem_object_ops.put_pages(obj, pages);

Leak sorted, so this lgtm.

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

> +	mutex_unlock(&obj->mm.lock);
>  	return 0;
>  
>  err_xfer:
>  	obj->ops = &i915_gem_object_ops;
> -	return ret;
> +	obj->mm.pages = pages;
> +err_unlock:
> +	mutex_unlock(&obj->mm.lock);
> +	return err;
>  }
>  
>  static int
> -- 
> 2.11.0

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2017-06-30 11:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-15  8:25 [PATCH 1/4] drm/i915: Trim struct_mutex usage for kms Chris Wilson
2017-06-15  8:25 ` [PATCH 2/4] drm/i915: Defer cleanup of active KMS state Chris Wilson
2017-06-15 16:38   ` Maarten Lankhorst
2017-06-15  8:25 ` [PATCH 3/4] drm/i915: Make i915_gem_object_phys_attach() use obj->mm.lock more appropriately Chris Wilson
2017-06-30 11:40   ` Ville Syrjälä [this message]
2017-06-15  8:25 ` [PATCH 4/4] drm/i915: Pin the pages before acquiring struct_mutex for display Chris Wilson
2017-06-15  8:47 ` ✓ Fi.CI.BAT: success for series starting with [1/4] drm/i915: Trim struct_mutex usage for kms Patchwork
2017-06-15 16:50 ` [PATCH 1/4] " Maarten Lankhorst

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=20170630114008.GQ12629@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.