File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -103,10 +103,36 @@ static bool dma_fence_array_enable_signaling(struct dma_fence *fence)
103
103
static bool dma_fence_array_signaled (struct dma_fence * fence )
104
104
{
105
105
struct dma_fence_array * array = to_dma_fence_array (fence );
106
+ int num_pending ;
107
+ unsigned int i ;
106
108
107
- if (atomic_read (& array -> num_pending ) > 0 )
109
+ /*
110
+ * We need to read num_pending before checking the enable_signal bit
111
+ * to avoid racing with the enable_signaling() implementation, which
112
+ * might decrement the counter, and cause a partial check.
113
+ * atomic_read_acquire() pairs with atomic_dec_and_test() in
114
+ * dma_fence_array_enable_signaling()
115
+ *
116
+ * The !--num_pending check is here to account for the any_signaled case
117
+ * if we race with enable_signaling(), that means the !num_pending check
118
+ * in the is_signalling_enabled branch might be outdated (num_pending
119
+ * might have been decremented), but that's fine. The user will get the
120
+ * right value when testing again later.
121
+ */
122
+ num_pending = atomic_read_acquire (& array -> num_pending );
123
+ if (test_bit (DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT , & array -> base .flags )) {
124
+ if (num_pending <= 0 )
125
+ goto signal ;
108
126
return false;
127
+ }
128
+
129
+ for (i = 0 ; i < array -> num_fences ; ++ i ) {
130
+ if (dma_fence_is_signaled (array -> fences [i ]) && !-- num_pending )
131
+ goto signal ;
132
+ }
133
+ return false;
109
134
135
+ signal :
110
136
dma_fence_array_clear_pending_error (array );
111
137
return true;
112
138
}
You can’t perform that action at this time.
0 commit comments