Linux virtualization list
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>
Cc: dri-devel@lists.freedesktop.org, virtualization@lists.linux.dev,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [PATCH] dma-buf: improve robustness of dma_fence_unwrap_for_each
Date: Tue, 01 Dec 2026 17:03:28 +0000	[thread overview]
Message-ID: <sashiko-outbox-243781@kernel.org> (raw)
In-Reply-To: <20261201165600.9415-1-christian.koenig@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] dma-buf: build failure in xe_sync_entry_add_deps() after unwrap
  macro change
--

commit aec8a67605f7a8aa3f0d24386ca64c094e746176
Author: Christian König <ckoenig.leichtzumerken@gmail.com>

dma-buf: improve robustness of dma_fence_unwrap_for_each

This commit adds a cleanup function for struct dma_fence_unwrap, embeds
the cursor inside dma_fence_unwrap_for_each() with __cleanup(), and
updates callers to pass two arguments instead of three.

> diff --git a/include/linux/dma-fence-unwrap.h b/include/linux/dma-fence-unwrap.h
> index 7bfacdf79de21..1829e2a655b95 100644
> --- a/include/linux/dma-fence-unwrap.h
> +++ b/include/linux/dma-fence-unwrap.h
> @@ -32,27 +32,33 @@ struct dma_fence_unwrap {
>  	unsigned int index;
>  };
>  
> -struct dma_fence *dma_fence_unwrap_first(struct dma_fence *head,
> -					 struct dma_fence_unwrap *cursor);
> -struct dma_fence *dma_fence_unwrap_next(struct dma_fence_unwrap *cursor);
> +struct dma_fence_unwrap dma_fence_unwrap_first(struct dma_fence *head,
> +					       struct dma_fence **fence);
> +void dma_fence_unwrap_next(struct dma_fence_unwrap *cursor,
> +			   struct dma_fence **fence);
> +void dma_fence_unwrap_cleanup(struct dma_fence_unwrap *cursor);
> +
> +/* Helper for dma_fence_unwrap_for_each(). Internal use only. */
> +#define __dma_fence_unwrap_for_each(fence, cursor, head)	\
> +	for (struct dma_fence_unwrap cursor			\
> +	     __cleanup(dma_fence_unwrap_cleanup)		\
> +	     = dma_fence_unwrap_first(head, &(fence)); fence;	\
> +	     dma_fence_unwrap_next(&cursor, &(fence)))
>  
>  /**
>   * dma_fence_unwrap_for_each - iterate over all fences in containers
>   * @fence: current fence
> - * @cursor: current position inside the containers
>   * @head: starting point for the iterator
>   *
>   * Unwrap dma_fence_chain and dma_fence_array containers and deep dive into all
>   * potential fences in them. If @head is just a normal fence only that one is
>   * returned.
>   */
> -#define dma_fence_unwrap_for_each(fence, cursor, head)			\
> -	for (fence = dma_fence_unwrap_first(head, cursor); fence;	\
> -	     fence = dma_fence_unwrap_next(cursor))
> +#define dma_fence_unwrap_for_each(fence, head) \
> +	__dma_fence_unwrap_for_each(fence, __UNIQUE_ID(cursor), head)

[Severity: High]
Does changing dma_fence_unwrap_for_each() to take two arguments break the
build in xe_sync_entry_add_deps() when CONFIG_DRM_XE is enabled?

drivers/gpu/drm/xe/xe_sync.c:xe_sync_entry_add_deps() {
	struct dma_fence_unwrap iter;
    ...
	dma_fence_unwrap_for_each(fence, &iter, sync->fence) {
		/*
		 * There is no dma_fence_unwrap_stop() helper to drop the
		 * reference the iterator holds, so keep iterating without
		 * doing anything once an error has occurred.
		 */
		if (err || dma_fence_is_signaled(fence))
			continue;

		err = drm_sched_job_add_dependency(&job->drm,
						   dma_fence_get(fence));
	}
    ...
}

xe_sync_entry_add_deps() still passes three arguments to
dma_fence_unwrap_for_each() and retains the manual error-continuation
workaround.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201165600.9415-1-christian.koenig@amd.com?part=1

  reply	other threads:[~2026-12-01 17:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 16:55 [PATCH] dma-buf: improve robustness of dma_fence_unwrap_for_each Christian König
2026-12-01 17:03 ` sashiko-bot [this message]
2026-12-02  8:37 ` Boris Brezillon
2026-12-02  9:01 ` Tvrtko Ursulin
2026-12-02 12:43   ` Christian König

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=sashiko-outbox-243781@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=ckoenig.leichtzumerken@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=eperezma@redhat.com \
    --cc=mst@redhat.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=virtualization@lists.linux.dev \
    /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