The return code of dma_fence_signal() is not really useful as there is
nothing reasonable to do if a fence was already signaled. That return
code shall be removed from the kernel.
Ignore dma_fence_signal()'s return code.
Suggested-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Philipp Stanner <phasta@kernel.org>
---
drivers/gpu/drm/xe/xe_hw_fence.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_hw_fence.c b/drivers/gpu/drm/xe/xe_hw_fence.c
index b2a0c46dfcd4..959b30dde724 100644
--- a/drivers/gpu/drm/xe/xe_hw_fence.c
+++ b/drivers/gpu/drm/xe/xe_hw_fence.c
@@ -85,7 +85,6 @@ void xe_hw_fence_irq_finish(struct xe_hw_fence_irq *irq)
{
struct xe_hw_fence *fence, *next;
unsigned long flags;
- int err;
bool tmp;
if (XE_WARN_ON(!list_empty(&irq->pending))) {
@@ -93,9 +92,9 @@ void xe_hw_fence_irq_finish(struct xe_hw_fence_irq *irq)
spin_lock_irqsave(&irq->lock, flags);
list_for_each_entry_safe(fence, next, &irq->pending, irq_link) {
list_del_init(&fence->irq_link);
- err = dma_fence_signal_locked(&fence->dma);
+ XE_WARN_ON(dma_fence_test_signaled_flag(&fence->dma));
+ dma_fence_signal_locked(&fence->dma);
dma_fence_put(&fence->dma);
- XE_WARN_ON(err);
}
spin_unlock_irqrestore(&irq->lock, flags);
dma_fence_end_signalling(tmp);
--
2.49.0
Hi Philipp,
in the subject /dma_fenc_signal/dma_fence_signal/
> @@ -85,7 +85,6 @@ void xe_hw_fence_irq_finish(struct xe_hw_fence_irq *irq)
> {
> struct xe_hw_fence *fence, *next;
> unsigned long flags;
> - int err;
> bool tmp;
>
> if (XE_WARN_ON(!list_empty(&irq->pending))) {
> @@ -93,9 +92,9 @@ void xe_hw_fence_irq_finish(struct xe_hw_fence_irq *irq)
> spin_lock_irqsave(&irq->lock, flags);
> list_for_each_entry_safe(fence, next, &irq->pending, irq_link) {
> list_del_init(&fence->irq_link);
> - err = dma_fence_signal_locked(&fence->dma);
why don't we do
XE_WARN_ON(dma_fence_signal_locked(..))
instead?
Andi
> + XE_WARN_ON(dma_fence_test_signaled_flag(&fence->dma));
> + dma_fence_signal_locked(&fence->dma);
> dma_fence_put(&fence->dma);
> - XE_WARN_ON(err);
> }
> spin_unlock_irqrestore(&irq->lock, flags);
> dma_fence_end_signalling(tmp);
> --
> 2.49.0
>
On Wed, Nov 26, 2025 at 11:56:57PM +0100, Andi Shyti wrote:
> Hi Philipp,
>
> in the subject /dma_fenc_signal/dma_fence_signal/
>
> > @@ -85,7 +85,6 @@ void xe_hw_fence_irq_finish(struct xe_hw_fence_irq *irq)
> > {
> > struct xe_hw_fence *fence, *next;
> > unsigned long flags;
> > - int err;
> > bool tmp;
> >
> > if (XE_WARN_ON(!list_empty(&irq->pending))) {
> > @@ -93,9 +92,9 @@ void xe_hw_fence_irq_finish(struct xe_hw_fence_irq *irq)
> > spin_lock_irqsave(&irq->lock, flags);
> > list_for_each_entry_safe(fence, next, &irq->pending, irq_link) {
> > list_del_init(&fence->irq_link);
> > - err = dma_fence_signal_locked(&fence->dma);
>
> why don't we do
>
> XE_WARN_ON(dma_fence_signal_locked(..))
>
IIRC the above statement can compile out. So the patch looks correct to me.
Matt
> instead?
>
> Andi
>
> > + XE_WARN_ON(dma_fence_test_signaled_flag(&fence->dma));
> > + dma_fence_signal_locked(&fence->dma);
> > dma_fence_put(&fence->dma);
> > - XE_WARN_ON(err);
> > }
> > spin_unlock_irqrestore(&irq->lock, flags);
> > dma_fence_end_signalling(tmp);
> > --
> > 2.49.0
> >
Hi Matt,
On Wed, Nov 26, 2025 at 03:56:32PM -0800, Matthew Brost wrote:
> On Wed, Nov 26, 2025 at 11:56:57PM +0100, Andi Shyti wrote:
> > > @@ -85,7 +85,6 @@ void xe_hw_fence_irq_finish(struct xe_hw_fence_irq *irq)
> > > @@ -93,9 +92,9 @@ void xe_hw_fence_irq_finish(struct xe_hw_fence_irq *irq)
> > > spin_lock_irqsave(&irq->lock, flags);
> > > list_for_each_entry_safe(fence, next, &irq->pending, irq_link) {
> > > list_del_init(&fence->irq_link);
> > > - err = dma_fence_signal_locked(&fence->dma);
> >
> > why don't we do
> >
> > XE_WARN_ON(dma_fence_signal_locked(..))
> >
>
> IIRC the above statement can compile out. So the patch looks correct to me.
you have defined XE_WARN_ON as WARN_ON that should always
evaluate the content and, depending on the configuration, it
prints the logs or not.
What I don't like from this patch is that we end up checking
twice for the DMA_FENCE_FLAG_SIGNALED_BIT bit.
Thanks,
Andi
On Thu, 2025-11-27 at 14:37 +0100, Andi Shyti wrote:
> Hi Matt,
>
> On Wed, Nov 26, 2025 at 03:56:32PM -0800, Matthew Brost wrote:
> > On Wed, Nov 26, 2025 at 11:56:57PM +0100, Andi Shyti wrote:
> > > > @@ -85,7 +85,6 @@ void xe_hw_fence_irq_finish(struct xe_hw_fence_irq *irq)
> > > > @@ -93,9 +92,9 @@ void xe_hw_fence_irq_finish(struct xe_hw_fence_irq *irq)
> > > > spin_lock_irqsave(&irq->lock, flags);
> > > > list_for_each_entry_safe(fence, next, &irq->pending, irq_link) {
> > > > list_del_init(&fence->irq_link);
> > > > - err = dma_fence_signal_locked(&fence->dma);
> > >
> > > why don't we do
> > >
> > > XE_WARN_ON(dma_fence_signal_locked(..))
because it's impossible because the series is about removing the return
codes from the dma_fence_signal_* functions.
> > >
> >
> > IIRC the above statement can compile out. So the patch looks correct to me.
>
> you have defined XE_WARN_ON as WARN_ON that should always
> evaluate the content and, depending on the configuration, it
> prints the logs or not.
>
> What I don't like from this patch is that we end up checking
> twice for the DMA_FENCE_FLAG_SIGNALED_BIT bit.
Depends on what you mean by "we". The Xe code checks it only once, with
dma_fence_test_signaled_flag(). The dma_fence backend checks it yet
again, as it always does, to avoid signaling a signaled fence.
That's not racy here, however, because the fence lock is already being
held, as evidenced by the current usage of dma_fence_signal_locked().
P.
On Thu, Nov 27, 2025 at 02:51:39PM +0100, Philipp Stanner wrote:
> On Thu, 2025-11-27 at 14:37 +0100, Andi Shyti wrote:
> > On Wed, Nov 26, 2025 at 03:56:32PM -0800, Matthew Brost wrote:
> > > On Wed, Nov 26, 2025 at 11:56:57PM +0100, Andi Shyti wrote:
> > > > > @@ -85,7 +85,6 @@ void xe_hw_fence_irq_finish(struct xe_hw_fence_irq *irq)
> > > > > @@ -93,9 +92,9 @@ void xe_hw_fence_irq_finish(struct xe_hw_fence_irq *irq)
> > > > > spin_lock_irqsave(&irq->lock, flags);
> > > > > list_for_each_entry_safe(fence, next, &irq->pending, irq_link) {
> > > > > list_del_init(&fence->irq_link);
> > > > > - err = dma_fence_signal_locked(&fence->dma);
> > > >
> > > > why don't we do
> > > >
> > > > XE_WARN_ON(dma_fence_signal_locked(..))
>
> because it's impossible because the series is about removing the return
> codes from the dma_fence_signal_* functions.
oh yes, the last patch. Sorry, I went on reviewing and lost the
final target from sight.
> > > >
> > >
> > > IIRC the above statement can compile out. So the patch looks correct to me.
> >
> > you have defined XE_WARN_ON as WARN_ON that should always
> > evaluate the content and, depending on the configuration, it
> > prints the logs or not.
> >
> > What I don't like from this patch is that we end up checking
> > twice for the DMA_FENCE_FLAG_SIGNALED_BIT bit.
>
> Depends on what you mean by "we". The Xe code checks it only once, with
> dma_fence_test_signaled_flag(). The dma_fence backend checks it yet
> again, as it always does, to avoid signaling a signaled fence.
>
> That's not racy here, however, because the fence lock is already being
> held, as evidenced by the current usage of dma_fence_signal_locked().
I haven't said it's racy, I just didn't like that we are testing
for the DMA_FENCE_FLAG_SIGNALED_BIT twice. On the other hand,
with dma_fence_signal_locked() being void, I wouldn't know how to
do it better. So that I guess it's fine.
Andi
On Wed, Nov 26, 2025 at 02:19:12PM +0100, Philipp Stanner wrote:
> The return code of dma_fence_signal() is not really useful as there is
> nothing reasonable to do if a fence was already signaled. That return
> code shall be removed from the kernel.
>
> Ignore dma_fence_signal()'s return code.
>
> Suggested-by: Christian König <christian.koenig@amd.com>
> Signed-off-by: Philipp Stanner <phasta@kernel.org>
> ---
> drivers/gpu/drm/xe/xe_hw_fence.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_hw_fence.c b/drivers/gpu/drm/xe/xe_hw_fence.c
> index b2a0c46dfcd4..959b30dde724 100644
> --- a/drivers/gpu/drm/xe/xe_hw_fence.c
> +++ b/drivers/gpu/drm/xe/xe_hw_fence.c
> @@ -85,7 +85,6 @@ void xe_hw_fence_irq_finish(struct xe_hw_fence_irq *irq)
> {
> struct xe_hw_fence *fence, *next;
> unsigned long flags;
> - int err;
> bool tmp;
>
> if (XE_WARN_ON(!list_empty(&irq->pending))) {
> @@ -93,9 +92,9 @@ void xe_hw_fence_irq_finish(struct xe_hw_fence_irq *irq)
> spin_lock_irqsave(&irq->lock, flags);
> list_for_each_entry_safe(fence, next, &irq->pending, irq_link) {
> list_del_init(&fence->irq_link);
> - err = dma_fence_signal_locked(&fence->dma);
> + XE_WARN_ON(dma_fence_test_signaled_flag(&fence->dma));
> + dma_fence_signal_locked(&fence->dma);
If you also want fix Xe to use dma_fence_test_signaled_flag in all
places where we manually check DMA_FENCE_FLAG_SIGNALED_BIT, I'm not
going to complain. Ofc I can also do this in follow if patch when patch
#1 merges too.
Anyways this patch LGTM:
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> dma_fence_put(&fence->dma);
> - XE_WARN_ON(err);
> }
> spin_unlock_irqrestore(&irq->lock, flags);
> dma_fence_end_signalling(tmp);
> --
> 2.49.0
>
© 2016 - 2025 Red Hat, Inc.