De-stage android's sync framework
Subsystems (4)
cover De-stage android's sync framework
From: Gustavo Padovan <[email protected]>
This patch series de-stage the sync framework, and in order to accomplish that a bunch of cleanups/improvements on the sync and fence were made.
The sync framework contained some abstractions around struct fence and those were removed in the de-staging process among other changes:
Userspace visible changes
-------------------------
* The sw_sync file was moved from /dev/sw_sync to <debugfs>/sync/sw_sync. No other change.
Kernel API changes
------------------
* struct sync_timeline is now struct fence_timeline
* sync_timeline_ops is now fence_timeline_ops and they now carry struct fence as parameter instead of struct sync_pt
* a .cleanup() fence op was added to allow sync_fence to run a cleanup when the fence_timeline is destroyed
* added fence_add_used_data() to pass a private point to struct fence. This pointer is sent back on the .cleanup op.
* The sync timeline function were moved to be fence_timeline functions:
- sync_timeline_create() -> fence_timeline_create()
- sync_timeline_get() -> fence_timeline_get()
- sync_timeline_put() -> fence_timeline_put()
- sync_timeline_destroy() -> fence_timeline_destroy()
- sync_timeline_signal() -> fence_timeline_signal()
* sync_pt_create() was replaced be fence_create_on_timeline()
Internal changes
----------------
* fence_timeline_ops was removed in favor of direct use fence_ops
* fence default functions were created for fence_ops
* removed structs sync_pt, sw_sync_timeline and sw_sync_pt
Gustavo Padovan (29):
staging/android: fix sync framework documentation staging/android: fix checkpatch warning
staging/android: rename sync_fence_release staging/android: rename 'android_fence' to 'sync_fence' staging/android: remove not used sync_timeline ops staging/android: create a 'sync' dir for debugfs information staging/android: move sw_sync file to debugfs file staging/android: Remove WARN_ON_ONCE when releasing sync_fence staging/android: rename struct sync_fence's variables to 'sync_fence' staging/android: rename 'sync_pt' to 'fence' in struct sync_fence_cb dma-buf/fence: move sync_timeline to fence_timeline staging/android: remove struct sync_pt
dma-buf/fence: create fence_default_enable_signaling() dma-buf/fence: create fence_default_release() dma-buf/fence: create fence_default_get_driver_name() dma-buf/fence: create fence_default_timeline_name() dma-buf/fence: store last signaled value on fence timeline dma-buf/fence: create default .fence_value_str() and
.timeline_value_str()
dma-buf/fence: create fence_default_fill_driver_data() dma-buf/fence: remove fence_timeline_ops
dma-buf/fence: add fence_create_on_timeline() staging/android: remove sync_pt_create()
staging/android: remove sw_sync_timeline and sw_sync_pt dma-buf/fence: add debug to fence timeline
dma-buf/fence: remove unused var from fence_timeline_signal() dma-buf/fence: remove pointless fence_timeline_signal at destroy phase dma-buf/fence: add .cleanup() callback
staging/android: use .cleanup() to interrupt any sync_fence waiter dma-buf/fence: de-stage sync framework
drivers/Kconfig | 2 +
drivers/dma-buf/Kconfig | 22 +
drivers/dma-buf/Makefile | 4 +-
drivers/dma-buf/fence.c | 333 ++++++++++
drivers/dma-buf/fence_debug.c | 128 ++++
drivers/dma-buf/sw_sync.c | 65 ++
drivers/dma-buf/sync.c | 527 +++++++++++++++
drivers/dma-buf/sync_debug.c | 279 ++++++++
drivers/staging/android/Kconfig | 28 -
drivers/staging/android/Makefile | 2 -
drivers/staging/android/sw_sync.c | 260 --------
drivers/staging/android/sync.c | 732 ---------------------
drivers/staging/android/sync.h | 366 -----------
drivers/staging/android/sync_debug.c | 256 -------
include/linux/fence.h | 77 +++
.../staging/android => include/linux}/sw_sync.h | 30 +-
include/linux/sync.h | 201 ++++++
include/trace/events/fence.h | 18 +
.../android/trace => include/trace/events}/sync.h | 41 +-
.../android/uapi => include/uapi/linux}/sw_sync.h | 0
.../android/uapi => include/uapi/linux}/sync.h | 0
21 files changed, 1672 insertions(+), 1699 deletions(-)
create mode 100644 drivers/dma-buf/Kconfig
create mode 100644 drivers/dma-buf/fence_debug.c
create mode 100644 drivers/dma-buf/sw_sync.c
create mode 100644 drivers/dma-buf/sync.c
create mode 100644 drivers/dma-buf/sync_debug.c
delete mode 100644 drivers/staging/android/sw_sync.c
delete mode 100644 drivers/staging/android/sync.c
delete mode 100644 drivers/staging/android/sync.h
delete mode 100644 drivers/staging/android/sync_debug.c
rename {drivers/staging/android => include/linux}/sw_sync.h (55%)
create mode 100644 include/linux/sync.h
rename {drivers/staging/android/trace => include/trace/events}/sync.h (53%)
rename {drivers/staging/android/uapi => include/uapi/linux}/sw_sync.h (100%)
rename {drivers/staging/android/uapi => include/uapi/linux}/sync.h (100%)Signature · 1 line
2.5.0
RFC 1/29 staging/android: fix sync framework documentation
From: Gustavo Padovan <[email protected]>
Updates comments about functions and structures.
--- drivers/staging/android/sync.h | 45 ++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 24 deletions(-)
drivers/staging/android/sync.h +21 -24
@@ -110,15 +110,9 @@ struct sync_timeline {/** * struct sync_pt - sync point -* @fence: base fence class +* @base: base fence class * @child_list: membership in sync_timeline.child_list_head * @active_list: membership in sync_timeline.active_list_head -* @signaled_list: membership in temporary signaled_list on stack -* @fence: sync_fence to which the sync_pt belongs -* @pt_list: membership in sync_fence.pt_list_head -* @status: 1: signaled, 0:active, <0: error -* @timestamp: time which sync_pt status transitioned from active to -* signaled or error. */ struct sync_pt {struct fence base;
@@ -144,12 +138,11 @@ struct sync_fence_cb {* @file: file representing this fence * @kref: reference count on fence. * @name: name of sync_fence. Useful for debugging -* @pt_list_head: list of sync_pts in the fence. immutable once fence -* is created -* @status: 0: signaled, >0:active, <0: error -* -* @wq: wait queue for fence signaling * @sync_fence_list: membership in global fence list +* @num_fences number of sync_pts in the fence +* @wq: wait queue for fence signaling +* @status: 0: signaled, >0:active, <0: error +* @cbs: sync_pts callback information */ struct sync_fence {struct file *file;
@@ -172,9 +165,8 @@ typedef void (*sync_callback_t)(struct sync_fence *fence,/** * struct sync_fence_waiter - metadata for asynchronous waiter on a fence -* @waiter_list: membership in sync_fence.waiter_list_head +* @work: wait_queue for the fence waiter * @callback: function pointer to call when fence signals -* @callback_data: pointer to pass to @callback */ struct sync_fence_waiter {wait_queue_t work;
@@ -200,7 +192,8 @@ static inline void sync_fence_waiter_init(struct sync_fence_waiter *waiter,* * Creates a new sync_timeline which will use the implementation specified by * @ops. @size bytes will be allocated allowing for implementation specific -* data to be kept after the generic sync_timeline struct. +* data to be kept after the generic sync_timeline struct. Returns the +* sync_timeline object or NULL in case of error. */ struct sync_timeline *sync_timeline_create (const struct sync_timeline_ops *ops,int size,const char *name);
@@ -231,7 +224,8 @@ void sync_timeline_signal(struct sync_timeline *obj);* * Creates a new sync_pt as a child of @parent. @size bytes will be * allocated allowing for implementation specific data to be kept after -* the generic sync_timeline struct. +* the generic sync_timeline struct. Returns the sync_pt object or +* NULL in case of error. */ struct sync_pt *sync_pt_create (struct sync_timeline *parent,int size);
@@ -275,7 +269,8 @@ struct sync_fence *sync_fence_create_dma(const char *name, struct fence *pt);* @b: fence b * * Creates a new fence which contains copies of all the sync_pts in both -* @a and @b. @a and @b remain valid, independent fences. +* @a and @b. @a and @b remain valid, independent fences. Returns the +* new merged fence or NULL in case of error. */ struct sync_fence *sync_fence_merge (const char *name,struct sync_fence *a,struct sync_fence *b);
@@ -285,7 +280,7 @@ struct sync_fence *sync_fence_merge(const char *name,* @fd: fd referencing a fence * * Ensures @fd references a valid fence, increments the refcount of the backing -* file, and returns the fence. +* file, and returns the fence. Returns the fence or NULL in case of error. */ struct sync_fence *sync_fence_fdget (int fd);
@@ -313,10 +308,10 @@ void sync_fence_install(struct sync_fence *fence, int fd);* @fence: fence to wait on * @waiter: waiter callback struck * -* Returns 1 if @fence has already signaled. -* * Registers a callback to be called when @fence signals or has an error. * @waiter should be initialized with sync_fence_waiter_init(). +* +* Returns 1 if @fence has already signaled, 0 if not or <0 if error. */ int sync_fence_wait_async (struct sync_fence *fence,struct sync_fence_waiter *waiter);
@@ -326,11 +321,11 @@ int sync_fence_wait_async(struct sync_fence *fence,* @fence: fence to wait on * @waiter: waiter callback struck * -* returns 0 if waiter was removed from fence's async waiter list. -* returns -ENOENT if waiter was not found on fence's async waiter list. -* * Cancels a previously registered async wait. Will fail gracefully if * @waiter was never registered or if @fence has already signaled @waiter. +* +* Returns 0 if waiter was removed from fence's async waiter list. +* Returns -ENOENT if waiter was not found on fence's async waiter list. */ int sync_fence_cancel_async (struct sync_fence *fence,struct sync_fence_waiter *waiter);
@@ -341,7 +336,9 @@ int sync_fence_cancel_async(struct sync_fence *fence,* @tiemout: timeout in ms * * Wait for @fence to be signaled or have an error. Waits indefinitely -* if @timeout < 0 +* if @timeout < 0. +* +* Returns 0 if fence signaled, > 0 if it is still active and <0 on error */ int sync_fence_wait (struct sync_fence *fence,long timeout);
Signature · 1 line
2.5.0
RFC 17/29 dma-buf/fence: store last signaled value on fence timeline
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
Now fence timeline is aware of the last signaled fence, as it receives the increment to the current value in fence_timeline_signal().
That allow us to create a fence_default_signaled() using timeline->value and fence->seqno in the comparison.
--- drivers/dma-buf/fence.c | 21 +++++++++++++++++++-- drivers/staging/android/sw_sync.c | 16 ++-------------- drivers/staging/android/sync.c | 17 +++-------------- drivers/staging/android/sync.h | 3 ++- include/linux/fence.h | 12 +++--------- 5 files changed, 29 insertions(+), 40 deletions(-)
drivers/dma-buf/fence.c +19 -2
@@ -149,7 +149,7 @@ void fence_timeline_destroy(struct fence_timeline *timeline)/* * signal any children that their parent is going away. */ -fence_timeline_signal (timeline); +fence_timeline_signal (timeline,0 );fence_timeline_put (timeline); }EXPORT_SYMBOL (fence_timeline_destroy);
@@ -157,11 +157,12 @@ EXPORT_SYMBOL(fence_timeline_destroy);/** * fence_timeline_signal - signal fences on a fence_timeline * @timeline [in] the fence_timeline to signal fences +* @inc [in[ num to increment on timeline->value * * This function signal fences on a given timeline and remove * those from the active_list. */ -void fence_timeline_signal (struct fence_timeline *timeline) +void fence_timeline_signal (struct fence_timeline *timeline,unsigned int inc) {unsigned long flags;LIST_HEAD (signaled_pts);
@@ -169,6 +170,8 @@ void fence_timeline_signal(struct fence_timeline *timeline)spin_lock_irqsave (&timeline->lock, flags); + timeline->value += inc; +list_for_each_entry_safe (fence, next, &timeline->active_list_head, active_list) {if (fence_is_signaled_locked (fence))
@@ -470,6 +473,20 @@ const char *fence_default_get_timeline_name(struct fence *fence)EXPORT_SYMBOL (fence_default_get_timeline_name);/** +* fence_default_signaled - default .signaled fence ops +* @fence: [in] the fence to check if signaled or not +* +* This functions checks if a fence was signaled or not. +*/ +bool fence_default_signaled (struct fence *fence) +{ +struct fence_timeline *timeline =fence_parent (fence); + +return (fence->seqno > timeline->value) ? false : true; +} +EXPORT_SYMBOL (fence_default_signaled); + +/** * fence_default_enable_signaling - default op for .enable_signaling * @fence: [in] the fence to enable signaling *
drivers/staging/android/sw_sync.c +2 -14
@@ -30,7 +30,7 @@ struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value)struct sw_sync_pt *pt; pt = (struct sw_sync_pt *) -sync_pt_create (&obj->obj,sizeof (struct sw_sync_pt )); +sync_pt_create (&obj->obj,sizeof (struct sw_sync_pt ), value); pt->value = value;
@@ -38,15 +38,6 @@ struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value) }EXPORT_SYMBOL (sw_sync_pt_create); -static int sw_sync_fence_has_signaled (struct fence *fence) -{ -struct sw_sync_pt *pt = (struct sw_sync_pt *)fence; -struct sw_sync_timeline *obj = - (struct sw_sync_timeline *)fence_parent (fence); - -return (pt->value > obj->value) ?0 :1 ; -} -static int sw_sync_fill_driver_data (struct fence *fence,void *data,int size) {
@@ -77,7 +68,6 @@ static void sw_sync_fence_value_str(struct fence *fence, }static struct fence_timeline_ops sw_sync_timeline_ops = { - .has_signaled = sw_sync_fence_has_signaled, .fill_driver_data = sw_sync_fill_driver_data, .timeline_value_str = sw_sync_timeline_value_str, .fence_value_str = sw_sync_fence_value_str,
@@ -96,8 +86,6 @@ EXPORT_SYMBOL(sw_sync_timeline_create);void sw_sync_timeline_inc (struct sw_sync_timeline *obj,u32 inc) { - obj->value += inc; - -fence_timeline_signal (&obj->obj); +fence_timeline_signal (&obj->obj, inc); }EXPORT_SYMBOL (sw_sync_timeline_inc);
drivers/staging/android/sync.c +3 -14
@@ -34,7 +34,7 @@static const struct fence_ops sync_fence_ops;static const struct file_operations sync_fence_fops; -struct fence *sync_pt_create (struct fence_timeline *obj,int size) +struct fence *sync_pt_create (struct fence_timeline *obj,int size,u32 value) {unsigned long flags;struct fence *fence;
@@ -49,7 +49,7 @@ struct fence *sync_pt_create(struct fence_timeline *obj, int size)spin_lock_irqsave (&obj->lock, flags);fence_timeline_get (obj);fence_init (fence, &sync_fence_ops, &obj->lock, - obj->context, ++obj->value); + obj->context, value);list_add_tail (&fence->child_list, &obj->child_list_head);INIT_LIST_HEAD (&fence->active_list);spin_unlock_irqrestore (&obj->lock, flags);
@@ -321,17 +321,6 @@ int sync_fence_wait(struct sync_fence *sync_fence, long timeout) }EXPORT_SYMBOL (sync_fence_wait); -static bool sync_fence_signaled (struct fence *fence) -{ -struct fence_timeline *parent =fence_parent (fence); -int ret; - - ret = parent->ops->has_signaled (fence); -if (ret <0 ) - fence->status = ret; -return ret; -} -static int sync_fence_fill_driver_data (struct fence *fence,void *data,int size) {
@@ -372,7 +361,7 @@ static const struct fence_ops sync_fence_ops = { .get_driver_name = fence_default_get_driver_name, .get_timeline_name = fence_default_get_timeline_name, .enable_signaling = fence_default_enable_signaling, - .signaled = sync_fence_signaled, + .signaled = fence_default_signaled, .wait = fence_default_wait, .release = fence_default_release, .fill_driver_data = sync_fence_fill_driver_data,
drivers/staging/android/sync.h +2 -1
@@ -82,7 +82,8 @@ static inline void sync_fence_waiter_init(struct sync_fence_waiter *waiter,* API for fence_timeline implementers */ -struct fence *sync_pt_create (struct fence_timeline *parent,int size); +struct fence *sync_pt_create (struct fence_timeline *parent,int size, +u32 value);/** * sync_fence_create() - creates a sync fence
include/linux/fence.h +3 -9
@@ -36,10 +36,6 @@ struct fence_ops;struct fence_cb ;/** * struct fence_timeline_ops - fence context implementation ops -* @has_signaled: returns: -* 1 if pt has signaled -* 0 if pt has not signaled -* <0 on error * @fill_driver_data: write implementation specific driver data to data. * should return an error if there is not enough room * as specified by size. This information is returned
@@ -48,9 +44,6 @@ struct fence_cb;* @pt_value_str: fill str with the value of the sync_pt */ struct fence_timeline_ops { -/* required */ -int (*has_signaled)(struct fence *fence); -/* optional */ int (*fill_driver_data)(struct fence *fence,void *data,int size);
@@ -80,7 +73,7 @@ struct fence_timeline {char drv_name[32 ];const struct fence_timeline_ops *ops;bool destroyed; -int value; +unsigned int value;int context;struct list_head child_list_head;struct list_head active_list_head;
@@ -97,7 +90,7 @@ struct fence_timeline *fence_timeline_create(unsigned num,void fence_timeline_get (struct fence_timeline *timeline);void fence_timeline_put (struct fence_timeline *timeline);void fence_timeline_destroy (struct fence_timeline *timeline); -void fence_timeline_signal (struct fence_timeline *timeline); +void fence_timeline_signal (struct fence_timeline *timeline,unsigned int inc);/** * struct fence - software synchronization primitive
@@ -296,6 +289,7 @@ int fence_signal(struct fence *fence);int fence_signal_locked (struct fence *fence);const char *fence_default_get_driver_name (struct fence *fence);const char *fence_default_get_timeline_name (struct fence *fence); +bool fence_default_signaled (struct fence *fence);bool fence_default_enable_signaling (struct fence *fence);signed long fence_default_wait (struct fence *fence,bool intr,signed long timeout);void fence_default_release (struct fence *fence);
Signature · 1 line
2.5.0
RFC 2/29 staging/android: fix checkpatch warning
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
Trivial indentation fix.
--- drivers/staging/android/sync.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/android/sync.h +1 -1
@@ -358,6 +358,6 @@ void sync_dump(void);# define sync_dump ()#endif int sync_fence_wake_up_wq (wait_queue_t *curr,unsigned mode, -int wake_flags,void *key); +int wake_flags,void *key);#endif /* _LINUX_SYNC_H */
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 3/29 staging/android: rename sync_fence_release
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
To avoid collision with an upcoming rename change the name of sync_fence_release() to sync_fence_release_file()
--- drivers/staging/android/sync.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/android/sync.c +2 -2
@@ -534,7 +534,7 @@ static void sync_fence_free(struct kref *kref)kfree (fence); } -static int sync_fence_release (struct inode *inode,struct file *file) +static int sync_fence_file_release (struct inode *inode,struct file *file) {struct sync_fence *fence = file->private_data;
@@ -724,7 +724,7 @@ static long sync_fence_ioctl(struct file *file, unsigned int cmd, }static const struct file_operations sync_fence_fops = { - .release = sync_fence_release, + .release = sync_fence_file_release, .poll = sync_fence_poll, .unlocked_ioctl = sync_fence_ioctl, .compat_ioctl = sync_fence_ioctl,
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 4/29 staging/android: rename 'android_fence' to 'sync_fence'
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
As we are de-staging it rename it to a name that is not related to android.
--- drivers/staging/android/sync.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-)
drivers/staging/android/sync.c +20 -20
@@ -31,7 +31,7 @@#define CREATE_TRACE_POINTS #include "trace/sync.h" -static const struct fence_ops android_fence_ops; +static const struct fence_ops sync_fence_ops;static const struct file_operations sync_fence_fops; struct sync_timeline *sync_timeline_create(const struct sync_timeline_ops *ops,
@@ -135,7 +135,7 @@ struct sync_pt *sync_pt_create(struct sync_timeline *obj, int size)spin_lock_irqsave (&obj->child_list_lock, flags);sync_timeline_get (obj); -fence_init (&pt->base, &android_fence_ops, &obj->child_list_lock, +fence_init (&pt->base, &sync_fence_ops, &obj->child_list_lock, obj->context, ++obj->value);list_add_tail (&pt->child_list, &obj->child_list_head);INIT_LIST_HEAD (&pt->active_list);
@@ -411,7 +411,7 @@ int sync_fence_wait(struct sync_fence *fence, long timeout) }EXPORT_SYMBOL (sync_fence_wait); -static const char *android_fence_get_driver_name (struct fence *fence) +static const char *sync_fence_get_driver_name (struct fence *fence) { struct sync_pt *pt = container_of(fence, struct sync_pt, base);struct sync_timeline *parent =sync_pt_parent (pt);
@@ -419,7 +419,7 @@ static const char *android_fence_get_driver_name(struct fence *fence)return parent->ops->driver_name; } -static const char *android_fence_get_timeline_name (struct fence *fence) +static const char *sync_fence_get_timeline_name (struct fence *fence) { struct sync_pt *pt = container_of(fence, struct sync_pt, base);struct sync_timeline *parent =sync_pt_parent (pt);
@@ -427,7 +427,7 @@ static const char *android_fence_get_timeline_name(struct fence *fence)return parent->name; } -static void android_fence_release (struct fence *fence) +static void sync_fence_release (struct fence *fence) { struct sync_pt *pt = container_of(fence, struct sync_pt, base);struct sync_timeline *parent =sync_pt_parent (pt);
@@ -446,7 +446,7 @@ static void android_fence_release(struct fence *fence)fence_free (&pt->base); } -static bool android_fence_signaled (struct fence *fence) +static bool sync_fence_signaled (struct fence *fence) { struct sync_pt *pt = container_of(fence, struct sync_pt, base);struct sync_timeline *parent =sync_pt_parent (pt);
@@ -458,19 +458,19 @@ static bool android_fence_signaled(struct fence *fence)return ret; } -static bool android_fence_enable_signaling (struct fence *fence) +static bool sync_fence_enable_signaling (struct fence *fence) { struct sync_pt *pt = container_of(fence, struct sync_pt, base);struct sync_timeline *parent =sync_pt_parent (pt); -if (android_fence_signaled (fence)) +if (sync_fence_signaled (fence))return false;list_add_tail (&pt->active_list, &parent->active_list_head);return true; } -static int android_fence_fill_driver_data (struct fence *fence, +static int sync_fence_fill_driver_data (struct fence *fence,void *data,int size) { struct sync_pt *pt = container_of(fence, struct sync_pt, base);
@@ -481,7 +481,7 @@ static int android_fence_fill_driver_data(struct fence *fence,return parent->ops->fill_driver_data (pt, data, size); } -static void android_fence_value_str (struct fence *fence, +static void sync_fence_value_str (struct fence *fence,char *str,int size) { struct sync_pt *pt = container_of(fence, struct sync_pt, base);
@@ -495,7 +495,7 @@ static void android_fence_value_str(struct fence *fence, parent->ops->pt_value_str (pt, str, size); } -static void android_fence_timeline_value_str (struct fence *fence, +static void sync_fence_timeline_value_str (struct fence *fence,char *str,int size) { struct sync_pt *pt = container_of(fence, struct sync_pt, base);
@@ -509,16 +509,16 @@ static void android_fence_timeline_value_str(struct fence *fence, parent->ops->timeline_value_str (parent, str, size); } -static const struct fence_ops android_fence_ops = { - .get_driver_name = android_fence_get_driver_name, - .get_timeline_name = android_fence_get_timeline_name, - .enable_signaling = android_fence_enable_signaling, - .signaled = android_fence_signaled, +static const struct fence_ops sync_fence_ops = { + .get_driver_name = sync_fence_get_driver_name, + .get_timeline_name = sync_fence_get_timeline_name, + .enable_signaling = sync_fence_enable_signaling, + .signaled = sync_fence_signaled, .wait = fence_default_wait, - .release = android_fence_release, - .fill_driver_data = android_fence_fill_driver_data, - .fence_value_str = android_fence_value_str, - .timeline_value_str = android_fence_timeline_value_str, + .release = sync_fence_release, + .fill_driver_data = sync_fence_fill_driver_data, + .fence_value_str = sync_fence_value_str, + .timeline_value_str = sync_fence_timeline_value_str, };static void sync_fence_free (struct kref *kref)
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 5/29 staging/android: remove not used sync_timeline ops
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
.dup and .compare are not used by the sync framework, so remove them from sw_sync.
--- drivers/staging/android/sw_sync.c | 29 +---------------------------- drivers/staging/android/sync.c | 6 ------ drivers/staging/android/sync.h | 19 ------------------- 3 files changed, 1 insertion(+), 53 deletions(-)
drivers/staging/android/sw_sync.c +1 -28
@@ -25,14 +25,6 @@#include "sw_sync.h" -static int sw_sync_cmp (u32 a,u32 b) -{ -if (a == b) -return 0 ; - -return ((s32 )a - (s32 )b) <0 ?-1 :1 ; -} -struct sync_pt *sw_sync_pt_create (struct sw_sync_timeline *obj,u32 value) {struct sw_sync_pt *pt;
@@ -46,30 +38,13 @@ struct sync_pt *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value) }EXPORT_SYMBOL (sw_sync_pt_create); -static struct sync_pt *sw_sync_pt_dup (struct sync_pt *sync_pt) -{ -struct sw_sync_pt *pt = (struct sw_sync_pt *)sync_pt; -struct sw_sync_timeline *obj = - (struct sw_sync_timeline *)sync_pt_parent (sync_pt); - -return (struct sync_pt *)sw_sync_pt_create (obj, pt->value); -} -static int sw_sync_pt_has_signaled (struct sync_pt *sync_pt) {struct sw_sync_pt *pt = (struct sw_sync_pt *)sync_pt;struct sw_sync_timeline *obj = (struct sw_sync_timeline *)sync_pt_parent (sync_pt); -return sw_sync_cmp (obj->value, pt->value) >=0 ; -} - -static int sw_sync_pt_compare (struct sync_pt *a,struct sync_pt *b) -{ -struct sw_sync_pt *pt_a = (struct sw_sync_pt *)a; -struct sw_sync_pt *pt_b = (struct sw_sync_pt *)b; - -return sw_sync_cmp (pt_a->value, pt_b->value); +return (pt->value > obj->value) ?0 :1 ; } static int sw_sync_fill_driver_data(struct sync_pt *sync_pt,
@@ -103,9 +78,7 @@ static void sw_sync_pt_value_str(struct sync_pt *sync_pt,static struct sync_timeline_ops sw_sync_timeline_ops = { .driver_name ="sw_sync" , - .dup = sw_sync_pt_dup, .has_signaled = sw_sync_pt_has_signaled, - .compare = sw_sync_pt_compare, .fill_driver_data = sw_sync_fill_driver_data, .timeline_value_str = sw_sync_timeline_value_str, .pt_value_str = sw_sync_pt_value_str,
drivers/staging/android/sync.c +0 -6
@@ -68,9 +68,6 @@ static void sync_timeline_free(struct kref *kref)sync_timeline_debug_remove (obj); -if (obj->ops->release_obj) - obj->ops->release_obj (obj); -kfree (obj); }
@@ -439,9 +436,6 @@ static void sync_fence_release(struct fence *fence)list_del (&pt->active_list);spin_unlock_irqrestore (fence->lock, flags); -if (parent->ops->free_pt) - parent->ops->free_pt (pt); -sync_timeline_put (parent);fence_free (&pt->base); }
drivers/staging/android/sync.h +0 -19
@@ -30,17 +30,10 @@ struct sync_fence;/** * struct sync_timeline_ops - sync object implementation ops * @driver_name: name of the implementation -* @dup: duplicate a sync_pt * @has_signaled: returns: * 1 if pt has signaled * 0 if pt has not signaled * <0 on error -* @compare: returns: -* 1 if b will signal before a -* 0 if a and b will signal at the same time -* -1 if a will signal before b -* @free_pt: called before sync_pt is freed -* @release_obj: called before sync_timeline is freed * @fill_driver_data: write implementation specific driver data to data. * should return an error if there is not enough room * as specified by size. This information is returned
@@ -52,20 +45,8 @@ struct sync_timeline_ops {const char *driver_name;/* required */ -struct sync_pt * (*dup)(struct sync_pt *pt); - -/* required */ int (*has_signaled)(struct sync_pt *pt); -/* required */ -int (*compare)(struct sync_pt *a,struct sync_pt *b); - -/* optional */ -void (*free_pt)(struct sync_pt *sync_pt); - -/* optional */ -void (*release_obj)(struct sync_timeline *sync_timeline); -/* optional */ int (*fill_driver_data)(struct sync_pt *syncpt,void *data,int size);
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 6/29 staging/android: create a 'sync' dir for debugfs information
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
Creates the 'sync' dir on debugfs root dir and move the 'sync' file to sync/info. This is the preparation to add more debug info and control.
--- drivers/staging/android/sync_debug.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
drivers/staging/android/sync_debug.c +17 -4
@@ -15,6 +15,7 @@*/ #include <linux/debugfs.h> +#include <linux/module.h> #include <linux/export.h> #include <linux/file.h> #include <linux/fs.h>
@@ -30,6 +31,8 @@#ifdef CONFIG_DEBUG_FS +static struct dentry *dbgfs; +static LIST_HEAD (sync_timeline_list_head);static DEFINE_SPINLOCK (sync_timeline_list_lock);static LIST_HEAD (sync_fence_list_head);
@@ -208,13 +211,13 @@ static int sync_debugfs_show(struct seq_file *s, void *unused)return 0 ; } -static int sync_debugfs_open (struct inode *inode,struct file *file) +static int sync_info_debugfs_open (struct inode *inode,struct file *file) {return single_open (file, sync_debugfs_show, inode->i_private); } -static const struct file_operations sync_debugfs_fops = { - .open = sync_debugfs_open, +static const struct file_operations sync_info_debugfs_fops = { + .open = sync_info_debugfs_open, .read = seq_read, .llseek = seq_lseek, .release = single_release,
@@ -222,11 +225,21 @@ static const struct file_operations sync_debugfs_fops = {static __init int sync_debugfs_init (void ) { -debugfs_create_file ("sync" ,S_IRUGO ,NULL ,NULL , &sync_debugfs_fops); + dbgfs =debugfs_create_dir ("sync" ,NULL ); + +debugfs_create_file ("info" ,0444 , dbgfs,NULL , &sync_info_debugfs_fops); +return 0 ; }late_initcall (sync_debugfs_init); +static __exit void sync_debugfs_exit(void) +{ +if (dbgfs) +debugfs_remove_recursive (dbgfs); +} +module_exit (sync_debugfs_exit); +#define DUMP_CHUNK 256static char sync_dump_buf[64 *1024 ];void sync_dump (void )
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 7/29 staging/android: move sw_sync file to debugfs file
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
This remove CONFIG_SW_SYNC_USER and instead compile the sw_sync file into debugpfs under <debugfs>/sync/sw_sync.
--- drivers/staging/android/Kconfig | 9 --- drivers/staging/android/sw_sync.c | 129 ----------------------------------- drivers/staging/android/sync_debug.c | 118 +++++++++++++++++++++++++++++++- 3 files changed, 117 insertions(+), 139 deletions(-)
drivers/staging/android/Kconfig +0 -9
@@ -57,15 +57,6 @@ config SW_SYNC synchronization. Useful when there is no hardware primitive backing the synchronization. -config SW_SYNC_USER - bool "Userspace API for SW_SYNC" - default n - depends on SW_SYNC - ---help--- - Provides a user space API to the sw sync object. - *WARNING* improper use of this can result in deadlocking kernel - drivers from userspace. - source "drivers/staging/android/ion/Kconfig" endif # if ANDROID
drivers/staging/android/sw_sync.c +0 -129
132 lines not on this page · raw message
drivers/staging/android/sync_debug.c +117 -1
135 lines not on this page · raw message
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 8/29 staging/android: Remove WARN_ON_ONCE when releasing sync_fence
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
There isn't any problem on removing the sync_pts from the active_list when the fence is released. If the user decides to close the fence before it is signaled we should do it and not warn about anything.
--- drivers/staging/android/sync.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/android/sync.c +2 -1
@@ -432,8 +432,9 @@ static void sync_fence_release(struct fence *fence)spin_lock_irqsave (fence->lock, flags);list_del (&pt->child_list); -if (WARN_ON_ONCE (!list_empty (&pt->active_list))) +if (!list_empty (&pt->active_list))list_del (&pt->active_list); +spin_unlock_irqrestore (fence->lock, flags);sync_timeline_put (parent);
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 9/29 staging/android: rename struct sync_fence's variables to 'sync_fence'
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
To avoid confusion with struct fence vars that are most of the time called 'fence' as well we should rename all struct sync_fence's to sync_fence.
--- drivers/staging/android/sync.c | 192 ++++++++++++++++++----------------- drivers/staging/android/sync.h | 2 +- drivers/staging/android/sync_debug.c | 39 +++---- 3 files changed, 120 insertions(+), 113 deletions(-)
drivers/staging/android/sync.c +99 -93
@@ -149,61 +149,62 @@ EXPORT_SYMBOL(sync_pt_free);static struct sync_fence *sync_fence_alloc (int size,const char *name) { -struct sync_fence *fence; +struct sync_fence *sync_fence; - fence =kzalloc (size,GFP_KERNEL ); -if (!fence) + sync_fence =kzalloc (size,GFP_KERNEL ); +if (!sync_fence)return NULL ; - fence->file =anon_inode_getfile ("sync_fence" , &sync_fence_fops, - fence,0 ); -if (IS_ERR (fence->file)) + sync_fence->file =anon_inode_getfile ("sync_fence" , &sync_fence_fops, + sync_fence,0 ); +if (IS_ERR (sync_fence->file)) goto err; -kref_init (&fence->kref); -strlcpy (fence->name, name,sizeof (fence->name)); +kref_init (&sync_fence->kref); +strlcpy (sync_fence->name, name,sizeof (sync_fence->name)); -init_waitqueue_head (&fence->wq); +init_waitqueue_head (&sync_fence->wq); -return fence; +return sync_fence; err: -kfree (fence); +kfree (sync_fence);return NULL ; }static void fence_check_cb_func (struct fence *f,struct fence_cb *cb) {struct sync_fence_cb *check; -struct sync_fence *fence; +struct sync_fence *sync_fence; check = container_of(cb, struct sync_fence_cb, cb); - fence = check->fence; + sync_fence = check->sync_fence; -if (atomic_dec_and_test (&fence->status)) -wake_up_all (&fence->wq); +if (atomic_dec_and_test (&sync_fence->status)) +wake_up_all (&sync_fence->wq); }/* TODO: implement a create which takes more that one sync_pt */ struct sync_fence *sync_fence_create_dma (const char *name,struct fence *pt) { -struct sync_fence *fence; +struct sync_fence *sync_fence; - fence = sync_fence_alloc(offsetof(struct sync_fence, cbs[1]), name); -if (!fence) + sync_fence = sync_fence_alloc(offsetof(struct sync_fence, cbs[1]), + name); +if (!sync_fence)return NULL ; - fence->num_fences =1 ; -atomic_set (&fence->status,1 ); + sync_fence->num_fences =1 ; +atomic_set (&sync_fence->status,1 ); - fence->cbs[0 ].sync_pt = pt; - fence->cbs[0 ].fence = fence; -if (fence_add_callback (pt, &fence->cbs[0 ].cb, fence_check_cb_func)) -atomic_dec (&fence->status); + sync_fence->cbs[0 ].sync_pt = pt; + sync_fence->cbs[0 ].sync_fence = sync_fence; +if (fence_add_callback (pt, &sync_fence->cbs[0 ].cb, fence_check_cb_func)) +atomic_dec (&sync_fence->status); -sync_fence_debug_add (fence); +sync_fence_debug_add (sync_fence); -return fence; +return sync_fence; }EXPORT_SYMBOL (sync_fence_create_dma);
@@ -231,25 +232,26 @@ err: }EXPORT_SYMBOL (sync_fence_fdget); -void sync_fence_put (struct sync_fence *fence) +void sync_fence_put (struct sync_fence *sync_fence) { -fput (fence->file); +fput (sync_fence->file); }EXPORT_SYMBOL (sync_fence_put); -void sync_fence_install (struct sync_fence *fence,int fd) +void sync_fence_install (struct sync_fence *sync_fence,int fd) { -fd_install (fd, fence->file); +fd_install (fd, sync_fence->file); }EXPORT_SYMBOL (sync_fence_install); -static void sync_fence_add_pt (struct sync_fence *fence, +static void sync_fence_add_pt (struct sync_fence *sync_fence,int *i,struct fence *pt) { - fence->cbs[*i].sync_pt = pt; - fence->cbs[*i].fence = fence; + sync_fence->cbs[*i].sync_pt = pt; + sync_fence->cbs[*i].sync_fence = sync_fence; -if (!fence_add_callback (pt, &fence->cbs[*i].cb, fence_check_cb_func)) { +if (!fence_add_callback (pt, &sync_fence->cbs[*i].cb, + fence_check_cb_func)) {fence_get (pt); (*i)++; }
@@ -259,15 +261,15 @@ struct sync_fence *sync_fence_merge(const char *name, struct sync_fence *a, struct sync_fence *b) { int num_fences = a->num_fences + b->num_fences; -struct sync_fence *fence; +struct sync_fence *sync_fence;int i, i_a, i_b; unsigned long size = offsetof(struct sync_fence, cbs[num_fences]); - fence =sync_fence_alloc (size, name); -if (!fence) + sync_fence =sync_fence_alloc (size, name); +if (!sync_fence)return NULL ; -atomic_set (&fence->status, num_fences); +atomic_set (&sync_fence->status, num_fences);/* * Assume sync_fence a and b are both ordered and have no
@@ -281,18 +283,18 @@ struct sync_fence *sync_fence_merge(const char *name,struct fence *pt_b = b->cbs[i_b].sync_pt;if (pt_a->context < pt_b->context) { -sync_fence_add_pt (fence, &i, pt_a); +sync_fence_add_pt (sync_fence, &i, pt_a); i_a++; }else if (pt_a->context > pt_b->context) { -sync_fence_add_pt (fence, &i, pt_b); +sync_fence_add_pt (sync_fence, &i, pt_b); i_b++; }else {if (pt_a->seqno - pt_b->seqno <=INT_MAX ) -sync_fence_add_pt (fence, &i, pt_a); +sync_fence_add_pt (sync_fence, &i, pt_a);else -sync_fence_add_pt (fence, &i, pt_b); +sync_fence_add_pt (sync_fence, &i, pt_b); i_a++; i_b++;
@@ -300,17 +302,17 @@ struct sync_fence *sync_fence_merge(const char *name, }for (; i_a < a->num_fences; i_a++) -sync_fence_add_pt (fence, &i, a->cbs[i_a].sync_pt); +sync_fence_add_pt (sync_fence, &i, a->cbs[i_a].sync_pt);for (; i_b < b->num_fences; i_b++) -sync_fence_add_pt (fence, &i, b->cbs[i_b].sync_pt); +sync_fence_add_pt (sync_fence, &i, b->cbs[i_b].sync_pt);if (num_fences > i) -atomic_sub (num_fences - i, &fence->status); - fence->num_fences = i; +atomic_sub (num_fences - i, &sync_fence->status); + sync_fence->num_fences = i; -sync_fence_debug_add (fence); -return fence; +sync_fence_debug_add (sync_fence); +return sync_fence; }EXPORT_SYMBOL (sync_fence_merge);
@@ -326,10 +328,10 @@ int sync_fence_wake_up_wq(wait_queue_t *curr, unsigned mode,return 1 ; } -int sync_fence_wait_async (struct sync_fence *fence, +int sync_fence_wait_async (struct sync_fence *sync_fence,struct sync_fence_waiter *waiter) { -int err =atomic_read (&fence->status); +int err =atomic_read (&sync_fence->status);unsigned long flags;if (err <0 )
@@ -339,13 +341,13 @@ int sync_fence_wait_async(struct sync_fence *fence,return 1 ;init_waitqueue_func_entry (&waiter->work, sync_fence_wake_up_wq); - waiter->work.private = fence; + waiter->work.private = sync_fence; -spin_lock_irqsave (&fence->wq.lock, flags); - err =atomic_read (&fence->status); +spin_lock_irqsave (&sync_fence->wq.lock, flags); + err =atomic_read (&sync_fence->status);if (err >0 ) -__add_wait_queue_tail (&fence->wq, &waiter->work); -spin_unlock_irqrestore (&fence->wq.lock, flags); +__add_wait_queue_tail (&sync_fence->wq, &waiter->work); +spin_unlock_irqrestore (&sync_fence->wq.lock, flags);if (err <0 )return err;
@@ -354,23 +356,23 @@ int sync_fence_wait_async(struct sync_fence *fence, }EXPORT_SYMBOL (sync_fence_wait_async); -int sync_fence_cancel_async (struct sync_fence *fence, +int sync_fence_cancel_async (struct sync_fence *sync_fence,struct sync_fence_waiter *waiter) {unsigned long flags;int ret =0 ; -spin_lock_irqsave (&fence->wq.lock, flags); +spin_lock_irqsave (&sync_fence->wq.lock, flags);if (!list_empty (&waiter->work.task_list))list_del_init (&waiter->work.task_list);else ret = -ENOENT ; -spin_unlock_irqrestore (&fence->wq.lock, flags); +spin_unlock_irqrestore (&sync_fence->wq.lock, flags);return ret; }EXPORT_SYMBOL (sync_fence_cancel_async); -int sync_fence_wait (struct sync_fence *fence,long timeout) +int sync_fence_wait (struct sync_fence *sync_fence,long timeout) {long ret;int i;
@@ -380,28 +382,28 @@ int sync_fence_wait(struct sync_fence *fence, long timeout)else timeout =msecs_to_jiffies (timeout); -trace_sync_wait (fence,1 ); -for (i =0 ; i < fence->num_fences; ++i) -trace_sync_pt (fence->cbs[i].sync_pt); - ret =wait_event_interruptible_timeout (fence->wq, -atomic_read (&fence->status) <=0 , +trace_sync_wait (sync_fence,1 ); +for (i =0 ; i < sync_fence->num_fences; ++i) +trace_sync_pt (sync_fence->cbs[i].sync_pt); + ret =wait_event_interruptible_timeout (sync_fence->wq, +atomic_read (&sync_fence->status) <=0 , timeout); -trace_sync_wait (fence,0 ); +trace_sync_wait (sync_fence,0 );if (ret <0 ) {return ret; }else if (ret ==0 ) {if (timeout) { -pr_info ("fence timeout on [%p] after %dms\n" , fence, -jiffies_to_msecs (timeout)); +pr_info ("sync_fence timeout on [%p] after %dms\n" , + sync_fence,jiffies_to_msecs (timeout));sync_dump (); }return -ETIME ; } - ret =atomic_read (&fence->status); + ret =atomic_read (&sync_fence->status);if (ret) { -pr_info ("fence error %ld on [%p]\n" , ret, fence); +pr_info ("sync_fence error %ld on [%p]\n" , ret, sync_fence);sync_dump (); }return ret;
@@ -518,35 +520,37 @@ static const struct fence_ops sync_fence_ops = {static void sync_fence_free (struct kref *kref) { - struct sync_fence *fence = container_of(kref, struct sync_fence, kref); + struct sync_fence *sync_fence = container_of(kref, struct sync_fence, + kref);int i; -for (i =0 ; i < fence->num_fences; ++i) { -fence_remove_callback (fence->cbs[i].sync_pt, &fence->cbs[i].cb); -fence_put (fence->cbs[i].sync_pt); +for (i =0 ; i < sync_fence->num_fences; ++i) { +fence_remove_callback (sync_fence->cbs[i].sync_pt, + &sync_fence->cbs[i].cb); +fence_put (sync_fence->cbs[i].sync_pt); } -kfree (fence); +kfree (sync_fence); }static int sync_fence_file_release (struct inode *inode,struct file *file) { -struct sync_fence *fence = file->private_data; +struct sync_fence *sync_fence = file->private_data; -sync_fence_debug_remove (fence); +sync_fence_debug_remove (sync_fence); -kref_put (&fence->kref, sync_fence_free); +kref_put (&sync_fence->kref, sync_fence_free);return 0 ; }static unsigned int sync_fence_poll (struct file *file,poll_table *wait) { -struct sync_fence *fence = file->private_data; +struct sync_fence *sync_fence = file->private_data;int status; -poll_wait (file, &fence->wq, wait); +poll_wait (file, &sync_fence->wq, wait); - status =atomic_read (&fence->status); + status =atomic_read (&sync_fence->status);if (!status)return POLLIN ;
@@ -555,17 +559,19 @@ static unsigned int sync_fence_poll(struct file *file, poll_table *wait)return 0 ; } -static long sync_fence_ioctl_wait (struct sync_fence *fence,unsigned long arg) +static long sync_fence_ioctl_wait (struct sync_fence *sync_fence, +unsigned long arg) {__s32 value;if (copy_from_user (&value, (void __user *)arg,sizeof (value)))return -EFAULT ; -return sync_fence_wait (fence, value); +return sync_fence_wait (sync_fence, value); } -static long sync_fence_ioctl_merge (struct sync_fence *fence,unsigned long arg) +static long sync_fence_ioctl_merge (struct sync_fence *sync_fence, +unsigned long arg) {int fd =get_unused_fd_flags (O_CLOEXEC );int err;
@@ -587,7 +593,7 @@ static long sync_fence_ioctl_merge(struct sync_fence *fence, unsigned long arg) } data.name[sizeof (data.name) -1 ] ='\0' ; - fence3 =sync_fence_merge (data.name, fence, fence2); + fence3 =sync_fence_merge (data.name, sync_fence, fence2);if (!fence3) { err = -ENOMEM ; goto err_put_fence2;
@@ -646,7 +652,7 @@ static int sync_fill_pt_info(struct fence *fence, void *data, int size)return info->len; } -static long sync_fence_ioctl_fence_info (struct sync_fence *fence, +static long sync_fence_ioctl_fence_info (struct sync_fence *sync_fence,unsigned long arg) {struct sync_fence_info_data *data;
@@ -667,15 +673,15 @@ static long sync_fence_ioctl_fence_info(struct sync_fence *fence,if (!data)return -ENOMEM ; -strlcpy (data->name, fence->name,sizeof (data->name)); - data->status =atomic_read (&fence->status); +strlcpy (data->name, sync_fence->name,sizeof (data->name)); + data->status =atomic_read (&sync_fence->status);if (data->status >=0 ) data->status = !data->status; len =sizeof (struct sync_fence_info_data ); -for (i =0 ; i < fence->num_fences; ++i) { -struct fence *pt = fence->cbs[i].sync_pt; +for (i =0 ; i < sync_fence->num_fences; ++i) { +struct fence *pt = sync_fence->cbs[i].sync_pt; ret =sync_fill_pt_info (pt, (u8 *)data + len, size - len);
@@ -701,17 +707,17 @@ out:static long sync_fence_ioctl (struct file *file,unsigned int cmd,unsigned long arg) { -struct sync_fence *fence = file->private_data; +struct sync_fence *sync_fence = file->private_data;switch (cmd) {case SYNC_IOC_WAIT : -return sync_fence_ioctl_wait (fence, arg); +return sync_fence_ioctl_wait (sync_fence, arg);case SYNC_IOC_MERGE : -return sync_fence_ioctl_merge (fence, arg); +return sync_fence_ioctl_merge (sync_fence, arg);case SYNC_IOC_FENCE_INFO : -return sync_fence_ioctl_fence_info (fence, arg); +return sync_fence_ioctl_fence_info (sync_fence, arg);default :return -ENOTTY ;
drivers/staging/android/sync.h +1 -1
@@ -111,7 +111,7 @@ static inline struct sync_timeline *sync_pt_parent(struct sync_pt *pt)struct sync_fence_cb {struct fence_cb cb;struct fence *sync_pt; -struct sync_fence *fence; +struct sync_fence *sync_fence; };/**
drivers/staging/android/sync_debug.c +20 -19
@@ -56,21 +56,21 @@ void sync_timeline_debug_remove(struct sync_timeline *obj)spin_unlock_irqrestore (&sync_timeline_list_lock, flags); } -void sync_fence_debug_add (struct sync_fence *fence) +void sync_fence_debug_add (struct sync_fence *sync_fence) {unsigned long flags;spin_lock_irqsave (&sync_fence_list_lock, flags); -list_add_tail (&fence->sync_fence_list, &sync_fence_list_head); +list_add_tail (&sync_fence->sync_fence_list, &sync_fence_list_head);spin_unlock_irqrestore (&sync_fence_list_lock, flags); } -void sync_fence_debug_remove (struct sync_fence *fence) +void sync_fence_debug_remove (struct sync_fence *sync_fence) {unsigned long flags;spin_lock_irqsave (&sync_fence_list_lock, flags); -list_del (&fence->sync_fence_list); +list_del (&sync_fence->sync_fence_list);spin_unlock_irqrestore (&sync_fence_list_lock, flags); }
@@ -152,21 +152,22 @@ static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj)spin_unlock_irqrestore (&obj->child_list_lock, flags); } -static void sync_print_fence (struct seq_file *s,struct sync_fence *fence) +static void sync_print_sync_fence (struct seq_file *s, +struct sync_fence *sync_fence) {wait_queue_t *pos;unsigned long flags;int i; -seq_printf (s,"[%p] %s: %s\n" , fence, fence->name, -sync_status_str (atomic_read (&fence->status))); +seq_printf (s,"[%p] %s: %s\n" , sync_fence, sync_fence->name, +sync_status_str (atomic_read (&sync_fence->status))); -for (i =0 ; i < fence->num_fences; ++i) { -sync_print_pt (s, fence->cbs[i].sync_pt, true); +for (i =0 ; i < sync_fence->num_fences; ++i) { +sync_print_pt (s, sync_fence->cbs[i].sync_pt, true); } -spin_lock_irqsave (&fence->wq.lock, flags); -list_for_each_entry (pos, &fence->wq.task_list, task_list) { +spin_lock_irqsave (&sync_fence->wq.lock, flags); +list_for_each_entry (pos, &sync_fence->wq.task_list, task_list) {struct sync_fence_waiter *waiter;if (pos->func != &sync_fence_wake_up_wq)
@@ -176,7 +177,7 @@ static void sync_print_fence(struct seq_file *s, struct sync_fence *fence)seq_printf (s,"waiter %pF\n" , waiter->callback); } -spin_unlock_irqrestore (&fence->wq.lock, flags); +spin_unlock_irqrestore (&sync_fence->wq.lock, flags); }static int sync_debugfs_show (struct seq_file *s,void *unused)
@@ -201,10 +202,10 @@ static int sync_debugfs_show(struct seq_file *s, void *unused)spin_lock_irqsave (&sync_fence_list_lock, flags);list_for_each (pos, &sync_fence_list_head) { -struct sync_fence *fence = +struct sync_fence *sync_fence = container_of(pos, struct sync_fence, sync_fence_list); -sync_print_fence (s, fence); +sync_print_sync_fence (s, sync_fence);seq_puts (s,"\n" ); }spin_unlock_irqrestore (&sync_fence_list_lock, flags);
@@ -260,7 +261,7 @@ static long sw_sync_ioctl_create_fence(struct sw_sync_timeline *obj,int fd =get_unused_fd_flags (O_CLOEXEC );int err;struct sync_pt *pt; -struct sync_fence *fence; +struct sync_fence *sync_fence;struct sw_sync_create_fence_data data;if (fd <0 )
@@ -278,8 +279,8 @@ static long sw_sync_ioctl_create_fence(struct sw_sync_timeline *obj, } data.name[sizeof (data.name) -1 ] ='\0' ; - fence =sync_fence_create (data.name, pt); -if (!fence) { + sync_fence =sync_fence_create (data.name, pt); +if (!sync_fence) {sync_pt_free (pt); err = -ENOMEM ; goto err;
@@ -287,12 +288,12 @@ static long sw_sync_ioctl_create_fence(struct sw_sync_timeline *obj, data.fence = fd;if (copy_to_user ((void __user *)arg, &data,sizeof (data))) { -sync_fence_put (fence); +sync_fence_put (sync_fence); err = -EFAULT ; goto err; } -sync_fence_install (fence, fd); +sync_fence_install (sync_fence, fd);return 0 ;
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 10/29 staging/android: rename 'sync_pt' to 'fence' in struct sync_fence_cb
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
'sync_pt' is actually declared as struct fence so to make the name means its type we rename it to 'fence'.
--- drivers/staging/android/sync.c | 20 ++++++++++---------- drivers/staging/android/sync.h | 2 +- drivers/staging/android/sync_debug.c | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-)
drivers/staging/android/sync.c +10 -10
@@ -197,7 +197,7 @@ struct sync_fence *sync_fence_create_dma(const char *name, struct fence *pt) sync_fence->num_fences =1 ;atomic_set (&sync_fence->status,1 ); - sync_fence->cbs[0 ].sync_pt = pt; + sync_fence->cbs[0 ].fence = pt; sync_fence->cbs[0 ].sync_fence = sync_fence;if (fence_add_callback (pt, &sync_fence->cbs[0 ].cb, fence_check_cb_func))atomic_dec (&sync_fence->status);
@@ -247,7 +247,7 @@ EXPORT_SYMBOL(sync_fence_install); static void sync_fence_add_pt(struct sync_fence *sync_fence, int *i, struct fence *pt) { - sync_fence->cbs[*i].sync_pt = pt; + sync_fence->cbs[*i].fence = pt; sync_fence->cbs[*i].sync_fence = sync_fence; if (!fence_add_callback(pt, &sync_fence->cbs[*i].cb,
@@ -279,8 +279,8 @@ struct sync_fence *sync_fence_merge(const char *name,* and sync_fence_create, this is a reasonable assumption. */ for (i = i_a = i_b =0 ; i_a < a->num_fences && i_b < b->num_fences; ) { -struct fence *pt_a = a->cbs[i_a].sync_pt; -struct fence *pt_b = b->cbs[i_b].sync_pt; +struct fence *pt_a = a->cbs[i_a].fence; +struct fence *pt_b = b->cbs[i_b].fence;if (pt_a->context < pt_b->context) {sync_fence_add_pt (sync_fence, &i, pt_a);
@@ -302,10 +302,10 @@ struct sync_fence *sync_fence_merge(const char *name, }for (; i_a < a->num_fences; i_a++) -sync_fence_add_pt (sync_fence, &i, a->cbs[i_a].sync_pt); +sync_fence_add_pt (sync_fence, &i, a->cbs[i_a].fence);for (; i_b < b->num_fences; i_b++) -sync_fence_add_pt (sync_fence, &i, b->cbs[i_b].sync_pt); +sync_fence_add_pt (sync_fence, &i, b->cbs[i_b].fence);if (num_fences > i)atomic_sub (num_fences - i, &sync_fence->status);
@@ -384,7 +384,7 @@ int sync_fence_wait(struct sync_fence *sync_fence, long timeout)trace_sync_wait (sync_fence,1 );for (i =0 ; i < sync_fence->num_fences; ++i) -trace_sync_pt (sync_fence->cbs[i].sync_pt); +trace_sync_pt (sync_fence->cbs[i].fence); ret =wait_event_interruptible_timeout (sync_fence->wq,atomic_read (&sync_fence->status) <=0 , timeout);
@@ -525,9 +525,9 @@ static void sync_fence_free(struct kref *kref)int i;for (i =0 ; i < sync_fence->num_fences; ++i) { -fence_remove_callback (sync_fence->cbs[i].sync_pt, +fence_remove_callback (sync_fence->cbs[i].fence, &sync_fence->cbs[i].cb); -fence_put (sync_fence->cbs[i].sync_pt); +fence_put (sync_fence->cbs[i].fence); }kfree (sync_fence);
@@ -681,7 +681,7 @@ static long sync_fence_ioctl_fence_info(struct sync_fence *sync_fence, len =sizeof (struct sync_fence_info_data );for (i =0 ; i < sync_fence->num_fences; ++i) { -struct fence *pt = sync_fence->cbs[i].sync_pt; +struct fence *pt = sync_fence->cbs[i].fence; ret =sync_fill_pt_info (pt, (u8 *)data + len, size - len);
drivers/staging/android/sync.h +1 -1
@@ -110,7 +110,7 @@ static inline struct sync_timeline *sync_pt_parent(struct sync_pt *pt)struct sync_fence_cb {struct fence_cb cb; -struct fence *sync_pt; +struct fence *fence;struct sync_fence *sync_fence; };
drivers/staging/android/sync_debug.c +1 -1
@@ -163,7 +163,7 @@ static void sync_print_sync_fence(struct seq_file *s, sync_status_str(atomic_read(&sync_fence->status)));for (i =0 ; i < sync_fence->num_fences; ++i) { -sync_print_pt (s, sync_fence->cbs[i].sync_pt, true); +sync_print_pt (s, sync_fence->cbs[i].fence, true); }spin_lock_irqsave (&sync_fence->wq.lock, flags);
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 11/29 dma-buf/fence: move sync_timeline to fence_timeline
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
Add the sync timeline from sync framework to fence synchronization system. This is an attempt to remove some duplication between sync.c and fence.c
The sync_timeline was no more than a wrapper on top of the fence framework to be used by sw_sync. It simplifies some accesses, for example, when you have a struct fence you don't need get the sync_pt related to it to know the parent timeline, it is just a matter of calling fence_parent() now.
This is just the initial step, the idea is to connect sw_sync direct with fences removing some abstractions in between.
The sync API changes here are:
* struct sync_timeline is now struct fence_timeline
* sync_timeline_ops is now fence_timeline_ops and they now carry struct fence as parameter instead of struct sync_pt
* sync_timeline_create() -> fence_timeline_create()
* sync_timeline_get() -> fence_timeline_get()
* sync_timeline_put() -> fence_timeline_put()
* sync_timeline_destroy() -> fence_timeline_destroy()
* sync_timeline_signal() -> fence_timeline_signal()
--- drivers/dma-buf/fence.c | 125 +++++++++++++++++++++++++++++ drivers/staging/android/sw_sync.c | 27 ++++--- drivers/staging/android/sw_sync.h | 2 +- drivers/staging/android/sync.c | 150 +++++++---------------------------- drivers/staging/android/sync.h | 130 +----------------------------- drivers/staging/android/sync_debug.c | 26 +++--- drivers/staging/android/trace/sync.h | 24 ------ include/linux/fence.h | 75 ++++++++++++++++++ include/trace/events/fence.h | 24 ++++++ 9 files changed, 285 insertions(+), 298 deletions(-)
drivers/dma-buf/fence.c +125 -0
@@ -52,6 +52,131 @@ unsigned fence_context_alloc(unsigned num)EXPORT_SYMBOL (fence_context_alloc);/** +* fence_timeline_create - create a new fence_timeline +* @num: [in] amount of contexts to allocate +* @ops: [in] timeline ops of the caller +* @size: [in] size to allocate struct fence_timeline +* @name: [in] name of the timeline +* +* This function will return the new fence_timeline or NULL in case of error. +* It allocs and initializes a new fence_timeline with a proper fence context +* number assigned to it. +*/ +struct fence_timeline *fence_timeline_create (unsigned num, +struct fence_timeline_ops *ops, +int size,const char *name) +{ +struct fence_timeline *timeline; + +if (size <sizeof (*timeline)) +return NULL ; + + timeline =kzalloc (size,GFP_KERNEL ); +if (!timeline) +return NULL ; + +kref_init (&timeline->kref); + timeline->ops = ops; + timeline->context =fence_context_alloc (1 ); +strlcpy (timeline->name, name,sizeof (timeline->name)); + +INIT_LIST_HEAD (&timeline->child_list_head); +INIT_LIST_HEAD (&timeline->active_list_head); +spin_lock_init (&timeline->lock); + +return timeline; +} +EXPORT_SYMBOL (fence_timeline_create); + +/** +* fence_timeline_free - free resources of fence_timeline +* @kref [in] the kref of the fence_timeline to be freed +* +* This function frees a fence_timeline which is matter of a simple +* call to kfree() +*/ +static void fence_timeline_free (struct kref *kref) +{ +struct fence_timeline *timeline = + container_of(kref, struct fence_timeline, kref); + +kfree (timeline); +} + +/** +* fence_timeline_get - get a reference to the timeline +* @timeline [in] the fence_timeline to get a reference +* +* This function increase the refcnt for the given timeline. +*/ +void fence_timeline_get (struct fence_timeline *timeline) +{ +kref_get (&timeline->kref); +} +EXPORT_SYMBOL (fence_timeline_get); + +/** +* fence_timeline_put - put a reference to the timeline +* @timeline [in] the fence_timeline to put a reference +* +* This function decreases the refcnt for the given timeline +* and frees it if gets to zero. +*/ +void fence_timeline_put (struct fence_timeline *timeline) +{ +kref_put (&timeline->kref, fence_timeline_free); +} +EXPORT_SYMBOL (fence_timeline_put); + +/** +* fence_timeline_destroy - destroy a fence_timeline +* @timeline [in] the fence_timeline to destroy +* +* This function destroys a timeline. It signals any active fence first. +*/ +void fence_timeline_destroy (struct fence_timeline *timeline) +{ + timeline->destroyed = true; +/* +* Ensure timeline is marked as destroyed before +* changing timeline's fences status. +*/ +smp_wmb (); + +/* +* signal any children that their parent is going away. +*/ +fence_timeline_signal (timeline); +fence_timeline_put (timeline); +} +EXPORT_SYMBOL (fence_timeline_destroy); + +/** +* fence_timeline_signal - signal fences on a fence_timeline +* @timeline [in] the fence_timeline to signal fences +* +* This function signal fences on a given timeline and remove +* those from the active_list. +*/ +void fence_timeline_signal (struct fence_timeline *timeline) +{ +unsigned long flags; +LIST_HEAD (signaled_pts); +struct fence *fence, *next; + +spin_lock_irqsave (&timeline->lock, flags); + +list_for_each_entry_safe (fence, next, &timeline->active_list_head, + active_list) { +if (fence_is_signaled_locked (fence)) +list_del_init (&fence->active_list); + } + +spin_unlock_irqrestore (&timeline->lock, flags); +} +EXPORT_SYMBOL (fence_timeline_signal); + +/** * fence_signal_locked - signal completion of a fence * @fence: the fence to signal *
drivers/staging/android/sw_sync.c +14 -13
@@ -38,18 +38,19 @@ struct sync_pt *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value) }EXPORT_SYMBOL (sw_sync_pt_create); -static int sw_sync_pt_has_signaled (struct sync_pt *sync_pt) +static int sw_sync_fence_has_signaled (struct fence *fence) { -struct sw_sync_pt *pt = (struct sw_sync_pt *)sync_pt; +struct sw_sync_pt *pt = (struct sw_sync_pt *)fence;struct sw_sync_timeline *obj = - (struct sw_sync_timeline *)sync_pt_parent (sync_pt); + (struct sw_sync_timeline *)fence_parent (fence);return (pt->value > obj->value) ?0 :1 ; } -static int sw_sync_fill_driver_data (struct sync_pt *sync_pt, +static int sw_sync_fill_driver_data (struct fence *fence,void *data,int size) { +struct sync_pt *sync_pt = (struct sync_pt *)fence;struct sw_sync_pt *pt = (struct sw_sync_pt *)sync_pt;if (size <sizeof (pt->value))
@@ -60,34 +61,34 @@ static int sw_sync_fill_driver_data(struct sync_pt *sync_pt,return sizeof (pt->value); } -static void sw_sync_timeline_value_str (struct sync_timeline *sync_timeline, +static void sw_sync_timeline_value_str (struct fence_timeline *fence_timeline,char *str,int size) {struct sw_sync_timeline *timeline = - (struct sw_sync_timeline *)sync_timeline; + (struct sw_sync_timeline *)fence_timeline;snprintf (str, size,"%d" , timeline->value); } -static void sw_sync_pt_value_str (struct sync_pt *sync_pt, +static void sw_sync_fence_value_str (struct fence *fence,char *str,int size) { -struct sw_sync_pt *pt = (struct sw_sync_pt *)sync_pt; +struct sw_sync_pt *pt = (struct sw_sync_pt *)fence;snprintf (str, size,"%d" , pt->value); } -static struct sync_timeline_ops sw_sync_timeline_ops = { +static struct fence_timeline_ops sw_sync_timeline_ops = { .driver_name ="sw_sync" , - .has_signaled = sw_sync_pt_has_signaled, + .has_signaled = sw_sync_fence_has_signaled, .fill_driver_data = sw_sync_fill_driver_data, .timeline_value_str = sw_sync_timeline_value_str, - .pt_value_str = sw_sync_pt_value_str, + .fence_value_str = sw_sync_fence_value_str, };struct sw_sync_timeline *sw_sync_timeline_create (const char *name) {struct sw_sync_timeline *obj = (struct sw_sync_timeline *) -sync_timeline_create (&sw_sync_timeline_ops, +fence_timeline_create (1 , &sw_sync_timeline_ops,sizeof (struct sw_sync_timeline ), name);
@@ -99,6 +100,6 @@ void sw_sync_timeline_inc(struct sw_sync_timeline *obj, u32 inc) { obj->value += inc; -sync_timeline_signal (&obj->obj); +fence_timeline_signal (&obj->obj); }EXPORT_SYMBOL (sw_sync_timeline_inc);
drivers/staging/android/sw_sync.h +1 -1
@@ -23,7 +23,7 @@#include "uapi/sw_sync.h" struct sw_sync_timeline { -struct sync_timeline obj; +struct fence_timeline obj;u32 value; };
drivers/staging/android/sync.c +29 -121
229 lines not on this page · raw message
drivers/staging/android/sync.h +4 -126
156 lines not on this page · raw message
drivers/staging/android/sync_debug.c +13 -13
@@ -38,21 +38,21 @@ static DEFINE_SPINLOCK(sync_timeline_list_lock);static LIST_HEAD (sync_fence_list_head);static DEFINE_SPINLOCK (sync_fence_list_lock); -void sync_timeline_debug_add (struct sync_timeline *obj) +void sync_timeline_debug_add (struct fence_timeline *obj) {unsigned long flags;spin_lock_irqsave (&sync_timeline_list_lock, flags); -list_add_tail (&obj->sync_timeline_list, &sync_timeline_list_head); +list_add_tail (&obj->fence_timeline_list, &sync_timeline_list_head);spin_unlock_irqrestore (&sync_timeline_list_lock, flags); } -void sync_timeline_debug_remove (struct sync_timeline *obj) +void sync_timeline_debug_remove (struct fence_timeline *obj) {unsigned long flags;spin_lock_irqsave (&sync_timeline_list_lock, flags); -list_del (&obj->sync_timeline_list); +list_del (&obj->fence_timeline_list);spin_unlock_irqrestore (&sync_timeline_list_lock, flags); }
@@ -127,7 +127,7 @@ static void sync_print_pt(struct seq_file *s, struct fence *pt, bool fence)seq_puts (s,"\n" ); } -static void sync_print_obj (struct seq_file *s,struct sync_timeline *obj) +static void sync_print_obj (struct seq_file *s,struct fence_timeline *obj) {struct list_head *pos;unsigned long flags;
@@ -143,13 +143,13 @@ static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj)seq_puts (s,"\n" ); -spin_lock_irqsave (&obj->child_list_lock, flags); +spin_lock_irqsave (&obj->lock, flags);list_for_each (pos, &obj->child_list_head) { -struct sync_pt *pt = - container_of(pos, struct sync_pt, child_list); +struct sync_pt *pt = (struct sync_pt *) + container_of(pos, struct fence, child_list);sync_print_pt (s, &pt->base, false); } -spin_unlock_irqrestore (&obj->child_list_lock, flags); +spin_unlock_irqrestore (&obj->lock, flags); } static void sync_print_sync_fence(struct seq_file *s,
@@ -189,9 +189,9 @@ static int sync_debugfs_show(struct seq_file *s, void *unused)spin_lock_irqsave (&sync_timeline_list_lock, flags);list_for_each (pos, &sync_timeline_list_head) { -struct sync_timeline *obj = - container_of(pos, struct sync_timeline, - sync_timeline_list); +struct fence_timeline *obj = + container_of(pos, struct fence_timeline, + fence_timeline_list);sync_print_obj (s, obj);seq_puts (s,"\n" );
@@ -251,7 +251,7 @@ static int sw_sync_debugfs_release(struct inode *inode, struct file *file) {struct sw_sync_timeline *obj = file->private_data; -sync_timeline_destroy (&obj->obj); +fence_timeline_destroy (&obj->obj);return 0 ; }
drivers/staging/android/trace/sync.h +0 -24
@@ -8,30 +8,6 @@#include "../sync.h" #include <linux/tracepoint.h> -TRACE_EVENT (sync_timeline, - TP_PROTO(struct sync_timeline *timeline), - -TP_ARGS (timeline), - -TP_STRUCT__entry ( - __string(name, timeline->name) -__array (char, value,32 ) - ), - -TP_fast_assign ( - __assign_str(name, timeline->name); - if (timeline->ops->timeline_value_str) { - timeline->ops->timeline_value_str(timeline, - __entry->value, - sizeof(__entry->value)); - } else { - __entry->value[0 ] ='\0' ; - } - ), - -TP_printk ("name=%s value=%s" ,__get_str (name), __entry->value) -); - TRACE_EVENT(sync_wait, TP_PROTO(struct sync_fence *fence, int begin),
include/linux/fence.h +75 -0
96 lines not on this page · raw message
include/trace/events/fence.h +24 -0
@@ -48,6 +48,30 @@ TRACE_EVENT(fence_annotate_wait_on, __entry->waiting_context, __entry->waiting_seqno) ); +TRACE_EVENT (fence_timeline, + TP_PROTO(struct fence_timeline *timeline), + +TP_ARGS (timeline), + +TP_STRUCT__entry ( + __string(name, timeline->name) +__array (char, value,32 ) + ), + +TP_fast_assign ( + __assign_str(name, timeline->name); + if (timeline->ops->timeline_value_str) { + timeline->ops->timeline_value_str(timeline, + __entry->value, + sizeof(__entry->value)); + } else { + __entry->value[0 ] ='\0' ; + } + ), + +TP_printk ("name=%s value=%s" ,__get_str (name), __entry->value) +); + DECLARE_EVENT_CLASS(fence, TP_PROTO(struct fence *fence),
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 12/29 staging/android: remove struct sync_pt
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
struct sync_pt was just wrapping around struct fence and creating an extra abstraction layer. The only two members of struct sync_pt, child_list and active_list, were moved to struct fence in an earlier commit. After removing those two members struct sync_pt is nothing more than struct fence, so remove it all and use struct fence directly.
--- drivers/staging/android/sw_sync.c | 7 +++--- drivers/staging/android/sw_sync.h | 8 +++---- drivers/staging/android/sync.c | 33 ++++++++++++----------------- drivers/staging/android/sync.h | 21 ++++-------------- drivers/staging/android/sync_debug.c | 41 ++++++++++++++++++------------------ drivers/staging/android/trace/sync.h | 14 ++++++------ 6 files changed, 53 insertions(+), 71 deletions(-)
drivers/staging/android/sw_sync.c +3 -4
@@ -25,7 +25,7 @@#include "sw_sync.h" -struct sync_pt *sw_sync_pt_create (struct sw_sync_timeline *obj,u32 value) +struct fence *sw_sync_pt_create (struct sw_sync_timeline *obj,u32 value) {struct sw_sync_pt *pt;
@@ -34,7 +34,7 @@ struct sync_pt *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value) pt->value = value; -return (struct sync_pt *)pt; +return (struct fence *)pt; }EXPORT_SYMBOL (sw_sync_pt_create);
@@ -50,8 +50,7 @@ static int sw_sync_fence_has_signaled(struct fence *fence)static int sw_sync_fill_driver_data (struct fence *fence,void *data,int size) { -struct sync_pt *sync_pt = (struct sync_pt *)fence; -struct sw_sync_pt *pt = (struct sw_sync_pt *)sync_pt; +struct sw_sync_pt *pt = (struct sw_sync_pt *)fence;if (size <sizeof (pt->value))return -ENOMEM ;
drivers/staging/android/sw_sync.h +4 -4
@@ -29,7 +29,7 @@ struct sw_sync_timeline { };struct sw_sync_pt { -struct sync_pt pt; +struct fence pt;u32 value; };
@@ -38,7 +38,7 @@ struct sw_sync_pt {struct sw_sync_timeline *sw_sync_timeline_create (const char *name);void sw_sync_timeline_inc (struct sw_sync_timeline *obj,u32 inc); -struct sync_pt *sw_sync_pt_create (struct sw_sync_timeline *obj,u32 value); +struct fence *sw_sync_pt_create (struct sw_sync_timeline *obj,u32 value);#else static inline struct sw_sync_timeline *sw_sync_timeline_create (const char *name) {
@@ -49,8 +49,8 @@ static inline void sw_sync_timeline_inc(struct sw_sync_timeline *obj, u32 inc) { } -static inline struct sync_pt *sw_sync_pt_create (struct sw_sync_timeline *obj, -u32 value) +static inline struct fence *sw_sync_pt_create (struct sw_sync_timeline *obj, +u32 value) {return NULL ; }
drivers/staging/android/sync.c +14 -19
@@ -39,7 +39,7 @@ struct fence *sync_pt_create(struct fence_timeline *obj, int size)unsigned long flags;struct fence *fence; -if (size <sizeof (struct sync_pt )) +if (size <sizeof (*fence))return NULL ; fence =kzalloc (size,GFP_KERNEL );
@@ -57,12 +57,6 @@ struct fence *sync_pt_create(struct fence_timeline *obj, int size) }EXPORT_SYMBOL (sync_pt_create); -void sync_pt_free (struct sync_pt *pt) -{ -fence_put (&pt->base); -} -EXPORT_SYMBOL (sync_pt_free); -static struct sync_fence *sync_fence_alloc (int size,const char *name) {struct sync_fence *sync_fence;
@@ -101,7 +95,7 @@ static void fence_check_cb_func(struct fence *f, struct fence_cb *cb) }/* TODO: implement a create which takes more that one sync_pt */ -struct sync_fence *sync_fence_create_dma (const char *name,struct fence *pt) +struct sync_fence *sync_fence_create_dma (const char *name,struct fence *fence) {struct sync_fence *sync_fence;
@@ -113,9 +107,10 @@ struct sync_fence *sync_fence_create_dma(const char *name, struct fence *pt) sync_fence->num_fences =1 ;atomic_set (&sync_fence->status,1 ); - sync_fence->cbs[0 ].fence = pt; + sync_fence->cbs[0 ].fence = fence; sync_fence->cbs[0 ].sync_fence = sync_fence; -if (fence_add_callback (pt, &sync_fence->cbs[0 ].cb, fence_check_cb_func)) +if (fence_add_callback (fence, &sync_fence->cbs[0 ].cb, + fence_check_cb_func))atomic_dec (&sync_fence->status);sync_fence_debug_add (sync_fence);
@@ -124,9 +119,9 @@ struct sync_fence *sync_fence_create_dma(const char *name, struct fence *pt) }EXPORT_SYMBOL (sync_fence_create_dma); -struct sync_fence *sync_fence_create (const char *name,struct sync_pt *pt) +struct sync_fence *sync_fence_create (const char *name,struct fence *fence) { -return sync_fence_create_dma (name, &pt->base); +return sync_fence_create_dma (name, fence); }EXPORT_SYMBOL (sync_fence_create);
@@ -161,14 +156,14 @@ void sync_fence_install(struct sync_fence *sync_fence, int fd)EXPORT_SYMBOL (sync_fence_install);static void sync_fence_add_pt (struct sync_fence *sync_fence, -int *i,struct fence *pt) +int *i,struct fence *fence) { - sync_fence->cbs[*i].fence = pt; + sync_fence->cbs[*i].fence = fence; sync_fence->cbs[*i].sync_fence = sync_fence; -if (!fence_add_callback (pt, &sync_fence->cbs[*i].cb, +if (!fence_add_callback (fence, &sync_fence->cbs[*i].cb, fence_check_cb_func)) { -fence_get (pt); +fence_get (fence); (*i)++; } }
@@ -300,7 +295,7 @@ int sync_fence_wait(struct sync_fence *sync_fence, long timeout)trace_sync_wait (sync_fence,1 );for (i =0 ; i < sync_fence->num_fences; ++i) -trace_sync_pt (sync_fence->cbs[i].fence); +trace_fence (sync_fence->cbs[i].fence); ret =wait_event_interruptible_timeout (sync_fence->wq,atomic_read (&sync_fence->status) <=0 , timeout);
@@ -589,9 +584,9 @@ static long sync_fence_ioctl_fence_info(struct sync_fence *sync_fence, len =sizeof (struct sync_fence_info_data );for (i =0 ; i < sync_fence->num_fences; ++i) { -struct fence *pt = sync_fence->cbs[i].fence; +struct fence *fence = sync_fence->cbs[i].fence; - ret =sync_fill_pt_info (pt, (u8 *)data + len, size - len); + ret =sync_fill_pt_info (fence, (u8 *)data + len, size - len);if (ret <0 ) goto out;
drivers/staging/android/sync.h +4 -17
@@ -25,10 +25,6 @@struct sync_fence ; -struct sync_pt { -struct fence base; -}; -struct sync_fence_cb {struct fence_cb cb;struct fence *fence;
@@ -89,23 +85,14 @@ static inline void sync_fence_waiter_init(struct sync_fence_waiter *waiter,struct fence *sync_pt_create (struct fence_timeline *parent,int size);/** -* sync_pt_free() - frees a sync pt -* @pt: sync_pt to free -* -* This should only be called on sync_pts which have been created but -* not added to a fence. -*/ -void sync_pt_free (struct sync_pt *pt); - -/** * sync_fence_create() - creates a sync fence * @name: name of fence to create -* @pt: sync_pt to add to the fence +* @fence: fence to add to the sync_fence * -* Creates a fence containg @pt. Once this is called, the fence takes -* ownership of @pt. +* Creates a fence containg @fence. Once this is called, the fence takes +* ownership of @fence. */ -struct sync_fence *sync_fence_create (const char *name,struct sync_pt *pt); +struct sync_fence *sync_fence_create (const char *name,struct fence *fence);/** * sync_fence_create_dma() - creates a sync fence from dma-fence
drivers/staging/android/sync_debug.c +21 -20
99 lines not on this page · raw message
drivers/staging/android/trace/sync.h +7 -7
@@ -29,20 +29,20 @@ TRACE_EVENT(sync_wait, __get_str(name), __entry->status) ); -TRACE_EVENT(sync_pt, - TP_PROTO(struct fence *pt), +TRACE_EVENT(fence, + TP_PROTO(struct fence *fence), - TP_ARGS(pt), + TP_ARGS(fence), TP_STRUCT__entry( - __string(timeline, pt->ops->get_timeline_name(pt)) + __string(timeline, fence->ops->get_timeline_name(fence)) __array(char, value, 32) ), TP_fast_assign( - __assign_str(timeline, pt->ops->get_timeline_name(pt)); - if (pt->ops->fence_value_str) { - pt->ops->fence_value_str(pt, __entry->value, + __assign_str(timeline, fence->ops->get_timeline_name(fence)); + if (fence->ops->fence_value_str) { + fence->ops->fence_value_str(fence, __entry->value, sizeof(__entry->value)); } else { __entry->value[0] = '\0';
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 13/29 dma-buf/fence: create fence_default_enable_signaling()
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
Add a default .enable_signaling() op to be used on fence_ops vtable. fence_default_enable_signaling() checks if the was not signaled yet and adds it to the active_list.
--- drivers/dma-buf/fence.c | 22 ++++++++++++++++++++++ drivers/staging/android/sync.c | 13 +------------ include/linux/fence.h | 1 + 3 files changed, 24 insertions(+), 12 deletions(-)
drivers/dma-buf/fence.c +22 -0
@@ -438,6 +438,28 @@ fence_remove_callback(struct fence *fence, struct fence_cb *cb) }EXPORT_SYMBOL (fence_remove_callback); +/** +* fence_default_enable_signaling - default op for .enable_signaling +* @fence: [in] the fence to enable signaling +* +* This function checks if the fence was already signaled and if not +* adds it to the list of active fences. +*/ +bool fence_default_enable_signaling (struct fence *fence) +{ +struct fence_timeline *timeline =fence_parent (fence); + +if (!timeline) +return false; + +if (fence->ops->signaled && fence->ops->signaled (fence)) +return false; + +list_add_tail (&fence->active_list, &timeline->active_list_head); +return true; +} +EXPORT_SYMBOL (fence_default_enable_signaling); +struct default_wait_cb {struct fence_cb base;struct task_struct *task;
drivers/staging/android/sync.c +1 -12
@@ -362,17 +362,6 @@ static bool sync_fence_signaled(struct fence *fence)return ret; } -static bool sync_fence_enable_signaling (struct fence *fence) -{ -struct fence_timeline *parent =fence_parent (fence); - -if (sync_fence_signaled (fence)) -return false; - -list_add_tail (&fence->active_list, &parent->active_list_head); -return true; -} -static int sync_fence_fill_driver_data (struct fence *fence,void *data,int size) {
@@ -412,7 +401,7 @@ static void sync_fence_timeline_value_str(struct fence *fence,static const struct fence_ops sync_fence_ops = { .get_driver_name = sync_fence_get_driver_name, .get_timeline_name = sync_fence_get_timeline_name, - .enable_signaling = sync_fence_enable_signaling, + .enable_signaling = fence_default_enable_signaling, .signaled = sync_fence_signaled, .wait = fence_default_wait, .release = sync_fence_release,
include/linux/fence.h +1 -0
@@ -295,6 +295,7 @@ static inline void fence_put(struct fence *fence)int fence_signal (struct fence *fence);int fence_signal_locked (struct fence *fence); +bool fence_default_enable_signaling (struct fence *fence);signed long fence_default_wait (struct fence *fence,bool intr,signed long timeout);int fence_add_callback (struct fence *fence,struct fence_cb *cb,fence_func_t func);
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 14/29 dma-buf/fence: create fence_default_release()
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
Add a default .release() op to be used on fence_ops vtable. It removes the fences from any list it was added, removes a timeline ref and free the fence.
--- drivers/dma-buf/fence.c | 28 ++++++++++++++++++++++++++++ drivers/staging/android/sync.c | 18 +----------------- include/linux/fence.h | 1 + 3 files changed, 30 insertions(+), 17 deletions(-)
drivers/dma-buf/fence.c +28 -0
@@ -544,6 +544,34 @@ out: }EXPORT_SYMBOL (fence_default_wait); +/** +* fence_default_release - default .release op +* @fence: [in] the fence to release +* +* This function removes the fence from the child_list * and active_list +* (if it was active) and drops its timeline ref. Finally it frees the +* fence. +*/ +void fence_default_release (struct fence *fence) +{ +struct fence_timeline *timeline =fence_parent (fence); +unsigned long flags; + +if (!timeline) +return ; + +spin_lock_irqsave (fence->lock, flags); +list_del (&fence->child_list); +if (!list_empty (&fence->active_list)) +list_del (&fence->active_list); + +spin_unlock_irqrestore (fence->lock, flags); + +fence_timeline_put (timeline); +fence_free (fence); +} +EXPORT_SYMBOL (fence_default_release); +static bool fence_test_signaled_any (struct fence **fences,uint32_t count) {
drivers/staging/android/sync.c +1 -17
@@ -335,22 +335,6 @@ static const char *sync_fence_get_timeline_name(struct fence *fence)return parent->name; } -static void sync_fence_release (struct fence *fence) -{ -struct fence_timeline *parent =fence_parent (fence); -unsigned long flags; - -spin_lock_irqsave (fence->lock, flags); -list_del (&fence->child_list); -if (!list_empty (&fence->active_list)) -list_del (&fence->active_list); - -spin_unlock_irqrestore (fence->lock, flags); - -fence_timeline_put (parent); -fence_free (fence); -} -static bool sync_fence_signaled (struct fence *fence) {struct fence_timeline *parent =fence_parent (fence);
@@ -404,7 +388,7 @@ static const struct fence_ops sync_fence_ops = { .enable_signaling = fence_default_enable_signaling, .signaled = sync_fence_signaled, .wait = fence_default_wait, - .release = sync_fence_release, + .release = fence_default_release, .fill_driver_data = sync_fence_fill_driver_data, .fence_value_str = sync_fence_value_str, .timeline_value_str = sync_fence_timeline_value_str,
include/linux/fence.h +1 -0
@@ -297,6 +297,7 @@ int fence_signal(struct fence *fence);int fence_signal_locked (struct fence *fence);bool fence_default_enable_signaling (struct fence *fence);signed long fence_default_wait (struct fence *fence,bool intr,signed long timeout); +void fence_default_release (struct fence *fence);int fence_add_callback (struct fence *fence,struct fence_cb *cb,fence_func_t func);bool fence_remove_callback (struct fence *fence,struct fence_cb *cb);
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 15/29 dma-buf/fence: create fence_default_get_driver_name()
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
Move driver name handling to fence and create a default function for it. Returns the driver which the fence belongs.
--- drivers/dma-buf/fence.c | 19 ++++++++++++++++++- drivers/staging/android/sw_sync.c | 3 +-- drivers/staging/android/sync.c | 9 +-------- drivers/staging/android/sync_debug.c | 2 +- include/linux/fence.h | 8 ++++---- 5 files changed, 25 insertions(+), 16 deletions(-)
drivers/dma-buf/fence.c +18 -1
@@ -56,6 +56,7 @@ EXPORT_SYMBOL(fence_context_alloc);* @num: [in] amount of contexts to allocate * @ops: [in] timeline ops of the caller * @size: [in] size to allocate struct fence_timeline +* @drv_name: [in] name of the driver * @name: [in] name of the timeline * * This function will return the new fence_timeline or NULL in case of error.
@@ -64,7 +65,8 @@ EXPORT_SYMBOL(fence_context_alloc);*/ struct fence_timeline *fence_timeline_create (unsigned num,struct fence_timeline_ops *ops, -int size,const char *name) +int size,const char *drv_name, +const char *name) {struct fence_timeline *timeline;
@@ -79,6 +81,7 @@ struct fence_timeline *fence_timeline_create(unsigned num, timeline->ops = ops; timeline->context =fence_context_alloc (1 );strlcpy (timeline->name, name,sizeof (timeline->name)); +strlcpy (timeline->drv_name, drv_name,sizeof (timeline->drv_name));INIT_LIST_HEAD (&timeline->child_list_head);INIT_LIST_HEAD (&timeline->active_list_head);
@@ -439,6 +442,20 @@ fence_remove_callback(struct fence *fence, struct fence_cb *cb)EXPORT_SYMBOL (fence_remove_callback);/** +* fence_default_get_driver_name - default .get_driver_name op +* @fence: [in] the fence to get driver name +* +* This function returns the name of the driver that the fence belongs. +*/ +const char *fence_default_get_driver_name (struct fence *fence) +{ +struct fence_timeline *parent =fence_parent (fence); + +return parent->drv_name; +} +EXPORT_SYMBOL (fence_default_get_driver_name); + +/** * fence_default_enable_signaling - default op for .enable_signaling * @fence: [in] the fence to enable signaling *
drivers/staging/android/sw_sync.c +1 -2
@@ -77,7 +77,6 @@ static void sw_sync_fence_value_str(struct fence *fence, }static struct fence_timeline_ops sw_sync_timeline_ops = { - .driver_name ="sw_sync" , .has_signaled = sw_sync_fence_has_signaled, .fill_driver_data = sw_sync_fill_driver_data, .timeline_value_str = sw_sync_timeline_value_str,
@@ -89,7 +88,7 @@ struct sw_sync_timeline *sw_sync_timeline_create(const char *name)struct sw_sync_timeline *obj = (struct sw_sync_timeline *)fence_timeline_create (1 , &sw_sync_timeline_ops,sizeof (struct sw_sync_timeline ), - name); +"sw_sync" , name);return obj; }
drivers/staging/android/sync.c +1 -8
@@ -321,13 +321,6 @@ int sync_fence_wait(struct sync_fence *sync_fence, long timeout) }EXPORT_SYMBOL (sync_fence_wait); -static const char *sync_fence_get_driver_name (struct fence *fence) -{ -struct fence_timeline *parent =fence_parent (fence); - -return parent->ops->driver_name; -} -static const char *sync_fence_get_timeline_name (struct fence *fence) {struct fence_timeline *parent =fence_parent (fence);
@@ -383,7 +376,7 @@ static void sync_fence_timeline_value_str(struct fence *fence, }static const struct fence_ops sync_fence_ops = { - .get_driver_name = sync_fence_get_driver_name, + .get_driver_name = fence_default_get_driver_name, .get_timeline_name = sync_fence_get_timeline_name, .enable_signaling = fence_default_enable_signaling, .signaled = sync_fence_signaled,
drivers/staging/android/sync_debug.c +1 -1
@@ -133,7 +133,7 @@ static void sync_print_obj(struct seq_file *s, struct fence_timeline *obj)struct list_head *pos;unsigned long flags; -seq_printf (s,"%s %s" , obj->name, obj->ops->driver_name); +seq_printf (s,"%s %s" , obj->name, obj->drv_name);if (obj->ops->timeline_value_str) {char value[64 ];
include/linux/fence.h +4 -4
@@ -36,7 +36,6 @@ struct fence_ops;struct fence_cb ;/** * struct fence_timeline_ops - fence context implementation ops -* @driver_name: name of the implementation * @has_signaled: returns: * 1 if pt has signaled * 0 if pt has not signaled
@@ -49,8 +48,6 @@ struct fence_cb;* @pt_value_str: fill str with the value of the sync_pt */ struct fence_timeline_ops { -const char *driver_name; -/* required */ int (*has_signaled)(struct fence *fence);
@@ -80,6 +77,7 @@ struct fence_timeline_ops {struct fence_timeline {struct kref kref;char name[32 ]; +char drv_name[32 ];const struct fence_timeline_ops *ops;bool destroyed;int value;
@@ -94,7 +92,8 @@ struct fence_timeline {struct fence_timeline *fence_timeline_create (unsigned num,struct fence_timeline_ops *ops, -int size,const char *name); +int size,const char *drv_name, +const char *name);void fence_timeline_get (struct fence_timeline *timeline);void fence_timeline_put (struct fence_timeline *timeline);void fence_timeline_destroy (struct fence_timeline *timeline);
@@ -295,6 +294,7 @@ static inline void fence_put(struct fence *fence)int fence_signal (struct fence *fence);int fence_signal_locked (struct fence *fence); +const char *fence_default_get_driver_name (struct fence *fence);bool fence_default_enable_signaling (struct fence *fence);signed long fence_default_wait (struct fence *fence,bool intr,signed long timeout);void fence_default_release (struct fence *fence);
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 16/29 dma-buf/fence: create fence_default_timeline_name()
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
The fence timeline struct already receives the name of the timeline so we can use a default function to return the timeline name.
--- drivers/dma-buf/fence.c | 14 ++++++++++++++ drivers/staging/android/sync.c | 9 +-------- include/linux/fence.h | 1 + 3 files changed, 16 insertions(+), 8 deletions(-)
drivers/dma-buf/fence.c +14 -0
@@ -456,6 +456,20 @@ const char *fence_default_get_driver_name(struct fence *fence)EXPORT_SYMBOL (fence_default_get_driver_name);/** +* fence_default_get_timeline_name - default get_timeline_name op +* @fence: [in] the fence to retrieve timeline name +* +* This function returns the name of the timeline which the fence belongs to. +*/ +const char *fence_default_get_timeline_name (struct fence *fence) +{ +struct fence_timeline *parent =fence_parent (fence); + +return parent->name; +} +EXPORT_SYMBOL (fence_default_get_timeline_name); + +/** * fence_default_enable_signaling - default op for .enable_signaling * @fence: [in] the fence to enable signaling *
drivers/staging/android/sync.c +1 -8
@@ -321,13 +321,6 @@ int sync_fence_wait(struct sync_fence *sync_fence, long timeout) }EXPORT_SYMBOL (sync_fence_wait); -static const char *sync_fence_get_timeline_name (struct fence *fence) -{ -struct fence_timeline *parent =fence_parent (fence); - -return parent->name; -} -static bool sync_fence_signaled (struct fence *fence) {struct fence_timeline *parent =fence_parent (fence);
@@ -377,7 +370,7 @@ static void sync_fence_timeline_value_str(struct fence *fence,static const struct fence_ops sync_fence_ops = { .get_driver_name = fence_default_get_driver_name, - .get_timeline_name = sync_fence_get_timeline_name, + .get_timeline_name = fence_default_get_timeline_name, .enable_signaling = fence_default_enable_signaling, .signaled = sync_fence_signaled, .wait = fence_default_wait,
include/linux/fence.h +1 -0
@@ -295,6 +295,7 @@ static inline void fence_put(struct fence *fence)int fence_signal (struct fence *fence);int fence_signal_locked (struct fence *fence);const char *fence_default_get_driver_name (struct fence *fence); +const char *fence_default_get_timeline_name (struct fence *fence);bool fence_default_enable_signaling (struct fence *fence);signed long fence_default_wait (struct fence *fence,bool intr,signed long timeout);void fence_default_release (struct fence *fence);
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 18/29 dma-buf/fence: create default .fence_value_str() and .timeline_value_str()
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
Provide simple default functions to help users retrieve the values of the fence and the timeline.
--- drivers/dma-buf/fence.c | 31 +++++++++++++++++++++++++++++++ drivers/staging/android/sw_sync.c | 18 ------------------ drivers/staging/android/sync.c | 30 ++---------------------------- drivers/staging/android/sync_debug.c | 11 +---------- include/linux/fence.h | 10 ++-------- include/trace/events/fence.h | 12 +++--------- 6 files changed, 39 insertions(+), 73 deletions(-)
drivers/dma-buf/fence.c +31 -0
@@ -620,6 +620,37 @@ void fence_default_release(struct fence *fence) }EXPORT_SYMBOL (fence_default_release); +/** +* fence_default_value_str - default .fence_value_str fence ops +* @fence: [in] the fence to get the value from +* @str: [out] the string pointer to write the value +* @size: [in] the size of the allocated string +* +* This functions returns a string containing the value of the fence. +*/ +void fence_default_value_str (struct fence *fence,char *str,int size) +{ +snprintf (str, size,"%d" , fence->seqno); +} +EXPORT_SYMBOL (fence_default_value_str); + +/** +* fence_default_timeline_value_str - default .timeline_value_str fence ops +* @fence: [in] the timeline child fence +* @str: [out] the string pointer to write the value +* @size: [in] the size of the allocated string +* +* This functions returns a string containing the value of the last signaled +* fence in this timeline. +*/ +void fence_default_timeline_value_str (struct fence *fence,char *str,int size) +{ +struct fence_timeline *timeline =fence_parent (fence); + +snprintf (str, size,"%d" , timeline->value); +} +EXPORT_SYMBOL (fence_default_timeline_value_str); +static bool fence_test_signaled_any (struct fence **fences,uint32_t count) {
drivers/staging/android/sw_sync.c +0 -18
@@ -51,26 +51,8 @@ static int sw_sync_fill_driver_data(struct fence *fence,return sizeof (pt->value); } -static void sw_sync_timeline_value_str (struct fence_timeline *fence_timeline, -char *str,int size) -{ -struct sw_sync_timeline *timeline = - (struct sw_sync_timeline *)fence_timeline; -snprintf (str, size,"%d" , timeline->value); -} - -static void sw_sync_fence_value_str (struct fence *fence, -char *str,int size) -{ -struct sw_sync_pt *pt = (struct sw_sync_pt *)fence; - -snprintf (str, size,"%d" , pt->value); -} -static struct fence_timeline_ops sw_sync_timeline_ops = { .fill_driver_data = sw_sync_fill_driver_data, - .timeline_value_str = sw_sync_timeline_value_str, - .fence_value_str = sw_sync_fence_value_str, };struct sw_sync_timeline *sw_sync_timeline_create (const char *name)
drivers/staging/android/sync.c +2 -28
@@ -331,32 +331,6 @@ static int sync_fence_fill_driver_data(struct fence *fence,return parent->ops->fill_driver_data (fence, data, size); } -static void sync_fence_value_str (struct fence *fence, -char *str,int size) -{ -struct fence_timeline *parent =fence_parent (fence); - -if (!parent->ops->fence_value_str) { -if (size) - *str =0 ; -return ; - } - parent->ops->fence_value_str (fence, str, size); -} - -static void sync_fence_timeline_value_str (struct fence *fence, -char *str,int size) -{ -struct fence_timeline *parent =fence_parent (fence); - -if (!parent->ops->timeline_value_str) { -if (size) - *str =0 ; -return ; - } - parent->ops->timeline_value_str (parent, str, size); -} -static const struct fence_ops sync_fence_ops = { .get_driver_name = fence_default_get_driver_name, .get_timeline_name = fence_default_get_timeline_name,
@@ -365,8 +339,8 @@ static const struct fence_ops sync_fence_ops = { .wait = fence_default_wait, .release = fence_default_release, .fill_driver_data = sync_fence_fill_driver_data, - .fence_value_str = sync_fence_value_str, - .timeline_value_str = sync_fence_timeline_value_str, + .fence_value_str = fence_default_value_str, + .timeline_value_str = fence_default_timeline_value_str, };static void sync_fence_free (struct kref *kref)
drivers/staging/android/sync_debug.c +1 -10
@@ -133,16 +133,7 @@ static void sync_print_obj(struct seq_file *s, struct fence_timeline *obj)struct list_head *pos;unsigned long flags; -seq_printf (s,"%s %s" , obj->name, obj->drv_name); - -if (obj->ops->timeline_value_str) { -char value[64 ]; - - obj->ops->timeline_value_str (obj, value,sizeof (value)); -seq_printf (s,": %s" , value); - } - -seq_puts (s,"\n" ); +seq_printf (s,"%s %s: %d\n" , obj->name, obj->drv_name, obj->value);spin_lock_irqsave (&obj->lock, flags);list_for_each (pos, &obj->child_list_head) {
include/linux/fence.h +2 -8
@@ -40,19 +40,11 @@ struct fence_cb;* should return an error if there is not enough room * as specified by size. This information is returned * to userspace by SYNC_IOC_FENCE_INFO. -* @timeline_value_str: fill str with the value of the sync_timeline's counter * @pt_value_str: fill str with the value of the sync_pt */ struct fence_timeline_ops {/* optional */ int (*fill_driver_data)(struct fence *fence,void *data,int size); - -/* optional */ -void (*timeline_value_str)(struct fence_timeline *timeline,char *str, -int size); - -/* optional */ -void (*fence_value_str)(struct fence *fence,char *str,int size); };/**
@@ -293,6 +285,8 @@ bool fence_default_signaled(struct fence *fence);bool fence_default_enable_signaling (struct fence *fence);signed long fence_default_wait (struct fence *fence,bool intr,signed long timeout);void fence_default_release (struct fence *fence); +void fence_default_value_str (struct fence *fence,char *str,int size); +void fence_default_timeline_value_str (struct fence *fence,char *str,int size);int fence_add_callback (struct fence *fence,struct fence_cb *cb,fence_func_t func);bool fence_remove_callback (struct fence *fence,struct fence_cb *cb);
include/trace/events/fence.h +3 -9
@@ -55,21 +55,15 @@ TRACE_EVENT(fence_timeline,TP_STRUCT__entry ( __string(name, timeline->name) -__array (char, value,32 ) + __field(unsigned int, value) ),TP_fast_assign ( __assign_str(name, timeline->name); -if (timeline->ops->timeline_value_str) { - timeline->ops->timeline_value_str (timeline, - __entry->value, -sizeof (__entry->value)); - }else { - __entry->value[0 ] ='\0' ; - } + __entry->value = timeline->value; ), -TP_printk ("name=%s value=%s" ,__get_str (name), __entry->value) +TP_printk ("name=%s value=%u" ,__get_str (name), __entry->value) ); DECLARE_EVENT_CLASS(fence,
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 19/29 dma-buf/fence: create fence_default_fill_driver_data()
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
The value needed by sw_sync is now inside struct fence so we create a default ops to reply that value for us.
--- drivers/dma-buf/fence.c | 21 +++++++++++++++++++++ drivers/staging/android/sync.c | 12 +----------- include/linux/fence.h | 1 + 3 files changed, 23 insertions(+), 11 deletions(-)
drivers/dma-buf/fence.c +21 -0
@@ -621,6 +621,27 @@ void fence_default_release(struct fence *fence)EXPORT_SYMBOL (fence_default_release);/** +* fence_default_fill_driver_data - fence default .fill_driver_data ops +* @fence: [in] the fence to get the data from +* @data: [out] the data pointer to write the data +* @size: [in] the size of the allocated data +* +* This function return a driver data. In the case the fence seqno value. +* It is used at least by the sw_sync to send fence information to the +* userspace. +*/ +int fence_default_fill_driver_data (struct fence *fence,void *data,int size) +{ +if (size <sizeof (fence->seqno)) +return -ENOMEM ; + +memcpy (data, &fence->seqno,sizeof (fence->seqno)); + +return sizeof (fence->seqno); +} +EXPORT_SYMBOL (fence_default_fill_driver_data); + +/** * fence_default_value_str - default .fence_value_str fence ops * @fence: [in] the fence to get the value from * @str: [out] the string pointer to write the value
drivers/staging/android/sync.c +1 -11
@@ -321,16 +321,6 @@ int sync_fence_wait(struct sync_fence *sync_fence, long timeout) }EXPORT_SYMBOL (sync_fence_wait); -static int sync_fence_fill_driver_data (struct fence *fence, -void *data,int size) -{ -struct fence_timeline *parent =fence_parent (fence); - -if (!parent->ops->fill_driver_data) -return 0 ; -return parent->ops->fill_driver_data (fence, data, size); -} -static const struct fence_ops sync_fence_ops = { .get_driver_name = fence_default_get_driver_name, .get_timeline_name = fence_default_get_timeline_name,
@@ -338,7 +328,7 @@ static const struct fence_ops sync_fence_ops = { .signaled = fence_default_signaled, .wait = fence_default_wait, .release = fence_default_release, - .fill_driver_data = sync_fence_fill_driver_data, + .fill_driver_data = fence_default_fill_driver_data, .fence_value_str = fence_default_value_str, .timeline_value_str = fence_default_timeline_value_str, };
include/linux/fence.h +1 -0
@@ -285,6 +285,7 @@ bool fence_default_signaled(struct fence *fence);bool fence_default_enable_signaling (struct fence *fence);signed long fence_default_wait (struct fence *fence,bool intr,signed long timeout);void fence_default_release (struct fence *fence); +int fence_default_fill_driver_data (struct fence *fence,void *data,int size);void fence_default_value_str (struct fence *fence,char *str,int size);void fence_default_timeline_value_str (struct fence *fence,char *str,int size); int fence_add_callback(struct fence *fence, struct fence_cb *cb,
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 20/29 dma-buf/fence: remove fence_timeline_ops
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
fence_timeline_ops was just workarounding over fence_ops and was used chained in the fence ops. So remove it all to simplify the fence code flow.
--- drivers/dma-buf/fence.c | 7 ++----- drivers/staging/android/sw_sync.c | 20 +------------------- include/linux/fence.h | 19 ++----------------- 3 files changed, 5 insertions(+), 41 deletions(-)
drivers/dma-buf/fence.c +2 -5
@@ -54,7 +54,6 @@ EXPORT_SYMBOL(fence_context_alloc);/** * fence_timeline_create - create a new fence_timeline * @num: [in] amount of contexts to allocate -* @ops: [in] timeline ops of the caller * @size: [in] size to allocate struct fence_timeline * @drv_name: [in] name of the driver * @name: [in] name of the timeline
@@ -63,9 +62,8 @@ EXPORT_SYMBOL(fence_context_alloc);* It allocs and initializes a new fence_timeline with a proper fence context * number assigned to it. */ -struct fence_timeline *fence_timeline_create (unsigned num, -struct fence_timeline_ops *ops, -int size,const char *drv_name, +struct fence_timeline *fence_timeline_create (unsigned num,int size, +const char *drv_name,const char *name) {struct fence_timeline *timeline;
@@ -78,7 +76,6 @@ struct fence_timeline *fence_timeline_create(unsigned num,return NULL ;kref_init (&timeline->kref); - timeline->ops = ops; timeline->context =fence_context_alloc (1 );strlcpy (timeline->name, name,sizeof (timeline->name));strlcpy (timeline->drv_name, drv_name,sizeof (timeline->drv_name));
drivers/staging/android/sw_sync.c +1 -19
@@ -38,28 +38,10 @@ struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value) }EXPORT_SYMBOL (sw_sync_pt_create); -static int sw_sync_fill_driver_data (struct fence *fence, -void *data,int size) -{ -struct sw_sync_pt *pt = (struct sw_sync_pt *)fence; - -if (size <sizeof (pt->value)) -return -ENOMEM ; - -memcpy (data, &pt->value,sizeof (pt->value)); - -return sizeof (pt->value); -} - -static struct fence_timeline_ops sw_sync_timeline_ops = { - .fill_driver_data = sw_sync_fill_driver_data, -}; -struct sw_sync_timeline *sw_sync_timeline_create (const char *name) {struct sw_sync_timeline *obj = (struct sw_sync_timeline *) -fence_timeline_create (1 , &sw_sync_timeline_ops, -sizeof (struct sw_sync_timeline ), +fence_timeline_create (1 ,sizeof (struct sw_sync_timeline ),"sw_sync" , name);return obj;
include/linux/fence.h +2 -17
@@ -30,22 +30,9 @@#include <linux/printk.h> #include <linux/rcupdate.h> -struct fence_timeline ;struct fence ;struct fence_ops ;struct fence_cb ; -/** -* struct fence_timeline_ops - fence context implementation ops -* @fill_driver_data: write implementation specific driver data to data. -* should return an error if there is not enough room -* as specified by size. This information is returned -* to userspace by SYNC_IOC_FENCE_INFO. -* @pt_value_str: fill str with the value of the sync_pt -*/ -struct fence_timeline_ops { -/* optional */ -int (*fill_driver_data)(struct fence *fence,void *data,int size); -};/** * struct fence_timeline - timeline for software synchronization primitive
@@ -63,7 +50,6 @@ struct fence_timeline {struct kref kref;char name[32 ];char drv_name[32 ]; -const struct fence_timeline_ops *ops;bool destroyed;unsigned int value;int context;
@@ -75,9 +61,8 @@ struct fence_timeline {#endif }; -struct fence_timeline *fence_timeline_create (unsigned num, -struct fence_timeline_ops *ops, -int size,const char *drv_name, +struct fence_timeline *fence_timeline_create (unsigned num,int size, +const char *drv_name,const char *name);void fence_timeline_get (struct fence_timeline *timeline);void fence_timeline_put (struct fence_timeline *timeline);
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 21/29 dma-buf/fence: add fence_create_on_timeline()
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
This functions in intended to replace sync_pt_create() and it does exactly the same thing sync_pt_create() did.
--- drivers/dma-buf/fence.c | 38 ++++++++++++++++++++++++++++++++++++++ drivers/staging/android/sync.c | 20 ++------------------ include/linux/fence.h | 3 +++ 3 files changed, 43 insertions(+), 18 deletions(-)
drivers/dma-buf/fence.c +38 -0
@@ -768,6 +768,44 @@ err_free_cb:EXPORT_SYMBOL (fence_wait_any_timeout);/** +* fence_create_on_timeline - create a fence and add it to the timeline +* or until timeout elapses +* @obj: [in] timeline object +* @ops: [in] fence_ops to use +* @size: [in] size to allocate struct fence +* @value: [in] value of this fence +* +* This function allocates a new fence and initialize it as a child of the +* fence_timeline provided. The value received is the seqno used to know +* when the fence is signaled. +* +* Returns NULL if fails to allocate memory or size is too small. +*/ +struct fence *fence_create_on_timeline (struct fence_timeline *obj, +const struct fence_ops *ops,int size, +unsigned int value) +{ +unsigned long flags; +struct fence *fence; + +if (size <sizeof (*fence)) +return NULL ; + + fence =kzalloc (size,GFP_KERNEL ); +if (!fence) +return NULL ; + +spin_lock_irqsave (&obj->lock, flags); +fence_timeline_get (obj); +fence_init (fence, ops, &obj->lock, obj->context, value); +list_add_tail (&fence->child_list, &obj->child_list_head); +INIT_LIST_HEAD (&fence->active_list); +spin_unlock_irqrestore (&obj->lock, flags); +return fence; +} +EXPORT_SYMBOL (fence_create_on_timeline); + +/** * fence_init - Initialize a custom fence. * @fence: [in] the fence to initialize * @ops: [in] the fence_ops for operations on this fence
drivers/staging/android/sync.c +2 -18
@@ -36,24 +36,8 @@ static const struct file_operations sync_fence_fops;struct fence *sync_pt_create (struct fence_timeline *obj,int size,u32 value) { -unsigned long flags; -struct fence *fence; - -if (size <sizeof (*fence)) -return NULL ; - - fence =kzalloc (size,GFP_KERNEL ); -if (!fence) -return NULL ; - -spin_lock_irqsave (&obj->lock, flags); -fence_timeline_get (obj); -fence_init (fence, &sync_fence_ops, &obj->lock, - obj->context, value); -list_add_tail (&fence->child_list, &obj->child_list_head); -INIT_LIST_HEAD (&fence->active_list); -spin_unlock_irqrestore (&obj->lock, flags); -return fence; +return fence_create_on_timeline (obj, &sync_fence_ops, +sizeof (struct fence ), value); }EXPORT_SYMBOL (sync_pt_create);
include/linux/fence.h +3 -0
@@ -212,6 +212,9 @@ struct fence_ops {void (*timeline_value_str)(struct fence *fence,char *str,int size); }; +struct fence *fence_create_on_timeline (struct fence_timeline *obj, +const struct fence_ops *ops,int size, +unsigned int value);void fence_init (struct fence *fence,const struct fence_ops *ops,spinlock_t *lock,unsigned context,unsigned seqno);
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 22/29 staging/android: remove sync_pt_create()
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
get sw_sync_pt_create() to use fence_create_on_timeline() directly and remove an abstractions layers between fences and its users.
--- drivers/staging/android/sw_sync.c | 22 ++++++++++++++-------- drivers/staging/android/sync.c | 20 -------------------- drivers/staging/android/sync.h | 7 ------- 3 files changed, 14 insertions(+), 35 deletions(-)
drivers/staging/android/sw_sync.c +14 -8
@@ -25,16 +25,22 @@#include "sw_sync.h" +static const struct fence_ops sw_sync_fence_ops = { + .get_driver_name = fence_default_get_driver_name, + .get_timeline_name = fence_default_get_timeline_name, + .enable_signaling = fence_default_enable_signaling, + .signaled = fence_default_signaled, + .wait = fence_default_wait, + .release = fence_default_release, + .fill_driver_data = fence_default_fill_driver_data, + .fence_value_str = fence_default_value_str, + .timeline_value_str = fence_default_timeline_value_str, +}; +struct fence *sw_sync_pt_create (struct sw_sync_timeline *obj,u32 value) { -struct sw_sync_pt *pt; - - pt = (struct sw_sync_pt *) -sync_pt_create (&obj->obj,sizeof (struct sw_sync_pt ), value); - - pt->value = value; - -return (struct fence *)pt; +return fence_create_on_timeline (&obj->obj, &sw_sync_fence_ops, +sizeof (struct fence ), value); }EXPORT_SYMBOL (sw_sync_pt_create);
drivers/staging/android/sync.c +0 -20
@@ -31,16 +31,8 @@#define CREATE_TRACE_POINTS #include "trace/sync.h" -static const struct fence_ops sync_fence_ops;static const struct file_operations sync_fence_fops; -struct fence *sync_pt_create (struct fence_timeline *obj,int size,u32 value) -{ -return fence_create_on_timeline (obj, &sync_fence_ops, -sizeof (struct fence ), value); -} -EXPORT_SYMBOL (sync_pt_create); -static struct sync_fence *sync_fence_alloc (int size,const char *name) {struct sync_fence *sync_fence;
@@ -305,18 +297,6 @@ int sync_fence_wait(struct sync_fence *sync_fence, long timeout) }EXPORT_SYMBOL (sync_fence_wait); -static const struct fence_ops sync_fence_ops = { - .get_driver_name = fence_default_get_driver_name, - .get_timeline_name = fence_default_get_timeline_name, - .enable_signaling = fence_default_enable_signaling, - .signaled = fence_default_signaled, - .wait = fence_default_wait, - .release = fence_default_release, - .fill_driver_data = fence_default_fill_driver_data, - .fence_value_str = fence_default_value_str, - .timeline_value_str = fence_default_timeline_value_str, -}; -static void sync_fence_free (struct kref *kref) { struct sync_fence *sync_fence = container_of(kref, struct sync_fence,
drivers/staging/android/sync.h +0 -7
@@ -78,13 +78,6 @@ static inline void sync_fence_waiter_init(struct sync_fence_waiter *waiter, waiter->callback = callback; } -/* -* API for fence_timeline implementers -*/ - -struct fence *sync_pt_create (struct fence_timeline *parent,int size, -u32 value); -/** * sync_fence_create() - creates a sync fence * @name: name of fence to create
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 23/29 staging/android: remove sw_sync_timeline and sw_sync_pt
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
As we moved value storage to fence_timeline and fence those two structs became useless and can be removed now.
--- drivers/staging/android/sw_sync.c | 15 ++++++--------- drivers/staging/android/sw_sync.h | 24 ++++++------------------ drivers/staging/android/sync_debug.c | 12 ++++++------ 3 files changed, 18 insertions(+), 33 deletions(-)
drivers/staging/android/sw_sync.c +6 -9
@@ -37,25 +37,22 @@ static const struct fence_ops sw_sync_fence_ops = { .timeline_value_str = fence_default_timeline_value_str, }; -struct fence *sw_sync_pt_create (struct sw_sync_timeline *obj,u32 value) +struct fence *sw_sync_pt_create (struct fence_timeline *obj,u32 value) { -return fence_create_on_timeline (&obj->obj, &sw_sync_fence_ops, +return fence_create_on_timeline (obj, &sw_sync_fence_ops,sizeof (struct fence ), value); }EXPORT_SYMBOL (sw_sync_pt_create); -struct sw_sync_timeline *sw_sync_timeline_create (const char *name) +struct fence_timeline *sw_sync_timeline_create (const char *name) { -struct sw_sync_timeline *obj = (struct sw_sync_timeline *) -fence_timeline_create (1 ,sizeof (struct sw_sync_timeline ), +return fence_timeline_create (1 ,sizeof (struct fence_timeline ),"sw_sync" , name); - -return obj; }EXPORT_SYMBOL (sw_sync_timeline_create); -void sw_sync_timeline_inc (struct sw_sync_timeline *obj,u32 inc) +void sw_sync_timeline_inc (struct fence_timeline *obj,u32 inc) { -fence_timeline_signal (&obj->obj, inc); +fence_timeline_signal (obj, inc); }EXPORT_SYMBOL (sw_sync_timeline_inc);
drivers/staging/android/sw_sync.h +6 -18
@@ -22,34 +22,22 @@#include "sync.h" #include "uapi/sw_sync.h" -struct sw_sync_timeline { -struct fence_timeline obj; - -u32 value; -}; - -struct sw_sync_pt { -struct fence pt; - -u32 value; -}; -#if IS_ENABLED (CONFIG_SW_SYNC ) -struct sw_sync_timeline *sw_sync_timeline_create (const char *name); -void sw_sync_timeline_inc (struct sw_sync_timeline *obj,u32 inc); +struct fence_timeline *sw_sync_timeline_create (const char *name); +void sw_sync_timeline_inc (struct fence_timeline *obj,u32 inc); -struct fence *sw_sync_pt_create (struct sw_sync_timeline *obj,u32 value); +struct fence *sw_sync_pt_create (struct fence_timeline *obj,u32 value);#else -static inline struct sw_sync_timeline *sw_sync_timeline_create (const char *name) +static inline struct fence_timeline *sw_sync_timeline_create (const char *name) {return NULL ; } -static inline void sw_sync_timeline_inc (struct sw_sync_timeline *obj,u32 inc) +static inline void sw_sync_timeline_inc (struct fence_timeline *obj,u32 inc) { } -static inline struct fence *sw_sync_pt_create (struct sw_sync_timeline *obj, +static inline struct fence *sw_sync_pt_create (struct fence_timeline *obj,u32 value) {return NULL ;
drivers/staging/android/sync_debug.c +6 -6
@@ -225,7 +225,7 @@ static const struct file_operations sync_info_debugfs_fops = {/* opening sw_sync create a new sync obj */ static int sw_sync_debugfs_open (struct inode *inode,struct file *file) { -struct sw_sync_timeline *obj; +struct fence_timeline *obj;char task_comm[TASK_COMM_LEN ];get_task_comm (task_comm, current);
@@ -241,13 +241,13 @@ static int sw_sync_debugfs_open(struct inode *inode, struct file *file)static int sw_sync_debugfs_release (struct inode *inode,struct file *file) { -struct sw_sync_timeline *obj = file->private_data; +struct fence_timeline *obj = file->private_data; -fence_timeline_destroy (&obj->obj); +fence_timeline_destroy (obj);return 0 ; } -static long sw_sync_ioctl_create_fence (struct sw_sync_timeline *obj, +static long sw_sync_ioctl_create_fence (struct fence_timeline *obj,unsigned long arg) {int fd =get_unused_fd_flags (O_CLOEXEC );
@@ -294,7 +294,7 @@ err:return err; } -static long sw_sync_ioctl_inc (struct sw_sync_timeline *obj,unsigned long arg) +static long sw_sync_ioctl_inc (struct fence_timeline *obj,unsigned long arg) {u32 value;
@@ -309,7 +309,7 @@ static long sw_sync_ioctl_inc(struct sw_sync_timeline *obj, unsigned long arg)static long sw_sync_ioctl (struct file *file,unsigned int cmd,unsigned long arg) { -struct sw_sync_timeline *obj = file->private_data; +struct fence_timeline *obj = file->private_data;switch (cmd) {case SW_SYNC_IOC_CREATE_FENCE :
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 24/29 dma-buf/fence: add debug to fence timeline
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
Bring the debug information that belonged to sync_timeline and sync_pt back.
--- drivers/dma-buf/Makefile | 2 +- drivers/dma-buf/fence.c | 4 ++ drivers/dma-buf/fence_debug.c | 128 +++++++++++++++++++++++++++++++++++ drivers/staging/android/sync.h | 4 -- drivers/staging/android/sync_debug.c | 105 +--------------------------- include/linux/fence.h | 18 +++++ 6 files changed, 154 insertions(+), 107 deletions(-) create mode 100644 drivers/dma-buf/fence_debug.c
drivers/dma-buf/Makefile +1 -1
@@ -1 +1 @@ -obj-y := dma-buf.o fence.o reservation.o seqno-fence.o +obj-y := dma-buf.o fence.o fence_debug.o reservation.o seqno-fence.o
drivers/dma-buf/fence.c +4 -0
@@ -84,6 +84,8 @@ struct fence_timeline *fence_timeline_create(unsigned num, int size,INIT_LIST_HEAD (&timeline->active_list_head);spin_lock_init (&timeline->lock); +fence_timeline_debug_add (timeline); +return timeline; }EXPORT_SYMBOL (fence_timeline_create);
@@ -100,6 +102,8 @@ static void fence_timeline_free(struct kref *kref)struct fence_timeline *timeline = container_of(kref, struct fence_timeline, kref); +fence_timeline_debug_remove (timeline); +kfree (timeline); }
drivers/dma-buf/fence_debug.c new file +128 -0
128 lines not on this page · raw message
drivers/staging/android/sync.h +0 -4
@@ -184,15 +184,11 @@ int sync_fence_wait(struct sync_fence *fence, long timeout);#ifdef CONFIG_DEBUG_FS -void sync_timeline_debug_add (struct fence_timeline *obj); -void sync_timeline_debug_remove (struct fence_timeline *obj);void sync_fence_debug_add (struct sync_fence *fence);void sync_fence_debug_remove (struct sync_fence *fence);void sync_dump (void );#else -# define sync_timeline_debug_add (obj) -# define sync_timeline_debug_remove (obj)# define sync_fence_debug_add (fence)# define sync_fence_debug_remove (fence)# define sync_dump ()
drivers/staging/android/sync_debug.c +3 -102
134 lines not on this page · raw message
include/linux/fence.h +18 -0
@@ -407,6 +407,24 @@ static inline signed long fence_wait(struct fence *fence, bool intr)unsigned fence_context_alloc (unsigned num); +#ifdef CONFIG_DEBUG_FS + +void fence_timeline_debug_add (struct fence_timeline *obj); +void fence_timeline_debug_remove (struct fence_timeline *obj); +const char *fence_status_str (int status); +void fence_print (struct seq_file *s,struct fence *fence,bool show); +void fence_timeline_print (struct seq_file *s,struct fence_timeline *obj); +void fence_timeline_print_all (struct seq_file * s); + +#else +#define fence_timeline_debug_add (obj) +#define fence_timeline_debug_remove (obj) +#define fence_status_str (status) +#define fence_print (s, fence, show) +#define fence_timeline_print (s, obj) +#define fence_timeline_print_all (s) +#endif + #define FENCE_TRACE(f, fmt, args...) \ do { \ struct fence *__ff = (f); \
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 25/29 dma-buf/fence: remove unused var from fence_timeline_signal()
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
signaled_pts is not used in this function.
--- drivers/dma-buf/fence.c | 1 - 1 file changed, 1 deletion(-)
drivers/dma-buf/fence.c +0 -1
@@ -166,7 +166,6 @@ EXPORT_SYMBOL(fence_timeline_destroy);void fence_timeline_signal (struct fence_timeline *timeline,unsigned int inc) {unsigned long flags; -LIST_HEAD (signaled_pts);struct fence *fence, *next;spin_lock_irqsave (&timeline->lock, flags);
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 26/29 dma-buf/fence: remove pointless fence_timeline_signal at destroy phase
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
All changes to timeline value come through the user via fence_timeline_signal() calls. When fence_timeline_destroy() is called no changes on timeline->value happens hence call fence_timeline_signal() with no increment is pointless.
--- drivers/dma-buf/fence.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/dma-buf/fence.c +1 -5
@@ -136,7 +136,7 @@ EXPORT_SYMBOL(fence_timeline_put);* fence_timeline_destroy - destroy a fence_timeline * @timeline [in] the fence_timeline to destroy * -* This function destroys a timeline. It signals any active fence first. +* This function destroys a timeline. */ void fence_timeline_destroy (struct fence_timeline *timeline) {
@@ -147,10 +147,6 @@ void fence_timeline_destroy(struct fence_timeline *timeline)*/ smp_wmb (); -/* -* signal any children that their parent is going away. -*/ -fence_timeline_signal (timeline,0 );fence_timeline_put (timeline); }EXPORT_SYMBOL (fence_timeline_destroy);
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 27/29 dma-buf/fence: add .cleanup() callback
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
Called when the fence_timeline is destroyed so users can cleanup routines on fences.
--- drivers/dma-buf/fence.c | 24 ++++++++++++++++++++++++ include/linux/fence.h | 4 ++++ 2 files changed, 28 insertions(+)
drivers/dma-buf/fence.c +24 -0
@@ -140,6 +140,9 @@ EXPORT_SYMBOL(fence_timeline_put);*/ void fence_timeline_destroy (struct fence_timeline *timeline) { +unsigned long flags; +struct fence *fence, *next; + timeline->destroyed = true;/* * Ensure timeline is marked as destroyed before
@@ -147,6 +150,15 @@ void fence_timeline_destroy(struct fence_timeline *timeline)*/ smp_wmb (); +spin_lock_irqsave (&timeline->lock, flags); +list_for_each_entry_safe (fence, next, &timeline->active_list_head, + active_list) { +if (fence->ops->cleanup) + fence->ops->cleanup (fence, fence->priv); +list_del_init (&fence->active_list); + } +spin_unlock_irqrestore (&timeline->lock, flags); +fence_timeline_put (timeline); }EXPORT_SYMBOL (fence_timeline_destroy);
@@ -839,3 +851,15 @@ fence_init(struct fence *fence, const struct fence_ops *ops,trace_fence_init (fence); }EXPORT_SYMBOL (fence_init); + +/** +* fence_add_user_data - add private user data +* @fence: [in] the fence to use +* @user_data: [in] the private data to store +* +* This function adds a private user data point to struct fence. +*/ +void fence_add_user_data (struct fence *fence,void *user_data) +{ + fence->priv = user_data; +}
include/linux/fence.h +4 -0
@@ -116,6 +116,7 @@ struct fence {int status;struct list_head child_list;struct list_head active_list; +void *priv; };enum fence_flag_bits {
@@ -146,6 +147,7 @@ struct fence_cb {* @enable_signaling: enable software signaling of fence. * @signaled: [optional] peek whether the fence is signaled, can be null. * @wait: custom wait implementation, or fence_default_wait. +* @cleanup: [optional] called when the timeline is destroyed * @release: [optional] called on destruction of fence, can be null * @fill_driver_data: [optional] callback to fill in free-form debug info * Returns amount of bytes filled, or -errno.
@@ -205,6 +207,7 @@ struct fence_ops {bool (*enable_signaling)(struct fence *fence);bool (*signaled)(struct fence *fence);signed long (*wait)(struct fence *fence,bool intr,signed long timeout); +void (*cleanup)(struct fence *fence,void *user_data);void (*release)(struct fence *fence);int (*fill_driver_data)(struct fence *fence,void *data,int size);
@@ -217,6 +220,7 @@ struct fence *fence_create_on_timeline(struct fence_timeline *obj, unsigned int value);void fence_init (struct fence *fence,const struct fence_ops *ops,spinlock_t *lock,unsigned context,unsigned seqno); +void fence_add_user_data (struct fence *fence,void *user_data);void fence_release (struct kref *kref);void fence_free (struct fence *fence);
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 28/29 staging/android: use .cleanup() to interrupt any sync_fence waiter
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
When the timeline is being destroyed all the waiters waiting for the sync_fence to signal need to be woken up and finished as well.
--- drivers/staging/android/sw_sync.c | 8 ++++++++ drivers/staging/android/sync.c | 9 +++++++++ drivers/staging/android/sync.h | 2 ++ 3 files changed, 19 insertions(+)
drivers/staging/android/sw_sync.c +8 -0
@@ -25,6 +25,13 @@#include "sw_sync.h" +static void sw_sync_cleanup (struct fence *fence,void *user_data) +{ +struct sync_fence *sync_fence = user_data; + +sync_fence_cleanup (sync_fence); +} +static const struct fence_ops sw_sync_fence_ops = { .get_driver_name = fence_default_get_driver_name, .get_timeline_name = fence_default_get_timeline_name,
@@ -32,6 +39,7 @@ static const struct fence_ops sw_sync_fence_ops = { .signaled = fence_default_signaled, .wait = fence_default_wait, .release = fence_default_release, + .cleanup = sw_sync_cleanup, .fill_driver_data = fence_default_fill_driver_data, .fence_value_str = fence_default_value_str, .timeline_value_str = fence_default_timeline_value_str,
drivers/staging/android/sync.c +9 -0
@@ -91,6 +91,8 @@ struct sync_fence *sync_fence_create_dma(const char *name, struct fence *fence)sync_fence_debug_add (sync_fence); +fence_add_user_data (fence, sync_fence); +return sync_fence; }EXPORT_SYMBOL (sync_fence_create_dma);
@@ -101,6 +103,13 @@ struct sync_fence *sync_fence_create(const char *name, struct fence *fence) }EXPORT_SYMBOL (sync_fence_create); +void sync_fence_cleanup (struct sync_fence *sync_fence) +{ +atomic_set (&sync_fence->status, -ENOENT ); +wake_up_all (&sync_fence->wq); +} +EXPORT_SYMBOL (sync_fence_cleanup); +struct sync_fence *sync_fence_fdget (int fd) {struct file *file =fget (fd);
drivers/staging/android/sync.h +2 -0
@@ -98,6 +98,8 @@ struct sync_fence *sync_fence_create(const char *name, struct fence *fence);*/ struct sync_fence *sync_fence_create_dma (const char *name,struct fence *pt); +void sync_fence_cleanup (struct sync_fence *sync_fence); +/* * API for sync_fence consumers */
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 29/29 dma-buf/fence: de-stage sync framework
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
The sync framework is ready for mainline inclusion. Here we move it to drivers/dma-buf and the header files to the appropiated places.
The sync framework contained some abstractions around struct fence and those were removed in the de-staging process among other changes:
Userspace visible changes
-------------------------
* The sw_sync file was moved from /dev/sw_sync to <debugfs>/sync/sw_sync. No other change.
Kernel API changes
------------------
* struct sync_timeline is now struct fence_timeline
* sync_timeline_ops is now fence_timeline_ops and they now carry struct fence as parameter instead of struct sync_pt
* a .cleanup() fence op was added to allow sync_fence to run a cleanup when the fence_timeline is destroyed
* added fence_add_used_data() to pass a private point to struct fence. This pointer is sent back on the .cleanup op.
* The sync timeline function were moved to be fence_timeline functions:
- sync_timeline_create() -> fence_timeline_create()
- sync_timeline_get() -> fence_timeline_get()
- sync_timeline_put() -> fence_timeline_put()
- sync_timeline_destroy() -> fence_timeline_destroy()
- sync_timeline_signal() -> fence_timeline_signal() * sync_pt_create() was replaced be fence_create_on_timeline()
Internal changes
----------------
* fence_timeline_ops was removed in favor of direct use fence_ops
* fence default functions were created for fence_ops
* removed structs sync_pt, sw_sync_timeline and sw_sync_pt
---
drivers/Kconfig | 2 ++
drivers/dma-buf/Kconfig | 22 ++++++++++++++++++++++
drivers/dma-buf/Makefile | 2 ++
drivers/{staging/android => dma-buf}/sw_sync.c | 3 +--
drivers/{staging/android => dma-buf}/sync.c | 7 ++++---
drivers/{staging/android => dma-buf}/sync_debug.c | 2 +-
drivers/staging/android/Kconfig | 19 -------------------
drivers/staging/android/Makefile | 2 --
.../staging/android => include/linux}/sw_sync.h | 4 ++--
{drivers/staging/android => include/linux}/sync.h | 4 ++--
.../android/trace => include/trace/events}/sync.h | 5 ++---
.../android/uapi => include/uapi/linux}/sw_sync.h | 0
.../android/uapi => include/uapi/linux}/sync.h | 0
13 files changed, 38 insertions(+), 34 deletions(-)
create mode 100644 drivers/dma-buf/Kconfig
rename drivers/{staging/android => dma-buf}/sw_sync.c (98%)
rename drivers/{staging/android => dma-buf}/sync.c (99%)
rename drivers/{staging/android => dma-buf}/sync_debug.c (99%)
rename {drivers/staging/android => include/linux}/sw_sync.h (95%)
rename {drivers/staging/android => include/linux}/sync.h (99%)
rename {drivers/staging/android/trace => include/trace/events}/sync.h (92%)
rename {drivers/staging/android/uapi => include/uapi/linux}/sw_sync.h (100%)
rename {drivers/staging/android/uapi => include/uapi/linux}/sync.h (100%)drivers/Kconfig +2 -0
@@ -114,6 +114,8 @@ source "drivers/rtc/Kconfig" source "drivers/dma/Kconfig" +source "drivers/dma-buf/Kconfig" + source "drivers/dca/Kconfig" source "drivers/auxdisplay/Kconfig"
drivers/dma-buf/Kconfig new file +22 -0
@@ -0,0 +1,22 @@ +menu "DMABUF options" + +config SYNC + bool "Synchronization framework" + default n + select ANON_INODES + select DMA_SHARED_BUFFER + ---help--- + This option enables the framework for synchronization between multiple + drivers. Sync implementations can take advantage of hardware + synchronization built into devices like GPUs. + +config SW_SYNC + bool "Software synchronization objects" + default n + depends on SYNC + ---help--- + A sync object driver that uses a 32bit counter to coordinate + synchronization. Useful when there is no hardware primitive backing + the synchronization. + +endmenu
drivers/dma-buf/Makefile +2 -0
@@ -1 +1,3 @@ obj-y := dma-buf.o fence.o fence_debug.o reservation.o seqno-fence.o +obj-$(CONFIG_SYNC) += sync.o sync_debug.o +obj-$(CONFIG_SW_SYNC) += sw_sync.o
drivers/dma-buf/sw_sync.c renamed from drivers/staging/android/sw_sync.c +1 -2
@@ -22,8 +22,7 @@#include <linux/miscdevice.h> #include <linux/syscalls.h> #include <linux/uaccess.h> - -#include "sw_sync.h" +#include <linux/sw_sync.h> static void sw_sync_cleanup (struct fence *fence,void *user_data) {
drivers/dma-buf/sync.c renamed from drivers/staging/android/sync.c +4 -3
@@ -26,10 +26,10 @@#include <linux/uaccess.h> #include <linux/anon_inodes.h> -#include "sync.h" +#include <linux/sync.h> #define CREATE_TRACE_POINTS -#include "trace/sync.h" +#include <trace/events/sync.h> static const struct file_operations sync_fence_fops;
@@ -280,7 +280,7 @@ int sync_fence_wait(struct sync_fence *sync_fence, long timeout)trace_sync_wait (sync_fence,1 );for (i =0 ; i < sync_fence->num_fences; ++i) -trace_fence (sync_fence->cbs[i].fence); +trace_sync_fence (sync_fence->cbs[i].fence); ret =wait_event_interruptible_timeout (sync_fence->wq,atomic_read (&sync_fence->status) <=0 , timeout);
@@ -395,6 +395,7 @@ static long sync_fence_ioctl_merge(struct sync_fence *sync_fence,sync_fence_install (fence3, fd);sync_fence_put (fence2); +return 0 ; err_put_fence3:
drivers/dma-buf/sync_debug.c renamed from drivers/staging/android/sync_debug.c +1 -1
@@ -27,7 +27,7 @@#include <linux/uaccess.h> #include <linux/anon_inodes.h> #include <linux/time64.h> -#include "sw_sync.h" +#include <linux/sw_sync.h> #ifdef CONFIG_DEBUG_FS
drivers/staging/android/Kconfig +0 -19
@@ -38,25 +38,6 @@ config ANDROID_LOW_MEMORY_KILLER scripts (/init.rc), and it defines priority values with minimum free memory size for each priority. -config SYNC - bool "Synchronization framework" - default n - select ANON_INODES - select DMA_SHARED_BUFFER - ---help--- - This option enables the framework for synchronization between multiple - drivers. Sync implementations can take advantage of hardware - synchronization built into devices like GPUs. - -config SW_SYNC - bool "Software synchronization objects" - default n - depends on SYNC - ---help--- - A sync object driver that uses a 32bit counter to coordinate - synchronization. Useful when there is no hardware primitive backing - the synchronization. - source "drivers/staging/android/ion/Kconfig" endif # if ANDROID
drivers/staging/android/Makefile +0 -2
@@ -6,5 +6,3 @@ obj-$(CONFIG_ASHMEM) += ashmem.o obj-$(CONFIG_ANDROID_TIMED_OUTPUT) += timed_output.o obj-$(CONFIG_ANDROID_TIMED_GPIO) += timed_gpio.o obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER) += lowmemorykiller.o -obj-$(CONFIG_SYNC) += sync.o sync_debug.o -obj-$(CONFIG_SW_SYNC) += sw_sync.o
include/linux/sw_sync.h renamed from drivers/staging/android/sw_sync.h +2 -2
@@ -19,8 +19,8 @@#include <linux/types.h> #include <linux/kconfig.h> -#include "sync.h" -#include "uapi/sw_sync.h" +#include <linux/sync.h> +#include <uapi/linux/sw_sync.h> #if IS_ENABLED (CONFIG_SW_SYNC )struct fence_timeline *sw_sync_timeline_create (const char *name);
include/linux/sync.h renamed from drivers/staging/android/sync.h +2 -2
@@ -20,8 +20,8 @@#include <linux/spinlock.h> #include <linux/wait.h> #include <linux/fence.h> - -#include "uapi/sync.h" +#include <linux/sync.h> +#include <uapi/linux/sync.h> struct sync_fence ;
include/trace/events/sync.h renamed from drivers/staging/android/trace/sync.h +2 -3
@@ -1,11 +1,10 @@#undef TRACE_SYSTEM -#define TRACE_INCLUDE_PATH ../../drivers/staging/android/trace#define TRACE_SYSTEM sync#if !defined(_TRACE_SYNC_H) || defined(TRACE_HEADER_MULTI_READ )#define _TRACE_SYNC_H -#include "../sync.h" +#include <linux/sync.h> #include <linux/tracepoint.h> TRACE_EVENT(sync_wait,
@@ -29,7 +28,7 @@ TRACE_EVENT(sync_wait, __get_str(name), __entry->status) ); -TRACE_EVENT(fence, +TRACE_EVENT(sync_fence, TP_PROTO(struct fence *fence), TP_ARGS(fence),
include/uapi/linux/sw_sync.h renamed from drivers/staging/android/uapi/sw_sync.h +0 -0
include/uapi/linux/sync.h renamed from drivers/staging/android/uapi/sync.h +0 -0
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC 26/29] dma-buf/fence: remove pointless fence_timeline_signal at destroy phase
In reply to Gustavo PadovanQuoted 17 lines · Gustavo Padovan
From: Gustavo Padovan <[email protected]>
All changes to timeline value come through the user via
fence_timeline_signal()calls. Whenfence_timeline_destroy()is called no changes ontimeline->valuehappens hence callfence_timeline_signal()with no increment is pointless.Signed-off-by Gustavo Padovan <[email protected]>--- drivers/dma-buf/fence.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/dma-buf/fence.c +0
-0
drivers/dma-buf/fence.c EXPORT_SYMBOL(fence_timeline_put); · line 139
Quoted 5 lines
drivers/dma-buf/fence.c +1
-1@@ -136,7 +136,7 @@ EXPORT_SYMBOL(fence_timeline_put);* fence_timeline_destroy - destroy a fence_timeline * @timeline [in] the fence_timeline to destroy * -* This function destroys a timeline. It signals any active fence first. +* This function destroys a timeline.
The implementation for this was certainly broken but I would say it should be fixed to match the comment rather than just abandoned completely. That is, what happens if a timeline owner destroys their timeline while there are outstanding fences which other drivers are waiting on? That is presumably a bug in the code that called destroy prematurely, but bugs happen.
The old implementation simply leaked the fences. Doing a debugfs dump would show the timeline with all its outstanding fences still floating around forever after. Worse, anything waiting on them would never be signalled and is therefore potentially deadlocked.
Note that I haven't had chance to look through the entire patch series yet so maybe this has been fixed up elsewhere. If not, then I think it definitely needs looking into.
Quoted 14 lines
drivers/dma-buf/fence.c +0
-4*/ void fence_timeline_destroy (struct fence_timeline *timeline) {@@ -147,10 +147,6 @@ void fence_timeline_destroy(struct fence_timeline *timeline)*/ smp_wmb (); -/* -* signal any children that their parent is going away. -*/ -fence_timeline_signal (timeline,0 );fence_timeline_put (timeline); }EXPORT_SYMBOL (fence_timeline_destroy);
Re: [RFC 26/29] dma-buf/fence: remove pointless fence_timeline_signal at destroy phase
2016-01-15 John Harrison <[email protected]>:
Quoted 30 lines · Gustavo Padovan
Quoted 17 lines
From: Gustavo Padovan <[email protected]>
All changes to timeline value come through the user via
fence_timeline_signal()calls. Whenfence_timeline_destroy()is called no changes ontimeline->valuehappens hence callfence_timeline_signal()with no increment is pointless.Signed-off-by Gustavo Padovan <[email protected]>--- drivers/dma-buf/fence.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/dma-buf/fence.c +0
-0drivers/dma-buf/fence.c EXPORT_SYMBOL(fence_timeline_put); · line 139
Quoted 5 lines
drivers/dma-buf/fence.c +1
-1@@ -136,7 +136,7 @@ EXPORT_SYMBOL(fence_timeline_put);* fence_timeline_destroy - destroy a fence_timeline * @timeline [in] the fence_timeline to destroy * -* This function destroys a timeline. It signals any active fence first. +* This function destroys a timeline. The implementation for this was certainly broken but I would say it should be fixed to match the comment rather than just abandoned completely. That is, what happens if a timeline owner destroys their timeline while there are outstanding fences which other drivers are waiting on? That is presumably a bug in the code that called destroy prematurely, but bugs happen.
Quoted 9 lines
The old implementation simply leaked the fences. Doing a debugfs dump would show the timeline with all its outstanding fences still floating around forever after. Worse, anything waiting on them would never be signalled and is therefore potentially deadlocked.
Note that I haven't had chance to look through the entire patch series yet so maybe this has been fixed up elsewhere. If not, then I think it definitely needs looking into.
Patches 27 and 28 are attempt to fix that. I assumed that if some code is calling fence_timeline_destroy() it wants to stop everything so I worked on a solution that stops any waiter and allows the timeline to be destroyed.
No one is using fence_timeline_destroy() in mainline now, so it is definately a behaviour we can discuss.
Gustavo
Quoted 4 lines · Gustavo Padovan
From: Gustavo Padovan <[email protected]>
This patch series de-stage the sync framework, and in order to accomplish that a bunch of cleanups/improvements on the sync and fence were made.
Perhaps add/update a MAINTAINERS entry too?
Re: [RFC 26/29] dma-buf/fence: remove pointless fence_timeline_signal at destroy phase
In reply to Gustavo PadovanQuoted 10 lines · Gustavo Padovan
Patches 27 and 28 are attempt to fix that. I assumed that if some code is calling
fence_timeline_destroy()it wants to stop everything so I worked on a solution that stops any waiter and allows the timeline to be destroyed.No one is using
fence_timeline_destroy()in mainline now, so it is definately a behaviour we can discuss.Gustavo
+Tom Cherry and Dmitry Torokhov recently discovered that this was broken by the refactoring of Android sync on top of dma-buf fences.
Tom and Dmitry, did you send the proposed fix upstream?
_______________________________________________
dri-devel mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 31 lines · Gustavo Padovan
From: Gustavo Padovan <[email protected]>
This patch series de-stage the sync framework, and in order to accomplish that a bunch of cleanups/improvements on the sync and fence were made.
The sync framework contained some abstractions around struct fence and those were removed in the de-staging process among other changes:
Userspace visible changes
-------------------------* The
sw_syncfile was moved from/dev/sw_syncto <debugfs>/sync/sw_sync. No other change.Kernel API changes
------------------* struct
sync_timelineis now structfence_timeline
*sync_timeline_opsis nowfence_timeline_opsand they now carry struct fence as parameter instead of structsync_pt
* a .cleanup() fence op was added to allowsync_fenceto run a cleanup when thefence_timelineis destroyed
* addedfence_add_used_data()to pass a private point to struct fence. This pointer is sent back on the .cleanup op.
* The sync timeline function were moved to befence_timelinefunctions:
-sync_timeline_create()->fence_timeline_create()
-sync_timeline_get()->fence_timeline_get()
-sync_timeline_put()->fence_timeline_put()
-sync_timeline_destroy()->fence_timeline_destroy()
-sync_timeline_signal()->fence_timeline_signal()
Quoted 8 lines
*
sync_pt_create()was replaced befence_create_on_timeline()Internal changes
----------------*
fence_timeline_opswas removed in favor of direct usefence_ops
* fence default functions were created forfence_ops
* removed structssync_pt,sw_sync_timelineandsw_sync_pt
Bunch of fairly random comments all over:
- include/uapi/linux/sw_sync.h imo should be dropped, it's just a private debugfs interface between fence fds and the testsuite. Since the plan is to have the testcases integrated into the kernel tree too we don't need a public header.
- similar for include/linux/sw_sync.h Imo that should all be moved into sync_debug.c. Same for sw_sync.c, that should all land in sync_debug imo, and made optional with a Kconfig option. At least we should reuse CONFIG_DEBUGFS.
- fence_context and fence_timeline are really the same. timeline has some super-basic support for doing sw-only fence timelines, but imo that's not really worth keeping (and if so better to keep seperate in a sw-fence.c or similar, like seqno-fence.c). The other main thing timeline provides is support to clean up fences on a timeline. And imo that cleanup should be done by the core fence support, not by the add-on stuff.
Interlude about fence cleanup on driver unload:
Working drivers imo should never call timeline_destroy when there's still an unsignalled fence around for that timeline/context. That just means they're broken and failed to clean up all the pending work. So the problem really is only what to do with fences where the driver disappeared, and for that we essentially need a fence_revoke() function (which could be called internally from timeline_free). So here's what I think timeline_free should do:
for_each_fence_on_timel() {
WARN_ON(!fence_is_signalled());
fence_revoke(fence);
}Implementing fence_revoke is a bit tricky since we need to make sure the memory contained ->ops and similar stuff doesn't disappear. Simplest option might be to grab a temporary reference (using kref_get_unless_zero), and then exchange ->ops with one that has only a release function. We don't need anything else as long as all fence_* functions the kernel might call check for signalling correctly first (fence_wait is broken at least).
Or we just give up (for now) and declare module unload as slightly racy. dma-buf is similar. An intermediate option might be to at least add a THIS_MODULE reference to each fence (but that's a bit expensive ...).
- back to timeline vs. context: I have no idea how to best clean up this mess, but least painful option long-term is probably to switch over all current users of fence_context_alloc to timelines and remove the plain context interface.
- Imo the interface in include/linux/sync.h is duplicating too much of fence.h. I think the only bits we need are the refcounting, creating, fd-install and that's it. Plus a macro to loop over all the fences in a sync_fence. With that drivers will only ever deal with a pile of struct fence, making implicit fencing (using the fence list in dma-buf) and explicit fencing (using the fence list in sync_fence) much more similar.
And we can easily do that since no internal users ;-)
- get_timeline_name and get_driver_name are imo too much indirection, just add ->(drv_)name field to each of these.
- struct sync_fence is a major confusion imo against struct fence. It made much more sense in the pure-android world where fence == sync_pt. Maybe we can rename sync_fence to sync_fence_fd (a bit long, and fd is a bit inaccurate), sync_file (like this best), fence_file (sounds silly imo), or something else?
- I guess just not yet part of this rfc, but moving the testsuite and adding kerneldoc for this is planned I guess? If you feel like I think it'd be best. We pull the current dma-buf stuff into device-drivers.tmpl, but it's completely lacking overview docs and all that. And I'd like to duplicate at least the dma-buf/fence sections into the gpu.tmpl docbook.
- If we make timelines first class objects I think we could move some of the fields from struct fence to struct fence_timeline. E.g. the ops struct. That also makes it clearer that some of the vfuncs really should be taking a struct fence_timeline *timeline instead of a struct fence *fence as their primary parameter.
Cheers, Daniel
Quoted 73 lines
Gustavo Padovan (29):
staging/android: fix sync framework documentation staging/android: fix checkpatch warning
staging/android: renamesync_fence_releasestaging/android: rename 'android_fence' to 'sync_fence' staging/android: remove not usedsync_timelineops staging/android: create a 'sync' dir for debugfs information staging/android: movesw_syncfile to debugfs file staging/android: RemoveWARN_ON_ONCEwhen releasingsync_fencestaging/android: rename struct sync_fence's variables to 'sync_fence' staging/android: rename 'sync_pt' to 'fence' in structsync_fence_cbdma-buf/fence: movesync_timelinetofence_timelinestaging/android: remove structsync_pt
dma-buf/fence: createfence_default_enable_signaling()dma-buf/fence: createfence_default_release()dma-buf/fence: createfence_default_get_driver_name()dma-buf/fence: createfence_default_timeline_name()dma-buf/fence: store last signaled value on fence timeline dma-buf/fence: create default .fence_value_str() and
.timeline_value_str()
dma-buf/fence: createfence_default_fill_driver_data()dma-buf/fence: removefence_timeline_ops
dma-buf/fence: addfence_create_on_timeline()staging/android: removesync_pt_create()
staging/android: removesw_sync_timelineandsw_sync_ptdma-buf/fence: add debug to fence timeline
dma-buf/fence: remove unused var fromfence_timeline_signal()dma-buf/fence: remove pointlessfence_timeline_signalat destroy phase dma-buf/fence: add .cleanup() callback
staging/android: use .cleanup() to interrupt anysync_fencewaiter dma-buf/fence: de-stage sync frameworkdrivers/Kconfig | 2 + drivers/dma-buf/Kconfig | 22 + drivers/dma-buf/Makefile | 4 +- drivers/dma-buf/fence.c | 333 ++++++++++ drivers/dma-buf/fence_debug.c | 128 ++++ drivers/dma-buf/sw_sync.c | 65 ++ drivers/dma-buf/sync.c | 527 +++++++++++++++ drivers/dma-buf/sync_debug.c | 279 ++++++++ drivers/staging/android/Kconfig | 28 - drivers/staging/android/Makefile | 2 - drivers/staging/android/sw_sync.c | 260 -------- drivers/staging/android/sync.c | 732 --------------------- drivers/staging/android/sync.h | 366 ----------- drivers/staging/android/sync_debug.c | 256 ------- include/linux/fence.h | 77 +++ .../staging/android => include/linux}/sw_sync.h | 30 +- include/linux/sync.h | 201 ++++++ include/trace/events/fence.h | 18 + .../android/trace => include/trace/events}/sync.h | 41 +- .../android/uapi => include/uapi/linux}/sw_sync.h | 0 .../android/uapi => include/uapi/linux}/sync.h | 0 21 files changed, 1672 insertions(+), 1699 deletions(-) create mode 100644 drivers/dma-buf/Kconfig create mode 100644 drivers/dma-buf/fence_debug.c create mode 100644 drivers/dma-buf/sw_sync.c create mode 100644 drivers/dma-buf/sync.c create mode 100644 drivers/dma-buf/sync_debug.c delete mode 100644 drivers/staging/android/sw_sync.c delete mode 100644 drivers/staging/android/sync.c delete mode 100644 drivers/staging/android/sync.h delete mode 100644 drivers/staging/android/sync_debug.c rename {drivers/staging/android => include/linux}/sw_sync.h (55%) create mode 100644 include/linux/sync.h rename {drivers/staging/android/trace => include/trace/events}/sync.h (53%) rename {drivers/staging/android/uapi => include/uapi/linux}/sw_sync.h (100%) rename {drivers/staging/android/uapi => include/uapi/linux}/sync.h (100%)Signature · 1 line
2.5.0
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Hi Daniel,
2016-01-19 Daniel Vetter <[email protected]>:
Quoted 48 lines · Gustavo Padovan
Quoted 31 lines
From: Gustavo Padovan <[email protected]>
This patch series de-stage the sync framework, and in order to accomplish that a bunch of cleanups/improvements on the sync and fence were made.
The sync framework contained some abstractions around struct fence and those were removed in the de-staging process among other changes:
Userspace visible changes
-------------------------* The
sw_syncfile was moved from/dev/sw_syncto <debugfs>/sync/sw_sync. No other change.Kernel API changes
------------------* struct
sync_timelineis now structfence_timeline
*sync_timeline_opsis nowfence_timeline_opsand they now carry struct fence as parameter instead of structsync_pt
* a .cleanup() fence op was added to allowsync_fenceto run a cleanup when thefence_timelineis destroyed
* addedfence_add_used_data()to pass a private point to struct fence. This pointer is sent back on the .cleanup op.
* The sync timeline function were moved to befence_timelinefunctions:
-sync_timeline_create()->fence_timeline_create()
-sync_timeline_get()->fence_timeline_get()
-sync_timeline_put()->fence_timeline_put()
-sync_timeline_destroy()->fence_timeline_destroy()
-sync_timeline_signal()->fence_timeline_signal()Quoted 8 lines
*
sync_pt_create()was replaced befence_create_on_timeline()Internal changes
----------------*
fence_timeline_opswas removed in favor of direct usefence_ops
* fence default functions were created forfence_ops
* removed structssync_pt,sw_sync_timelineandsw_sync_ptBunch of fairly random comments all over:
-
include/uapi/linux/sw_sync.himo should be dropped, it's just a private debugfs interface between fence fds and the testsuite. Since the plan is to have the testcases integrated into the kernel tree too we don't need a public header.
Quoted 4 lines
- similar for
include/linux/sw_sync.hImo that should all be moved intosync_debug.c. Same forsw_sync.c, that should all land insync_debugimo, and made optional with aKconfigoption. At least we should reuseCONFIG_DEBUGFS.
These two items sounds reasonable to me.
Quoted 8 lines
-
fence_contextandfence_timelineare really the same. timeline has some super-basic support for doing sw-only fence timelines, but imo that's not really worth keeping (and if so better to keep seperate in asw-fence.cor similar, likeseqno-fence.c). The other main thing timeline provides is support to clean up fences on a timeline. And imo that cleanup should be done by the core fence support, not by the add-on stuff.
Yes, they are. But I currently doesn't know how to merge them best, so I decided to go for a RFC instead of trying some crazy solution touching all fence_context users.
Quoted 25 lines
Interlude about fence cleanup on driver unload:
Working drivers imo should never call
timeline_destroywhen there's still an unsignalled fence around for that timeline/context. That just means they're broken and failed to clean up all the pending work. So the problem really is only what to do with fences where the driver disappeared, and for that we essentially need afence_revoke()function (which could be called internally fromtimeline_free). So here's what I thinktimeline_freeshould do:for_each_fence_on_timel() { WARN_ON(!fence_is_signalled()); fence_revoke(fence); }Implementing
fence_revokeis a bit tricky since we need to make sure the memory contained ->ops and similar stuff doesn't disappear. Simplest option might be to grab a temporary reference (usingkref_get_unless_zero), and then exchange ->ops with one that has only a release function. We don't need anything else as long as all fence_* functions the kernel might call check for signalling correctly first (fence_waitis broken at least).
Quoted 3 lines
Or we just give up (for now) and declare module unload as slightly racy. dma-buf is similar. An intermediate option might be to at least add a
THIS_MODULEreference to each fence (but that's a bit expensive ...).
I'd say we just give up for now as we don't have any driver using timeline_destroy for now. So we could go for other improvements first.
Quoted 4 lines
- back to timeline vs. context: I have no idea how to best clean up this mess, but least painful option long-term is probably to switch over all current users of
fence_context_allocto timelines and remove the plain context interface.
Agreed.
Quoted 8 lines
- Imo the interface in
include/linux/sync.his duplicating too much offence.h. I think the only bits we need are the refcounting, creating, fd-install and that's it. Plus a macro to loop over all the fences in async_fence. With that drivers will only ever deal with a pile of struct fence, making implicit fencing (using the fence list in dma-buf) and explicit fencing (using the fence list insync_fence) much more similar.
Yes, most of the sync_fence waiting should not be exported. Drivers should only wait for fence imo, not sync_fences.
Quoted 11 lines
And we can easily do that since no internal users ;-)
-
get_timeline_nameandget_driver_nameare imo too much indirection, just add ->(drv_)name field to each of these.- struct
sync_fenceis a major confusion imo against struct fence. It made much more sense in the pure-android world where fence ==sync_pt. Maybe we can renamesync_fencetosync_fence_fd(a bit long, and fd is a bit inaccurate),sync_file(like this best),fence_file(sounds silly imo), or something else?
sync_file sounds good for me. fence_file feels like it a file for a single fence but we may have many fences on one sync_file.
Quoted 7 lines
- I guess just not yet part of this rfc, but moving the testsuite and adding kerneldoc for this is planned I guess? If you feel like I think it'd be best. We pull the current dma-buf stuff into device-drivers.tmpl, but it's completely lacking overview docs and all that. And I'd like to duplicate at least the dma-buf/fence sections into the gpu.tmpl docbook.
We have converted testsuite from android's libsync but we need to wait for Google to re-license it to send it upstream.
kerneldoc is planned for sure, but I'd say it will be better to have some users first, DRM for example.
Quoted 6 lines
- If we make timelines first class objects I think we could move some of the fields from struct fence to struct
fence_timeline. E.g. the ops struct. That also makes it clearer that some of the vfuncs really should be taking a structfence_timeline*timeline instead of a struct fence *fence as their primary parameter.
I'll keep that as a final goal and work RFC v2 and see how far we can get.
Gustavo
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 51 lines · Gustavo Padovan
Hi Daniel,
2016-01-19 Daniel Vetter <[email protected]>:
Quoted 47 lines · Gustavo Padovan
Quoted 31 lines
From: Gustavo Padovan <[email protected]>
This patch series de-stage the sync framework, and in order to accomplish that a bunch of cleanups/improvements on the sync and fence were made.
The sync framework contained some abstractions around struct fence and those were removed in the de-staging process among other changes:
Userspace visible changes
-------------------------* The
sw_syncfile was moved from/dev/sw_syncto <debugfs>/sync/sw_sync. No other change.Kernel API changes
------------------* struct
sync_timelineis now structfence_timeline
*sync_timeline_opsis nowfence_timeline_opsand they now carry struct fence as parameter instead of structsync_pt
* a .cleanup() fence op was added to allowsync_fenceto run a cleanup when thefence_timelineis destroyed
* addedfence_add_used_data()to pass a private point to struct fence. This pointer is sent back on the .cleanup op.
* The sync timeline function were moved to befence_timelinefunctions:
-sync_timeline_create()->fence_timeline_create()
-sync_timeline_get()->fence_timeline_get()
-sync_timeline_put()->fence_timeline_put()
-sync_timeline_destroy()->fence_timeline_destroy()
-sync_timeline_signal()->fence_timeline_signal()Quoted 8 lines
*
sync_pt_create()was replaced befence_create_on_timeline()Internal changes
----------------*
fence_timeline_opswas removed in favor of direct usefence_ops
* fence default functions were created forfence_ops
* removed structssync_pt,sw_sync_timelineandsw_sync_ptBunch of fairly random comments all over:
-
include/uapi/linux/sw_sync.himo should be dropped, it's just a private debugfs interface between fence fds and the testsuite. Since the plan is to have the testcases integrated into the kernel tree too we don't need a public header.
Quoted 5 lines
Quoted 4 lines
- similar for
include/linux/sw_sync.hImo that should all be moved intosync_debug.c. Same forsw_sync.c, that should all land insync_debugimo, and made optional with aKconfigoption. At least we should reuseCONFIG_DEBUGFS.These two items sounds reasonable to me.
I have just posted our in-progress IGT for testing i915 syncs (with a CC of Gustavo). It uses the sw_sync mechanisms. Can you take a quick look and see if it is the kind of thing you would expect us to be doing? Or is it using interfaces that you are planning to remove and/or make kernel only?
I'm not sure having a kernel only test is the best way to go. Having user land tests like IGT would be much more versatile.
Quoted 91 lines
Quoted 7 lines
-
fence_contextandfence_timelineare really the same. timeline has some super-basic support for doing sw-only fence timelines, but imo that's not really worth keeping (and if so better to keep seperate in asw-fence.cor similar, likeseqno-fence.c). The other main thing timeline provides is support to clean up fences on a timeline. And imo that cleanup should be done by the core fence support, not by the add-on stuff.Yes, they are. But I currently doesn't know how to merge them best, so I decided to go for a RFC instead of trying some crazy solution touching all
fence_contextusers.Quoted 24 lines
Interlude about fence cleanup on driver unload:
Working drivers imo should never call
timeline_destroywhen there's still an unsignalled fence around for that timeline/context. That just means they're broken and failed to clean up all the pending work. So the problem really is only what to do with fences where the driver disappeared, and for that we essentially need afence_revoke()function (which could be called internally fromtimeline_free). So here's what I thinktimeline_freeshould do:for_each_fence_on_timel() { WARN_ON(!fence_is_signalled()); fence_revoke(fence); }Implementing
fence_revokeis a bit tricky since we need to make sure the memory contained ->ops and similar stuff doesn't disappear. Simplest option might be to grab a temporary reference (usingkref_get_unless_zero), and then exchange ->ops with one that has only a release function. We don't need anything else as long as all fence_* functions the kernel might call check for signalling correctly first (fence_waitis broken at least).Quoted 3 lines
Or we just give up (for now) and declare module unload as slightly racy. dma-buf is similar. An intermediate option might be to at least add a
THIS_MODULEreference to each fence (but that's a bit expensive ...).I'd say we just give up for now as we don't have any driver using
timeline_destroyfor now. So we could go for other improvements first.Quoted 4 lines
- back to timeline vs. context: I have no idea how to best clean up this mess, but least painful option long-term is probably to switch over all current users of
fence_context_allocto timelines and remove the plain context interface.Agreed.
Quoted 7 lines
- Imo the interface in
include/linux/sync.his duplicating too much offence.h. I think the only bits we need are the refcounting, creating, fd-install and that's it. Plus a macro to loop over all the fences in async_fence. With that drivers will only ever deal with a pile of struct fence, making implicit fencing (using the fence list in dma-buf) and explicit fencing (using the fence list insync_fence) much more similar.Yes, most of the
sync_fencewaiting should not be exported. Drivers should only wait for fence imo, notsync_fences.Quoted 10 lines
And we can easily do that since no internal users ;-)
-
get_timeline_nameandget_driver_nameare imo too much indirection, just add ->(drv_)name field to each of these.- struct
sync_fenceis a major confusion imo against struct fence. It made much more sense in the pure-android world where fence ==sync_pt. Maybe we can renamesync_fencetosync_fence_fd(a bit long, and fd is a bit inaccurate),sync_file(like this best),fence_file(sounds silly imo), or something else?
sync_filesounds good for me.fence_filefeels like it a file for a single fence but we may have many fences on onesync_file.Quoted 6 lines
- I guess just not yet part of this rfc, but moving the testsuite and adding kerneldoc for this is planned I guess? If you feel like I think it'd be best. We pull the current dma-buf stuff into device-drivers.tmpl, but it's completely lacking overview docs and all that. And I'd like to duplicate at least the dma-buf/fence sections into the gpu.tmpl docbook.
We have converted testsuite from android's libsync but we need to wait for Google to re-license it to send it upstream.
kerneldoc is planned for sure, but I'd say it will be better to have some users first, DRM for example.
Quoted 5 lines
- If we make timelines first class objects I think we could move some of the fields from struct fence to struct
fence_timeline. E.g. the ops struct. That also makes it clearer that some of the vfuncs really should be taking a structfence_timeline*timeline instead of a struct fence *fence as their primary parameter.I'll keep that as a final goal and work RFC v2 and see how far we can get.
Gustavo
2016-01-19 John Harrison <[email protected]>:
Quoted 58 lines · Gustavo Padovan
Quoted 51 lines
Hi Daniel,
2016-01-19 Daniel Vetter <[email protected]>:
Quoted 47 lines · Gustavo Padovan
Quoted 31 lines
From: Gustavo Padovan <[email protected]>
This patch series de-stage the sync framework, and in order to accomplish that a bunch of cleanups/improvements on the sync and fence were made.
The sync framework contained some abstractions around struct fence and those were removed in the de-staging process among other changes:
Userspace visible changes
-------------------------* The
sw_syncfile was moved from/dev/sw_syncto <debugfs>/sync/sw_sync. No other change.Kernel API changes
------------------* struct
sync_timelineis now structfence_timeline
*sync_timeline_opsis nowfence_timeline_opsand they now carry struct fence as parameter instead of structsync_pt
* a .cleanup() fence op was added to allowsync_fenceto run a cleanup when thefence_timelineis destroyed
* addedfence_add_used_data()to pass a private point to struct fence. This pointer is sent back on the .cleanup op.
* The sync timeline function were moved to befence_timelinefunctions:
-sync_timeline_create()->fence_timeline_create()
-sync_timeline_get()->fence_timeline_get()
-sync_timeline_put()->fence_timeline_put()
-sync_timeline_destroy()->fence_timeline_destroy()
-sync_timeline_signal()->fence_timeline_signal()Quoted 8 lines
*
sync_pt_create()was replaced befence_create_on_timeline()Internal changes
----------------*
fence_timeline_opswas removed in favor of direct usefence_ops
* fence default functions were created forfence_ops
* removed structssync_pt,sw_sync_timelineandsw_sync_ptBunch of fairly random comments all over:
-
include/uapi/linux/sw_sync.himo should be dropped, it's just a private debugfs interface between fence fds and the testsuite. Since the plan is to have the testcases integrated into the kernel tree too we don't need a public header.Quoted 5 lines
Quoted 4 lines
- similar for
include/linux/sw_sync.hImo that should all be moved intosync_debug.c. Same forsw_sync.c, that should all land insync_debugimo, and made optional with aKconfigoption. At least we should reuseCONFIG_DEBUGFS.These two items sounds reasonable to me.
Quoted 7 lines
I have just posted our in-progress IGT for testing i915 syncs (with a CC of Gustavo). It uses the
sw_syncmechanisms. Can you take a quick look and see if it is the kind of thing you would expect us to be doing? Or is it using interfaces that you are planning to remove and/or make kernel only?I'm not sure having a kernel only test is the best way to go. Having user land tests like IGT would be much more versatile.
I agree with you, we should allow IGT and other test tools to access sw_sync. include/linux/sw_sync.h can be kept private, but the uapi one needs wil be needed for testing, unless we replicate the header file inside IGT, but not sure if it is a good idea.
Gustavo
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 65 lines · Gustavo Padovan
2016-01-19 John Harrison <[email protected]>:
Quoted 63 lines · Gustavo Padovan
Quoted 51 lines
Hi Daniel,
2016-01-19 Daniel Vetter <[email protected]>:
Quoted 47 lines · Gustavo Padovan
Quoted 31 lines
From: Gustavo Padovan <[email protected]>
This patch series de-stage the sync framework, and in order to accomplish that a bunch of cleanups/improvements on the sync and fence were made.
The sync framework contained some abstractions around struct fence and those were removed in the de-staging process among other changes:
Userspace visible changes
-------------------------* The
sw_syncfile was moved from/dev/sw_syncto <debugfs>/sync/sw_sync. No other change.Kernel API changes
------------------* struct
sync_timelineis now structfence_timeline
*sync_timeline_opsis nowfence_timeline_opsand they now carry struct fence as parameter instead of structsync_pt
* a .cleanup() fence op was added to allowsync_fenceto run a cleanup when thefence_timelineis destroyed
* addedfence_add_used_data()to pass a private point to struct fence. This pointer is sent back on the .cleanup op.
* The sync timeline function were moved to befence_timelinefunctions:
-sync_timeline_create()->fence_timeline_create()
-sync_timeline_get()->fence_timeline_get()
-sync_timeline_put()->fence_timeline_put()
-sync_timeline_destroy()->fence_timeline_destroy()
-sync_timeline_signal()->fence_timeline_signal()Quoted 8 lines
*
sync_pt_create()was replaced befence_create_on_timeline()Internal changes
----------------*
fence_timeline_opswas removed in favor of direct usefence_ops
* fence default functions were created forfence_ops
* removed structssync_pt,sw_sync_timelineandsw_sync_ptBunch of fairly random comments all over:
-
include/uapi/linux/sw_sync.himo should be dropped, it's just a private debugfs interface between fence fds and the testsuite. Since the plan is to have the testcases integrated into the kernel tree too we don't need a public header.Quoted 5 lines
Quoted 4 lines
- similar for
include/linux/sw_sync.hImo that should all be moved intosync_debug.c. Same forsw_sync.c, that should all land insync_debugimo, and made optional with aKconfigoption. At least we should reuseCONFIG_DEBUGFS.These two items sounds reasonable to me.
I have just posted our in-progress IGT for testing i915 syncs (with a CC of Gustavo). It uses the
sw_syncmechanisms. Can you take a quick look and see if it is the kind of thing you would expect us to be doing? Or is it using interfaces that you are planning to remove and/or make kernel only?
Quoted 7 lines
Quoted 2 lines
I'm not sure having a kernel only test is the best way to go. Having user land tests like IGT would be much more versatile.
I agree with you, we should allow IGT and other test tools to access
sw_sync.include/linux/sw_sync.hcan be kept private, but the uapi one needs wil be needed for testing, unless we replicate the header file inside IGT, but not sure if it is a good idea.
We replicate all the debugfs stuff in igt that igt needs. uapi really only should be stuff that's guaranteed to stick around, not debug interfaces we are ok with breaking (if needed).
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
2016-01-19 Daniel Vetter <[email protected]>:
Quoted 69 lines · Gustavo Padovan
Quoted 68 lines
2016-01-19 John Harrison <[email protected]>:
Quoted 65 lines · Gustavo Padovan
Quoted 51 lines
Hi Daniel,
2016-01-19 Daniel Vetter <[email protected]>:
Quoted 47 lines · Gustavo Padovan
Quoted 31 lines
From: Gustavo Padovan <[email protected]>
This patch series de-stage the sync framework, and in order to accomplish that a bunch of cleanups/improvements on the sync and fence were made.
The sync framework contained some abstractions around struct fence and those were removed in the de-staging process among other changes:
Userspace visible changes
-------------------------* The
sw_syncfile was moved from/dev/sw_syncto <debugfs>/sync/sw_sync. No other change.Kernel API changes
------------------* struct
sync_timelineis now structfence_timeline
*sync_timeline_opsis nowfence_timeline_opsand they now carry struct fence as parameter instead of structsync_pt
* a .cleanup() fence op was added to allowsync_fenceto run a cleanup when thefence_timelineis destroyed
* addedfence_add_used_data()to pass a private point to struct fence. This pointer is sent back on the .cleanup op.
* The sync timeline function were moved to befence_timelinefunctions:
-sync_timeline_create()->fence_timeline_create()
-sync_timeline_get()->fence_timeline_get()
-sync_timeline_put()->fence_timeline_put()
-sync_timeline_destroy()->fence_timeline_destroy()
-sync_timeline_signal()->fence_timeline_signal()Quoted 8 lines
*
sync_pt_create()was replaced befence_create_on_timeline()Internal changes
----------------*
fence_timeline_opswas removed in favor of direct usefence_ops
* fence default functions were created forfence_ops
* removed structssync_pt,sw_sync_timelineandsw_sync_ptBunch of fairly random comments all over:
-
include/uapi/linux/sw_sync.himo should be dropped, it's just a private debugfs interface between fence fds and the testsuite. Since the plan is to have the testcases integrated into the kernel tree too we don't need a public header.Quoted 5 lines
Quoted 4 lines
- similar for
include/linux/sw_sync.hImo that should all be moved intosync_debug.c. Same forsw_sync.c, that should all land insync_debugimo, and made optional with aKconfigoption. At least we should reuseCONFIG_DEBUGFS.These two items sounds reasonable to me.
I have just posted our in-progress IGT for testing i915 syncs (with a CC of Gustavo). It uses the
sw_syncmechanisms. Can you take a quick look and see if it is the kind of thing you would expect us to be doing? Or is it using interfaces that you are planning to remove and/or make kernel only?I'm not sure having a kernel only test is the best way to go. Having user land tests like IGT would be much more versatile.
Quoted 8 lines
Quoted 4 lines
I agree with you, we should allow IGT and other test tools to access
sw_sync.include/linux/sw_sync.hcan be kept private, but the uapi one needs wil be needed for testing, unless we replicate the header file inside IGT, but not sure if it is a good idea.We replicate all the debugfs stuff in igt that igt needs. uapi really only should be stuff that's guaranteed to stick around, not debug interfaces we are ok with breaking (if needed).
Okay, that sounds quite good for me.
Gustavo
2016-01-19 Daniel Vetter <[email protected]>:
Quoted 102 lines · Gustavo Padovan
Quoted 31 lines
From: Gustavo Padovan <[email protected]>
This patch series de-stage the sync framework, and in order to accomplish that a bunch of cleanups/improvements on the sync and fence were made.
The sync framework contained some abstractions around struct fence and those were removed in the de-staging process among other changes:
Userspace visible changes
-------------------------* The
sw_syncfile was moved from/dev/sw_syncto <debugfs>/sync/sw_sync. No other change.Kernel API changes
------------------* struct
sync_timelineis now structfence_timeline
*sync_timeline_opsis nowfence_timeline_opsand they now carry struct fence as parameter instead of structsync_pt
* a .cleanup() fence op was added to allowsync_fenceto run a cleanup when thefence_timelineis destroyed
* addedfence_add_used_data()to pass a private point to struct fence. This pointer is sent back on the .cleanup op.
* The sync timeline function were moved to befence_timelinefunctions:
-sync_timeline_create()->fence_timeline_create()
-sync_timeline_get()->fence_timeline_get()
-sync_timeline_put()->fence_timeline_put()
-sync_timeline_destroy()->fence_timeline_destroy()
-sync_timeline_signal()->fence_timeline_signal()Quoted 8 lines
*
sync_pt_create()was replaced befence_create_on_timeline()Internal changes
----------------*
fence_timeline_opswas removed in favor of direct usefence_ops
* fence default functions were created forfence_ops
* removed structssync_pt,sw_sync_timelineandsw_sync_ptBunch of fairly random comments all over:
-
include/uapi/linux/sw_sync.himo should be dropped, it's just a private debugfs interface between fence fds and the testsuite. Since the plan is to have the testcases integrated into the kernel tree too we don't need a public header.- similar for
include/linux/sw_sync.hImo that should all be moved intosync_debug.c. Same forsw_sync.c, that should all land insync_debugimo, and made optional with aKconfigoption. At least we should reuseCONFIG_DEBUGFS.-
fence_contextandfence_timelineare really the same. timeline has some super-basic support for doing sw-only fence timelines, but imo that's not really worth keeping (and if so better to keep seperate in asw-fence.cor similar, likeseqno-fence.c). The other main thing timeline provides is support to clean up fences on a timeline. And imo that cleanup should be done by the core fence support, not by the add-on stuff.Interlude about fence cleanup on driver unload:
Working drivers imo should never call
timeline_destroywhen there's still an unsignalled fence around for that timeline/context. That just means they're broken and failed to clean up all the pending work. So the problem really is only what to do with fences where the driver disappeared, and for that we essentially need afence_revoke()function (which could be called internally fromtimeline_free). So here's what I thinktimeline_freeshould do:for_each_fence_on_timel() { WARN_ON(!fence_is_signalled()); fence_revoke(fence); }Implementing
fence_revokeis a bit tricky since we need to make sure the memory contained ->ops and similar stuff doesn't disappear. Simplest option might be to grab a temporary reference (usingkref_get_unless_zero), and then exchange ->ops with one that has only a release function. We don't need anything else as long as all fence_* functions the kernel might call check for signalling correctly first (fence_waitis broken at least).Or we just give up (for now) and declare module unload as slightly racy. dma-buf is similar. An intermediate option might be to at least add a
THIS_MODULEreference to each fence (but that's a bit expensive ...).- back to timeline vs. context: I have no idea how to best clean up this mess, but least painful option long-term is probably to switch over all current users of
fence_context_allocto timelines and remove the plain context interface.- Imo the interface in
include/linux/sync.his duplicating too much offence.h. I think the only bits we need are the refcounting, creating, fd-install and that's it. Plus a macro to loop over all the fences in async_fence. With that drivers will only ever deal with a pile of struct fence, making implicit fencing (using the fence list in dma-buf) and explicit fencing (using the fence list insync_fence) much more similar.
Quoted 4 lines
And we can easily do that since no internal users ;-)
-
get_timeline_nameandget_driver_nameare imo too much indirection, just add ->(drv_)name field to each of these.
I don't think is a good idea to change that now as there are other fence users in the kernel using get_timeline_name and get_driver_name. What I propose is try get rid of this when moving ops from fences to fence_timeline.
Gustavo
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 8 lines · Gustavo Padovan
2016-01-19 Daniel Vetter <[email protected]>:
Quoted 2 lines
-
get_timeline_nameandget_driver_nameare imo too much indirection, just add ->(drv_)name field to each of these.I don't think is a good idea to change that now as there are other fence users in the kernel using
get_timeline_nameandget_driver_name. What I propose is try get rid of this when moving ops from fences tofence_timeline.
Makes sense. And yeah I only realized after sending that this wasn't added by your patches, just that your patches added the (core) users for it. -Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC 11/29] dma-buf/fence: move sync_timeline to fence_timeline
In reply to Gustavo PadovanQuoted 3 lines · Gustavo Padovan
/**
+ *fence_timeline_create- create a newfence_timeline
+ * @num: [in] amount of contexts to allocate
[...]
Quoted 5 lines
+ */
drivers/dma-buf/fence.c +4
-0+struct fence_timeline *fence_timeline_create (unsigned num, +struct fence_timeline_ops *ops, +int size,const char *name) +{
[...]
drivers/dma-buf/fence.c unsigned fence_context_alloc(unsigned num) · line 80
Quoted 1 line
drivers/dma-buf/fence.c +1
-0+ timeline->context =fence_context_alloc (1 );
fence_context_alloc(num)
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Hey,
Op 15-01-16 om 15:55 schreef Gustavo Padovan:
Quoted 49 lines
From: Gustavo Padovan <[email protected]>
This patch series de-stage the sync framework, and in order to accomplish that a bunch of cleanups/improvements on the sync and fence were made.
The sync framework contained some abstractions around struct fence and those were removed in the de-staging process among other changes:
Userspace visible changes
-------------------------* The
sw_syncfile was moved from/dev/sw_syncto <debugfs>/sync/sw_sync. No other change.Kernel API changes
------------------* struct
sync_timelineis now structfence_timeline
*sync_timeline_opsis nowfence_timeline_opsand they now carry struct fence as parameter instead of structsync_pt
* a .cleanup() fence op was added to allowsync_fenceto run a cleanup when thefence_timelineis destroyed
* addedfence_add_used_data()to pass a private point to struct fence. This pointer is sent back on the .cleanup op.
* The sync timeline function were moved to befence_timelinefunctions:
-sync_timeline_create()->fence_timeline_create()
-sync_timeline_get()->fence_timeline_get()
-sync_timeline_put()->fence_timeline_put()
-sync_timeline_destroy()->fence_timeline_destroy()
-sync_timeline_signal()->fence_timeline_signal()*
sync_pt_create()was replaced befence_create_on_timeline()Internal changes
----------------*
fence_timeline_opswas removed in favor of direct usefence_ops
* fence default functions were created forfence_ops
* removed structssync_pt,sw_sync_timelineandsw_sync_ptGustavo Padovan (29):
staging/android: fix sync framework documentation staging/android: fix checkpatch warning staging/android: renamesync_fence_releasestaging/android: rename 'android_fence' to 'sync_fence' staging/android: remove not usedsync_timelineops staging/android: create a 'sync' dir for debugfs information staging/android: movesw_syncfile to debugfs file staging/android: RemoveWARN_ON_ONCEwhen releasingsync_fence
Quoted 8 lines
staging/android: rename struct sync_fence's variables to '
sync_fence' staging/android: rename 'sync_pt' to 'fence' in structsync_fence_cbdma-buf/fence: movesync_timelinetofence_timelinestaging/android: remove structsync_pt
dma-buf/fence: createfence_default_enable_signaling()dma-buf/fence: createfence_default_release()dma-buf/fence: createfence_default_get_driver_name()dma-buf/fence: createfence_default_timeline_name()
This is misleading. I think timeline_fence prefix would be more appropriate here.
I also believe this should be done in multiple series. First series should de-stage the userspace fence framework. The next series should fix up android_fence and maybe rename it to timeline_fence since sync_fence is already used for the userspace fd, which would add more confusion?
Quoted 15 lines
dma-buf/fence: store last signaled value on fence timeline dma-buf/fence: create default .fence_value_str() and
.timeline_value_str()
dma-buf/fence: createfence_default_fill_driver_data()dma-buf/fence: removefence_timeline_ops
dma-buf/fence: addfence_create_on_timeline()staging/android: removesync_pt_create()
staging/android: removesw_sync_timelineandsw_sync_ptdma-buf/fence: add debug to fence timeline
dma-buf/fence: remove unused var fromfence_timeline_signal()dma-buf/fence: remove pointlessfence_timeline_signalat destroy phase dma-buf/fence: add .cleanup() callback
staging/android: use .cleanup() to interrupt anysync_fencewaiter dma-buf/fence: de-stage sync framework
2016-01-20 Maarten Lankhorst <[email protected]>:
Quoted 60 lines
Hey,
Op 15-01-16 om 15:55 schreef Gustavo Padovan:
Quoted 49 lines
From: Gustavo Padovan <[email protected]>
This patch series de-stage the sync framework, and in order to accomplish that a bunch of cleanups/improvements on the sync and fence were made.
The sync framework contained some abstractions around struct fence and those were removed in the de-staging process among other changes:
Userspace visible changes
-------------------------* The
sw_syncfile was moved from/dev/sw_syncto <debugfs>/sync/sw_sync. No other change.Kernel API changes
------------------* struct
sync_timelineis now structfence_timeline
*sync_timeline_opsis nowfence_timeline_opsand they now carry struct fence as parameter instead of structsync_pt
* a .cleanup() fence op was added to allowsync_fenceto run a cleanup when thefence_timelineis destroyed
* addedfence_add_used_data()to pass a private point to struct fence. This pointer is sent back on the .cleanup op.
* The sync timeline function were moved to befence_timelinefunctions:
-sync_timeline_create()->fence_timeline_create()
-sync_timeline_get()->fence_timeline_get()
-sync_timeline_put()->fence_timeline_put()
-sync_timeline_destroy()->fence_timeline_destroy()
-sync_timeline_signal()->fence_timeline_signal()*
sync_pt_create()was replaced befence_create_on_timeline()Internal changes
----------------*
fence_timeline_opswas removed in favor of direct usefence_ops
* fence default functions were created forfence_ops
* removed structssync_pt,sw_sync_timelineandsw_sync_ptGustavo Padovan (29):
staging/android: fix sync framework documentation staging/android: fix checkpatch warning staging/android: renamesync_fence_releasestaging/android: rename 'android_fence' to 'sync_fence' staging/android: remove not usedsync_timelineops staging/android: create a 'sync' dir for debugfs information staging/android: movesw_syncfile to debugfs file staging/android: RemoveWARN_ON_ONCEwhen releasingsync_fenceQuoted 8 lines
staging/android: rename struct sync_fence's variables to '
sync_fence' staging/android: rename 'sync_pt' to 'fence' in structsync_fence_cbdma-buf/fence: movesync_timelinetofence_timelinestaging/android: remove structsync_pt
dma-buf/fence: createfence_default_enable_signaling()dma-buf/fence: createfence_default_release()dma-buf/fence: createfence_default_get_driver_name()dma-buf/fence: createfence_default_timeline_name()
Quoted 1 line
This is misleading. I think
timeline_fenceprefix would be more appropriate here.
Why? These fence_default_.. functions are fence_ops and not related to fence_timeline in any way.
Quoted 2 lines
I also believe this should be done in multiple series. First series should de-stage the userspace fence framework. The next series should fix up
android_fenceand maybe rename it totimeline_fencesincesync_fenceis already used for the userspace fd, which would add more confusion?
Sure. I've been thinking on how to split this properly. I'm trying to add a bunch of clean up/renaming first, eg the sync_fence rename to sync_file that Daniel Vetter and I discussed.
Next my plan would be move sync_timeline to fence_timeline, add the fence_default.. fence_ops, clean up sw_sync and finally merge fence_context and fence_timeline.
Looking at how sync and fence It looks easier to me to de-stage sync_timeline first than userspace fence.
Gustavo
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Op 20-01-16 om 15:32 schreef Gustavo Padovan:
Quoted 62 lines
2016-01-20 Maarten Lankhorst <[email protected]>:
Quoted 60 lines
Hey,
Op 15-01-16 om 15:55 schreef Gustavo Padovan:
Quoted 57 lines
From: Gustavo Padovan <[email protected]>
This patch series de-stage the sync framework, and in order to accomplish that a bunch of cleanups/improvements on the sync and fence were made.
The sync framework contained some abstractions around struct fence and those were removed in the de-staging process among other changes:
Userspace visible changes
-------------------------* The
sw_syncfile was moved from/dev/sw_syncto <debugfs>/sync/sw_sync. No other change.Kernel API changes
------------------* struct
sync_timelineis now structfence_timeline
*sync_timeline_opsis nowfence_timeline_opsand they now carry struct fence as parameter instead of structsync_pt
* a .cleanup() fence op was added to allowsync_fenceto run a cleanup when thefence_timelineis destroyed
* addedfence_add_used_data()to pass a private point to struct fence. This pointer is sent back on the .cleanup op.
* The sync timeline function were moved to befence_timelinefunctions:
-sync_timeline_create()->fence_timeline_create()
-sync_timeline_get()->fence_timeline_get()
-sync_timeline_put()->fence_timeline_put()
-sync_timeline_destroy()->fence_timeline_destroy()
-sync_timeline_signal()->fence_timeline_signal()*
sync_pt_create()was replaced befence_create_on_timeline()Internal changes
----------------*
fence_timeline_opswas removed in favor of direct usefence_ops
* fence default functions were created forfence_ops
* removed structssync_pt,sw_sync_timelineandsw_sync_ptGustavo Padovan (29):
staging/android: fix sync framework documentation staging/android: fix checkpatch warning
staging/android: renamesync_fence_releasestaging/android: rename 'android_fence' to 'sync_fence' staging/android: remove not usedsync_timelineops staging/android: create a 'sync' dir for debugfs information staging/android: movesw_syncfile to debugfs file staging/android: RemoveWARN_ON_ONCEwhen releasingsync_fencestaging/android: rename struct sync_fence's variables to 'sync_fence' staging/android: rename 'sync_pt' to 'fence' in structsync_fence_cbdma-buf/fence: movesync_timelinetofence_timelinestaging/android: remove structsync_pt
dma-buf/fence: createfence_default_enable_signaling()dma-buf/fence: createfence_default_release()dma-buf/fence: createfence_default_get_driver_name()dma-buf/fence: createfence_default_timeline_name()
Quoted 3 lines
Quoted 1 line
This is misleading. I think
timeline_fenceprefix would be more appropriate here.Why? These
fence_default_.. functions arefence_opsand not related tofence_timelinein any way.
Because they're using fence_parent, which should probably be renamed to fence_to_timeline()
The name makes it sound as if they could apply to all type of fences, I don't think this is the case.
Quoted 11 lines
Quoted 1 line
I also believe this should be done in multiple series. First series should de-stage the userspace fence framework. The next series should fix up
android_fenceand maybe rename it totimeline_fencesincesync_fenceis already used for the userspace fd, which would add more confusion?Sure. I've been thinking on how to split this properly. I'm trying to add a bunch of clean up/renaming first, eg the
sync_fencerename tosync_filethat Daniel Vetter and I discussed.Next my plan would be move
sync_timelinetofence_timeline, add thefence_default..fence_ops, clean upsw_syncand finally mergefence_contextandfence_timeline.Looking at how sync and fence It looks easier to me to de-stage
sync_timelinefirst than userspace fence.
There's already code to add a sync_fence_create_dma export [1][2]. So if you want to de-stage it then there will be users for it.
sync_pt otoh has no upstream in-kernel users. It was a wrapper to keep android drivers api compatible with the fence api.
[1] https://patchwork.freedesktop.org/patch/67845/
[2] https://patchwork.freedesktop.org/patch/67846/
_______________________________________________
dri-devel mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 78 lines · Maarten Lankhorst
Op 20-01-16 om 15:32 schreef Gustavo Padovan:
Quoted 62 lines
2016-01-20 Maarten Lankhorst <[email protected]>:
Quoted 60 lines
Hey,
Op 15-01-16 om 15:55 schreef Gustavo Padovan:
Quoted 57 lines
From: Gustavo Padovan <[email protected]>
This patch series de-stage the sync framework, and in order to accomplish that a bunch of cleanups/improvements on the sync and fence were made.
The sync framework contained some abstractions around struct fence and those were removed in the de-staging process among other changes:
Userspace visible changes
-------------------------* The
sw_syncfile was moved from/dev/sw_syncto <debugfs>/sync/sw_sync. No other change.Kernel API changes
------------------* struct
sync_timelineis now structfence_timeline
*sync_timeline_opsis nowfence_timeline_opsand they now carry struct fence as parameter instead of structsync_pt
* a .cleanup() fence op was added to allowsync_fenceto run a cleanup when thefence_timelineis destroyed
* addedfence_add_used_data()to pass a private point to struct fence. This pointer is sent back on the .cleanup op.
* The sync timeline function were moved to befence_timelinefunctions:
-sync_timeline_create()->fence_timeline_create()
-sync_timeline_get()->fence_timeline_get()
-sync_timeline_put()->fence_timeline_put()
-sync_timeline_destroy()->fence_timeline_destroy()
-sync_timeline_signal()->fence_timeline_signal()*
sync_pt_create()was replaced befence_create_on_timeline()Internal changes
----------------*
fence_timeline_opswas removed in favor of direct usefence_ops
* fence default functions were created forfence_ops
* removed structssync_pt,sw_sync_timelineandsw_sync_ptGustavo Padovan (29):
staging/android: fix sync framework documentation staging/android: fix checkpatch warning
staging/android: renamesync_fence_releasestaging/android: rename 'android_fence' to 'sync_fence' staging/android: remove not usedsync_timelineops staging/android: create a 'sync' dir for debugfs information staging/android: movesw_syncfile to debugfs file staging/android: RemoveWARN_ON_ONCEwhen releasingsync_fencestaging/android: rename struct sync_fence's variables to 'sync_fence' staging/android: rename 'sync_pt' to 'fence' in structsync_fence_cbdma-buf/fence: movesync_timelinetofence_timelinestaging/android: remove structsync_pt
dma-buf/fence: createfence_default_enable_signaling()dma-buf/fence: createfence_default_release()dma-buf/fence: createfence_default_get_driver_name()dma-buf/fence: createfence_default_timeline_name()Quoted 3 lines
Quoted 1 line
This is misleading. I think
timeline_fenceprefix would be more appropriate here.Why? These
fence_default_.. functions arefence_opsand not related tofence_timelinein any way.Because they're using
fence_parent, which should probably be renamed tofence_to_timeline()The name makes it sound as if they could apply to all type of fences, I don't think this is the case.
Quoted 9 lines
Quoted 1 line
I also believe this should be done in multiple series. First series should de-stage the userspace fence framework. The next series should fix up
android_fenceand maybe rename it totimeline_fencesincesync_fenceis already used for the userspace fd, which would add more confusion?Sure. I've been thinking on how to split this properly. I'm trying to add a bunch of clean up/renaming first, eg the
sync_fencerename tosync_filethat Daniel Vetter and I discussed.Next my plan would be move
sync_timelinetofence_timeline, add thefence_default..fence_ops, clean upsw_syncand finally mergefence_contextandfence_timeline.
Quoted 8 lines
Quoted 2 lines
Looking at how sync and fence It looks easier to me to de-stage
sync_timelinefirst than userspace fence.There's already code to add a
sync_fence_create_dmaexport [1][2]. So if you want to de-stage it then there will be users for it.
sync_ptotoh has no upstream in-kernel users. It was a wrapper to keep android drivers api compatible with the fence api.[1] https://patchwork.freedesktop.org/patch/67845/
[2] https://patchwork.freedesktop.org/patch/67846/
We kinda don't have open-source userspace for this stuf though ... -Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
2016-01-20 Maarten Lankhorst <[email protected]>:
Quoted 63 lines
Op 20-01-16 om 15:32 schreef Gustavo Padovan:
Quoted 62 lines
2016-01-20 Maarten Lankhorst <[email protected]>:
Quoted 60 lines
Hey,
Op 15-01-16 om 15:55 schreef Gustavo Padovan:
Quoted 57 lines
From: Gustavo Padovan <[email protected]>
This patch series de-stage the sync framework, and in order to accomplish that a bunch of cleanups/improvements on the sync and fence were made.
The sync framework contained some abstractions around struct fence and those were removed in the de-staging process among other changes:
Userspace visible changes
-------------------------* The
sw_syncfile was moved from/dev/sw_syncto <debugfs>/sync/sw_sync. No other change.Kernel API changes
------------------* struct
sync_timelineis now structfence_timeline
*sync_timeline_opsis nowfence_timeline_opsand they now carry struct fence as parameter instead of structsync_pt
* a .cleanup() fence op was added to allowsync_fenceto run a cleanup when thefence_timelineis destroyed
* addedfence_add_used_data()to pass a private point to struct fence. This pointer is sent back on the .cleanup op.
* The sync timeline function were moved to befence_timelinefunctions:
-sync_timeline_create()->fence_timeline_create()
-sync_timeline_get()->fence_timeline_get()
-sync_timeline_put()->fence_timeline_put()
-sync_timeline_destroy()->fence_timeline_destroy()
-sync_timeline_signal()->fence_timeline_signal()*
sync_pt_create()was replaced befence_create_on_timeline()Internal changes
----------------*
fence_timeline_opswas removed in favor of direct usefence_ops
* fence default functions were created forfence_ops
* removed structssync_pt,sw_sync_timelineandsw_sync_ptGustavo Padovan (29):
staging/android: fix sync framework documentation staging/android: fix checkpatch warning
staging/android: renamesync_fence_releasestaging/android: rename 'android_fence' to 'sync_fence' staging/android: remove not usedsync_timelineops staging/android: create a 'sync' dir for debugfs information staging/android: movesw_syncfile to debugfs file staging/android: RemoveWARN_ON_ONCEwhen releasingsync_fencestaging/android: rename struct sync_fence's variables to 'sync_fence' staging/android: rename 'sync_pt' to 'fence' in structsync_fence_cbdma-buf/fence: movesync_timelinetofence_timelinestaging/android: remove structsync_pt
dma-buf/fence: createfence_default_enable_signaling()dma-buf/fence: createfence_default_release()dma-buf/fence: createfence_default_get_driver_name()dma-buf/fence: createfence_default_timeline_name()
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
This is misleading. I think
timeline_fenceprefix would be more appropriate here.Why? These
fence_default_.. functions arefence_opsand not related tofence_timelinein any way.Because they're using
fence_parent, which should probably be renamed tofence_to_timeline()The name makes it sound as if they could apply to all type of fences, I don't think this is the case.
Fair enough. I can change the naming. Also the final idea is to move fence_ops to be fence_timeline_ops so the naming makes sense.
Quoted 9 lines
Quoted 9 lines
Quoted 1 line
I also believe this should be done in multiple series. First series should de-stage the userspace fence framework. The next series should fix up
android_fenceand maybe rename it totimeline_fencesincesync_fenceis already used for the userspace fd, which would add more confusion?Sure. I've been thinking on how to split this properly. I'm trying to add a bunch of clean up/renaming first, eg the
sync_fencerename tosync_filethat Daniel Vetter and I discussed.Next my plan would be move
sync_timelinetofence_timeline, add thefence_default..fence_ops, clean upsw_syncand finally mergefence_contextandfence_timeline.
Quoted 5 lines
Quoted 2 lines
Looking at how sync and fence It looks easier to me to de-stage
sync_timelinefirst than userspace fence.There's already code to add a
sync_fence_create_dmaexport [1][2]. So if you want to de-stage it then there will be users for it.
sync_ptotoh has no upstream in-kernel users. It was a wrapper to keep android drivers api compatible with the fence api.
One of the first patches of my series is removing struct sync_pt, that means I am also removing sync_fence_create_dma() because sync_fence_create() now accepts struct fence as parameter. I don't sync_pt being useful for any in-kernel driver as it is just a wrapper on top of struct fence.
Gustavo
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC 26/29] dma-buf/fence: remove pointless fence_timeline_signal at destroy phase
In reply to Greg HackmannQuoted 10 lines · Greg Hackmann
Quoted 9 lines · Gustavo Padovan
Patches 27 and 28 are attempt to fix that. I assumed that if some code is calling
fence_timeline_destroy()it wants to stop everything so I worked on a solution that stops any waiter and allows the timeline to be destroyed.No one is using
fence_timeline_destroy()in mainline now, so it is definately a behaviour we can discuss.
Quoted 7 lines
Quoted 2 lines
Gustavo
+Tom Cherry and Dmitry Torokhov recently discovered that this was broken by the refactoring of Android sync on top of dma-buf fences.
Tom and Dmitry, did you send the proposed fix upstream?
There was a similar issue that I had originally thought to be related to fence_timeline_destroy() but was actually related to sync_fence_free(). Dmitry sent the patch upstream at
https://lkml.org/lkml/2015/12/14/953, but it does not look like it has received any feedback.
We saw real panics without this patch. I didn't see this patch or any similar changes in the destaging commits, and I would recommend it be looked at while destaging this driver.
Tom
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC 26/29] dma-buf/fence: remove pointless fence_timeline_signal at destroy phase
2016-02-09 Tom Cherry <[email protected]>:
Quoted 25 lines · Greg Hackmann
Quoted 10 lines · Gustavo Padovan
Quoted 9 lines
Patches 27 and 28 are attempt to fix that. I assumed that if some code is calling
fence_timeline_destroy()it wants to stop everything so I worked on a solution that stops any waiter and allows the timeline to be destroyed.No one is using
fence_timeline_destroy()in mainline now, so it is definately a behaviour we can discuss.Quoted 7 lines
Quoted 2 lines
Gustavo
+Tom Cherry and Dmitry Torokhov recently discovered that this was broken by the refactoring of Android sync on top of dma-buf fences.
Tom and Dmitry, did you send the proposed fix upstream?
There was a similar issue that I had originally thought to be related to
fence_timeline_destroy()but was actually related tosync_fence_free(). Dmitry sent the patch upstream at
https://lkml.org/lkml/2015/12/14/953, but it does not look like it has received any feedback.
Quoted 3 lines
We saw real panics without this patch. I didn't see this patch or any similar changes in the destaging commits, and I would recommend it be looked at while destaging this driver.
This patch is already uptream, Greg pushed it in December. :)
Gustavo
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 72 lines · John Harrison
Quoted 63 lines · Gustavo Padovan
Hi Daniel,
2016-01-19 Daniel Vetter <[email protected]>:
Quoted 58 lines · Gustavo Padovan
Quoted 39 lines
From: Gustavo Padovan <[email protected]>
This patch series de-stage the sync framework, and in order to accomplish that
a bunch of cleanups/improvements on the sync and fence were made.The sync framework contained some abstractions around struct fence and those
were removed in the de-staging process among other changes:Userspace visible changes
-------------------------* The
sw_syncfile was moved from/dev/sw_syncto
<debugfs>/sync/sw_sync. No
other change.Kernel API changes
------------------* struct
sync_timelineis now structfence_timeline
*sync_timeline_opsis nowfence_timeline_opsand they now carry
struct
fence as parameter instead of structsync_pt
* a .cleanup() fence op was added to allowsync_fenceto run a cleanup
when
thefence_timelineis destroyed
* addedfence_add_used_data()to pass a private point to struct fence.
This
pointer is sent back on the .cleanup op.
* The sync timeline function were moved to befence_timeline
functions:- sync_timeline_create() -> fence_timeline_create() - sync_timeline_get() -> fence_timeline_get() - sync_timeline_put() -> fence_timeline_put() - sync_timeline_destroy() -> fence_timeline_destroy() - sync_timeline_signal() -> fence_timeline_signal()Quoted 8 lines
*
sync_pt_create()was replaced befence_create_on_timeline()Internal changes
----------------*
fence_timeline_opswas removed in favor of direct usefence_ops
* fence default functions were created forfence_ops
* removed structssync_pt,sw_sync_timelineandsw_sync_ptBunch of fairly random comments all over:
-
include/uapi/linux/sw_sync.himo should be dropped, it's just a private debugfs interface between fence fds and the testsuite. Since the plan
is
to have the testcases integrated into the kernel tree too we don't
need
a public header.Quoted 6 lines
Quoted 4 lines
- similar for
include/linux/sw_sync.hImo that should all be moved intosync_debug.c. Same forsw_sync.c, that should all land insync_debugimo, and made optional with aKconfigoption. At least we should reuseCONFIG_DEBUGFS.These two items sounds reasonable to me.
Quoted 7 lines
I have just posted our in-progress IGT for testing i915 syncs (with a CC of Gustavo). It uses the
sw_syncmechanisms. Can you take a quick look and see if it is the kind of thing you would expect us to be doing? Or is it using interfaces that you are planning to remove and/or make kernel only?I'm not sure having a kernel only test is the best way to go. Having user land tests like IGT would be much more versatile.
Hi John,
I'm working on making the tests in igt useful for drivers other than i915 and would love to have tests for the fence functionality. Have you made any progress since you posted that RFC?
Thanks,
Tomeu
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel