stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/i915: Check the timeout passed to i915_wait_request
@ 2015-11-26 13:31 Chris Wilson
  2015-11-26 14:49 ` Daniel Vetter
  0 siblings, 1 reply; 4+ messages in thread
From: Chris Wilson @ 2015-11-26 13:31 UTC (permalink / raw)
  To: intel-gfx
  Cc: Chris Wilson, Lionel Landwerlin, Tvrtko Ursulin, Daniel Vetter,
	stable

We have relied upon the sole caller (wait_ioctl) validating the timeout
argument. However, when waiting for multiple requests I forgot to ensure
that the timeout was still positive on the later requests. This is more
simply done inside __i915_wait_request.

Fixes regression introduced in
commit b47161858ba13c9c7e03333132230d66e008dd55
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Mon Apr 27 13:41:17 2015 +0100

    drm/i915: Implement inter-engine read-read optimisations

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Lionel Landwerlin <lionel.g.landwerlin@linux.intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: stable@vger.kernel.org
---
 drivers/gpu/drm/i915/i915_gem.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 73c2c48729ec..8c19a980f5e6 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1210,8 +1210,16 @@ int __i915_wait_request(struct drm_i915_gem_request *req,
 	if (i915_gem_request_completed(req, true))
 		return 0;
 
-	timeout_expire = timeout ?
-		jiffies + nsecs_to_jiffies_timeout((u64)*timeout) : 0;
+	timeout_expire = 0;
+	if (timeout) {
+		if (WARN_ON(*timeout < 0))
+			return -EINVAL;
+
+		if (*timeout == 0)
+			return -ETIME;
+
+		timeout_expire = jiffies + nsecs_to_jiffies_timeout(*timeout);
+	}
 
 	if (INTEL_INFO(dev_priv)->gen >= 6)
 		gen6_rps_boost(dev_priv, rps, req->emitted_jiffies);
-- 
2.6.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/i915: Check the timeout passed to i915_wait_request
  2015-11-26 13:31 [PATCH] drm/i915: Check the timeout passed to i915_wait_request Chris Wilson
@ 2015-11-26 14:49 ` Daniel Vetter
  2015-11-26 16:06   ` Chris Wilson
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Vetter @ 2015-11-26 14:49 UTC (permalink / raw)
  To: Chris Wilson
  Cc: intel-gfx, Lionel Landwerlin, Tvrtko Ursulin, Daniel Vetter,
	stable

On Thu, Nov 26, 2015 at 01:31:42PM +0000, Chris Wilson wrote:
> We have relied upon the sole caller (wait_ioctl) validating the timeout
> argument. However, when waiting for multiple requests I forgot to ensure
> that the timeout was still positive on the later requests. This is more
> simply done inside __i915_wait_request.
> 
> Fixes regression introduced in
> commit b47161858ba13c9c7e03333132230d66e008dd55
> Author: Chris Wilson <chris@chris-wilson.co.uk>
> Date:   Mon Apr 27 13:41:17 2015 +0100
> 
>     drm/i915: Implement inter-engine read-read optimisations
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Lionel Landwerlin <lionel.g.landwerlin@linux.intel.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: stable@vger.kernel.org

Commit message should explain what the actual problem is - we add 1 jiffy
of delay for each wait_request, potentially waiting quite a bit longer
than what userspace asked for.

And not sure this really justifies for cc: stable, since all the wait
syscalls reserve the right to wait longer. Of course we should fix it,
just to keep validating this possible.

So with the commit message amended and cc: stable dropped this is
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/i915/i915_gem.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 73c2c48729ec..8c19a980f5e6 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -1210,8 +1210,16 @@ int __i915_wait_request(struct drm_i915_gem_request *req,
>  	if (i915_gem_request_completed(req, true))
>  		return 0;
>  
> -	timeout_expire = timeout ?
> -		jiffies + nsecs_to_jiffies_timeout((u64)*timeout) : 0;
> +	timeout_expire = 0;
> +	if (timeout) {
> +		if (WARN_ON(*timeout < 0))
> +			return -EINVAL;
> +
> +		if (*timeout == 0)
> +			return -ETIME;
> +
> +		timeout_expire = jiffies + nsecs_to_jiffies_timeout(*timeout);
> +	}
>  
>  	if (INTEL_INFO(dev_priv)->gen >= 6)
>  		gen6_rps_boost(dev_priv, rps, req->emitted_jiffies);
> -- 
> 2.6.2
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/i915: Check the timeout passed to i915_wait_request
  2015-11-26 14:49 ` Daniel Vetter
