mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Philipp Stanner <phasta@kernel.org>,
	Sumit Semwal <sumit.semwal@linaro.org>,
	Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dma-buf/dma-fence: Remove dma_fence_later()
Date: Thu, 19 Nov 2026 12:18:54 +0100	[thread overview]
Message-ID: <a8b6f088-9c02-47b7-91b7-5f66c098c078@amd.com> (raw)
In-Reply-To: <20261118145026.1755441-2-phasta@kernel.org>

On 11/18/26 15:50, Philipp Stanner wrote:
> dma_fence_later() does not have any in-tree users anymore.
> dma_fence_is_later() is available as an alternative.
> 
> Remove the surplus function.

Ah, yes please :)

> Signed-off-by: Philipp Stanner <phasta@kernel.org>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
> No idea why we have two such functions.
> 
> dma_fence_later() seems to be older, coming from a big-bang commit in
> 2014. Yet Christian added dma_fence_is_later() in 2015.
> 
> *shrug*

Because we had multiple occasions with dma_fence_later() where people were surprised that they got NULL in return resulting in NULL pointer dereference.

I wanted to phase out the old function over time but didn't noticed that this is actually finished.

Thanks,
Christian.

> ---
>  drivers/dma-buf/dma-fence.c |  6 ------
>  include/linux/dma-fence.h   | 26 --------------------------
>  2 files changed, 32 deletions(-)
> 
> diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
> index bd58688b81a7..2f805b788f8f 100644
> --- a/drivers/dma-buf/dma-fence.c
> +++ b/drivers/dma-buf/dma-fence.c
> @@ -1099,9 +1099,6 @@ __dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,
>   * refcount after committing with this fence, but it will need to hold a
>   * refcount again if &dma_fence_ops.enable_signaling gets called.
>   *
> - * context and seqno are used for easy comparison between fences, allowing
> - * to check which fence is later by simply using dma_fence_later().
> - *
>   * External locks are a relic of legacy use cases that needed a shared lock
>   * to serialize signaling when no out-of-order signaling was possible through
>   * &dma_fence_ops.signaled. Drivers have abandoned this concept since the
> @@ -1129,9 +1126,6 @@ EXPORT_SYMBOL(dma_fence_init);
>   * refcount after committing with this fence, but it will need to hold a
>   * refcount again if &dma_fence_ops.enable_signaling gets called.
>   *
> - * Context and seqno are used for easy comparison between fences, allowing
> - * to check which fence is later by simply using dma_fence_later().
> - *
>   * New users MUST NOT use external locks. Check the documentation in
>   * dma_fence_init() to understand the motives behind the legacy use cases.
>   */
> diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h
> index a3fa1341765e..e11e65b916f1 100644
> --- a/include/linux/dma-fence.h
> +++ b/include/linux/dma-fence.h
> @@ -633,32 +633,6 @@ static inline bool dma_fence_is_later_or_same(struct dma_fence *f1,
>  	return f1 == f2 || dma_fence_is_later(f1, f2);
>  }
>  
> -/**
> - * dma_fence_later - return the chronologically later fence
> - * @f1:	the first fence from the same context
> - * @f2:	the second fence from the same context
> - *
> - * Returns NULL if both fences are signaled, otherwise the fence that would be
> - * signaled last. Both fences must be from the same context, since a seqno is
> - * not re-used across contexts.
> - */
> -static inline struct dma_fence *dma_fence_later(struct dma_fence *f1,
> -						struct dma_fence *f2)
> -{
> -	if (WARN_ON(f1->context != f2->context))
> -		return NULL;
> -
> -	/*
> -	 * Can't check just DMA_FENCE_FLAG_SIGNALED_BIT here, it may never
> -	 * have been set if enable_signaling wasn't called, and enabling that
> -	 * here is overkill.
> -	 */
> -	if (dma_fence_is_later(f1, f2))
> -		return dma_fence_is_signaled(f1) ? NULL : f1;
> -	else
> -		return dma_fence_is_signaled(f2) ? NULL : f2;
> -}
> -
>  /**
>   * dma_fence_get_status_locked - returns the status upon completion
>   * @fence: the dma_fence to query


      reply	other threads:[~2026-11-19 11:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 14:50 Philipp Stanner
2026-11-19 11:18 ` Christian König [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a8b6f088-9c02-47b7-91b7-5f66c098c078@amd.com \
    --to=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=phasta@kernel.org \
    --cc=sumit.semwal@linaro.org \
    --cc=tvrtko.ursulin@igalia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®