@@ -25,7 +25,7 @@ i915_gem_object_wait_fence(struct dma_fence *fence,
25
25
return timeout ;
26
26
27
27
if (dma_fence_is_i915 (fence ))
28
- return i915_request_wait (to_request (fence ), flags , timeout );
28
+ return i915_request_wait_timeout (to_request (fence ), flags , timeout );
29
29
30
30
return dma_fence_wait_timeout (fence ,
31
31
flags & I915_WAIT_INTERRUPTIBLE ,
@@ -37,58 +37,29 @@ i915_gem_object_wait_reservation(struct dma_resv *resv,
37
37
unsigned int flags ,
38
38
long timeout )
39
39
{
40
- struct dma_fence * excl ;
41
- bool prune_fences = false;
42
-
43
- if (flags & I915_WAIT_ALL ) {
44
- struct dma_fence * * shared ;
45
- unsigned int count , i ;
46
- int ret ;
47
-
48
- ret = dma_resv_get_fences (resv , & excl , & count , & shared );
49
- if (ret )
50
- return ret ;
51
-
52
- for (i = 0 ; i < count ; i ++ ) {
53
- timeout = i915_gem_object_wait_fence (shared [i ],
54
- flags , timeout );
55
- if (timeout < 0 )
56
- break ;
57
-
58
- dma_fence_put (shared [i ]);
59
- }
40
+ struct dma_resv_iter cursor ;
41
+ struct dma_fence * fence ;
42
+ long ret = timeout ?: 1 ;
60
43
61
- for (; i < count ; i ++ )
62
- dma_fence_put (shared [i ]);
63
- kfree (shared );
44
+ dma_resv_iter_begin (& cursor , resv , flags & I915_WAIT_ALL );
45
+ dma_resv_for_each_fence_unlocked (& cursor , fence ) {
46
+ ret = i915_gem_object_wait_fence (fence , flags , timeout );
47
+ if (ret <= 0 )
48
+ break ;
64
49
65
- /*
66
- * If both shared fences and an exclusive fence exist,
67
- * then by construction the shared fences must be later
68
- * than the exclusive fence. If we successfully wait for
69
- * all the shared fences, we know that the exclusive fence
70
- * must all be signaled. If all the shared fences are
71
- * signaled, we can prune the array and recover the
72
- * floating references on the fences/requests.
73
- */
74
- prune_fences = count && timeout >= 0 ;
75
- } else {
76
- excl = dma_resv_get_excl_unlocked (resv );
50
+ if (timeout )
51
+ timeout = ret ;
77
52
}
78
-
79
- if (excl && timeout >= 0 )
80
- timeout = i915_gem_object_wait_fence (excl , flags , timeout );
81
-
82
- dma_fence_put (excl );
53
+ dma_resv_iter_end (& cursor );
83
54
84
55
/*
85
56
* Opportunistically prune the fences iff we know they have *all* been
86
57
* signaled.
87
58
*/
88
- if (prune_fences )
59
+ if (timeout > 0 )
89
60
dma_resv_prune (resv );
90
61
91
- return timeout ;
62
+ return ret ;
92
63
}
93
64
94
65
static void fence_set_priority (struct dma_fence * fence ,
@@ -177,7 +148,11 @@ i915_gem_object_wait(struct drm_i915_gem_object *obj,
177
148
178
149
timeout = i915_gem_object_wait_reservation (obj -> base .resv ,
179
150
flags , timeout );
180
- return timeout < 0 ? timeout : 0 ;
151
+
152
+ if (timeout < 0 )
153
+ return timeout ;
154
+
155
+ return !timeout ? - ETIME : 0 ;
181
156
}
182
157
183
158
static inline unsigned long nsecs_to_jiffies_timeout (const u64 n )
0 commit comments