Xe is one of the few users utilizing the return code of
dma_fence_signal() to check whether a fence had already been signaled by
someone else.
To clean up and simplify the dma_fence API, the few kernel users relying
on that behavior shall be ported to an alternative function.
Replace dma_fence_signal_locked() with
dma_fence_check_and_signal_locked().
Signed-off-by: Philipp Stanner <phasta@kernel.org>
---
drivers/gpu/drm/xe/xe_hw_fence.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_hw_fence.c b/drivers/gpu/drm/xe/xe_hw_fence.c
index b2a0c46dfcd4..f6057456e460 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,8 @@ 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_check_and_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 12/1/25 11:50, Philipp Stanner wrote:
> Xe is one of the few users utilizing the return code of
> dma_fence_signal() to check whether a fence had already been signaled by
> someone else.
>
> To clean up and simplify the dma_fence API, the few kernel users relying
> on that behavior shall be ported to an alternative function.
>
> Replace dma_fence_signal_locked() with
> dma_fence_check_and_signal_locked().
>
> Signed-off-by: Philipp Stanner <phasta@kernel.org>
Acked-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/xe/xe_hw_fence.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_hw_fence.c b/drivers/gpu/drm/xe/xe_hw_fence.c
> index b2a0c46dfcd4..f6057456e460 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,8 @@ 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_check_and_signal_locked(&fence->dma));
> dma_fence_put(&fence->dma);
> - XE_WARN_ON(err);
> }
> spin_unlock_irqrestore(&irq->lock, flags);
> dma_fence_end_signalling(tmp);
On Mon, Dec 01, 2025 at 11:50:08AM +0100, Philipp Stanner wrote:
> Xe is one of the few users utilizing the return code of
> dma_fence_signal() to check whether a fence had already been signaled by
> someone else.
>
> To clean up and simplify the dma_fence API, the few kernel users relying
> on that behavior shall be ported to an alternative function.
>
> Replace dma_fence_signal_locked() with
> dma_fence_check_and_signal_locked().
>
> Signed-off-by: Philipp Stanner <phasta@kernel.org>
> ---
> drivers/gpu/drm/xe/xe_hw_fence.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_hw_fence.c b/drivers/gpu/drm/xe/xe_hw_fence.c
> index b2a0c46dfcd4..f6057456e460 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,8 @@ 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_check_and_signal_locked(&fence->dma));
I think XE_WARN_ON can compile out in certain builds. Best to leave warn on logic as is.
Also a little confused by this new helper... Doesn't
dma_fence_signal_locked already check if a fence is already signaled and
bail? Running out the door so I don't have time dig in here, but can you
explain?
Matt
> 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,
> > @@ -93,9 +92,8 @@ 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_check_and_signal_locked(&fence->dma));
>
> I think XE_WARN_ON can compile out in certain builds. Best to leave warn on logic as is.
I don't think XE_WARN_ON compiles out. It should always evaluate
the content, then, depending on the build, it prints debug logs.
Andi
On Tue, Dec 02, 2025 at 09:47:39PM +0100, Andi Shyti wrote:
> Hi Matt,
>
> > > @@ -93,9 +92,8 @@ 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_check_and_signal_locked(&fence->dma));
> >
> > I think XE_WARN_ON can compile out in certain builds. Best to leave warn on logic as is.
>
> I don't think XE_WARN_ON compiles out. It should always evaluate
> the content, then, depending on the build, it prints debug logs.
Ah, ok. I thought XE_WARN_ON was tied to a Kconfig to compile out or
WARN_ON (this is what XE_WARN_ON resolves) compiled out in some kernel
builds. Upon more looking, I guess neither of these is the case.
So I guess this patch is actually:
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Sorry for the noise. Side note, we should probably just XE_WARN_ON too
since this is just WARN_ON.
Matt
>
> Andi
On Tue, Dec 02, 2025 at 01:04:24PM -0800, Matthew Brost wrote:
> On Tue, Dec 02, 2025 at 09:47:39PM +0100, Andi Shyti wrote:
> > Hi Matt,
> >
> > > > @@ -93,9 +92,8 @@ 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_check_and_signal_locked(&fence->dma));
> > >
> > > I think XE_WARN_ON can compile out in certain builds. Best to leave warn on logic as is.
> >
> > I don't think XE_WARN_ON compiles out. It should always evaluate
> > the content, then, depending on the build, it prints debug logs.
>
> Ah, ok. I thought XE_WARN_ON was tied to a Kconfig to compile out or
> WARN_ON (this is what XE_WARN_ON resolves) compiled out in some kernel
> builds. Upon more looking, I guess neither of these is the case.
>
> So I guess this patch is actually:
> Reviewed-by: Matthew Brost <matthew.brost@intel.com>
and
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
if needed to merge through any other tree...
>
> Sorry for the noise. Side note, we should probably just XE_WARN_ON too
> since this is just WARN_ON.
>
> Matt
>
> >
> > Andi
On Mon, 2025-12-01 at 11:38 -0800, Matthew Brost wrote:
> On Mon, Dec 01, 2025 at 11:50:08AM +0100, Philipp Stanner wrote:
> > Xe is one of the few users utilizing the return code of
> > dma_fence_signal() to check whether a fence had already been signaled by
> > someone else.
> >
> > To clean up and simplify the dma_fence API, the few kernel users relying
> > on that behavior shall be ported to an alternative function.
> >
> > Replace dma_fence_signal_locked() with
> > dma_fence_check_and_signal_locked().
> >
> > Signed-off-by: Philipp Stanner <phasta@kernel.org>
> > ---
> > drivers/gpu/drm/xe/xe_hw_fence.c | 4 +---
> > 1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/xe/xe_hw_fence.c b/drivers/gpu/drm/xe/xe_hw_fence.c
> > index b2a0c46dfcd4..f6057456e460 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,8 @@ 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_check_and_signal_locked(&fence->dma));
>
> I think XE_WARN_ON can compile out in certain builds. Best to leave warn on logic as is.
OK, will adjust.
>
> Also a little confused by this new helper... Doesn't
> dma_fence_signal_locked already check if a fence is already signaled and
> bail? Running out the door so I don't have time dig in here, but can you
> explain?
Yes, that is what dma_fence_signal_locked() *currently* does. The
series, however, is about removing that check from the default
interfaces because barely anyone uses dma_fence_signal() et.al.'s
return code. To simplify the interfaces.
The 2-3 users who need the code get this new function. See cover
letter.
P.
>
> Matt
>
> > dma_fence_put(&fence->dma);
> > - XE_WARN_ON(err);
> > }
> > spin_unlock_irqrestore(&irq->lock, flags);
> > dma_fence_end_signalling(tmp);
> > --
> > 2.49.0
> >
On Tue, Dec 02, 2025 at 08:17:17AM +0100, Philipp Stanner wrote:
> On Mon, 2025-12-01 at 11:38 -0800, Matthew Brost wrote:
> > On Mon, Dec 01, 2025 at 11:50:08AM +0100, Philipp Stanner wrote:
> > > Xe is one of the few users utilizing the return code of
> > > dma_fence_signal() to check whether a fence had already been signaled by
> > > someone else.
> > >
> > > To clean up and simplify the dma_fence API, the few kernel users relying
> > > on that behavior shall be ported to an alternative function.
> > >
> > > Replace dma_fence_signal_locked() with
> > > dma_fence_check_and_signal_locked().
> > >
> > > Signed-off-by: Philipp Stanner <phasta@kernel.org>
> > > ---
> > > drivers/gpu/drm/xe/xe_hw_fence.c | 4 +---
> > > 1 file changed, 1 insertion(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/xe/xe_hw_fence.c b/drivers/gpu/drm/xe/xe_hw_fence.c
> > > index b2a0c46dfcd4..f6057456e460 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,8 @@ 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_check_and_signal_locked(&fence->dma));
> >
> > I think XE_WARN_ON can compile out in certain builds. Best to leave warn on logic as is.
>
> OK, will adjust.
>
> >
> > Also a little confused by this new helper... Doesn't
> > dma_fence_signal_locked already check if a fence is already signaled and
> > bail? Running out the door so I don't have time dig in here, but can you
> > explain?
>
> Yes, that is what dma_fence_signal_locked() *currently* does. The
> series, however, is about removing that check from the default
> interfaces because barely anyone uses dma_fence_signal() et.al.'s
> return code. To simplify the interfaces.
> The 2-3 users who need the code get this new function. See cover
> letter.
>
Thanks for explaination. This should work then with XE_WARN_ON refactor.
Matt
>
> P.
>
> >
> > Matt
> >
> > > dma_fence_put(&fence->dma);
> > > - XE_WARN_ON(err);
> > > }
> > > spin_unlock_irqrestore(&irq->lock, flags);
> > > dma_fence_end_signalling(tmp);
> > > --
> > > 2.49.0
> > >
>
© 2016 - 2026 Red Hat, Inc.