AMD-GFX 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, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH 1/2] dma-buf: cleanup reservation_object_init/fini
Date: Thu, 27 Jun 2019 17:38:15 +0200	[thread overview]
Message-ID: <20190627153815.GL12905@phenom.ffwll.local> (raw)
In-Reply-To: <20190627101813.61430-1-christian.koenig@amd.com>

On Thu, Jun 27, 2019 at 12:18:12PM +0200, Christian König wrote:
> They are not used that often and certainly not in a hot path.
> Make them normal functions instead of an inline.
> 
> Signed-off-by: Christian König <christian.koenig@amd.com>

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

> ---
>  drivers/dma-buf/reservation.c | 45 ++++++++++++++++++++++++++++++++++
>  include/linux/reservation.h   | 46 ++---------------------------------
>  2 files changed, 47 insertions(+), 44 deletions(-)
> 
> diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c
> index 4d32e2c67862..ef710effedfa 100644
> --- a/drivers/dma-buf/reservation.c
> +++ b/drivers/dma-buf/reservation.c
> @@ -55,6 +55,51 @@ EXPORT_SYMBOL(reservation_seqcount_class);
>  const char reservation_seqcount_string[] = "reservation_seqcount";
>  EXPORT_SYMBOL(reservation_seqcount_string);
>  
> +/**
> + * reservation_object_init - initialize a reservation object
> + * @obj: the reservation object
> + */
> +void reservation_object_init(struct reservation_object *obj)
> +{
> +	ww_mutex_init(&obj->lock, &reservation_ww_class);
> +
> +	__seqcount_init(&obj->seq, reservation_seqcount_string,
> +			&reservation_seqcount_class);
> +	RCU_INIT_POINTER(obj->fence, NULL);
> +	RCU_INIT_POINTER(obj->fence_excl, NULL);
> +}
> +EXPORT_SYMBOL(reservation_object_init);
> +
> +/**
> + * reservation_object_fini - destroys a reservation object
> + * @obj: the reservation object
> + */
> +void reservation_object_fini(struct reservation_object *obj)
> +{
> +	int i;
> +	struct reservation_object_list *fobj;
> +	struct dma_fence *excl;
> +
> +	/*
> +	 * This object should be dead and all references must have
> +	 * been released to it, so no need to be protected with rcu.
> +	 */
> +	excl = rcu_dereference_protected(obj->fence_excl, 1);
> +	if (excl)
> +		dma_fence_put(excl);
> +
> +	fobj = rcu_dereference_protected(obj->fence, 1);
> +	if (fobj) {
> +		for (i = 0; i < fobj->shared_count; ++i)
> +			dma_fence_put(rcu_dereference_protected(fobj->shared[i], 1));
> +
> +		kfree(fobj);
> +	}
> +
> +	ww_mutex_destroy(&obj->lock);
> +}
> +EXPORT_SYMBOL(reservation_object_fini);
> +
>  /**
>   * reservation_object_reserve_shared - Reserve space to add shared fences to
>   * a reservation_object.
> diff --git a/include/linux/reservation.h b/include/linux/reservation.h
> index ee750765cc94..f47e8196d039 100644
> --- a/include/linux/reservation.h
> +++ b/include/linux/reservation.h
> @@ -81,50 +81,6 @@ struct reservation_object {
>  #define reservation_object_assert_held(obj) \
>  	lockdep_assert_held(&(obj)->lock.base)
>  
> -/**
> - * reservation_object_init - initialize a reservation object
> - * @obj: the reservation object
> - */
> -static inline void
> -reservation_object_init(struct reservation_object *obj)
> -{
> -	ww_mutex_init(&obj->lock, &reservation_ww_class);
> -
> -	__seqcount_init(&obj->seq, reservation_seqcount_string, &reservation_seqcount_class);
> -	RCU_INIT_POINTER(obj->fence, NULL);
> -	RCU_INIT_POINTER(obj->fence_excl, NULL);
> -}
> -
> -/**
> - * reservation_object_fini - destroys a reservation object
> - * @obj: the reservation object
> - */
> -static inline void
> -reservation_object_fini(struct reservation_object *obj)
> -{
> -	int i;
> -	struct reservation_object_list *fobj;
> -	struct dma_fence *excl;
> -
> -	/*
> -	 * This object should be dead and all references must have
> -	 * been released to it, so no need to be protected with rcu.
> -	 */
> -	excl = rcu_dereference_protected(obj->fence_excl, 1);
> -	if (excl)
> -		dma_fence_put(excl);
> -
> -	fobj = rcu_dereference_protected(obj->fence, 1);
> -	if (fobj) {
> -		for (i = 0; i < fobj->shared_count; ++i)
> -			dma_fence_put(rcu_dereference_protected(fobj->shared[i], 1));
> -
> -		kfree(fobj);
> -	}
> -
> -	ww_mutex_destroy(&obj->lock);
> -}
> -
>  /**
>   * reservation_object_get_list - get the reservation object's
>   * shared fence list, with update-side lock held
> @@ -267,6 +223,8 @@ reservation_object_get_excl_rcu(struct reservation_object *obj)
>  	return fence;
>  }
>  
> +void reservation_object_init(struct reservation_object *obj);
> +void reservation_object_fini(struct reservation_object *obj);
>  int reservation_object_reserve_shared(struct reservation_object *obj,
>  				      unsigned int num_fences);
>  void reservation_object_add_shared_fence(struct reservation_object *obj,
> -- 
> 2.17.1
> 
> _______________________________________________
> 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-06-27 15:38 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-27 10:18 [PATCH 1/2] dma-buf: cleanup reservation_object_init/fini Christian König
2019-06-27 10:18 ` [PATCH 2/2] dma-buf: cleanup shared fence removal Christian König
2019-06-27 10:43   ` Daniel Vetter
2019-06-27 13:19     ` Christian König
     [not found]       ` <f1a792c2-87e0-9aba-c6f1-0374122d025b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-06-27 15:34         ` Daniel Vetter
     [not found]           ` <CAKMK7uFoeugD0ASHm4DRLzq6h3aAvNhE1ODh-bxoH7Lucf1m3w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-06-27 15:48             ` Koenig, Christian
2019-06-27 17:10               ` Daniel Vetter
     [not found]                 ` <20190627171053.GN12905-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2019-06-27 17:20                   ` Koenig, Christian
     [not found]                     ` <4844af2e-fbff-ceb9-c16e-32bb7012559f-5C7GfCeVMHo@public.gmane.org>
2019-06-27 19:57                       ` Daniel Vetter
     [not found]                         ` <CAKMK7uF2Wb_K9MqALs8o_2i+HDhv=JcnHj6t4VAUO80UVpszZQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-06-28  6:32                           ` Koenig, Christian
2019-06-28  7:30                             ` Daniel Vetter
     [not found]                               ` <CAKMK7uFMZLemYkWTyOH_0akUbE53X44Xj7jky90G-jWtwSUicw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-06-28  8:40                                 ` Christian König
2019-06-28  9:41                                   ` Daniel Vetter
     [not found]                                     ` <CAKMK7uG-5e_V1OmWJKyHLGLXhBbex1LCVV7cdWjAgLSk-kTozA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-06-28 10:24                                       ` Koenig, Christian
2019-06-28 14:38                                         ` Daniel Vetter
     [not found]                                           ` <CAKMK7uFDKDhJQ05b6yb8Srz5E=YkzL+PGTZTYZX-b5dmWrwBVQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-06-28 15:21                                             ` Koenig, Christian
     [not found]                                               ` <af333288-9804-30e4-28ef-fda4c18b4a5d-5C7GfCeVMHo@public.gmane.org>
2019-06-28 16:40                                                 ` Daniel Vetter
2019-06-28 17:32                                                   ` Koenig, Christian
     [not found]                                                     ` <060a49d3-7196-1440-db93-4a19c9170f1b-5C7GfCeVMHo@public.gmane.org>
2019-07-02 13:50                                                       ` Daniel Vetter
2019-06-27 15:38 ` Daniel Vetter [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=20190627153815.GL12905@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=ckoenig.leichtzumerken@gmail.com \
    --cc=dri-devel@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