From: Gustavo Padovan gustavo.padovan@collabora.co.uk
Hi,
The following patches do a clean up on the sw_sync inteface. It starts by removing struct sync_timeline_ops, which was creating unecessary wrappers in the code and the start to organize the sync_timeline and sw_sync code better.
sw_sync interface was moved to sw_sync.c along with sync_timeline - which is now internal to sw_sync.
The next step after this work is the actual de-stage of SW_SYNC and the upstreaming of selftests for sw_sync and sync_file.
Please review!
Gustavo
--- Gustavo Padovan (13): staging/android: store last signaled value on sync timeline staging/android: remove .{fence,timeline}_value_str() from timeline_ops staging/android: remove struct sync_timeline_ops staging/android: remove sw_sync_timeline and sw_sync_pt staging/android: remove sw_sync.[ch] files staging/android: rename android_fence to timeline_fence staging/android: remove unnecessary check for fence staging/android: remove size arg of sync_timeline_create() staging/android: bring struct sync_pt back staging/android: move sw_sync related code to sw_sync.c staging/android: clean up #includes in the sync framework staging/android: make sync_timeline internal to sw_sync staging/android: make sw_ioctl info internal to sw_sync.c
drivers/staging/android/Kconfig | 16 +- drivers/staging/android/Makefile | 3 +- drivers/staging/android/sw_sync.c | 355 +++++++++++++++++++++++++++++---- drivers/staging/android/sw_sync.h | 59 ------ drivers/staging/android/sync.c | 221 -------------------- drivers/staging/android/sync.h | 95 ++------- drivers/staging/android/sync_debug.c | 152 +------------- drivers/staging/android/trace/sync.h | 12 +- drivers/staging/android/uapi/sw_sync.h | 32 --- include/linux/fence.h | 2 - 10 files changed, 350 insertions(+), 597 deletions(-) delete mode 100644 drivers/staging/android/sw_sync.h delete mode 100644 drivers/staging/android/sync.c delete mode 100644 drivers/staging/android/uapi/sw_sync.h
From: Gustavo Padovan gustavo.padovan@collabora.co.uk
Now fence timeline is aware of the last signaled fence, as it receives the increment to the current value in sync_timeline_signal().
That allow us to remove .has_signaled() from timeline_ops as we can directly compare using timeline->value and fence->seqno in sync.c
Signed-off-by: Gustavo Padovan gustavo.padovan@collabora.co.uk --- drivers/staging/android/sw_sync.c | 16 ++-------------- drivers/staging/android/sync.c | 15 +++++++-------- drivers/staging/android/sync.h | 14 +++++--------- 3 files changed, 14 insertions(+), 31 deletions(-)
diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index af39ff5..428e22c 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -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 void sw_sync_timeline_value_str(struct sync_timeline *sync_timeline, char *str, int size) { @@ -64,7 +55,6 @@ static void sw_sync_fence_value_str(struct fence *fence, char *str, int size)
static struct sync_timeline_ops sw_sync_timeline_ops = { .driver_name = "sw_sync", - .has_signaled = sw_sync_fence_has_signaled, .timeline_value_str = sw_sync_timeline_value_str, .fence_value_str = sw_sync_fence_value_str, }; @@ -82,8 +72,6 @@ EXPORT_SYMBOL(sw_sync_timeline_create);
void sw_sync_timeline_inc(struct sw_sync_timeline *obj, u32 inc) { - obj->value += inc; - - sync_timeline_signal(&obj->obj); + sync_timeline_signal(&obj->obj, inc); } EXPORT_SYMBOL(sw_sync_timeline_inc); diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index 1d14c83..8dd2181 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -90,7 +90,7 @@ void sync_timeline_destroy(struct sync_timeline *obj) } EXPORT_SYMBOL(sync_timeline_destroy);
-void sync_timeline_signal(struct sync_timeline *obj) +void sync_timeline_signal(struct sync_timeline *obj, unsigned int inc) { unsigned long flags; struct fence *fence, *next; @@ -99,6 +99,8 @@ void sync_timeline_signal(struct sync_timeline *obj)
spin_lock_irqsave(&obj->child_list_lock, flags);
+ obj->value += inc; + list_for_each_entry_safe(fence, next, &obj->active_list_head, active_list) { if (fence_is_signaled_locked(fence)) @@ -109,7 +111,8 @@ void sync_timeline_signal(struct sync_timeline *obj) } EXPORT_SYMBOL(sync_timeline_signal);
-struct fence *sync_pt_create(struct sync_timeline *obj, int size) +struct fence *sync_pt_create(struct sync_timeline *obj, int size, + unsigned int value) { unsigned long flags; struct fence *fence; @@ -124,7 +127,7 @@ struct fence *sync_pt_create(struct sync_timeline *obj, int size) spin_lock_irqsave(&obj->child_list_lock, flags); sync_timeline_get(obj); fence_init(fence, &android_fence_ops, &obj->child_list_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->child_list_lock, flags); @@ -164,12 +167,8 @@ static void android_fence_release(struct fence *fence) static bool android_fence_signaled(struct fence *fence) { struct sync_timeline *parent = fence_parent(fence); - int ret;
- ret = parent->ops->has_signaled(fence); - if (ret < 0) - fence->status = ret; - return ret; + return (fence->seqno > parent->value) ? false : true; }
static bool android_fence_enable_signaling(struct fence *fence) diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index b56885c..627525c 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -28,19 +28,12 @@ struct sync_timeline; /** * struct sync_timeline_ops - sync object implementation ops * @driver_name: name of the implementation - * @has_signaled: returns: - * 1 if pt has signaled - * 0 if pt has not signaled - * <0 on error * @timeline_value_str: fill str with the value of the sync_timeline's counter * @fence_value_str: fill str with the value of the fence */ struct sync_timeline_ops { const char *driver_name;
- /* required */ - int (*has_signaled)(struct fence *fence); - /* optional */ void (*timeline_value_str)(struct sync_timeline *timeline, char *str, int size); @@ -117,23 +110,26 @@ void sync_timeline_destroy(struct sync_timeline *obj); /** * sync_timeline_signal() - signal a status change on a sync_timeline * @obj: sync_timeline to signal + * @inc: num to increment on timeline->value * * A sync implementation should call this any time one of it's fences * has signaled or has an error condition. */ -void sync_timeline_signal(struct sync_timeline *obj); +void sync_timeline_signal(struct sync_timeline *obj, unsigned int inc);
/** * sync_pt_create() - creates a sync pt * @parent: fence's parent sync_timeline * @size: size to allocate for this pt + * @inc: value of the fence * * Creates a new fence as a child of @parent. @size bytes will be * allocated allowing for implementation specific data to be kept after * the generic sync_timeline struct. Returns the fence object or * NULL in case of error. */ -struct fence *sync_pt_create(struct sync_timeline *parent, int size); +struct fence *sync_pt_create(struct sync_timeline *parent, int size, + unsigned int inc);
#ifdef CONFIG_DEBUG_FS
From: Gustavo Padovan gustavo.padovan@collabora.co.uk
Now that the value of fence and the timeline are not stored by sw_sync anymore we can remove this extra abstraction to retrieve this data.
This patch changes both fence_ops (.fence_value_str and .timeline_value_str) to return the str directly.
It also clean up struct sync_timeline_ops by removing both ops from there.
Signed-off-by: Gustavo Padovan gustavo.padovan@collabora.co.uk --- drivers/staging/android/sw_sync.c | 17 ----------------- drivers/staging/android/sync.c | 16 ++-------------- drivers/staging/android/sync.h | 9 --------- drivers/staging/android/sync_debug.c | 12 ++---------- drivers/staging/android/trace/sync.h | 12 +++--------- 5 files changed, 7 insertions(+), 59 deletions(-)
diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index 428e22c..4200b12 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -38,25 +38,8 @@ struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value) } EXPORT_SYMBOL(sw_sync_pt_create);
-static void sw_sync_timeline_value_str(struct sync_timeline *sync_timeline, - char *str, int size) -{ - struct sw_sync_timeline *timeline = - (struct sw_sync_timeline *)sync_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 sync_timeline_ops sw_sync_timeline_ops = { .driver_name = "sw_sync", - .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) diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index 8dd2181..c75d1e6 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -185,14 +185,7 @@ static bool android_fence_enable_signaling(struct fence *fence) static void android_fence_value_str(struct fence *fence, char *str, int size) { - struct sync_timeline *parent = fence_parent(fence); - - if (!parent->ops->fence_value_str) { - if (size) - *str = 0; - return; - } - parent->ops->fence_value_str(fence, str, size); + snprintf(str, size, "%d", fence->seqno); }
static void android_fence_timeline_value_str(struct fence *fence, @@ -200,12 +193,7 @@ static void android_fence_timeline_value_str(struct fence *fence, { struct sync_timeline *parent = fence_parent(fence);
- if (!parent->ops->timeline_value_str) { - if (size) - *str = 0; - return; - } - parent->ops->timeline_value_str(parent, str, size); + snprintf(str, size, "%d", parent->value); }
static const struct fence_ops android_fence_ops = { diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index 627525c..29f8c19 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -28,18 +28,9 @@ struct sync_timeline; /** * struct sync_timeline_ops - sync object implementation ops * @driver_name: name of the implementation - * @timeline_value_str: fill str with the value of the sync_timeline's counter - * @fence_value_str: fill str with the value of the fence */ struct sync_timeline_ops { const char *driver_name; - - /* optional */ - void (*timeline_value_str)(struct sync_timeline *timeline, char *str, - int size); - - /* optional */ - void (*fence_value_str)(struct fence *fence, char *str, int size); };
/** diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index 5f57499..c532457 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -133,16 +133,8 @@ static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj) struct list_head *pos; unsigned long flags;
- seq_printf(s, "%s %s", obj->name, obj->ops->driver_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->ops->driver_name, + obj->value);
spin_lock_irqsave(&obj->child_list_lock, flags); list_for_each(pos, &obj->child_list_head) { diff --git a/drivers/staging/android/trace/sync.h b/drivers/staging/android/trace/sync.h index a0f80f4..d7f6457f 100644 --- a/drivers/staging/android/trace/sync.h +++ b/drivers/staging/android/trace/sync.h @@ -15,21 +15,15 @@ TRACE_EVENT(sync_timeline,
TP_STRUCT__entry( __string(name, timeline->name) - __array(char, value, 32) + __field(u32, 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=%d", __get_str(name), __entry->value) );
#endif /* if !defined(_TRACE_SYNC_H) || defined(TRACE_HEADER_MULTI_READ) */
From: Gustavo Padovan gustavo.padovan@collabora.co.uk
Move drv_name, the last field of sync_timeline_ops, to sync_timeline and remove sync_timeline_ops.
struct sync_timeline_ops was just an extra abstraction on top of fence_ops, and in the last few commits we removed all it ops in favor of cleaner fence_ops.
Signed-off-by: Gustavo Padovan gustavo.padovan@collabora.co.uk --- drivers/staging/android/sw_sync.c | 9 ++------- drivers/staging/android/sync.c | 8 ++++---- drivers/staging/android/sync.h | 28 +++++++++------------------- drivers/staging/android/sync_debug.c | 3 +-- 4 files changed, 16 insertions(+), 32 deletions(-)
diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index 4200b12..c5e92c6 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -38,16 +38,11 @@ struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value) } EXPORT_SYMBOL(sw_sync_pt_create);
-static struct sync_timeline_ops sw_sync_timeline_ops = { - .driver_name = "sw_sync", -}; - 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, - sizeof(struct sw_sync_timeline), - name); + sync_timeline_create(sizeof(struct sw_sync_timeline), + "sw_sync", name);
return obj; } diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index c75d1e6..b3efcaa 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -30,8 +30,8 @@
static const struct fence_ops android_fence_ops;
-struct sync_timeline *sync_timeline_create(const struct sync_timeline_ops *ops, - int size, const char *name) +struct sync_timeline *sync_timeline_create(int size, const char *drv_name, + const char *name) { struct sync_timeline *obj;
@@ -43,9 +43,9 @@ struct sync_timeline *sync_timeline_create(const struct sync_timeline_ops *ops, return NULL;
kref_init(&obj->kref); - obj->ops = ops; obj->context = fence_context_alloc(1); strlcpy(obj->name, name, sizeof(obj->name)); + strlcpy(obj->drv_name, drv_name, sizeof(obj->drv_name));
INIT_LIST_HEAD(&obj->child_list_head); INIT_LIST_HEAD(&obj->active_list_head); @@ -139,7 +139,7 @@ static const char *android_fence_get_driver_name(struct fence *fence) { struct sync_timeline *parent = fence_parent(fence);
- return parent->ops->driver_name; + return parent->drv_name; }
static const char *android_fence_get_timeline_name(struct fence *fence) diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index 29f8c19..f003e97 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -23,20 +23,10 @@ #include <linux/sync_file.h> #include <uapi/linux/sync_file.h>
-struct sync_timeline; - -/** - * struct sync_timeline_ops - sync object implementation ops - * @driver_name: name of the implementation - */ -struct sync_timeline_ops { - const char *driver_name; -}; - /** * struct sync_timeline - sync object * @kref: reference count on fence. - * @ops: ops that define the implementation of the sync_timeline + * @drv_name: drv_name of the driver using the sync_timeline * @name: name of the sync_timeline. Useful for debugging * @destroyed: set when sync_timeline is destroyed * @child_list_head: list of children sync_pts for this sync_timeline @@ -47,7 +37,7 @@ struct sync_timeline_ops { */ struct sync_timeline { struct kref kref; - const struct sync_timeline_ops *ops; + char drv_name[32]; char name[32];
/* protected by child_list_lock */ @@ -76,17 +66,17 @@ static inline struct sync_timeline *fence_parent(struct fence *fence)
/** * sync_timeline_create() - creates a sync object - * @ops: specifies the implementation ops for the object * @size: size to allocate for this obj + * @drv_name: sync_timeline driver name * @name: sync_timeline name * - * 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. Returns the - * sync_timeline object or NULL in case of error. + * Creates a new sync_timeline. @size bytes will be allocated allowing + * for implementation specific 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); +struct sync_timeline *sync_timeline_create(int size, const char *drv_name, + const char *name);
/** * sync_timeline_destroy() - destroys a sync object diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index c532457..e5634f2 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -133,8 +133,7 @@ static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj) struct list_head *pos; unsigned long flags;
- seq_printf(s, "%s %s: %d\n", obj->name, obj->ops->driver_name, - obj->value); + seq_printf(s, "%s %s: %d\n", obj->name, obj->drv_name, obj->value);
spin_lock_irqsave(&obj->child_list_lock, flags); list_for_each(pos, &obj->child_list_head) {
From: Gustavo Padovan gustavo.padovan@collabora.co.uk
As we moved value storage to sync_timeline and fence those two structs became useless and can be removed now.
Signed-off-by: Gustavo Padovan gustavo.padovan@collabora.co.uk --- drivers/staging/android/sw_sync.c | 24 +++++++----------------- drivers/staging/android/sw_sync.h | 24 ++++++------------------ drivers/staging/android/sync_debug.c | 12 ++++++------ 3 files changed, 19 insertions(+), 41 deletions(-)
diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index c5e92c6..461dbd9 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -25,31 +25,21 @@
#include "sw_sync.h"
-struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value) +struct fence *sw_sync_pt_create(struct 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 sync_pt_create(obj, sizeof(struct fence), value); } EXPORT_SYMBOL(sw_sync_pt_create);
-struct sw_sync_timeline *sw_sync_timeline_create(const char *name) +struct sync_timeline *sw_sync_timeline_create(const char *name) { - struct sw_sync_timeline *obj = (struct sw_sync_timeline *) - sync_timeline_create(sizeof(struct sw_sync_timeline), - "sw_sync", name); - - return obj; + return sync_timeline_create(sizeof(struct sync_timeline), + "sw_sync", name); } EXPORT_SYMBOL(sw_sync_timeline_create);
-void sw_sync_timeline_inc(struct sw_sync_timeline *obj, u32 inc) +void sw_sync_timeline_inc(struct sync_timeline *obj, u32 inc) { - sync_timeline_signal(&obj->obj, inc); + sync_timeline_signal(obj, inc); } EXPORT_SYMBOL(sw_sync_timeline_inc); diff --git a/drivers/staging/android/sw_sync.h b/drivers/staging/android/sw_sync.h index e18667b..9f26c62 100644 --- a/drivers/staging/android/sw_sync.h +++ b/drivers/staging/android/sw_sync.h @@ -22,34 +22,22 @@ #include "sync.h" #include "uapi/sw_sync.h"
-struct sw_sync_timeline { - struct sync_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 sync_timeline *sw_sync_timeline_create(const char *name); +void sw_sync_timeline_inc(struct sync_timeline *obj, u32 inc);
-struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value); +struct fence *sw_sync_pt_create(struct sync_timeline *obj, u32 value); #else -static inline struct sw_sync_timeline *sw_sync_timeline_create(const char *name) +static inline struct sync_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 sync_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 sync_timeline *obj, u32 value) { return NULL; diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index e5634f2..e207a4d 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -209,7 +209,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 sync_timeline *obj; char task_comm[TASK_COMM_LEN];
get_task_comm(task_comm, current); @@ -225,13 +225,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 sync_timeline *obj = file->private_data;
- sync_timeline_destroy(&obj->obj); + sync_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 sync_timeline *obj, unsigned long arg) { int fd = get_unused_fd_flags(O_CLOEXEC); @@ -277,7 +277,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 sync_timeline *obj, unsigned long arg) { u32 value;
@@ -292,7 +292,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 sync_timeline *obj = file->private_data;
switch (cmd) { case SW_SYNC_IOC_CREATE_FENCE:
From: Gustavo Padovan gustavo.padovan@collabora.co.uk
We can glue the sw_sync file operations directly on the sync framework without the need to pass through sw_sync wrappers.
It only builds sw_sync debugfs file support if CONFIG_SW_SYNC is enabled.
Signed-off-by: Gustavo Padovan gustavo.padovan@collabora.co.uk --- drivers/staging/android/Makefile | 1 - drivers/staging/android/sw_sync.c | 45 ---------------------------------- drivers/staging/android/sw_sync.h | 47 ------------------------------------ drivers/staging/android/sync_debug.c | 17 ++++++++++--- 4 files changed, 13 insertions(+), 97 deletions(-) delete mode 100644 drivers/staging/android/sw_sync.c delete mode 100644 drivers/staging/android/sw_sync.h
diff --git a/drivers/staging/android/Makefile b/drivers/staging/android/Makefile index 980d6dc..bf45967 100644 --- a/drivers/staging/android/Makefile +++ b/drivers/staging/android/Makefile @@ -5,4 +5,3 @@ obj-y += ion/ obj-$(CONFIG_ASHMEM) += ashmem.o obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER) += lowmemorykiller.o obj-$(CONFIG_SYNC) += sync.o sync_debug.o -obj-$(CONFIG_SW_SYNC) += sw_sync.o diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c deleted file mode 100644 index 461dbd9..0000000 --- a/drivers/staging/android/sw_sync.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * drivers/base/sw_sync.c - * - * Copyright (C) 2012 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#include <linux/kernel.h> -#include <linux/init.h> -#include <linux/export.h> -#include <linux/file.h> -#include <linux/fs.h> -#include <linux/miscdevice.h> -#include <linux/syscalls.h> -#include <linux/uaccess.h> - -#include "sw_sync.h" - -struct fence *sw_sync_pt_create(struct sync_timeline *obj, u32 value) -{ - return sync_pt_create(obj, sizeof(struct fence), value); -} -EXPORT_SYMBOL(sw_sync_pt_create); - -struct sync_timeline *sw_sync_timeline_create(const char *name) -{ - return sync_timeline_create(sizeof(struct sync_timeline), - "sw_sync", name); -} -EXPORT_SYMBOL(sw_sync_timeline_create); - -void sw_sync_timeline_inc(struct sync_timeline *obj, u32 inc) -{ - sync_timeline_signal(obj, inc); -} -EXPORT_SYMBOL(sw_sync_timeline_inc); diff --git a/drivers/staging/android/sw_sync.h b/drivers/staging/android/sw_sync.h deleted file mode 100644 index 9f26c62..0000000 --- a/drivers/staging/android/sw_sync.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * include/linux/sw_sync.h - * - * Copyright (C) 2012 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#ifndef _LINUX_SW_SYNC_H -#define _LINUX_SW_SYNC_H - -#include <linux/types.h> -#include <linux/kconfig.h> -#include "sync.h" -#include "uapi/sw_sync.h" - -#if IS_ENABLED(CONFIG_SW_SYNC) -struct sync_timeline *sw_sync_timeline_create(const char *name); -void sw_sync_timeline_inc(struct sync_timeline *obj, u32 inc); - -struct fence *sw_sync_pt_create(struct sync_timeline *obj, u32 value); -#else -static inline struct sync_timeline *sw_sync_timeline_create(const char *name) -{ - return NULL; -} - -static inline void sw_sync_timeline_inc(struct sync_timeline *obj, u32 inc) -{ -} - -static inline struct fence *sw_sync_pt_create(struct sync_timeline *obj, - u32 value) -{ - return NULL; -} -#endif /* IS_ENABLED(CONFIG_SW_SYNC) */ - -#endif /* _LINUX_SW_SYNC_H */ diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index e207a4d..dc85d5f 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -27,7 +27,11 @@ #include <linux/anon_inodes.h> #include <linux/time64.h> #include <linux/sync_file.h> -#include "sw_sync.h" +#include <linux/types.h> +#include <linux/kconfig.h> + +#include "uapi/sw_sync.h" +#include "sync.h"
#ifdef CONFIG_DEBUG_FS
@@ -200,6 +204,7 @@ static const struct file_operations sync_info_debugfs_fops = { .release = single_release, };
+#if IS_ENABLED(CONFIG_SW_SYNC) /* * *WARNING* * @@ -214,7 +219,7 @@ static int sw_sync_debugfs_open(struct inode *inode, struct file *file)
get_task_comm(task_comm, current);
- obj = sw_sync_timeline_create(task_comm); + obj = sync_timeline_create(sizeof(*obj), "sw_sync", task_comm); if (!obj) return -ENOMEM;
@@ -248,7 +253,7 @@ static long sw_sync_ioctl_create_fence(struct sync_timeline *obj, goto err; }
- fence = sw_sync_pt_create(obj, data.value); + fence = sync_pt_create(obj, sizeof(*fence), data.value); if (!fence) { err = -ENOMEM; goto err; @@ -284,7 +289,7 @@ static long sw_sync_ioctl_inc(struct sync_timeline *obj, unsigned long arg) if (copy_from_user(&value, (void __user *)arg, sizeof(value))) return -EFAULT;
- sw_sync_timeline_inc(obj, value); + sync_timeline_signal(obj, value);
return 0; } @@ -312,14 +317,18 @@ static const struct file_operations sw_sync_debugfs_fops = { .unlocked_ioctl = sw_sync_ioctl, .compat_ioctl = sw_sync_ioctl, }; +#endif
static __init int sync_debugfs_init(void) { dbgfs = debugfs_create_dir("sync", NULL);
debugfs_create_file("info", 0444, dbgfs, NULL, &sync_info_debugfs_fops); + +#if IS_ENABLED(CONFIG_SW_SYNC) debugfs_create_file("sw_sync", 0644, dbgfs, NULL, &sw_sync_debugfs_fops); +#endif
return 0; }
From: Gustavo Padovan gustavo.padovan@collabora.co.uk
We are moving out of staging/android so rename it to a name that is not related to android anymore.
Signed-off-by: Gustavo Padovan gustavo.padovan@collabora.co.uk --- drivers/staging/android/sync.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index b3efcaa..442d808 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -28,7 +28,7 @@ #define CREATE_TRACE_POINTS #include "trace/sync.h"
-static const struct fence_ops android_fence_ops; +static const struct fence_ops timeline_fence_ops;
struct sync_timeline *sync_timeline_create(int size, const char *drv_name, const char *name) @@ -126,7 +126,7 @@ struct fence *sync_pt_create(struct sync_timeline *obj, int size,
spin_lock_irqsave(&obj->child_list_lock, flags); sync_timeline_get(obj); - fence_init(fence, &android_fence_ops, &obj->child_list_lock, + fence_init(fence, &timeline_fence_ops, &obj->child_list_lock, obj->context, value); list_add_tail(&fence->child_list, &obj->child_list_head); INIT_LIST_HEAD(&fence->active_list); @@ -135,21 +135,21 @@ struct fence *sync_pt_create(struct sync_timeline *obj, int size, } EXPORT_SYMBOL(sync_pt_create);
-static const char *android_fence_get_driver_name(struct fence *fence) +static const char *timeline_fence_get_driver_name(struct fence *fence) { struct sync_timeline *parent = fence_parent(fence);
return parent->drv_name; }
-static const char *android_fence_get_timeline_name(struct fence *fence) +static const char *timeline_fence_get_timeline_name(struct fence *fence) { struct sync_timeline *parent = fence_parent(fence);
return parent->name; }
-static void android_fence_release(struct fence *fence) +static void timeline_fence_release(struct fence *fence) { struct sync_timeline *parent = fence_parent(fence); unsigned long flags; @@ -164,31 +164,31 @@ static void android_fence_release(struct fence *fence) fence_free(fence); }
-static bool android_fence_signaled(struct fence *fence) +static bool timeline_fence_signaled(struct fence *fence) { struct sync_timeline *parent = fence_parent(fence);
return (fence->seqno > parent->value) ? false : true; }
-static bool android_fence_enable_signaling(struct fence *fence) +static bool timeline_fence_enable_signaling(struct fence *fence) { struct sync_timeline *parent = fence_parent(fence);
- if (android_fence_signaled(fence)) + if (timeline_fence_signaled(fence)) return false;
list_add_tail(&fence->active_list, &parent->active_list_head); return true; }
-static void android_fence_value_str(struct fence *fence, +static void timeline_fence_value_str(struct fence *fence, char *str, int size) { snprintf(str, size, "%d", fence->seqno); }
-static void android_fence_timeline_value_str(struct fence *fence, +static void timeline_fence_timeline_value_str(struct fence *fence, char *str, int size) { struct sync_timeline *parent = fence_parent(fence); @@ -196,13 +196,13 @@ static void android_fence_timeline_value_str(struct fence *fence, snprintf(str, size, "%d", parent->value); }
-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 timeline_fence_ops = { + .get_driver_name = timeline_fence_get_driver_name, + .get_timeline_name = timeline_fence_get_timeline_name, + .enable_signaling = timeline_fence_enable_signaling, + .signaled = timeline_fence_signaled, .wait = fence_default_wait, - .release = android_fence_release, - .fence_value_str = android_fence_value_str, - .timeline_value_str = android_fence_timeline_value_str, + .release = timeline_fence_release, + .fence_value_str = timeline_fence_value_str, + .timeline_value_str = timeline_fence_timeline_value_str, };
From: Gustavo Padovan gustavo.padovan@collabora.co.uk
When we call sync_print_fence() fence is always valid.
Signed-off-by: Gustavo Padovan gustavo.padovan@collabora.co.uk --- drivers/staging/android/sync_debug.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index dc85d5f..6282046 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -109,7 +109,7 @@ static void sync_print_fence(struct seq_file *s, struct fence *fence, bool show) seq_printf(s, "@%lld.%09ld", (s64)ts64.tv_sec, ts64.tv_nsec); }
- if ((!fence || fence->ops->timeline_value_str) && + if (fence->ops->timeline_value_str && fence->ops->fence_value_str) { char value[64]; bool success; @@ -117,10 +117,9 @@ static void sync_print_fence(struct seq_file *s, struct fence *fence, bool show) fence->ops->fence_value_str(fence, value, sizeof(value)); success = strlen(value);
- if (success) + if (success) { seq_printf(s, ": %s", value);
- if (success && fence) { fence->ops->timeline_value_str(fence, value, sizeof(value));
From: Gustavo Padovan gustavo.padovan@collabora.co.uk
After we removed sw_sync_timeline this arg has not been really used by anyone, all its users pass the size of struct sync_timeline there.
So simplify this function but not requiring the size anymore.
Signed-off-by: Gustavo Padovan gustavo.padovan@collabora.co.uk --- drivers/staging/android/sync.c | 7 ++----- drivers/staging/android/sync.h | 7 ++----- drivers/staging/android/sync_debug.c | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index 442d808..c83a599 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -30,15 +30,12 @@
static const struct fence_ops timeline_fence_ops;
-struct sync_timeline *sync_timeline_create(int size, const char *drv_name, +struct sync_timeline *sync_timeline_create(const char *drv_name, const char *name) { struct sync_timeline *obj;
- if (size < sizeof(struct sync_timeline)) - return NULL; - - obj = kzalloc(size, GFP_KERNEL); + obj = kzalloc(sizeof(*obj), GFP_KERNEL); if (!obj) return NULL;
diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index f003e97..f2fbf98 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -66,16 +66,13 @@ static inline struct sync_timeline *fence_parent(struct fence *fence)
/** * sync_timeline_create() - creates a sync object - * @size: size to allocate for this obj * @drv_name: sync_timeline driver name * @name: sync_timeline name * - * Creates a new sync_timeline. @size bytes will be allocated allowing - * for implementation specific data to be kept after the generic - * sync_timeline struct. Returns the sync_timeline object or NULL in + * Creates a new sync_timeline. Returns the sync_timeline object or NULL in * case of error. */ -struct sync_timeline *sync_timeline_create(int size, const char *drv_name, +struct sync_timeline *sync_timeline_create(const char *drv_name, const char *name);
/** diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index 6282046..cb0f888 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -218,7 +218,7 @@ static int sw_sync_debugfs_open(struct inode *inode, struct file *file)
get_task_comm(task_comm, current);
- obj = sync_timeline_create(sizeof(*obj), "sw_sync", task_comm); + obj = sync_timeline_create("sw_sync", task_comm); if (!obj) return -ENOMEM;
From: Gustavo Padovan gustavo.padovan@collabora.co.uk
Move the list_head members from sync_pt to struct fence was a mistake, they will not be used by struct fence as planned before, so here we create sync_pt again to bring the list heads back.
Signed-off-by: Gustavo Padovan gustavo.padovan@collabora.co.uk --- drivers/staging/android/sync.c | 40 ++++++++++++++++++------------------ drivers/staging/android/sync.h | 29 ++++++++++++++++++++++---- drivers/staging/android/sync_debug.c | 16 +++++++-------- include/linux/fence.h | 2 -- 4 files changed, 53 insertions(+), 34 deletions(-)
diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index c83a599..aab80ec 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -28,8 +28,6 @@ #define CREATE_TRACE_POINTS #include "trace/sync.h"
-static const struct fence_ops timeline_fence_ops; - struct sync_timeline *sync_timeline_create(const char *drv_name, const char *name) { @@ -90,7 +88,7 @@ EXPORT_SYMBOL(sync_timeline_destroy); void sync_timeline_signal(struct sync_timeline *obj, unsigned int inc) { unsigned long flags; - struct fence *fence, *next; + struct sync_pt *pt, *next;
trace_sync_timeline(obj);
@@ -98,37 +96,37 @@ void sync_timeline_signal(struct sync_timeline *obj, unsigned int inc)
obj->value += inc;
- list_for_each_entry_safe(fence, next, &obj->active_list_head, + list_for_each_entry_safe(pt, next, &obj->active_list_head, active_list) { - if (fence_is_signaled_locked(fence)) - list_del_init(&fence->active_list); + if (fence_is_signaled_locked(&pt->base)) + list_del_init(&pt->active_list); }
spin_unlock_irqrestore(&obj->child_list_lock, flags); } EXPORT_SYMBOL(sync_timeline_signal);
-struct fence *sync_pt_create(struct sync_timeline *obj, int size, +struct sync_pt *sync_pt_create(struct sync_timeline *obj, int size, unsigned int value) { unsigned long flags; - struct fence *fence; + struct sync_pt *pt;
- if (size < sizeof(*fence)) + if (size < sizeof(*pt)) return NULL;
- fence = kzalloc(size, GFP_KERNEL); - if (!fence) + pt = kzalloc(size, GFP_KERNEL); + if (!pt) return NULL;
spin_lock_irqsave(&obj->child_list_lock, flags); sync_timeline_get(obj); - fence_init(fence, &timeline_fence_ops, &obj->child_list_lock, + fence_init(&pt->base, &timeline_fence_ops, &obj->child_list_lock, obj->context, value); - list_add_tail(&fence->child_list, &obj->child_list_head); - INIT_LIST_HEAD(&fence->active_list); + list_add_tail(&pt->child_list, &obj->child_list_head); + INIT_LIST_HEAD(&pt->active_list); spin_unlock_irqrestore(&obj->child_list_lock, flags); - return fence; + return pt; } EXPORT_SYMBOL(sync_pt_create);
@@ -148,13 +146,14 @@ static const char *timeline_fence_get_timeline_name(struct fence *fence)
static void timeline_fence_release(struct fence *fence) { + struct sync_pt *pt = fence_to_sync_pt(fence); struct sync_timeline *parent = fence_parent(fence); unsigned long flags;
spin_lock_irqsave(fence->lock, flags); - list_del(&fence->child_list); - if (WARN_ON_ONCE(!list_empty(&fence->active_list))) - list_del(&fence->active_list); + list_del(&pt->child_list); + if (WARN_ON_ONCE(!list_empty(&pt->active_list))) + list_del(&pt->active_list); spin_unlock_irqrestore(fence->lock, flags);
sync_timeline_put(parent); @@ -170,12 +169,13 @@ static bool timeline_fence_signaled(struct fence *fence)
static bool timeline_fence_enable_signaling(struct fence *fence) { + struct sync_pt *pt = fence_to_sync_pt(fence); struct sync_timeline *parent = fence_parent(fence);
if (timeline_fence_signaled(fence)) return false;
- list_add_tail(&fence->active_list, &parent->active_list_head); + list_add_tail(&pt->active_list, &parent->active_list_head); return true; }
@@ -193,7 +193,7 @@ static void timeline_fence_timeline_value_str(struct fence *fence, snprintf(str, size, "%d", parent->value); }
-static const struct fence_ops timeline_fence_ops = { +const struct fence_ops timeline_fence_ops = { .get_driver_name = timeline_fence_get_driver_name, .get_timeline_name = timeline_fence_get_timeline_name, .enable_signaling = timeline_fence_enable_signaling, diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index f2fbf98..14b61cb 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -60,6 +60,27 @@ static inline struct sync_timeline *fence_parent(struct fence *fence) child_list_lock); }
+/** + * struct sync_pt - sync_pt object + * @base: base fence object + * @child_list: sync timeline child's list + * @active_list: sync timeline active child's list + */ +struct sync_pt { + struct fence base; + struct list_head child_list; + struct list_head active_list; +}; + +extern const struct fence_ops timeline_fence_ops; + +static inline struct sync_pt *fence_to_sync_pt(struct fence *fence) +{ + if (fence->ops != &timeline_fence_ops) + return NULL; + return container_of(fence, struct sync_pt, base); +} + /* * API for sync_timeline implementers */ @@ -101,13 +122,13 @@ void sync_timeline_signal(struct sync_timeline *obj, unsigned int inc); * @size: size to allocate for this pt * @inc: value of the fence * - * Creates a new fence as a child of @parent. @size bytes will be + * 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. Returns the fence object or + * the generic sync_timeline struct. Returns the sync_pt object or * NULL in case of error. */ -struct fence *sync_pt_create(struct sync_timeline *parent, int size, - unsigned int inc); +struct sync_pt *sync_pt_create(struct sync_timeline *parent, int size, + unsigned int inc);
#ifdef CONFIG_DEBUG_FS
diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index cb0f888..703f198 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -140,9 +140,9 @@ static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj)
spin_lock_irqsave(&obj->child_list_lock, flags); list_for_each(pos, &obj->child_list_head) { - struct fence *fence = - container_of(pos, struct fence, child_list); - sync_print_fence(s, fence, false); + struct sync_pt *pt = + container_of(pos, struct sync_pt, child_list); + sync_print_fence(s, &pt->base, false); } spin_unlock_irqrestore(&obj->child_list_lock, flags); } @@ -240,7 +240,7 @@ static long sw_sync_ioctl_create_fence(struct sync_timeline *obj, { int fd = get_unused_fd_flags(O_CLOEXEC); int err; - struct fence *fence; + struct sync_pt *pt; struct sync_file *sync_file; struct sw_sync_create_fence_data data;
@@ -252,15 +252,15 @@ static long sw_sync_ioctl_create_fence(struct sync_timeline *obj, goto err; }
- fence = sync_pt_create(obj, sizeof(*fence), data.value); - if (!fence) { + pt = sync_pt_create(obj, sizeof(*pt), data.value); + if (!pt) { err = -ENOMEM; goto err; }
- sync_file = sync_file_create(fence); + sync_file = sync_file_create(&pt->base); if (!sync_file) { - fence_put(fence); + fence_put(&pt->base); err = -ENOMEM; goto err; } diff --git a/include/linux/fence.h b/include/linux/fence.h index 2b17698..5aa95eb 100644 --- a/include/linux/fence.h +++ b/include/linux/fence.h @@ -79,8 +79,6 @@ struct fence { unsigned long flags; ktime_t timestamp; int status; - struct list_head child_list; - struct list_head active_list; };
enum fence_flag_bits {
From: Gustavo Padovan gustavo.padovan@collabora.co.uk
Split sync_debug and sw_sync in two different files.
Signed-off-by: Gustavo Padovan gustavo.padovan@collabora.co.uk --- drivers/staging/android/Makefile | 1 + drivers/staging/android/sw_sync.c | 136 +++++++++++++++++++++++++++++++++++ drivers/staging/android/sync.h | 2 + drivers/staging/android/sync_debug.c | 115 ----------------------------- 4 files changed, 139 insertions(+), 115 deletions(-) create mode 100644 drivers/staging/android/sw_sync.c
diff --git a/drivers/staging/android/Makefile b/drivers/staging/android/Makefile index bf45967..980d6dc 100644 --- a/drivers/staging/android/Makefile +++ b/drivers/staging/android/Makefile @@ -5,3 +5,4 @@ obj-y += ion/ obj-$(CONFIG_ASHMEM) += ashmem.o obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER) += lowmemorykiller.o obj-$(CONFIG_SYNC) += sync.o sync_debug.o +obj-$(CONFIG_SW_SYNC) += sw_sync.o diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c new file mode 100644 index 0000000..90e3ee5 --- /dev/null +++ b/drivers/staging/android/sw_sync.c @@ -0,0 +1,136 @@ +/* + * drivers/dma-buf/sw_sync.c + * + * Copyright (C) 2012 Google, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include <linux/file.h> +#include <linux/fs.h> +#include <linux/uaccess.h> +#include <linux/sync_file.h> + +#include "uapi/sw_sync.h" +#include "sync.h" + +/* + * *WARNING* + * + * improper use of this can result in deadlocking kernel drivers from userspace. + */ + +/* opening sw_sync create a new sync obj */ +static int sw_sync_debugfs_open(struct inode *inode, struct file *file) +{ + struct sync_timeline *obj; + char task_comm[TASK_COMM_LEN]; + + get_task_comm(task_comm, current); + + obj = sync_timeline_create("sw_sync", task_comm); + if (!obj) + return -ENOMEM; + + file->private_data = obj; + + return 0; +} + +static int sw_sync_debugfs_release(struct inode *inode, struct file *file) +{ + struct sync_timeline *obj = file->private_data; + + sync_timeline_destroy(obj); + return 0; +} + +static long sw_sync_ioctl_create_fence(struct sync_timeline *obj, + unsigned long arg) +{ + int fd = get_unused_fd_flags(O_CLOEXEC); + int err; + struct sync_pt *pt; + struct sync_file *sync_file; + struct sw_sync_create_fence_data data; + + if (fd < 0) + return fd; + + if (copy_from_user(&data, (void __user *)arg, sizeof(data))) { + err = -EFAULT; + goto err; + } + + pt = sync_pt_create(obj, sizeof(*pt), data.value); + if (!pt) { + err = -ENOMEM; + goto err; + } + + sync_file = sync_file_create(&pt->base); + if (!sync_file) { + fence_put(&pt->base); + err = -ENOMEM; + goto err; + } + + data.fence = fd; + if (copy_to_user((void __user *)arg, &data, sizeof(data))) { + fput(sync_file->file); + err = -EFAULT; + goto err; + } + + fd_install(fd, sync_file->file); + + return 0; + +err: + put_unused_fd(fd); + return err; +} + +static long sw_sync_ioctl_inc(struct sync_timeline *obj, unsigned long arg) +{ + u32 value; + + if (copy_from_user(&value, (void __user *)arg, sizeof(value))) + return -EFAULT; + + sync_timeline_signal(obj, value); + + return 0; +} + +static long sw_sync_ioctl(struct file *file, unsigned int cmd, + unsigned long arg) +{ + struct sync_timeline *obj = file->private_data; + + switch (cmd) { + case SW_SYNC_IOC_CREATE_FENCE: + return sw_sync_ioctl_create_fence(obj, arg); + + case SW_SYNC_IOC_INC: + return sw_sync_ioctl_inc(obj, arg); + + default: + return -ENOTTY; + } +} + +const struct file_operations sw_sync_debugfs_fops = { + .open = sw_sync_debugfs_open, + .release = sw_sync_debugfs_release, + .unlocked_ioctl = sw_sync_ioctl, + .compat_ioctl = sw_sync_ioctl, +}; diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index 14b61cb..02ecf44 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -132,6 +132,8 @@ struct sync_pt *sync_pt_create(struct sync_timeline *parent, int size,
#ifdef CONFIG_DEBUG_FS
+extern const struct file_operations sw_sync_debugfs_fops; + void sync_timeline_debug_add(struct sync_timeline *obj); void sync_timeline_debug_remove(struct sync_timeline *obj); void sync_file_debug_add(struct sync_file *fence); diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index 703f198..2733cc3 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -203,121 +203,6 @@ static const struct file_operations sync_info_debugfs_fops = { .release = single_release, };
-#if IS_ENABLED(CONFIG_SW_SYNC) -/* - * *WARNING* - * - * improper use of this can result in deadlocking kernel drivers from userspace. - */ - -/* opening sw_sync create a new sync obj */ -static int sw_sync_debugfs_open(struct inode *inode, struct file *file) -{ - struct sync_timeline *obj; - char task_comm[TASK_COMM_LEN]; - - get_task_comm(task_comm, current); - - obj = sync_timeline_create("sw_sync", task_comm); - if (!obj) - return -ENOMEM; - - file->private_data = obj; - - return 0; -} - -static int sw_sync_debugfs_release(struct inode *inode, struct file *file) -{ - struct sync_timeline *obj = file->private_data; - - sync_timeline_destroy(obj); - return 0; -} - -static long sw_sync_ioctl_create_fence(struct sync_timeline *obj, - unsigned long arg) -{ - int fd = get_unused_fd_flags(O_CLOEXEC); - int err; - struct sync_pt *pt; - struct sync_file *sync_file; - struct sw_sync_create_fence_data data; - - if (fd < 0) - return fd; - - if (copy_from_user(&data, (void __user *)arg, sizeof(data))) { - err = -EFAULT; - goto err; - } - - pt = sync_pt_create(obj, sizeof(*pt), data.value); - if (!pt) { - err = -ENOMEM; - goto err; - } - - sync_file = sync_file_create(&pt->base); - if (!sync_file) { - fence_put(&pt->base); - err = -ENOMEM; - goto err; - } - - data.fence = fd; - if (copy_to_user((void __user *)arg, &data, sizeof(data))) { - fput(sync_file->file); - err = -EFAULT; - goto err; - } - - fd_install(fd, sync_file->file); - - return 0; - -err: - put_unused_fd(fd); - return err; -} - -static long sw_sync_ioctl_inc(struct sync_timeline *obj, unsigned long arg) -{ - u32 value; - - if (copy_from_user(&value, (void __user *)arg, sizeof(value))) - return -EFAULT; - - sync_timeline_signal(obj, value); - - return 0; -} - -static long sw_sync_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) -{ - struct sync_timeline *obj = file->private_data; - - switch (cmd) { - case SW_SYNC_IOC_CREATE_FENCE: - return sw_sync_ioctl_create_fence(obj, arg); - - case SW_SYNC_IOC_INC: - return sw_sync_ioctl_inc(obj, arg); - - default: - return -ENOTTY; - } -} - -static const struct file_operations sw_sync_debugfs_fops = { - .open = sw_sync_debugfs_open, - .release = sw_sync_debugfs_release, - .unlocked_ioctl = sw_sync_ioctl, - .compat_ioctl = sw_sync_ioctl, -}; -#endif - static __init int sync_debugfs_init(void) { dbgfs = debugfs_create_dir("sync", NULL);
From: Gustavo Padovan gustavo.padovan@collabora.co.uk
Most of the includes there are not necessary anymore.
Signed-off-by: Gustavo Padovan gustavo.padovan@collabora.co.uk --- drivers/staging/android/sync.c | 6 ------ drivers/staging/android/sync.h | 3 --- drivers/staging/android/sync_debug.c | 16 ---------------- 3 files changed, 25 deletions(-)
diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index aab80ec..bb12d86 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -14,14 +14,8 @@ * */
-#include <linux/debugfs.h> #include <linux/export.h> -#include <linux/kernel.h> -#include <linux/sched.h> -#include <linux/seq_file.h> #include <linux/slab.h> -#include <linux/uaccess.h> -#include <linux/anon_inodes.h>
#include "sync.h"
diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index 02ecf44..54c515b 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -13,9 +13,6 @@ #ifndef _LINUX_SYNC_H #define _LINUX_SYNC_H
-#include <linux/types.h> -#include <linux/kref.h> -#include <linux/ktime.h> #include <linux/list.h> #include <linux/spinlock.h> #include <linux/fence.h> diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index 2733cc3..864ad01 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -15,22 +15,6 @@ */
#include <linux/debugfs.h> -#include <linux/export.h> -#include <linux/file.h> -#include <linux/fs.h> -#include <linux/kernel.h> -#include <linux/poll.h> -#include <linux/sched.h> -#include <linux/seq_file.h> -#include <linux/slab.h> -#include <linux/uaccess.h> -#include <linux/anon_inodes.h> -#include <linux/time64.h> -#include <linux/sync_file.h> -#include <linux/types.h> -#include <linux/kconfig.h> - -#include "uapi/sw_sync.h" #include "sync.h"
#ifdef CONFIG_DEBUG_FS
From: Gustavo Padovan gustavo.padovan@collabora.co.uk
The only use sync_timeline will have in upstream kernel is for debugging through the SW_SYNC interface. So make it internal to SW_SYNC to avoid people use it in the future.
Signed-off-by: Gustavo Padovan gustavo.padovan@collabora.co.uk --- drivers/staging/android/Kconfig | 16 +-- drivers/staging/android/Makefile | 3 +- drivers/staging/android/sw_sync.c | 211 ++++++++++++++++++++++++++++++++++++++ drivers/staging/android/sync.c | 199 ----------------------------------- drivers/staging/android/sync.h | 49 --------- 5 files changed, 216 insertions(+), 262 deletions(-) delete mode 100644 drivers/staging/android/sync.c
diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig index 6480f60..f52c682 100644 --- a/drivers/staging/android/Kconfig +++ b/drivers/staging/android/Kconfig @@ -24,26 +24,18 @@ 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" + bool "Software synchronization framework" default n - depends on SYNC depends on SYNC_FILE ---help--- A sync object driver that uses a 32bit counter to coordinate synchronization. Useful when there is no hardware primitive backing the synchronization.
+ WARNING: improper use of this can result in deadlocking kernel + drivers from userspace. Intended for test and debug only. + source "drivers/staging/android/ion/Kconfig"
endif # if ANDROID diff --git a/drivers/staging/android/Makefile b/drivers/staging/android/Makefile index 980d6dc..7ca61b7 100644 --- a/drivers/staging/android/Makefile +++ b/drivers/staging/android/Makefile @@ -4,5 +4,4 @@ obj-y += ion/
obj-$(CONFIG_ASHMEM) += ashmem.o obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER) += lowmemorykiller.o -obj-$(CONFIG_SYNC) += sync.o sync_debug.o -obj-$(CONFIG_SW_SYNC) += sw_sync.o +obj-$(CONFIG_SW_SYNC) += sw_sync.o sync_debug.o diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index 90e3ee5..4922233 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -17,11 +17,222 @@ #include <linux/file.h> #include <linux/fs.h> #include <linux/uaccess.h> +#include <linux/slab.h> #include <linux/sync_file.h>
#include "uapi/sw_sync.h" #include "sync.h"
+#define CREATE_TRACE_POINTS +#include "trace/sync.h" + +/** + * sync_timeline_create() - creates a sync object + * @drv_name: sync_timeline driver name + * @name: sync_timeline name + * + * Creates a new sync_timeline. Returns the sync_timeline object or NULL in + * case of error. + */ +struct sync_timeline *sync_timeline_create(const char *drv_name, + const char *name) +{ + struct sync_timeline *obj; + + obj = kzalloc(sizeof(*obj), GFP_KERNEL); + if (!obj) + return NULL; + + kref_init(&obj->kref); + obj->context = fence_context_alloc(1); + strlcpy(obj->name, name, sizeof(obj->name)); + strlcpy(obj->drv_name, drv_name, sizeof(obj->drv_name)); + + INIT_LIST_HEAD(&obj->child_list_head); + INIT_LIST_HEAD(&obj->active_list_head); + spin_lock_init(&obj->child_list_lock); + + sync_timeline_debug_add(obj); + + return obj; +} + +static void sync_timeline_free(struct kref *kref) +{ + struct sync_timeline *obj = + container_of(kref, struct sync_timeline, kref); + + sync_timeline_debug_remove(obj); + + kfree(obj); +} + +static void sync_timeline_get(struct sync_timeline *obj) +{ + kref_get(&obj->kref); +} + +static void sync_timeline_put(struct sync_timeline *obj) +{ + kref_put(&obj->kref, sync_timeline_free); +} + +/** + * sync_timeline_destroy() - destroys a sync object + * @obj: sync_timeline to destroy + * + * A sync implementation should call this when the @obj is going away + * (i.e. module unload.) @obj won't actually be freed until all its children + * fences are freed. + */ +static void sync_timeline_destroy(struct sync_timeline *obj) +{ + obj->destroyed = true; + /* + * Ensure timeline is marked as destroyed before + * changing timeline's fences status. + */ + smp_wmb(); + + sync_timeline_put(obj); +} + +/** + * sync_timeline_signal() - signal a status change on a sync_timeline + * @obj: sync_timeline to signal + * @inc: num to increment on timeline->value + * + * A sync implementation should call this any time one of it's fences + * has signaled or has an error condition. + */ +static void sync_timeline_signal(struct sync_timeline *obj, unsigned int inc) +{ + unsigned long flags; + struct sync_pt *pt, *next; + + trace_sync_timeline(obj); + + spin_lock_irqsave(&obj->child_list_lock, flags); + + obj->value += inc; + + list_for_each_entry_safe(pt, next, &obj->active_list_head, + active_list) { + if (fence_is_signaled_locked(&pt->base)) + list_del_init(&pt->active_list); + } + + spin_unlock_irqrestore(&obj->child_list_lock, flags); +} + +/** + * sync_pt_create() - creates a sync pt + * @parent: fence's parent sync_timeline + * @size: size to allocate for this pt + * @inc: value of the fence + * + * 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. Returns the sync_pt object or + * NULL in case of error. + */ +static struct sync_pt *sync_pt_create(struct sync_timeline *obj, int size, + unsigned int value) +{ + unsigned long flags; + struct sync_pt *pt; + + if (size < sizeof(*pt)) + return NULL; + + pt = kzalloc(size, GFP_KERNEL); + if (!pt) + return NULL; + + spin_lock_irqsave(&obj->child_list_lock, flags); + sync_timeline_get(obj); + fence_init(&pt->base, &timeline_fence_ops, &obj->child_list_lock, + obj->context, value); + list_add_tail(&pt->child_list, &obj->child_list_head); + INIT_LIST_HEAD(&pt->active_list); + spin_unlock_irqrestore(&obj->child_list_lock, flags); + return pt; +} + +static const char *timeline_fence_get_driver_name(struct fence *fence) +{ + struct sync_timeline *parent = fence_parent(fence); + + return parent->drv_name; +} + +static const char *timeline_fence_get_timeline_name(struct fence *fence) +{ + struct sync_timeline *parent = fence_parent(fence); + + return parent->name; +} + +static void timeline_fence_release(struct fence *fence) +{ + struct sync_pt *pt = fence_to_sync_pt(fence); + struct sync_timeline *parent = fence_parent(fence); + unsigned long flags; + + spin_lock_irqsave(fence->lock, flags); + list_del(&pt->child_list); + if (WARN_ON_ONCE(!list_empty(&pt->active_list))) + list_del(&pt->active_list); + spin_unlock_irqrestore(fence->lock, flags); + + sync_timeline_put(parent); + fence_free(fence); +} + +static bool timeline_fence_signaled(struct fence *fence) +{ + struct sync_timeline *parent = fence_parent(fence); + + return (fence->seqno > parent->value) ? false : true; +} + +static bool timeline_fence_enable_signaling(struct fence *fence) +{ + struct sync_pt *pt = fence_to_sync_pt(fence); + struct sync_timeline *parent = fence_parent(fence); + + if (timeline_fence_signaled(fence)) + return false; + + list_add_tail(&pt->active_list, &parent->active_list_head); + return true; +} + +static void timeline_fence_value_str(struct fence *fence, + char *str, int size) +{ + snprintf(str, size, "%d", fence->seqno); +} + +static void timeline_fence_timeline_value_str(struct fence *fence, + char *str, int size) +{ + struct sync_timeline *parent = fence_parent(fence); + + snprintf(str, size, "%d", parent->value); +} + +const struct fence_ops timeline_fence_ops = { + .get_driver_name = timeline_fence_get_driver_name, + .get_timeline_name = timeline_fence_get_timeline_name, + .enable_signaling = timeline_fence_enable_signaling, + .signaled = timeline_fence_signaled, + .wait = fence_default_wait, + .release = timeline_fence_release, + .fence_value_str = timeline_fence_value_str, + .timeline_value_str = timeline_fence_timeline_value_str, +}; + /* * *WARNING* * diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c deleted file mode 100644 index bb12d86..0000000 --- a/drivers/staging/android/sync.c +++ /dev/null @@ -1,199 +0,0 @@ -/* - * drivers/base/sync.c - * - * Copyright (C) 2012 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#include <linux/export.h> -#include <linux/slab.h> - -#include "sync.h" - -#define CREATE_TRACE_POINTS -#include "trace/sync.h" - -struct sync_timeline *sync_timeline_create(const char *drv_name, - const char *name) -{ - struct sync_timeline *obj; - - obj = kzalloc(sizeof(*obj), GFP_KERNEL); - if (!obj) - return NULL; - - kref_init(&obj->kref); - obj->context = fence_context_alloc(1); - strlcpy(obj->name, name, sizeof(obj->name)); - strlcpy(obj->drv_name, drv_name, sizeof(obj->drv_name)); - - INIT_LIST_HEAD(&obj->child_list_head); - INIT_LIST_HEAD(&obj->active_list_head); - spin_lock_init(&obj->child_list_lock); - - sync_timeline_debug_add(obj); - - return obj; -} -EXPORT_SYMBOL(sync_timeline_create); - -static void sync_timeline_free(struct kref *kref) -{ - struct sync_timeline *obj = - container_of(kref, struct sync_timeline, kref); - - sync_timeline_debug_remove(obj); - - kfree(obj); -} - -static void sync_timeline_get(struct sync_timeline *obj) -{ - kref_get(&obj->kref); -} - -static void sync_timeline_put(struct sync_timeline *obj) -{ - kref_put(&obj->kref, sync_timeline_free); -} - -void sync_timeline_destroy(struct sync_timeline *obj) -{ - obj->destroyed = true; - /* - * Ensure timeline is marked as destroyed before - * changing timeline's fences status. - */ - smp_wmb(); - - sync_timeline_put(obj); -} -EXPORT_SYMBOL(sync_timeline_destroy); - -void sync_timeline_signal(struct sync_timeline *obj, unsigned int inc) -{ - unsigned long flags; - struct sync_pt *pt, *next; - - trace_sync_timeline(obj); - - spin_lock_irqsave(&obj->child_list_lock, flags); - - obj->value += inc; - - list_for_each_entry_safe(pt, next, &obj->active_list_head, - active_list) { - if (fence_is_signaled_locked(&pt->base)) - list_del_init(&pt->active_list); - } - - spin_unlock_irqrestore(&obj->child_list_lock, flags); -} -EXPORT_SYMBOL(sync_timeline_signal); - -struct sync_pt *sync_pt_create(struct sync_timeline *obj, int size, - unsigned int value) -{ - unsigned long flags; - struct sync_pt *pt; - - if (size < sizeof(*pt)) - return NULL; - - pt = kzalloc(size, GFP_KERNEL); - if (!pt) - return NULL; - - spin_lock_irqsave(&obj->child_list_lock, flags); - sync_timeline_get(obj); - fence_init(&pt->base, &timeline_fence_ops, &obj->child_list_lock, - obj->context, value); - list_add_tail(&pt->child_list, &obj->child_list_head); - INIT_LIST_HEAD(&pt->active_list); - spin_unlock_irqrestore(&obj->child_list_lock, flags); - return pt; -} -EXPORT_SYMBOL(sync_pt_create); - -static const char *timeline_fence_get_driver_name(struct fence *fence) -{ - struct sync_timeline *parent = fence_parent(fence); - - return parent->drv_name; -} - -static const char *timeline_fence_get_timeline_name(struct fence *fence) -{ - struct sync_timeline *parent = fence_parent(fence); - - return parent->name; -} - -static void timeline_fence_release(struct fence *fence) -{ - struct sync_pt *pt = fence_to_sync_pt(fence); - struct sync_timeline *parent = fence_parent(fence); - unsigned long flags; - - spin_lock_irqsave(fence->lock, flags); - list_del(&pt->child_list); - if (WARN_ON_ONCE(!list_empty(&pt->active_list))) - list_del(&pt->active_list); - spin_unlock_irqrestore(fence->lock, flags); - - sync_timeline_put(parent); - fence_free(fence); -} - -static bool timeline_fence_signaled(struct fence *fence) -{ - struct sync_timeline *parent = fence_parent(fence); - - return (fence->seqno > parent->value) ? false : true; -} - -static bool timeline_fence_enable_signaling(struct fence *fence) -{ - struct sync_pt *pt = fence_to_sync_pt(fence); - struct sync_timeline *parent = fence_parent(fence); - - if (timeline_fence_signaled(fence)) - return false; - - list_add_tail(&pt->active_list, &parent->active_list_head); - return true; -} - -static void timeline_fence_value_str(struct fence *fence, - char *str, int size) -{ - snprintf(str, size, "%d", fence->seqno); -} - -static void timeline_fence_timeline_value_str(struct fence *fence, - char *str, int size) -{ - struct sync_timeline *parent = fence_parent(fence); - - snprintf(str, size, "%d", parent->value); -} - -const struct fence_ops timeline_fence_ops = { - .get_driver_name = timeline_fence_get_driver_name, - .get_timeline_name = timeline_fence_get_timeline_name, - .enable_signaling = timeline_fence_enable_signaling, - .signaled = timeline_fence_signaled, - .wait = fence_default_wait, - .release = timeline_fence_release, - .fence_value_str = timeline_fence_value_str, - .timeline_value_str = timeline_fence_timeline_value_str, -}; diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index 54c515b..8e203bf 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -78,55 +78,6 @@ static inline struct sync_pt *fence_to_sync_pt(struct fence *fence) return container_of(fence, struct sync_pt, base); }
-/* - * API for sync_timeline implementers - */ - -/** - * sync_timeline_create() - creates a sync object - * @drv_name: sync_timeline driver name - * @name: sync_timeline name - * - * Creates a new sync_timeline. Returns the sync_timeline object or NULL in - * case of error. - */ -struct sync_timeline *sync_timeline_create(const char *drv_name, - const char *name); - -/** - * sync_timeline_destroy() - destroys a sync object - * @obj: sync_timeline to destroy - * - * A sync implementation should call this when the @obj is going away - * (i.e. module unload.) @obj won't actually be freed until all its children - * fences are freed. - */ -void sync_timeline_destroy(struct sync_timeline *obj); - -/** - * sync_timeline_signal() - signal a status change on a sync_timeline - * @obj: sync_timeline to signal - * @inc: num to increment on timeline->value - * - * A sync implementation should call this any time one of it's fences - * has signaled or has an error condition. - */ -void sync_timeline_signal(struct sync_timeline *obj, unsigned int inc); - -/** - * sync_pt_create() - creates a sync pt - * @parent: fence's parent sync_timeline - * @size: size to allocate for this pt - * @inc: value of the fence - * - * 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. Returns the sync_pt object or - * NULL in case of error. - */ -struct sync_pt *sync_pt_create(struct sync_timeline *parent, int size, - unsigned int inc); - #ifdef CONFIG_DEBUG_FS
extern const struct file_operations sw_sync_debugfs_fops;
From: Gustavo Padovan gustavo.padovan@collabora.co.uk
We don't want to export this from the kernel. This is interface is only for testing and debug. So testers shall copy the ioctl info in their own projects.
Signed-off-by: Gustavo Padovan gustavo.padovan@collabora.co.uk --- drivers/staging/android/sw_sync.c | 13 ++++++++++++- drivers/staging/android/uapi/sw_sync.h | 32 -------------------------------- 2 files changed, 12 insertions(+), 33 deletions(-) delete mode 100644 drivers/staging/android/uapi/sw_sync.h
diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index 4922233..7a7acc1 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -20,12 +20,23 @@ #include <linux/slab.h> #include <linux/sync_file.h>
-#include "uapi/sw_sync.h" #include "sync.h"
#define CREATE_TRACE_POINTS #include "trace/sync.h"
+struct sw_sync_create_fence_data { + __u32 value; + char name[32]; + __s32 fence; /* fd of new fence */ +}; + +#define SW_SYNC_IOC_MAGIC 'W' + +#define SW_SYNC_IOC_CREATE_FENCE _IOWR(SW_SYNC_IOC_MAGIC, 0,\ + struct sw_sync_create_fence_data) +#define SW_SYNC_IOC_INC _IOW(SW_SYNC_IOC_MAGIC, 1, __u32) + /** * sync_timeline_create() - creates a sync object * @drv_name: sync_timeline driver name diff --git a/drivers/staging/android/uapi/sw_sync.h b/drivers/staging/android/uapi/sw_sync.h deleted file mode 100644 index 9b5d486..0000000 --- a/drivers/staging/android/uapi/sw_sync.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2012 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#ifndef _UAPI_LINUX_SW_SYNC_H -#define _UAPI_LINUX_SW_SYNC_H - -#include <linux/types.h> - -struct sw_sync_create_fence_data { - __u32 value; - char name[32]; - __s32 fence; /* fd of new fence */ -}; - -#define SW_SYNC_IOC_MAGIC 'W' - -#define SW_SYNC_IOC_CREATE_FENCE _IOWR(SW_SYNC_IOC_MAGIC, 0,\ - struct sw_sync_create_fence_data) -#define SW_SYNC_IOC_INC _IOW(SW_SYNC_IOC_MAGIC, 1, __u32) - -#endif /* _UAPI_LINUX_SW_SYNC_H */
dri-devel@lists.freedesktop.org