@ 2015-11-26 16:06   ` Chris Wilson
  2015-12-01  9:04     ` [Intel-gfx] " Jani Nikula
  0 siblings, 1 reply; 4+ messages in thread
From: Chris Wilson @ 2015-11-26 16:06 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: intel-gfx, Lionel Landwerlin, Tvrtko Ursulin, Daniel Vetter,
	stable

On Thu, Nov 26, 2015 at 03:49:00PM +0100, Daniel Vetter wrote:
> On Thu, Nov 26, 2015 at 01:31:42PM +0000, Chris Wilson wrote:
> > We have relied upon the sole caller (wait_ioctl) validating the timeout
> > argument. However, when waiting for multiple requests I forgot to ensure
> > that the timeout was still positive on the later requests. This is more
> > simply done inside __i915_wait_request.
> > 
> > Fixes regression introduced in
> > commit b47161858ba13c9c7e03333132230d66e008dd55
> > Author: Chris Wilson <chris@chris-wilson.co.uk>
> > Date:   Mon Apr 27 13:41:17 2015 +0100
> > 
> >     drm/i915: Implement inter-engine read-read optimisations
> > 
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Lionel Landwerlin <lionel.g.landwerlin@linux.intel.com>
> > Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Cc: stable@vger.kernel.org
> 
> Commit message should explain what the actual problem is - we add 1 jiffy
> of delay for each wait_request, potentially waiting quite a bit longer
> than what userspace asked for.
> 
> And not sure this really justifies for cc: stable, since all the wait
> syscalls reserve the right to wait longer. Of course we should fix it,
> just to keep validating this possible.

Dropping stable is fine, that was just a knee jerk reaction to finding a
regression. The impact is 1 jiffie for each extra active ring for a
wait_ioctl with a timeout -- I don't think anyone has noticed.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Intel-gfx] [PATCH] drm/i915: Check the timeout passed to i915_wait_request
  2015-11-26 16:06   ` Chris Wilson
@ 2015-12-01  9:04     ` Jani Nikula
  0 siblings, 0 replies; 4+ messages in thread
From: Jani Nikula @ 2015-12-01  9:04 UTC (permalink / raw)
  To: Chris Wilson, Daniel Vetter
  Cc: Lionel Landwerlin, Daniel Vetter, intel-gfx, stable

On Thu, 26 Nov 2015, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> On Thu, Nov 26, 2015 at 03:49:00PM +0100, Daniel Vetter wrote:
>> On Thu, Nov 26, 2015 at 01:31:42PM +0000, Chris Wilson wrote:
>> > We have relied upon the sole caller (wait_ioctl) validating the timeout
>> > argument. However, when waiting for multiple requests I forgot to ensure
>> > that the timeout was still positive on the later requests. This is more
>> > simply done inside __i915_wait_request.
>> > 
>> > Fixes regression introduced in
>> > commit b47161858ba13c9c7e03333132230d66e008dd55
>> > Author: Chris Wilson <chris@chris-wilson.co.uk>
>> > Date:   Mon Apr 27 13:41:17 2015 +0100
>> > 
>> >     drm/i915: Implement inter-engine read-read optimisations
>> > 
>> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
>> > Cc: Lionel Landwerlin <lionel.g.landwerlin@linux.intel.com>
>> > Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
>> > Cc: stable@vger.kernel.org
>> 
>> Commit message should explain what the actual problem is - we add 1 jiffy
>> of delay for each wait_request, potentially waiting quite a bit longer
>> than what userspace asked for.
>> 
>> And not sure this really justifies for cc: stable, since all the wait
>> syscalls reserve the right to wait longer. Of course we should fix it,
>> just to keep validating this possible.
>
> Dropping stable is fine, that was just a knee jerk reaction to finding a
> regression. The impact is 1 jiffie for each extra active ring for a
> wait_ioctl with a timeout -- I don't think anyone has noticed.

Pushed to drm-intel-fixes with some random copy-paste added about the 1
jiffy. Thanks for the patch and review.

BR,
Jani.


-- 
Jani Nikula, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-12-01  9:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-26 13:31 [PATCH] drm/i915: Check the timeout passed to i915_wait_request Chris Wilson
2015-11-26 14:49 ` Daniel Vetter
2015-11-26 16:06   ` Chris Wilson
2015-12-01  9:04     ` [Intel-gfx] " Jani Nikula

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).