Commit b55b54b5 authored by Gustavo Padovan's avatar Gustavo Padovan Committed by Greg Kroah-Hartman

staging/android: remove struct sync_pt

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.
Signed-off-by: default avatarGustavo Padovan <gustavo.padovan@collabora.co.uk>
Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c88b26dd
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include "sw_sync.h" #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; struct sw_sync_pt *pt;
...@@ -34,23 +34,23 @@ struct sync_pt *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value) ...@@ -34,23 +34,23 @@ struct sync_pt *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value)
pt->value = value; pt->value = value;
return (struct sync_pt *)pt; return (struct fence *)pt;
} }
EXPORT_SYMBOL(sw_sync_pt_create); 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 *obj =
(struct sw_sync_timeline *)sync_pt_parent(sync_pt); (struct sw_sync_timeline *)fence_parent(fence);
return (pt->value > obj->value) ? 0 : 1; 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) void *data, int size)
{ {
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)) if (size < sizeof(pt->value))
return -ENOMEM; return -ENOMEM;
...@@ -68,20 +68,19 @@ static void sw_sync_timeline_value_str(struct sync_timeline *sync_timeline, ...@@ -68,20 +68,19 @@ static void sw_sync_timeline_value_str(struct sync_timeline *sync_timeline,
snprintf(str, size, "%d", timeline->value); 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)
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); snprintf(str, size, "%d", pt->value);
} }
static struct sync_timeline_ops sw_sync_timeline_ops = { static struct sync_timeline_ops sw_sync_timeline_ops = {
.driver_name = "sw_sync", .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, .fill_driver_data = sw_sync_fill_driver_data,
.timeline_value_str = sw_sync_timeline_value_str, .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 *sw_sync_timeline_create(const char *name)
......
...@@ -29,7 +29,7 @@ struct sw_sync_timeline { ...@@ -29,7 +29,7 @@ struct sw_sync_timeline {
}; };
struct sw_sync_pt { struct sw_sync_pt {
struct sync_pt pt; struct fence pt;
u32 value; u32 value;
}; };
...@@ -38,7 +38,7 @@ struct sw_sync_pt { ...@@ -38,7 +38,7 @@ struct sw_sync_pt {
struct sw_sync_timeline *sw_sync_timeline_create(const char *name); struct sw_sync_timeline *sw_sync_timeline_create(const char *name);
void sw_sync_timeline_inc(struct sw_sync_timeline *obj, u32 inc); 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 #else
static inline struct sw_sync_timeline *sw_sync_timeline_create(const char *name) static inline struct sw_sync_timeline *sw_sync_timeline_create(const char *name)
{ {
...@@ -49,7 +49,7 @@ static inline void sw_sync_timeline_inc(struct sw_sync_timeline *obj, u32 inc) ...@@ -49,7 +49,7 @@ 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, static inline struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj,
u32 value) u32 value)
{ {
return NULL; return NULL;
......
...@@ -102,51 +102,45 @@ void sync_timeline_signal(struct sync_timeline *obj) ...@@ -102,51 +102,45 @@ void sync_timeline_signal(struct sync_timeline *obj)
{ {
unsigned long flags; unsigned long flags;
LIST_HEAD(signaled_pts); LIST_HEAD(signaled_pts);
struct sync_pt *pt, *next; struct fence *fence, *next;
trace_sync_timeline(obj); trace_sync_timeline(obj);
spin_lock_irqsave(&obj->child_list_lock, flags); spin_lock_irqsave(&obj->child_list_lock, flags);
list_for_each_entry_safe(pt, next, &obj->active_list_head, list_for_each_entry_safe(fence, next, &obj->active_list_head,
active_list) { active_list) {
if (fence_is_signaled_locked(&pt->base)) if (fence_is_signaled_locked(fence))
list_del_init(&pt->active_list); list_del_init(&fence->active_list);
} }
spin_unlock_irqrestore(&obj->child_list_lock, flags); spin_unlock_irqrestore(&obj->child_list_lock, flags);
} }
EXPORT_SYMBOL(sync_timeline_signal); EXPORT_SYMBOL(sync_timeline_signal);
struct sync_pt *sync_pt_create(struct sync_timeline *obj, int size) struct fence *sync_pt_create(struct sync_timeline *obj, int size)
{ {
unsigned long flags; unsigned long flags;
struct sync_pt *pt; struct fence *fence;
if (size < sizeof(struct sync_pt)) if (size < sizeof(*fence))
return NULL; return NULL;
pt = kzalloc(size, GFP_KERNEL); fence = kzalloc(size, GFP_KERNEL);
if (!pt) if (!fence)
return NULL; return NULL;
spin_lock_irqsave(&obj->child_list_lock, flags); spin_lock_irqsave(&obj->child_list_lock, flags);
sync_timeline_get(obj); sync_timeline_get(obj);
fence_init(&pt->base, &android_fence_ops, &obj->child_list_lock, fence_init(fence, &android_fence_ops, &obj->child_list_lock,
obj->context, ++obj->value); obj->context, ++obj->value);
list_add_tail(&pt->child_list, &obj->child_list_head); list_add_tail(&fence->child_list, &obj->child_list_head);
INIT_LIST_HEAD(&pt->active_list); INIT_LIST_HEAD(&fence->active_list);
spin_unlock_irqrestore(&obj->child_list_lock, flags); spin_unlock_irqrestore(&obj->child_list_lock, flags);
return pt; return fence;
} }
EXPORT_SYMBOL(sync_pt_create); 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_file *sync_file_alloc(int size, const char *name) static struct sync_file *sync_file_alloc(int size, const char *name)
{ {
struct sync_file *sync_file; struct sync_file *sync_file;
...@@ -184,8 +178,8 @@ static void fence_check_cb_func(struct fence *f, struct fence_cb *cb) ...@@ -184,8 +178,8 @@ static void fence_check_cb_func(struct fence *f, struct fence_cb *cb)
wake_up_all(&sync_file->wq); wake_up_all(&sync_file->wq);
} }
/* TODO: implement a create which takes more that one sync_pt */ /* TODO: implement a create which takes more that one fence */
struct sync_file *sync_file_create_dma(const char *name, struct fence *pt) struct sync_file *sync_file_create_dma(const char *name, struct fence *fence)
{ {
struct sync_file *sync_file; struct sync_file *sync_file;
...@@ -197,9 +191,10 @@ struct sync_file *sync_file_create_dma(const char *name, struct fence *pt) ...@@ -197,9 +191,10 @@ struct sync_file *sync_file_create_dma(const char *name, struct fence *pt)
sync_file->num_fences = 1; sync_file->num_fences = 1;
atomic_set(&sync_file->status, 1); atomic_set(&sync_file->status, 1);
sync_file->cbs[0].fence = pt; sync_file->cbs[0].fence = fence;
sync_file->cbs[0].sync_file = sync_file; sync_file->cbs[0].sync_file = sync_file;
if (fence_add_callback(pt, &sync_file->cbs[0].cb, fence_check_cb_func)) if (fence_add_callback(fence, &sync_file->cbs[0].cb,
fence_check_cb_func))
atomic_dec(&sync_file->status); atomic_dec(&sync_file->status);
sync_file_debug_add(sync_file); sync_file_debug_add(sync_file);
...@@ -208,9 +203,9 @@ struct sync_file *sync_file_create_dma(const char *name, struct fence *pt) ...@@ -208,9 +203,9 @@ struct sync_file *sync_file_create_dma(const char *name, struct fence *pt)
} }
EXPORT_SYMBOL(sync_file_create_dma); EXPORT_SYMBOL(sync_file_create_dma);
struct sync_file *sync_file_create(const char *name, struct sync_pt *pt) struct sync_file *sync_file_create(const char *name, struct fence *fence)
{ {
return sync_file_create_dma(name, &pt->base); return sync_file_create_dma(name, fence);
} }
EXPORT_SYMBOL(sync_file_create); EXPORT_SYMBOL(sync_file_create);
...@@ -245,14 +240,14 @@ void sync_file_install(struct sync_file *sync_file, int fd) ...@@ -245,14 +240,14 @@ void sync_file_install(struct sync_file *sync_file, int fd)
EXPORT_SYMBOL(sync_file_install); EXPORT_SYMBOL(sync_file_install);
static void sync_file_add_pt(struct sync_file *sync_file, int *i, static void sync_file_add_pt(struct sync_file *sync_file, int *i,
struct fence *pt) struct fence *fence)
{ {
sync_file->cbs[*i].fence = pt; sync_file->cbs[*i].fence = fence;
sync_file->cbs[*i].sync_file = sync_file; sync_file->cbs[*i].sync_file = sync_file;
if (!fence_add_callback(pt, &sync_file->cbs[*i].cb, if (!fence_add_callback(fence, &sync_file->cbs[*i].cb,
fence_check_cb_func)) { fence_check_cb_func)) {
fence_get(pt); fence_get(fence);
(*i)++; (*i)++;
} }
} }
...@@ -328,7 +323,7 @@ int sync_file_wait(struct sync_file *sync_file, long timeout) ...@@ -328,7 +323,7 @@ int sync_file_wait(struct sync_file *sync_file, long timeout)
trace_sync_wait(sync_file, 1); trace_sync_wait(sync_file, 1);
for (i = 0; i < sync_file->num_fences; ++i) for (i = 0; i < sync_file->num_fences; ++i)
trace_sync_pt(sync_file->cbs[i].fence); trace_fence(sync_file->cbs[i].fence);
ret = wait_event_interruptible_timeout(sync_file->wq, ret = wait_event_interruptible_timeout(sync_file->wq,
atomic_read(&sync_file->status) <= 0, atomic_read(&sync_file->status) <= 0,
timeout); timeout);
...@@ -356,43 +351,39 @@ EXPORT_SYMBOL(sync_file_wait); ...@@ -356,43 +351,39 @@ EXPORT_SYMBOL(sync_file_wait);
static const char *android_fence_get_driver_name(struct fence *fence) static const char *android_fence_get_driver_name(struct fence *fence)
{ {
struct sync_pt *pt = container_of(fence, struct sync_pt, base); struct sync_timeline *parent = fence_parent(fence);
struct sync_timeline *parent = sync_pt_parent(pt);
return parent->ops->driver_name; return parent->ops->driver_name;
} }
static const char *android_fence_get_timeline_name(struct fence *fence) static const char *android_fence_get_timeline_name(struct fence *fence)
{ {
struct sync_pt *pt = container_of(fence, struct sync_pt, base); struct sync_timeline *parent = fence_parent(fence);
struct sync_timeline *parent = sync_pt_parent(pt);
return parent->name; return parent->name;
} }
static void android_fence_release(struct fence *fence) static void android_fence_release(struct fence *fence)
{ {
struct sync_pt *pt = container_of(fence, struct sync_pt, base); struct sync_timeline *parent = fence_parent(fence);
struct sync_timeline *parent = sync_pt_parent(pt);
unsigned long flags; unsigned long flags;
spin_lock_irqsave(fence->lock, flags); spin_lock_irqsave(fence->lock, flags);
list_del(&pt->child_list); list_del(&fence->child_list);
if (WARN_ON_ONCE(!list_empty(&pt->active_list))) if (WARN_ON_ONCE(!list_empty(&fence->active_list)))
list_del(&pt->active_list); list_del(&fence->active_list);
spin_unlock_irqrestore(fence->lock, flags); spin_unlock_irqrestore(fence->lock, flags);
sync_timeline_put(parent); sync_timeline_put(parent);
fence_free(&pt->base); fence_free(fence);
} }
static bool android_fence_signaled(struct fence *fence) static bool android_fence_signaled(struct fence *fence)
{ {
struct sync_pt *pt = container_of(fence, struct sync_pt, base); struct sync_timeline *parent = fence_parent(fence);
struct sync_timeline *parent = sync_pt_parent(pt);
int ret; int ret;
ret = parent->ops->has_signaled(pt); ret = parent->ops->has_signaled(fence);
if (ret < 0) if (ret < 0)
fence->status = ret; fence->status = ret;
return ret; return ret;
...@@ -400,46 +391,42 @@ static bool android_fence_signaled(struct fence *fence) ...@@ -400,46 +391,42 @@ static bool android_fence_signaled(struct fence *fence)
static bool android_fence_enable_signaling(struct fence *fence) static bool android_fence_enable_signaling(struct fence *fence)
{ {
struct sync_pt *pt = container_of(fence, struct sync_pt, base); struct sync_timeline *parent = fence_parent(fence);
struct sync_timeline *parent = sync_pt_parent(pt);
if (android_fence_signaled(fence)) if (android_fence_signaled(fence))
return false; return false;
list_add_tail(&pt->active_list, &parent->active_list_head); list_add_tail(&fence->active_list, &parent->active_list_head);
return true; return true;
} }
static int android_fence_fill_driver_data(struct fence *fence, static int android_fence_fill_driver_data(struct fence *fence,
void *data, int size) void *data, int size)
{ {
struct sync_pt *pt = container_of(fence, struct sync_pt, base); struct sync_timeline *parent = fence_parent(fence);
struct sync_timeline *parent = sync_pt_parent(pt);
if (!parent->ops->fill_driver_data) if (!parent->ops->fill_driver_data)
return 0; return 0;
return parent->ops->fill_driver_data(pt, data, size); return parent->ops->fill_driver_data(fence, data, size);
} }
static void android_fence_value_str(struct fence *fence, static void android_fence_value_str(struct fence *fence,
char *str, int size) char *str, int size)
{ {
struct sync_pt *pt = container_of(fence, struct sync_pt, base); struct sync_timeline *parent = fence_parent(fence);
struct sync_timeline *parent = sync_pt_parent(pt);
if (!parent->ops->pt_value_str) { if (!parent->ops->fence_value_str) {
if (size) if (size)
*str = 0; *str = 0;
return; return;
} }
parent->ops->pt_value_str(pt, str, size); parent->ops->fence_value_str(fence, str, size);
} }
static void android_fence_timeline_value_str(struct fence *fence, static void android_fence_timeline_value_str(struct fence *fence,
char *str, int size) char *str, int size)
{ {
struct sync_pt *pt = container_of(fence, struct sync_pt, base); struct sync_timeline *parent = fence_parent(fence);
struct sync_timeline *parent = sync_pt_parent(pt);
if (!parent->ops->timeline_value_str) { if (!parent->ops->timeline_value_str) {
if (size) if (size)
...@@ -624,9 +611,9 @@ static long sync_file_ioctl_fence_info(struct sync_file *sync_file, ...@@ -624,9 +611,9 @@ static long sync_file_ioctl_fence_info(struct sync_file *sync_file,
len = sizeof(struct sync_file_info_data); len = sizeof(struct sync_file_info_data);
for (i = 0; i < sync_file->num_fences; ++i) { for (i = 0; i < sync_file->num_fences; ++i) {
struct fence *pt = sync_file->cbs[i].fence; struct fence *fence = sync_file->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) if (ret < 0)
goto out; goto out;
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include "uapi/sync.h" #include "uapi/sync.h"
struct sync_timeline; struct sync_timeline;
struct sync_pt;
struct sync_file; struct sync_file;
/** /**
...@@ -39,23 +38,23 @@ struct sync_file; ...@@ -39,23 +38,23 @@ struct sync_file;
* as specified by size. This information is returned * as specified by size. This information is returned
* to userspace by SYNC_IOC_FENCE_INFO. * to userspace by SYNC_IOC_FENCE_INFO.
* @timeline_value_str: fill str with the value of the sync_timeline's counter * @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 * @fence_value_str: fill str with the value of the fence
*/ */
struct sync_timeline_ops { struct sync_timeline_ops {
const char *driver_name; const char *driver_name;
/* required */ /* required */
int (*has_signaled)(struct sync_pt *pt); int (*has_signaled)(struct fence *fence);
/* optional */ /* optional */
int (*fill_driver_data)(struct sync_pt *syncpt, void *data, int size); int (*fill_driver_data)(struct fence *fence, void *data, int size);
/* optional */ /* optional */
void (*timeline_value_str)(struct sync_timeline *timeline, char *str, void (*timeline_value_str)(struct sync_timeline *timeline, char *str,
int size); int size);
/* optional */ /* optional */
void (*pt_value_str)(struct sync_pt *pt, char *str, int size); void (*fence_value_str)(struct fence *fence, char *str, int size);
}; };
/** /**
...@@ -66,7 +65,7 @@ struct sync_timeline_ops { ...@@ -66,7 +65,7 @@ struct sync_timeline_ops {
* @destroyed: set when sync_timeline is destroyed * @destroyed: set when sync_timeline is destroyed
* @child_list_head: list of children sync_pts for this sync_timeline * @child_list_head: list of children sync_pts for this sync_timeline
* @child_list_lock: lock protecting @child_list_head, destroyed, and * @child_list_lock: lock protecting @child_list_head, destroyed, and
* sync_pt.status * fence.status
* @active_list_head: list of active (unsignaled/errored) sync_pts * @active_list_head: list of active (unsignaled/errored) sync_pts
* @sync_timeline_list: membership in global sync_timeline_list * @sync_timeline_list: membership in global sync_timeline_list
*/ */
...@@ -89,22 +88,9 @@ struct sync_timeline { ...@@ -89,22 +88,9 @@ struct sync_timeline {
#endif #endif
}; };
/** static inline struct sync_timeline *fence_parent(struct fence *fence)
* struct sync_pt - sync point
* @base: base fence class
* @child_list: membership in sync_timeline.child_list_head
* @active_list: membership in sync_timeline.active_list_head
*/
struct sync_pt {
struct fence base;
struct list_head child_list;
struct list_head active_list;
};
static inline struct sync_timeline *sync_pt_parent(struct sync_pt *pt)
{ {
return container_of(pt->base.lock, struct sync_timeline, return container_of(fence->lock, struct sync_timeline,
child_list_lock); child_list_lock);
} }
...@@ -164,7 +150,7 @@ struct sync_timeline *sync_timeline_create(const struct sync_timeline_ops *ops, ...@@ -164,7 +150,7 @@ struct sync_timeline *sync_timeline_create(const struct sync_timeline_ops *ops,
* *
* A sync implementation should call this when the @obj is going away * 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 * (i.e. module unload.) @obj won't actually be freed until all its children
* sync_pts are freed. * fences are freed.
*/ */
void sync_timeline_destroy(struct sync_timeline *obj); void sync_timeline_destroy(struct sync_timeline *obj);
...@@ -172,41 +158,32 @@ void sync_timeline_destroy(struct sync_timeline *obj); ...@@ -172,41 +158,32 @@ void sync_timeline_destroy(struct sync_timeline *obj);
* sync_timeline_signal() - signal a status change on a sync_timeline * sync_timeline_signal() - signal a status change on a sync_timeline
* @obj: sync_timeline to signal * @obj: sync_timeline to signal
* *
* A sync implementation should call this any time one of it's sync_pts * A sync implementation should call this any time one of it's fences
* has signaled or has an error condition. * has signaled or has an error condition.
*/ */
void sync_timeline_signal(struct sync_timeline *obj); void sync_timeline_signal(struct sync_timeline *obj);
/** /**
* sync_pt_create() - creates a sync pt * sync_pt_create() - creates a sync pt
* @parent: sync_pt's parent sync_timeline * @parent: fence's parent sync_timeline
* @size: size to allocate for this pt * @size: size to allocate for this pt
* *
* Creates a new sync_pt as a child of @parent. @size bytes will be * Creates a new fence as a child of @parent. @size bytes will be
* allocated allowing for implementation specific data to be kept after * allocated allowing for implementation specific data to be kept after
* the generic sync_timeline struct. Returns the sync_pt object or * the generic sync_timeline struct. Returns the fence object or
* NULL in case of error. * NULL in case of error.
*/ */
struct sync_pt *sync_pt_create(struct sync_timeline *parent, int size); struct fence *sync_pt_create(struct sync_timeline *parent, int size);
/** /**
* sync_pt_free() - frees a sync pt * sync_fence_create() - creates a sync fence
* @pt: sync_pt to free * @name: name of fence to create
* @fence: fence to add to the sync_fence
* *
* This should only be called on sync_pts which have been created but * Creates a sync_file containg @fence. Once this is called, the sync_file
* not added to a fence. * takes ownership of @fence.
*/
void sync_pt_free(struct sync_pt *pt);
/**
* sync_file_create() - creates a sync file
* @name: name of file to create
* @pt: sync_pt to add to the file
*
* Creates a sync_file containg @pt. Once this is called, the sync_file takes
* ownership of @pt.
*/ */
struct sync_file *sync_file_create(const char *name, struct sync_pt *pt); struct sync_file *sync_file_create(const char *name, struct fence *fence);
/** /**
* sync_file_create_dma() - creates a sync file from dma-fence * sync_file_create_dma() - creates a sync file from dma-fence
...@@ -228,7 +205,7 @@ struct sync_file *sync_file_create_dma(const char *name, struct fence *pt); ...@@ -228,7 +205,7 @@ struct sync_file *sync_file_create_dma(const char *name, struct fence *pt);
* @a: sync_file a * @a: sync_file a
* @b: sync_file b * @b: sync_file b
* *
* Creates a new sync_file which contains copies of all the sync_pts in both * Creates a new sync_file which contains copies of all the fences in both
* @a and @b. @a and @b remain valid, independent sync_file. Returns the * @a and @b. @a and @b remain valid, independent sync_file. Returns the
* new merged sync_file or NULL in case of error. * new merged sync_file or NULL in case of error.
*/ */
......
...@@ -85,39 +85,40 @@ static const char *sync_status_str(int status) ...@@ -85,39 +85,40 @@ static const char *sync_status_str(int status)
return "error"; return "error";
} }
static void sync_print_pt(struct seq_file *s, struct fence *pt, bool fence) static void sync_print_fence(struct seq_file *s, struct fence *fence, bool show)
{ {
int status = 1; int status = 1;
struct sync_timeline *parent = fence_parent(fence);
if (fence_is_signaled_locked(pt)) if (fence_is_signaled_locked(fence))
status = pt->status; status = fence->status;
seq_printf(s, " %s%spt %s", seq_printf(s, " %s%sfence %s",
fence && pt->ops->get_timeline_name ? show ? parent->name : "",
pt->ops->get_timeline_name(pt) : "", show ? "_" : "",
fence ? "_" : "",
sync_status_str(status)); sync_status_str(status));
if (status <= 0) { if (status <= 0) {
struct timespec64 ts64 = struct timespec64 ts64 =
ktime_to_timespec64(pt->timestamp); ktime_to_timespec64(fence->timestamp);
seq_printf(s, "@%lld.%09ld", (s64)ts64.tv_sec, ts64.tv_nsec); seq_printf(s, "@%lld.%09ld", (s64)ts64.tv_sec, ts64.tv_nsec);
} }
if ((!fence || pt->ops->timeline_value_str) && if ((!fence || fence->ops->timeline_value_str) &&
pt->ops->fence_value_str) { fence->ops->fence_value_str) {
char value[64]; char value[64];
bool success; bool success;
pt->ops->fence_value_str(pt, value, sizeof(value)); fence->ops->fence_value_str(fence, value, sizeof(value));
success = strlen(value); success = strlen(value);
if (success) if (success)
seq_printf(s, ": %s", value); seq_printf(s, ": %s", value);
if (success && fence) { if (success && fence) {
pt->ops->timeline_value_str(pt, value, sizeof(value)); fence->ops->timeline_value_str(fence, value,
sizeof(value));
if (strlen(value)) if (strlen(value))
seq_printf(s, " / %s", value); seq_printf(s, " / %s", value);
...@@ -145,24 +146,24 @@ static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj) ...@@ -145,24 +146,24 @@ static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj)
spin_lock_irqsave(&obj->child_list_lock, flags); spin_lock_irqsave(&obj->child_list_lock, flags);
list_for_each(pos, &obj->child_list_head) { list_for_each(pos, &obj->child_list_head) {
struct sync_pt *pt = struct fence *fence =
container_of(pos, struct sync_pt, child_list); container_of(pos, struct fence, child_list);
sync_print_pt(s, &pt->base, false); sync_print_fence(s, fence, false);
} }
spin_unlock_irqrestore(&obj->child_list_lock, flags); spin_unlock_irqrestore(&obj->child_list_lock, flags);
} }
static void sync_print_sync_file(struct seq_file *s, static void sync_print_sync_file(struct seq_file *s,
struct sync_file *sync_file) struct sync_file *sync_file)
{ {
int i; int i;
seq_printf(s, "[%p] %s: %s\n", sync_file, sync_file->name, seq_printf(s, "[%p] %s: %s\n", sync_file, sync_file->name,
sync_status_str(atomic_read(&sync_file->status))); sync_status_str(atomic_read(&sync_file->status)));
for (i = 0; i < sync_file->num_fences; ++i) for (i = 0; i < sync_file->num_fences; ++i)
sync_print_pt(s, sync_file->cbs[i].fence, true); sync_print_fence(s, sync_file->cbs[i].fence, true);
} }
static int sync_debugfs_show(struct seq_file *s, void *unused) static int sync_debugfs_show(struct seq_file *s, void *unused)
{ {
...@@ -244,7 +245,7 @@ static long sw_sync_ioctl_create_fence(struct sw_sync_timeline *obj, ...@@ -244,7 +245,7 @@ static long sw_sync_ioctl_create_fence(struct sw_sync_timeline *obj,
{ {
int fd = get_unused_fd_flags(O_CLOEXEC); int fd = get_unused_fd_flags(O_CLOEXEC);
int err; int err;
struct sync_pt *pt; struct fence *fence;
struct sync_file *sync_file; struct sync_file *sync_file;
struct sw_sync_create_fence_data data; struct sw_sync_create_fence_data data;
...@@ -256,16 +257,16 @@ static long sw_sync_ioctl_create_fence(struct sw_sync_timeline *obj, ...@@ -256,16 +257,16 @@ static long sw_sync_ioctl_create_fence(struct sw_sync_timeline *obj,
goto err; goto err;
} }
pt = sw_sync_pt_create(obj, data.value); fence = sw_sync_pt_create(obj, data.value);
if (!pt) { if (!fence) {
err = -ENOMEM; err = -ENOMEM;
goto err; goto err;
} }
data.name[sizeof(data.name) - 1] = '\0'; data.name[sizeof(data.name) - 1] = '\0';
sync_file = sync_file_create(data.name, pt); sync_file = sync_file_create(data.name, fence);
if (!sync_file) { if (!sync_file) {
sync_pt_free(pt); fence_put(fence);
err = -ENOMEM; err = -ENOMEM;
goto err; goto err;
} }
......
...@@ -53,20 +53,20 @@ TRACE_EVENT(sync_wait, ...@@ -53,20 +53,20 @@ TRACE_EVENT(sync_wait,
__get_str(name), __entry->status) __get_str(name), __entry->status)
); );
TRACE_EVENT(sync_pt, TRACE_EVENT(fence,
TP_PROTO(struct fence *pt), TP_PROTO(struct fence *fence),
TP_ARGS(pt), TP_ARGS(fence),
TP_STRUCT__entry( TP_STRUCT__entry(
__string(timeline, pt->ops->get_timeline_name(pt)) __string(timeline, fence->ops->get_timeline_name(fence))
__array(char, value, 32) __array(char, value, 32)
), ),
TP_fast_assign( TP_fast_assign(
__assign_str(timeline, pt->ops->get_timeline_name(pt)); __assign_str(timeline, fence->ops->get_timeline_name(fence));
if (pt->ops->fence_value_str) { if (fence->ops->fence_value_str) {
pt->ops->fence_value_str(pt, __entry->value, fence->ops->fence_value_str(fence, __entry->value,
sizeof(__entry->value)); sizeof(__entry->value));
} else { } else {
__entry->value[0] = '\0'; __entry->value[0] = '\0';
......
...@@ -79,6 +79,8 @@ struct fence { ...@@ -79,6 +79,8 @@ struct fence {
unsigned long flags; unsigned long flags;
ktime_t timestamp; ktime_t timestamp;
int status; int status;
struct list_head child_list;
struct list_head active_list;
}; };
enum fence_flag_bits { enum fence_flag_bits {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment