From: zhoucm1 <zhoucm1-5C7GfCeVMHo@public.gmane.org>
To: "Christian König" <christian.koenig-5C7GfCeVMHo@public.gmane.org>,
"Chunming Zhou" <david1.zhou-5C7GfCeVMHo@public.gmane.org>,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: Dave Airlie <airlied-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Daniel Rakos <Daniel.Rakos-5C7GfCeVMHo@public.gmane.org>,
Daniel Vetter <daniel-/w4YWyX8dFk@public.gmane.org>,
amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH 1/4] [RFC]drm: add syncobj timeline support v6
Date: Wed, 19 Sep 2018 15:32:02 +0800 [thread overview]
Message-ID: <4c5ed732-ebfb-4e4b-66ce-65b85b200928@amd.com> (raw)
In-Reply-To: <04e91247-387c-ed5d-0793-9eb1d37d12bd-5C7GfCeVMHo@public.gmane.org>
On 2018年09月19日 15:18, Christian König wrote:
> Am 19.09.2018 um 06:26 schrieb Chunming Zhou:
[snip]
>> *fence = NULL;
>> drm_syncobj_add_callback_locked(syncobj, cb, func);
>> @@ -164,6 +177,153 @@ void drm_syncobj_remove_callback(struct
>> drm_syncobj *syncobj,
>> spin_unlock(&syncobj->lock);
>> }
>> +static void drm_syncobj_timeline_init(struct drm_syncobj *syncobj)
>
> We still have _timeline_ in the name here.
the func is relevant to timeline members, or which name is proper?
>
>> +{
>> + spin_lock(&syncobj->lock);
>> + syncobj->timeline_context = dma_fence_context_alloc(1);
[snip]
>> +}
>> +
>> +int drm_syncobj_lookup_fence(struct drm_syncobj *syncobj, u64 point,
>> + struct dma_fence **fence) {
>> +
>> + return drm_syncobj_search_fence(syncobj, point,
>> + DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT,
>
> I still have a bad feeling setting that flag as default cause it might
> change the behavior for the UAPI.
>
> Maybe export drm_syncobj_search_fence directly? E.g. with the flags
> parameter.
previous v5 indeed do this, you let me wrap it, need change back?
Regards,
David Zhou
>
> Regards,
> Christian.
>
>> + fence);
>> +}
>> +EXPORT_SYMBOL(drm_syncobj_lookup_fence);
>> +
>> /**
>> * drm_syncobj_find_fence - lookup and reference the fence in a
>> sync object
>> * @file_private: drm file private pointer
>> @@ -228,7 +443,7 @@ static int drm_syncobj_assign_null_handle(struct
>> drm_syncobj *syncobj)
>> * @fence: out parameter for the fence
>> *
>> * This is just a convenience function that combines
>> drm_syncobj_find() and
>> - * drm_syncobj_fence_get().
>> + * drm_syncobj_lookup_fence().
>> *
>> * Returns 0 on success or a negative error value on failure. On
>> success @fence
>> * contains a reference to the fence, which must be released by
>> calling
>> @@ -236,18 +451,11 @@ static int
>> drm_syncobj_assign_null_handle(struct drm_syncobj *syncobj)
>> */
>> int drm_syncobj_find_fence(struct drm_file *file_private,
>> u32 handle, u64 point,
>> - struct dma_fence **fence)
>> -{
>> + struct dma_fence **fence) {
>> struct drm_syncobj *syncobj = drm_syncobj_find(file_private,
>> handle);
>> - int ret = 0;
>> -
>> - if (!syncobj)
>> - return -ENOENT;
>> + int ret;
>> - *fence = drm_syncobj_fence_get(syncobj);
>> - if (!*fence) {
>> - ret = -EINVAL;
>> - }
>> + ret = drm_syncobj_lookup_fence(syncobj, point, fence);
>> drm_syncobj_put(syncobj);
>> return ret;
>> }
>> @@ -264,7 +472,7 @@ void drm_syncobj_free(struct kref *kref)
>> struct drm_syncobj *syncobj = container_of(kref,
>> struct drm_syncobj,
>> refcount);
>> - drm_syncobj_replace_fence(syncobj, 0, NULL);
>> + drm_syncobj_timeline_fini(syncobj);
>> kfree(syncobj);
>> }
>> EXPORT_SYMBOL(drm_syncobj_free);
>> @@ -294,6 +502,11 @@ int drm_syncobj_create(struct drm_syncobj
>> **out_syncobj, uint32_t flags,
>> kref_init(&syncobj->refcount);
>> INIT_LIST_HEAD(&syncobj->cb_list);
>> spin_lock_init(&syncobj->lock);
>> + if (flags & DRM_SYNCOBJ_CREATE_TYPE_TIMELINE)
>> + syncobj->type = DRM_SYNCOBJ_TYPE_TIMELINE;
>> + else
>> + syncobj->type = DRM_SYNCOBJ_TYPE_INDIVIDUAL;
>> + drm_syncobj_timeline_init(syncobj);
>> if (flags & DRM_SYNCOBJ_CREATE_SIGNALED) {
>> ret = drm_syncobj_assign_null_handle(syncobj);
>> @@ -576,7 +789,8 @@ drm_syncobj_create_ioctl(struct drm_device *dev,
>> void *data,
>> return -ENODEV;
>> /* no valid flags yet */
>> - if (args->flags & ~DRM_SYNCOBJ_CREATE_SIGNALED)
>> + if (args->flags & ~(DRM_SYNCOBJ_CREATE_SIGNALED |
>> + DRM_SYNCOBJ_CREATE_TYPE_TIMELINE))
>> return -EINVAL;
>> return drm_syncobj_create_as_handle(file_private,
>> @@ -669,9 +883,8 @@ static void syncobj_wait_syncobj_func(struct
>> drm_syncobj *syncobj,
>> struct syncobj_wait_entry *wait =
>> container_of(cb, struct syncobj_wait_entry, syncobj_cb);
>> - /* This happens inside the syncobj lock */
>> - wait->fence =
>> dma_fence_get(rcu_dereference_protected(syncobj->fence,
>> - lockdep_is_held(&syncobj->lock)));
>> + drm_syncobj_search_fence(syncobj, 0, 0, &wait->fence);
>> +
>> wake_up_process(wait->task);
>> }
>> @@ -698,7 +911,8 @@ static signed long
>> drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,
>> signaled_count = 0;
>> for (i = 0; i < count; ++i) {
>> entries[i].task = current;
>> - entries[i].fence = drm_syncobj_fence_get(syncobjs[i]);
>> + ret = drm_syncobj_search_fence(syncobjs[i], 0, 0,
>> + &entries[i].fence);
>> if (!entries[i].fence) {
>> if (flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT) {
>> continue;
>> @@ -970,12 +1184,19 @@ drm_syncobj_reset_ioctl(struct drm_device
>> *dev, void *data,
>> if (ret < 0)
>> return ret;
>> - for (i = 0; i < args->count_handles; i++)
>> - drm_syncobj_replace_fence(syncobjs[i], 0, NULL);
>> -
>> + for (i = 0; i < args->count_handles; i++) {
>> + if (syncobjs[i]->type == DRM_SYNCOBJ_TYPE_TIMELINE) {
>> + DRM_ERROR("timeline syncobj cannot reset!\n");
>> + ret = -EINVAL;
>> + goto out;
>> + }
>> + drm_syncobj_timeline_fini(syncobjs[i]);
>> + drm_syncobj_timeline_init(syncobjs[i]);
>> + }
>> +out:
>> drm_syncobj_array_free(syncobjs, args->count_handles);
>> - return 0;
>> + return ret;
>> }
>> int
>> diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
>> b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
>> index 0a8d2d64f380..a040fa3281df 100644
>> --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
>> +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
>> @@ -2137,7 +2137,7 @@ await_fence_array(struct i915_execbuffer *eb,
>> if (!(flags & I915_EXEC_FENCE_WAIT))
>> continue;
>> - fence = drm_syncobj_fence_get(syncobj);
>> + drm_syncobj_lookup_fence(syncobj, 0, &fence);
>> if (!fence)
>> return -EINVAL;
>> diff --git a/include/drm/drm_syncobj.h b/include/drm/drm_syncobj.h
>> index 425432b85a87..6dac479fedfe 100644
>> --- a/include/drm/drm_syncobj.h
>> +++ b/include/drm/drm_syncobj.h
>> @@ -30,6 +30,11 @@
>> struct drm_syncobj_cb;
>> +enum drm_syncobj_type {
>> + DRM_SYNCOBJ_TYPE_INDIVIDUAL,
>> + DRM_SYNCOBJ_TYPE_TIMELINE
>> +};
>> +
>> /**
>> * struct drm_syncobj - sync object.
>> *
>> @@ -41,19 +46,36 @@ struct drm_syncobj {
>> */
>> struct kref refcount;
>> /**
>> - * @fence:
>> - * NULL or a pointer to the fence bound to this object.
>> - *
>> - * This field should not be used directly. Use
>> drm_syncobj_fence_get()
>> - * and drm_syncobj_replace_fence() instead.
>> + * @type: indicate syncobj type
>> + */
>> + enum drm_syncobj_type type;
>> + /**
>> + * @wq: wait signal operation work queue
>> + */
>> + wait_queue_head_t wq;
>> + /**
>> + * @timeline_context: fence context used by timeline
>> */
>> - struct dma_fence __rcu *fence;
>> + u64 timeline_context;
>> /**
>> - * @cb_list: List of callbacks to call when the &fence gets
>> replaced.
>> + * @timeline: syncobj timeline value, which indicates point is
>> signaled.
>> */
>> + u64 timeline;
>> + /**
>> + * @signal_point: which indicates the latest signaler point.
>> + */
>> + u64 signal_point;
>> + /**
>> + * @signal_pt_list: signaler point list.
>> + */
>> + struct list_head signal_pt_list;
>> +
>> + /**
>> + * @cb_list: List of callbacks to call when the &fence gets
>> replaced.
>> + */
>> struct list_head cb_list;
>> /**
>> - * @lock: Protects &cb_list and write-locks &fence.
>> + * @lock: Protects syncobj list and write-locks &fence.
>> */
>> spinlock_t lock;
>> /**
>> @@ -68,7 +90,7 @@ typedef void (*drm_syncobj_func_t)(struct
>> drm_syncobj *syncobj,
>> /**
>> * struct drm_syncobj_cb - callback for drm_syncobj_add_callback
>> * @node: used by drm_syncob_add_callback to append this struct to
>> - * &drm_syncobj.cb_list
>> + * &drm_syncobj.cb_list
>> * @func: drm_syncobj_func_t to call
>> *
>> * This struct will be initialized by drm_syncobj_add_callback,
>> additional
>> @@ -106,29 +128,6 @@ drm_syncobj_put(struct drm_syncobj *obj)
>> kref_put(&obj->refcount, drm_syncobj_free);
>> }
>> -/**
>> - * drm_syncobj_fence_get - get a reference to a fence in a sync object
>> - * @syncobj: sync object.
>> - *
>> - * This acquires additional reference to &drm_syncobj.fence
>> contained in @obj,
>> - * if not NULL. It is illegal to call this without already holding a
>> reference.
>> - * No locks required.
>> - *
>> - * Returns:
>> - * Either the fence of @obj or NULL if there's none.
>> - */
>> -static inline struct dma_fence *
>> -drm_syncobj_fence_get(struct drm_syncobj *syncobj)
>> -{
>> - struct dma_fence *fence;
>> -
>> - rcu_read_lock();
>> - fence = dma_fence_get_rcu_safe(&syncobj->fence);
>> - rcu_read_unlock();
>> -
>> - return fence;
>> -}
>> -
>> struct drm_syncobj *drm_syncobj_find(struct drm_file *file_private,
>> u32 handle);
>> void drm_syncobj_replace_fence(struct drm_syncobj *syncobj, u64 point,
>> @@ -142,5 +141,7 @@ int drm_syncobj_create(struct drm_syncobj
>> **out_syncobj, uint32_t flags,
>> int drm_syncobj_get_handle(struct drm_file *file_private,
>> struct drm_syncobj *syncobj, u32 *handle);
>> int drm_syncobj_get_fd(struct drm_syncobj *syncobj, int *p_fd);
>> +int drm_syncobj_lookup_fence(struct drm_syncobj *syncobj, u64 point,
>> + struct dma_fence **fence);
>> #endif
>> diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
>> index 300f336633f2..cebdb2541eb7 100644
>> --- a/include/uapi/drm/drm.h
>> +++ b/include/uapi/drm/drm.h
>> @@ -717,6 +717,7 @@ struct drm_prime_handle {
>> struct drm_syncobj_create {
>> __u32 handle;
>> #define DRM_SYNCOBJ_CREATE_SIGNALED (1 << 0)
>> +#define DRM_SYNCOBJ_CREATE_TYPE_TIMELINE (1 << 1)
>> __u32 flags;
>> };
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2018-09-19 7:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-19 4:26 [PATCH 1/4] [RFC]drm: add syncobj timeline support v6 Chunming Zhou
[not found] ` <20180919042659.3769-1-david1.zhou-5C7GfCeVMHo@public.gmane.org>
2018-09-19 4:26 ` [PATCH 2/4] drm: add support of syncobj timeline point wait v2 Chunming Zhou
2018-09-19 4:26 ` [PATCH 3/4] drm: add timeline syncobj payload query ioctl Chunming Zhou
2018-09-19 4:26 ` [PATCH 4/4] drm/amdgpu: add timeline support in amdgpu CS Chunming Zhou
2018-09-19 7:18 ` [PATCH 1/4] [RFC]drm: add syncobj timeline support v6 Christian König
[not found] ` <04e91247-387c-ed5d-0793-9eb1d37d12bd-5C7GfCeVMHo@public.gmane.org>
2018-09-19 7:32 ` zhoucm1 [this message]
2018-09-19 7:32 ` zhoucm1
[not found] ` <392512eb-271d-3d16-263b-f2429dedfffc-5C7GfCeVMHo@public.gmane.org>
2018-09-19 7:45 ` Christian König
[not found] ` <9bdce2dd-2129-3ed9-56f0-db4b14005194-5C7GfCeVMHo@public.gmane.org>
2018-09-19 8:03 ` Zhou, David(ChunMing)
[not found] ` <BY1PR12MB05021AF8F3FD552CC133BCC6B41C0-PicGAnIBOobrCwm+z9iKNgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-09-19 8:07 ` Christian König
[not found] ` <3ed55b7b-5a61-5001-e767-96039dc07bbe-5C7GfCeVMHo@public.gmane.org>
2018-09-19 9:00 ` zhoucm1
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=4c5ed732-ebfb-4e4b-66ce-65b85b200928@amd.com \
--to=zhoucm1-5c7gfcevmho@public.gmane.org \
--cc=Daniel.Rakos-5C7GfCeVMHo@public.gmane.org \
--cc=airlied-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=christian.koenig-5C7GfCeVMHo@public.gmane.org \
--cc=daniel-/w4YWyX8dFk@public.gmane.org \
--cc=david1.zhou-5C7GfCeVMHo@public.gmane.org \
--cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.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