All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Zhou, David(ChunMing)" <David1.Zhou@amd.com>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>
Cc: "daniel.vetter@ffwll.ch" <daniel.vetter@ffwll.ch>
Subject: RE: [PATCH 4/7] drm/syncobj: use only a single stub fence
Date: Fri, 16 Nov 2018 05:54:27 +0000	[thread overview]
Message-ID: <BY1PR12MB05025441CA04E72AA9EF5F61B4DD0@BY1PR12MB0502.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20181115111245.30161-5-christian.koenig@amd.com>



> -----Original Message-----
> From: Christian König <ckoenig.leichtzumerken@gmail.com>
> Sent: Thursday, November 15, 2018 7:13 PM
> To: dri-devel@lists.freedesktop.org
> Cc: chris@chris-wilson.co.uk; daniel.vetter@ffwll.ch; eric@anholt.net; Zhou,
> David(ChunMing) <David1.Zhou@amd.com>
> Subject: [PATCH 4/7] drm/syncobj: use only a single stub fence
> 
> Extract of useful code from the timeline work. Let's use just a single stub
> fence instance instead of allocating a new one all the time.
> 
> Signed-off-by: Chunming Zhou <david1.zhou@amd.com>
> Signed-off-by: Christian König <christian.koenig@amd.com>

It is a good conclusion during previous review, there already is my Sined-off, I cannot give RB on that, need other people take an action.

