public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org,
	"Christian König" <christian.koenig@amd.com>,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 5/4] dma-fence: Have dma_fence_signal call signal_locked
Date: Wed, 14 Aug 2019 19:20:53 +0200	[thread overview]
Message-ID: <20190814172053.GM7444@phenom.ffwll.local> (raw)
In-Reply-To: <20190811091523.9382-1-chris@chris-wilson.co.uk>

On Sun, Aug 11, 2019 at 10:15:23AM +0100, Chris Wilson wrote:
> Now that dma_fence_signal always takes the spinlock to flush the
> cb_list, simply take the spinlock and call dma_fence_signal_locked() to
> avoid code repetition.
> 
> Suggested-by: Christian König <christian.koenig@amd.com>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Christian König <christian.koenig@amd.com>

Hm, I think this largely defeats the point of having the lockless signal
enabling trickery in dma_fence. Maybe that part isn't needed by anyone,
but feels like a thing that needs a notch more thought. And if we need it,
maybe a bit more cleanup.

I guess with the addition of more fancy atomic BITs we could avoid this
too ... but no idea whether that's worth the effort.
-Daniel

> ---
>  drivers/dma-buf/dma-fence.c | 32 ++++++++++++--------------------
>  1 file changed, 12 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
> index ab4a456bba04..367b71084d34 100644
> --- a/drivers/dma-buf/dma-fence.c
> +++ b/drivers/dma-buf/dma-fence.c
> @@ -122,26 +122,18 @@ EXPORT_SYMBOL(dma_fence_context_alloc);
>   */
>  int dma_fence_signal_locked(struct dma_fence *fence)
>  {
> -	int ret = 0;
> -
> -	lockdep_assert_held(fence->lock);
> -
>  	if (WARN_ON(!fence))
>  		return -EINVAL;
>  
> -	if (!__dma_fence_signal(fence)) {
> -		ret = -EINVAL;
> +	lockdep_assert_held(fence->lock);
>  
> -		/*
> -		 * we might have raced with the unlocked dma_fence_signal,
> -		 * still run through all callbacks
> -		 */
> -	} else {
> -		__dma_fence_signal__timestamp(fence, ktime_get());
> -	}
> +	if (!__dma_fence_signal(fence))
> +		return -EINVAL;
>  
> +	__dma_fence_signal__timestamp(fence, ktime_get());
>  	__dma_fence_signal__notify(fence);
> -	return ret;
> +
> +	return 0;
>  }
>  EXPORT_SYMBOL(dma_fence_signal_locked);
>  
> @@ -161,19 +153,19 @@ EXPORT_SYMBOL(dma_fence_signal_locked);
>  int dma_fence_signal(struct dma_fence *fence)
>  {
>  	unsigned long flags;
> +	int ret;
>  
>  	if (!fence)
>  		return -EINVAL;
>  
> -	if (!__dma_fence_signal(fence))
> -		return -EINVAL;
> -
> -	__dma_fence_signal__timestamp(fence, ktime_get());
> +	if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
> +		return 0;
>  
>  	spin_lock_irqsave(fence->lock, flags);
> -	__dma_fence_signal__notify(fence);
> +	ret = dma_fence_signal_locked(fence);
>  	spin_unlock_irqrestore(fence->lock, flags);
> -	return 0;
> +
> +	return ret;
>  }
>  EXPORT_SYMBOL(dma_fence_signal);
>  
> -- 
> 2.23.0.rc1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2019-08-14 17:20 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-10 15:34 [PATCH 1/4] dma-fence: Propagate errors to dma-fence-array container Chris Wilson
2019-08-10 15:34 ` [PATCH 2/4] dma-fence: Report the composite sync_file status Chris Wilson
2019-08-12  9:05   ` [Intel-gfx] " Matthew Auld
2019-08-10 15:34 ` [PATCH 3/4] dma-fence: Refactor signaling for manual invocation Chris Wilson
2019-08-12 14:34   ` Koenig, Christian
2019-08-12 14:43     ` Chris Wilson
2019-08-12 14:50       ` Koenig, Christian
2019-08-12 14:53         ` Chris Wilson
2019-08-13  6:59           ` Koenig, Christian
2019-08-13  8:25             ` Chris Wilson
2019-08-13  8:49               ` Koenig, Christian
2019-08-10 15:34 ` [PATCH 4/4] dma-fence: Always execute signal callbacks Chris Wilson
2019-08-11  9:01   ` Koenig, Christian
2019-08-11  9:15     ` [PATCH 5/4] dma-fence: Have dma_fence_signal call signal_locked Chris Wilson
2019-08-11 16:09       ` Koenig, Christian
2019-08-14 17:20       ` Daniel Vetter [this message]
2019-08-15 18:45         ` Chris Wilson
2019-08-15 18:48           ` Daniel Vetter
2019-08-15 19:03             ` Chris Wilson
2019-08-15 19:29               ` Chris Wilson
2019-08-16  7:58                 ` Koenig, Christian
2019-08-10 15:56 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/4] dma-fence: Propagate errors to dma-fence-array container Patchwork
2019-08-10 16:20 ` ✓ Fi.CI.BAT: success " Patchwork
2019-08-11  8:34 ` ✓ Fi.CI.IGT: " Patchwork
2019-08-11  8:58 ` [PATCH 1/4] " Koenig, Christian
2019-08-11 11:56   ` Chris Wilson
2019-08-11  9:21 ` ✗ Fi.CI.BAT: failure for series starting with [1/4] dma-fence: Propagate errors to dma-fence-array container (rev2) Patchwork
2019-08-11 12:02 ` ✗ Fi.CI.BAT: failure for series starting with [1/4] dma-fence: Propagate errors to dma-fence-array container (rev3) Patchwork
2019-08-11 12:09 ` [PATCH v3] dma-fence: Propagate errors to dma-fence-array container Chris Wilson
2019-08-11 12:20 ` ✗ Fi.CI.BAT: failure for series starting with [v3] dma-fence: Propagate errors to dma-fence-array container (rev4) Patchwork
2019-08-11 12:21 ` [PATCH v4] dma-fence: Propagate errors to dma-fence-array container Chris Wilson
2019-08-11 16:08   ` Koenig, Christian
2019-08-11 16:25     ` [PATCH v5] " Chris Wilson
2019-08-11 16:28       ` Koenig, Christian
2019-08-11 19:33   ` [PATCH v4] " kbuild test robot
2019-08-11 13:08 ` ✗ Fi.CI.BAT: failure for series starting with [v4] dma-fence: Propagate errors to dma-fence-array container (rev5) Patchwork
2019-08-11 16:38 ` ✗ Fi.CI.BAT: failure for series starting with [v5] dma-fence: Propagate errors to dma-fence-array container (rev6) Patchwork
2019-08-15 19:22 ` ✗ Fi.CI.BAT: failure for series starting with [v5] dma-fence: Propagate errors to dma-fence-array container (rev7) Patchwork

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=20190814172053.GM7444@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=chris@chris-wilson.co.uk \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /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