[PATCH] only propagate parser errors
Tvrtko Ursulin
tvrtko.ursulin at linux.intel.com
Wed Apr 14 10:37:50 UTC 2021
From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 2 ++
drivers/gpu/drm/i915/i915_sw_fence.c | 8 ++++----
drivers/gpu/drm/i915/i915_sw_fence.h | 8 ++++++++
include/linux/dma-fence.h | 1 +
4 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index 5964e67c7d36..ce2c0a4b98bc 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -2522,6 +2522,8 @@ static int eb_parse_pipeline(struct i915_execbuffer *eb,
}
dma_fence_work_init(&pw->base, &eb_parse_ops);
+ /* Propagate errors for security. */
+ __set_bit(DMA_FENCE_FLAG_PROPAGATE_ERROR, &pw->base.dma.flags);
pw->engine = eb->engine;
pw->batch = eb->batch->vma;
diff --git a/drivers/gpu/drm/i915/i915_sw_fence.c b/drivers/gpu/drm/i915/i915_sw_fence.c
index 2744558f3050..2ee917932ccf 100644
--- a/drivers/gpu/drm/i915/i915_sw_fence.c
+++ b/drivers/gpu/drm/i915/i915_sw_fence.c
@@ -449,7 +449,7 @@ static void dma_i915_sw_fence_wake_timer(struct dma_fence *dma,
fence = xchg(&cb->base.fence, NULL);
if (fence) {
- i915_sw_fence_set_error_once(fence, dma->error);
+ i915_sw_fence_propagate_dma_fence_error(fence, dma);
i915_sw_fence_complete(fence);
}
@@ -480,7 +480,7 @@ int i915_sw_fence_await_dma_fence(struct i915_sw_fence *fence,
might_sleep_if(gfpflags_allow_blocking(gfp));
if (dma_fence_is_signaled(dma)) {
- i915_sw_fence_set_error_once(fence, dma->error);
+ i915_sw_fence_propagate_dma_fence_error(fence, dma);
return 0;
}
@@ -496,7 +496,7 @@ int i915_sw_fence_await_dma_fence(struct i915_sw_fence *fence,
if (ret)
return ret;
- i915_sw_fence_set_error_once(fence, dma->error);
+ i915_sw_fence_propagate_dma_fence_error(fence, dma);
return 0;
}
@@ -548,7 +548,7 @@ int __i915_sw_fence_await_dma_fence(struct i915_sw_fence *fence,
debug_fence_assert(fence);
if (dma_fence_is_signaled(dma)) {
- i915_sw_fence_set_error_once(fence, dma->error);
+ i915_sw_fence_propagate_dma_fence_error(fence, dma);
return 0;
}
diff --git a/drivers/gpu/drm/i915/i915_sw_fence.h b/drivers/gpu/drm/i915/i915_sw_fence.h
index 30a863353ee6..872ef80ebd10 100644
--- a/drivers/gpu/drm/i915/i915_sw_fence.h
+++ b/drivers/gpu/drm/i915/i915_sw_fence.h
@@ -116,4 +116,12 @@ i915_sw_fence_set_error_once(struct i915_sw_fence *fence, int error)
cmpxchg(&fence->error, 0, error);
}
+static inline void
+i915_sw_fence_propagate_dma_fence_error(struct i915_sw_fence *fence,
+ struct dma_fence *dma)
+{
+ if (unlikely(test_bit(DMA_FENCE_FLAG_PROPAGATE_ERROR, &dma->flags)))
+ i915_sw_fence_set_error_once(fence, dma->error);
+}
+
#endif /* _I915_SW_FENCE_H_ */
diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h
index 6ffb4b2c6371..8dabe1650f11 100644
--- a/include/linux/dma-fence.h
+++ b/include/linux/dma-fence.h
@@ -99,6 +99,7 @@ enum dma_fence_flag_bits {
DMA_FENCE_FLAG_SIGNALED_BIT,
DMA_FENCE_FLAG_TIMESTAMP_BIT,
DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
+ DMA_FENCE_FLAG_PROPAGATE_ERROR,
DMA_FENCE_FLAG_USER_BITS, /* must always be last member */
};
--
2.27.0
More information about the Intel-gfx-trybot
mailing list