[PATCH] drm/i915: Use acquire when checking software fence completion

Gui-Dong Han posted 1 patch 13 hours ago
drivers/gpu/drm/i915/i915_sw_fence.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] drm/i915: Use acquire when checking software fence completion
Posted by Gui-Dong Han 13 hours ago
__i915_sw_fence_wake_up_all() publishes completion with
atomic_set_release(). Pair it with atomic_read_acquire() in
i915_sw_fence_done().

Without acquire ordering, a waiter can observe the completed state while
still reading stale data written before completion, such as fence->error.
This can prevent errors from completed dependencies from being propagated.

i915_sw_fence_signaled() also accepts the state before the completion
callback finishes, and its callers do not consume completion data. It does
not need acquire ordering.

Fixes: e68a139f6bf3 ("drm/i915: Add a sw fence for collecting up dma fences")
Signed-off-by: Gui-Dong Han <hanguidong02@gmail.com>
---
Found by auditing atomic operations used for synchronization.
A similar fix can be found in 6df8e84aa6b5.
---
 drivers/gpu/drm/i915/i915_sw_fence.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_sw_fence.h b/drivers/gpu/drm/i915/i915_sw_fence.h
index f752bfc7c6e1..16563c66c984 100644
--- a/drivers/gpu/drm/i915/i915_sw_fence.h
+++ b/drivers/gpu/drm/i915/i915_sw_fence.h
@@ -105,7 +105,7 @@ static inline bool i915_sw_fence_signaled(const struct i915_sw_fence *fence)
 
 static inline bool i915_sw_fence_done(const struct i915_sw_fence *fence)
 {
-	return atomic_read(&fence->pending) < 0;
+	return atomic_read_acquire(&fence->pending) < 0;
 }
 
 static inline void i915_sw_fence_wait(struct i915_sw_fence *fence)
-- 
2.34.1