-David
> ---
>  drivers/gpu/drm/drm_syncobj.c | 67 ++++++++++++++++++++++------------
> ---------
>  1 file changed, 35 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_syncobj.c
> b/drivers/gpu/drm/drm_syncobj.c index f190414511ae..4c45acb326b9
> 100644
> --- a/drivers/gpu/drm/drm_syncobj.c
> +++ b/drivers/gpu/drm/drm_syncobj.c
> @@ -56,10 +56,8 @@
>  #include "drm_internal.h"
>  #include <drm/drm_syncobj.h>
> 
> -struct drm_syncobj_stub_fence {
> -	struct dma_fence base;
> -	spinlock_t lock;
> -};
> +static DEFINE_SPINLOCK(stub_fence_lock); static struct dma_fence
> +stub_fence;
> 
>  static const char *drm_syncobj_stub_fence_get_name(struct dma_fence
> *fence)  { @@ -71,6 +69,25 @@ static const struct dma_fence_ops
> drm_syncobj_stub_fence_ops = {
>  	.get_timeline_name = drm_syncobj_stub_fence_get_name,  };
> 
> +/**
> + * drm_syncobj_get_stub_fence - return a signaled fence
> + *
> + * Return a stub fence which is already signaled.
> + */
> +static struct dma_fence *drm_syncobj_get_stub_fence(void) {
> +	spin_lock(&stub_fence_lock);
> +	if (!stub_fence.ops) {
> +		dma_fence_init(&stub_fence,
> +			       &drm_syncobj_stub_fence_ops,
> +			       &stub_fence_lock,
> +			       0, 0);
> +		dma_fence_signal_locked(&stub_fence);
> +	}
> +	spin_unlock(&stub_fence_lock);
> +
> +	return dma_fence_get(&stub_fence);
> +}
> 
>  /**
>   * drm_syncobj_find - lookup and reference a sync object.
> @@ -190,23 +207,18 @@ void drm_syncobj_replace_fence(struct
> drm_syncobj *syncobj,  }  EXPORT_SYMBOL(drm_syncobj_replace_fence);
> 
> -static int drm_syncobj_assign_null_handle(struct drm_syncobj *syncobj)
> +/**
> + * drm_syncobj_assign_null_handle - assign a stub fence to the sync
> +object
> + * @syncobj: sync object to assign the fence on
> + *
> + * Assign a already signaled stub fence to the sync object.
> + */
> +static void drm_syncobj_assign_null_handle(struct drm_syncobj *syncobj)
>  {
> -	struct drm_syncobj_stub_fence *fence;
> -	fence = kzalloc(sizeof(*fence), GFP_KERNEL);
> -	if (fence == NULL)
> -		return -ENOMEM;
> +	struct dma_fence *fence = drm_syncobj_get_stub_fence();
> 
> -	spin_lock_init(&fence->lock);
> -	dma_fence_init(&fence->base, &drm_syncobj_stub_fence_ops,
> -		       &fence->lock, 0, 0);
> -	dma_fence_signal(&fence->base);
> -
> -	drm_syncobj_replace_fence(syncobj, &fence->base);
> -
> -	dma_fence_put(&fence->base);
> -
> -	return 0;
> +	drm_syncobj_replace_fence(syncobj, fence);
> +	dma_fence_put(fence);
>  }
> 
>  /**
> @@ -273,7 +285,6 @@ EXPORT_SYMBOL(drm_syncobj_free);  int
> drm_syncobj_create(struct drm_syncobj **out_syncobj, uint32_t flags,
>  		       struct dma_fence *fence)
>  {
> -	int ret;
>  	struct drm_syncobj *syncobj;
> 
>  	syncobj = kzalloc(sizeof(struct drm_syncobj), GFP_KERNEL); @@ -
> 284,13 +295,8 @@ int drm_syncobj_create(struct drm_syncobj
> **out_syncobj, uint32_t flags,
>  	INIT_LIST_HEAD(&syncobj->cb_list);
>  	spin_lock_init(&syncobj->lock);
> 
> -	if (flags & DRM_SYNCOBJ_CREATE_SIGNALED) {
> -		ret = drm_syncobj_assign_null_handle(syncobj);
> -		if (ret < 0) {
> -			drm_syncobj_put(syncobj);
> -			return ret;
> -		}
> -	}
> +	if (flags & DRM_SYNCOBJ_CREATE_SIGNALED)
> +		drm_syncobj_assign_null_handle(syncobj);
> 
>  	if (fence)
>  		drm_syncobj_replace_fence(syncobj, fence); @@ -984,11
> +990,8 @@ drm_syncobj_signal_ioctl(struct drm_device *dev, void *data,
>  	if (ret < 0)
>  		return ret;
> 
> -	for (i = 0; i < args->count_handles; i++) {
> -		ret = drm_syncobj_assign_null_handle(syncobjs[i]);
> -		if (ret < 0)
> -			break;
> -	}
> +	for (i = 0; i < args->count_handles; i++)
> +		drm_syncobj_assign_null_handle(syncobjs[i]);
> 
>  	drm_syncobj_array_free(syncobjs, args->count_handles);
> 
> --
> 2.14.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2018-11-16  5:54 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-15 11:12 restart syncobj timeline changes Christian König
2018-11-15 11:12 ` [PATCH 1/7] dma-buf: make fence sequence numbers 64 bit Christian König
2018-11-16  5:26   ` Zhou, David(ChunMing)
2018-11-15 11:12 ` [PATCH 2/7] dma-buf: add new dma_fence_chain container Christian König
2018-11-16  5:51   ` Zhou, David(ChunMing)
2018-11-15 11:12 ` [PATCH 3/7] drm: revert "expand replace_fence to support timeline point v2" Christian König
2018-11-15 11:12 ` [PATCH 4/7] drm/syncobj: use only a single stub fence Christian König
2018-11-16  5:54   ` Zhou, David(ChunMing) [this message]
2018-11-15 11:12 ` [PATCH 5/7] drm/syncobj: move drm_syncobj_cb into drm_syncobj.c Christian König
2018-11-16  5:55   ` Zhou, David(ChunMing)
2018-11-15 11:12 ` [PATCH 6/7] drm/syncobj: add new drm_syncobj_add_point interface Christian König
2018-11-16  6:20   ` Zhou, David(ChunMing)
2018-11-15 11:12 ` [PATCH 7/7] drm/syncobj: use the timeline point in drm_syncobj_find_fence Christian König
2018-11-22  6:52   ` zhoucm1
2018-11-22 11:30     ` Christian König
2018-11-23  2:36       ` zhoucm1
2018-11-23 10:10         ` Koenig, Christian
2018-11-23 10:56           ` zhoucm1
2018-11-23 11:03             ` Christian König
2018-11-23 12:02               ` Koenig, Christian
2018-11-23 12:26                 ` Daniel Vetter
2018-11-23 12:40                   ` Christian König
2018-11-27  7:53                     ` Daniel Vetter
2018-11-23 13:15                 ` Chunming Zhou
2018-11-23 13:27                   ` Koenig, Christian
2018-11-23 13:42                     ` Chunming Zhou
2018-11-23 18:16                       ` Christian König
2018-11-24  8:28                         ` Chunming Zhou

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=BY1PR12MB05025441CA04E72AA9EF5F61B4DD0@BY1PR12MB0502.namprd12.prod.outlook.com \
    --to=david1.zhou@amd.com \
    --cc=ckoenig.leichtzumerken@gmail.com \
    --cc=daniel.vetter@ffwll.ch \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.