All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mika Kuoppala <mika.kuoppala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2 1/2] drm/i915: Do an unlocked wait before	set-cache-level ioctl
Date: Thu, 19 Jan 2017 13:42:47 +0200	[thread overview]
Message-ID: <87wpdrb7ig.fsf@gaia.fi.intel.com> (raw)
In-Reply-To: <20170119082211.21257-1-chris@chris-wilson.co.uk>

Chris Wilson <chris@chris-wilson.co.uk> writes:

> Since a change in cache level is likely to trigger an unbind, avoid
> waiting under the mutex by preemptively doing an unlocked wait.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/i915_gem.c | 29 +++++++++++++++++++----------
>  1 file changed, 19 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index c1c2765bb8d0..0926c291404c 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -3384,7 +3384,7 @@ int i915_gem_set_caching_ioctl(struct drm_device *dev, void *data,
>  	struct drm_i915_gem_caching *args = data;
>  	struct drm_i915_gem_object *obj;
>  	enum i915_cache_level level;
> -	int ret;
> +	int ret = 0;
>  
>  	switch (args->caching) {
>  	case I915_CACHING_NONE:
> @@ -3409,20 +3409,29 @@ int i915_gem_set_caching_ioctl(struct drm_device *dev, void *data,
>  		return -EINVAL;
>  	}
>  
> -	ret = i915_mutex_lock_interruptible(dev);
> +	obj = i915_gem_object_lookup(file, args->handle);

Does this need to be i915_gem_object_lookup_rcu?

-Mika

> +	if (!obj)
> +		return -ENOENT;
> +
> +	if (obj->cache_level == level)
> +		goto out;
> +
> +	ret = i915_gem_object_wait(obj,
> +				   I915_WAIT_INTERRUPTIBLE,
> +				   MAX_SCHEDULE_TIMEOUT,
> +				   to_rps_client(file));
>  	if (ret)
> -		return ret;
> +		goto out;
>  
> -	obj = i915_gem_object_lookup(file, args->handle);
> -	if (!obj) {
> -		ret = -ENOENT;
> -		goto unlock;
> -	}
> +	ret = i915_mutex_lock_interruptible(dev);
> +	if (ret)
> +		goto out;
>  
>  	ret = i915_gem_object_set_cache_level(obj, level);
> -	i915_gem_object_put(obj);
> -unlock:
>  	mutex_unlock(&dev->struct_mutex);
> +
> +out:
> +	i915_gem_object_put(obj);
>  	return ret;
>  }
>  
> -- 
> 2.11.0
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2017-01-19 11:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-19  8:22 [PATCH v2 1/2] drm/i915: Do an unlocked wait before set-cache-level ioctl Chris Wilson
2017-01-19  8:22 ` [PATCH v2 2/2] drm/i915: Priority boost for locked waits Chris Wilson
2017-01-19  8:54 ` ✓ Fi.CI.BAT: success for series starting with [v2,1/2] drm/i915: Do an unlocked wait before set-cache-level ioctl Patchwork
2017-01-19 11:36 ` [PATCH v2 1/2] " Mika Kuoppala
2017-01-19 11:43   ` Chris Wilson
2017-01-19 11:42 ` Mika Kuoppala [this message]
2017-01-19 11:51   ` Chris Wilson
2017-01-19 12:02     ` Mika Kuoppala

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=87wpdrb7ig.fsf@gaia.fi.intel.com \
    --to=mika.kuoppala@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.