@@ -96,9 +96,9 @@ static signed long i915_fence_wait(struct dma_fence *fence,
96
96
bool interruptible ,
97
97
signed long timeout )
98
98
{
99
- return i915_request_wait (to_request (fence ),
100
- interruptible | I915_WAIT_PRIORITY ,
101
- timeout );
99
+ return i915_request_wait_timeout (to_request (fence ),
100
+ interruptible | I915_WAIT_PRIORITY ,
101
+ timeout );
102
102
}
103
103
104
104
struct kmem_cache * i915_request_slab_cache (void )
@@ -1857,23 +1857,27 @@ static void request_wait_wake(struct dma_fence *fence, struct dma_fence_cb *cb)
1857
1857
}
1858
1858
1859
1859
/**
1860
- * i915_request_wait - wait until execution of request has finished
1860
+ * i915_request_wait_timeout - wait until execution of request has finished
1861
1861
* @rq: the request to wait upon
1862
1862
* @flags: how to wait
1863
1863
* @timeout: how long to wait in jiffies
1864
1864
*
1865
- * i915_request_wait () waits for the request to be completed, for a
1865
+ * i915_request_wait_timeout () waits for the request to be completed, for a
1866
1866
* maximum of @timeout jiffies (with MAX_SCHEDULE_TIMEOUT implying an
1867
1867
* unbounded wait).
1868
1868
*
1869
1869
* Returns the remaining time (in jiffies) if the request completed, which may
1870
- * be zero or -ETIME if the request is unfinished after the timeout expires.
1870
+ * be zero if the request is unfinished after the timeout expires.
1871
+ * If the timeout is 0, it will return 1 if the fence is signaled.
1872
+ *
1871
1873
* May return -EINTR is called with I915_WAIT_INTERRUPTIBLE and a signal is
1872
1874
* pending before the request completes.
1875
+ *
1876
+ * NOTE: This function has the same wait semantics as dma-fence.
1873
1877
*/
1874
- long i915_request_wait (struct i915_request * rq ,
1875
- unsigned int flags ,
1876
- long timeout )
1878
+ long i915_request_wait_timeout (struct i915_request * rq ,
1879
+ unsigned int flags ,
1880
+ long timeout )
1877
1881
{
1878
1882
const int state = flags & I915_WAIT_INTERRUPTIBLE ?
1879
1883
TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE ;
@@ -1883,7 +1887,7 @@ long i915_request_wait(struct i915_request *rq,
1883
1887
GEM_BUG_ON (timeout < 0 );
1884
1888
1885
1889
if (dma_fence_is_signaled (& rq -> fence ))
1886
- return timeout ;
1890
+ return timeout ?: 1 ;
1887
1891
1888
1892
if (!timeout )
1889
1893
return - ETIME ;
@@ -1992,6 +1996,39 @@ long i915_request_wait(struct i915_request *rq,
1992
1996
return timeout ;
1993
1997
}
1994
1998
1999
+ /**
2000
+ * i915_request_wait - wait until execution of request has finished
2001
+ * @rq: the request to wait upon
2002
+ * @flags: how to wait
2003
+ * @timeout: how long to wait in jiffies
2004
+ *
2005
+ * i915_request_wait() waits for the request to be completed, for a
2006
+ * maximum of @timeout jiffies (with MAX_SCHEDULE_TIMEOUT implying an
2007
+ * unbounded wait).
2008
+ *
2009
+ * Returns the remaining time (in jiffies) if the request completed, which may
2010
+ * be zero or -ETIME if the request is unfinished after the timeout expires.
2011
+ * May return -EINTR is called with I915_WAIT_INTERRUPTIBLE and a signal is
2012
+ * pending before the request completes.
2013
+ *
2014
+ * NOTE: This function behaves differently from dma-fence wait semantics for
2015
+ * timeout = 0. It returns 0 on success, and -ETIME if not signaled.
2016
+ */
2017
+ long i915_request_wait (struct i915_request * rq ,
2018
+ unsigned int flags ,
2019
+ long timeout )
2020
+ {
2021
+ long ret = i915_request_wait_timeout (rq , flags , timeout );
2022
+
2023
+ if (!ret )
2024
+ return - ETIME ;
2025
+
2026
+ if (ret > 0 && !timeout )
2027
+ return 0 ;
2028
+
2029
+ return ret ;
2030
+ }
2031
+
1995
2032
static int print_sched_attr (const struct i915_sched_attr * attr ,
1996
2033
char * buf , int x , int len )
1997
2034
{
0 commit comments