dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>
Cc: dri-devel@lists.freedesktop.org, jason@jlekstrand.net
Subject: Re: [PATCH 3/7] dma-buf: cleanup dma-resv shared fence debugging a bit
Date: Wed, 2 Jun 2021 14:41:30 +0200	[thread overview]
Message-ID: <YLd8ekMOcB1r0oVm@phenom.ffwll.local> (raw)
In-Reply-To: <20210602111714.212426-3-christian.koenig@amd.com>

On Wed, Jun 02, 2021 at 01:17:10PM +0200, Christian König wrote:
> Make that a function instead of inline.
> 
> Signed-off-by: Christian König <christian.koenig@amd.com>

Hm yeah pulling that out makes some sense.

> ---
>  drivers/dma-buf/dma-resv.c | 18 ++++++++++++++++++
>  include/linux/dma-resv.h   | 15 +++++++--------
>  2 files changed, 25 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c
> index 87f5d82d992a..6c6195315e9f 100644
> --- a/drivers/dma-buf/dma-resv.c
> +++ b/drivers/dma-buf/dma-resv.c
> @@ -208,6 +208,24 @@ int dma_resv_reserve_shared(struct dma_resv *obj, unsigned int num_fences)
>  }
>  EXPORT_SYMBOL(dma_resv_reserve_shared);
>  
> +#ifdef CONFIG_DEBUG_MUTEXES
> +/**
> + * dma_resv_reset_shared_max - reset shared fences for debugging
> + * @obj: the dma_resv object to reset
> + *
> + * Reset the shared_max to test if drivers do correct slot allocation.

I'd phrase this as

"Reset the number of pre-reserved shared slots to test that drivers do
correct slot allocation using dma_resv_reserve_shared(). See also
&dma_resv_list.shared_max."

That way it's a bit clearer how it all ties together.

The kerneldoc for dma_resv_list is also a bit thin, but another patch for
that. With the kerneldoc polish:

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>


> + */
> +void dma_resv_reset_shared_max(struct dma_resv *obj)
> +{
> +	/* Test shared fence slot reservation */
> +	if (rcu_access_pointer(obj->fence)) {
> +		struct dma_resv_list *fence = dma_resv_get_list(obj);
> +
> +		fence->shared_max = fence->shared_count;
> +	}
> +}
> +#endif
> +
>  /**
>   * dma_resv_add_shared_fence - Add a fence to a shared slot
>   * @obj: the reservation object
> diff --git a/include/linux/dma-resv.h b/include/linux/dma-resv.h
> index d44a77e8a7e3..f32a3d176513 100644
> --- a/include/linux/dma-resv.h
> +++ b/include/linux/dma-resv.h
> @@ -92,6 +92,12 @@ static inline struct dma_resv_list *dma_resv_get_list(struct dma_resv *obj)
>  					 dma_resv_held(obj));
>  }
>  
> +#ifdef CONFIG_DEBUG_MUTEXES
> +void dma_resv_reset_shared_max(struct dma_resv *obj);
> +#else
> +static inline void dma_resv_reset_shared_max(struct dma_resv *obj) {}
> +#endif
> +
>  /**
>   * dma_resv_lock - lock the reservation object
>   * @obj: the reservation object
> @@ -215,14 +221,7 @@ static inline struct ww_acquire_ctx *dma_resv_locking_ctx(struct dma_resv *obj)
>   */
>  static inline void dma_resv_unlock(struct dma_resv *obj)
>  {
> -#ifdef CONFIG_DEBUG_MUTEXES
> -	/* Test shared fence slot reservation */
> -	if (rcu_access_pointer(obj->fence)) {
> -		struct dma_resv_list *fence = dma_resv_get_list(obj);
> -
> -		fence->shared_max = fence->shared_count;
> -	}
> -#endif
> +	dma_resv_reset_shared_max(obj);
>  	ww_mutex_unlock(&obj->lock);
>  }
>  
> -- 
> 2.25.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

  reply	other threads:[~2021-06-02 12:41 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-02 11:17 [PATCH 1/7] dma-buf: fix inconsistent debug print Christian König
2021-06-02 11:17 ` [PATCH 2/7] dma-buf: add SPDX header and fix style in dma-resv.c Christian König
2021-06-02 12:34   ` Daniel Vetter
2021-06-02 12:47     ` Christian König
2021-06-02 12:55       ` Daniel Vetter
2021-06-02 11:17 ` [PATCH 3/7] dma-buf: cleanup dma-resv shared fence debugging a bit Christian König
2021-06-02 12:41   ` Daniel Vetter [this message]
2021-06-02 11:17 ` [PATCH 4/7] dma-buf: rename and cleanup dma_resv_get_excl Christian König
2021-06-02 12:43   ` Daniel Vetter
2021-06-02 20:04     ` Jason Ekstrand
2021-06-02 12:46   ` Daniel Vetter
2021-06-02 11:17 ` [PATCH 5/7] dma-buf: rename and cleanup dma_resv_get_list Christian König
2021-06-02 12:46   ` Daniel Vetter
2021-06-02 20:22   ` Jason Ekstrand
2021-06-06  8:53     ` Christian König
2021-06-07 19:42       ` Jason Ekstrand
2021-06-02 11:17 ` [PATCH 6/7] dma-buf: rename dma_resv_get_excl_rcu to _unlocked Christian König
2021-06-02 12:47   ` Daniel Vetter
2021-06-02 20:25   ` Jason Ekstrand
2021-06-02 11:17 ` [PATCH 7/7] dma-buf: drop the _rcu postfix on function names Christian König
2021-06-02 12:49   ` Daniel Vetter
2021-06-02 20:34   ` Jason Ekstrand
2021-06-06  9:08     ` Christian König
2021-06-02 12:33 ` [PATCH 1/7] dma-buf: fix inconsistent debug print Daniel Vetter
2021-06-02 12:36   ` Christian König
2021-06-02 12:50     ` Daniel Vetter

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=YLd8ekMOcB1r0oVm@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=ckoenig.leichtzumerken@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jason@jlekstrand.net \
    /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