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

staging/android: rename sync_fence to sync_file

sync_file has a more close meaning to what a sync_fence really, a struct
that represent a file that can be used by userspace to get information on
a fence, or wait for it to be signaled.
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 a44eb74c
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include "trace/sync.h" #include "trace/sync.h"
static const struct fence_ops android_fence_ops; static const struct fence_ops android_fence_ops;
static const struct file_operations sync_fence_fops; static const struct file_operations sync_file_fops;
struct sync_timeline *sync_timeline_create(const struct sync_timeline_ops *ops, struct sync_timeline *sync_timeline_create(const struct sync_timeline_ops *ops,
int size, const char *name) int size, const char *name)
...@@ -147,80 +147,81 @@ void sync_pt_free(struct sync_pt *pt) ...@@ -147,80 +147,81 @@ void sync_pt_free(struct sync_pt *pt)
} }
EXPORT_SYMBOL(sync_pt_free); EXPORT_SYMBOL(sync_pt_free);
static struct sync_fence *sync_fence_alloc(int size, const char *name) static struct sync_file *sync_file_alloc(int size, const char *name)
{ {
struct sync_fence *fence; struct sync_file *sync_file;
fence = kzalloc(size, GFP_KERNEL); sync_file = kzalloc(size, GFP_KERNEL);
if (!fence) if (!sync_file)
return NULL; return NULL;
fence->file = anon_inode_getfile("sync_fence", &sync_fence_fops, sync_file->file = anon_inode_getfile("sync_file", &sync_file_fops,
fence, 0); sync_file, 0);
if (IS_ERR(fence->file)) if (IS_ERR(sync_file->file))
goto err; goto err;
kref_init(&fence->kref); kref_init(&sync_file->kref);
strlcpy(fence->name, name, sizeof(fence->name)); strlcpy(sync_file->name, name, sizeof(sync_file->name));
init_waitqueue_head(&fence->wq); init_waitqueue_head(&sync_file->wq);
return fence; return sync_file;
err: err:
kfree(fence); kfree(sync_file);
return NULL; return NULL;
} }
static void fence_check_cb_func(struct fence *f, struct fence_cb *cb) static void fence_check_cb_func(struct fence *f, struct fence_cb *cb)
{ {
struct sync_fence_cb *check; struct sync_file_cb *check;
struct sync_fence *fence; struct sync_file *sync_file;
check = container_of(cb, struct sync_fence_cb, cb); check = container_of(cb, struct sync_file_cb, cb);
fence = check->fence; sync_file = check->sync_file;
if (atomic_dec_and_test(&fence->status)) if (atomic_dec_and_test(&sync_file->status))
wake_up_all(&fence->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 sync_pt */
struct sync_fence *sync_fence_create_dma(const char *name, struct fence *pt) struct sync_file *sync_file_create_dma(const char *name, struct fence *pt)
{ {
struct sync_fence *fence; struct sync_file *sync_file;
fence = sync_fence_alloc(offsetof(struct sync_fence, cbs[1]), name); sync_file = sync_file_alloc(offsetof(struct sync_file, cbs[1]),
if (!fence) name);
if (!sync_file)
return NULL; return NULL;
fence->num_fences = 1; sync_file->num_fences = 1;
atomic_set(&fence->status, 1); atomic_set(&sync_file->status, 1);
fence->cbs[0].sync_pt = pt; sync_file->cbs[0].sync_pt = pt;
fence->cbs[0].fence = fence; sync_file->cbs[0].sync_file = sync_file;
if (fence_add_callback(pt, &fence->cbs[0].cb, fence_check_cb_func)) if (fence_add_callback(pt, &sync_file->cbs[0].cb, fence_check_cb_func))
atomic_dec(&fence->status); atomic_dec(&sync_file->status);
sync_fence_debug_add(fence); sync_file_debug_add(sync_file);
return fence; return sync_file;
} }
EXPORT_SYMBOL(sync_fence_create_dma); EXPORT_SYMBOL(sync_file_create_dma);
struct sync_fence *sync_fence_create(const char *name, struct sync_pt *pt) struct sync_file *sync_file_create(const char *name, struct sync_pt *pt)
{ {
return sync_fence_create_dma(name, &pt->base); return sync_file_create_dma(name, &pt->base);
} }
EXPORT_SYMBOL(sync_fence_create); EXPORT_SYMBOL(sync_file_create);
struct sync_fence *sync_fence_fdget(int fd) struct sync_file *sync_file_fdget(int fd)
{ {
struct file *file = fget(fd); struct file *file = fget(fd);
if (!file) if (!file)
return NULL; return NULL;
if (file->f_op != &sync_fence_fops) if (file->f_op != &sync_file_fops)
goto err; goto err;
return file->private_data; return file->private_data;
...@@ -229,70 +230,71 @@ struct sync_fence *sync_fence_fdget(int fd) ...@@ -229,70 +230,71 @@ struct sync_fence *sync_fence_fdget(int fd)
fput(file); fput(file);
return NULL; return NULL;
} }
EXPORT_SYMBOL(sync_fence_fdget); EXPORT_SYMBOL(sync_file_fdget);
void sync_fence_put(struct sync_fence *fence) void sync_file_put(struct sync_file *sync_file)
{ {
fput(fence->file); fput(sync_file->file);
} }
EXPORT_SYMBOL(sync_fence_put); EXPORT_SYMBOL(sync_file_put);
void sync_fence_install(struct sync_fence *fence, int fd) void sync_file_install(struct sync_file *sync_file, int fd)
{ {
fd_install(fd, fence->file); fd_install(fd, sync_file->file);
} }
EXPORT_SYMBOL(sync_fence_install); EXPORT_SYMBOL(sync_file_install);
static void sync_fence_add_pt(struct sync_fence *fence, static void sync_file_add_pt(struct sync_file *sync_file, int *i,
int *i, struct fence *pt) struct fence *pt)
{ {
fence->cbs[*i].sync_pt = pt; sync_file->cbs[*i].sync_pt = pt;
fence->cbs[*i].fence = fence; sync_file->cbs[*i].sync_file = sync_file;
if (!fence_add_callback(pt, &fence->cbs[*i].cb, fence_check_cb_func)) { if (!fence_add_callback(pt, &sync_file->cbs[*i].cb,
fence_check_cb_func)) {
fence_get(pt); fence_get(pt);
(*i)++; (*i)++;
} }
} }
struct sync_fence *sync_fence_merge(const char *name, struct sync_file *sync_file_merge(const char *name,
struct sync_fence *a, struct sync_fence *b) struct sync_file *a, struct sync_file *b)
{ {
int num_fences = a->num_fences + b->num_fences; int num_fences = a->num_fences + b->num_fences;
struct sync_fence *fence; struct sync_file *sync_file;
int i, i_a, i_b; int i, i_a, i_b;
unsigned long size = offsetof(struct sync_fence, cbs[num_fences]); unsigned long size = offsetof(struct sync_file, cbs[num_fences]);
fence = sync_fence_alloc(size, name); sync_file = sync_file_alloc(size, name);
if (!fence) if (!sync_file)
return NULL; return NULL;
atomic_set(&fence->status, num_fences); atomic_set(&sync_file->status, num_fences);
/* /*
* Assume sync_fence a and b are both ordered and have no * Assume sync_file a and b are both ordered and have no
* duplicates with the same context. * duplicates with the same context.
* *
* If a sync_fence can only be created with sync_fence_merge * If a sync_file can only be created with sync_file_merge
* and sync_fence_create, this is a reasonable assumption. * and sync_file_create, this is a reasonable assumption.
*/ */
for (i = i_a = i_b = 0; i_a < a->num_fences && i_b < b->num_fences; ) { for (i = i_a = i_b = 0; i_a < a->num_fences && i_b < b->num_fences; ) {
struct fence *pt_a = a->cbs[i_a].sync_pt; struct fence *pt_a = a->cbs[i_a].sync_pt;
struct fence *pt_b = b->cbs[i_b].sync_pt; struct fence *pt_b = b->cbs[i_b].sync_pt;
if (pt_a->context < pt_b->context) { if (pt_a->context < pt_b->context) {
sync_fence_add_pt(fence, &i, pt_a); sync_file_add_pt(sync_file, &i, pt_a);
i_a++; i_a++;
} else if (pt_a->context > pt_b->context) { } else if (pt_a->context > pt_b->context) {
sync_fence_add_pt(fence, &i, pt_b); sync_file_add_pt(sync_file, &i, pt_b);
i_b++; i_b++;
} else { } else {
if (pt_a->seqno - pt_b->seqno <= INT_MAX) if (pt_a->seqno - pt_b->seqno <= INT_MAX)
sync_fence_add_pt(fence, &i, pt_a); sync_file_add_pt(sync_file, &i, pt_a);
else else
sync_fence_add_pt(fence, &i, pt_b); sync_file_add_pt(sync_file, &i, pt_b);
i_a++; i_a++;
i_b++; i_b++;
...@@ -300,21 +302,21 @@ struct sync_fence *sync_fence_merge(const char *name, ...@@ -300,21 +302,21 @@ struct sync_fence *sync_fence_merge(const char *name,
} }
for (; i_a < a->num_fences; i_a++) for (; i_a < a->num_fences; i_a++)
sync_fence_add_pt(fence, &i, a->cbs[i_a].sync_pt); sync_file_add_pt(sync_file, &i, a->cbs[i_a].sync_pt);
for (; i_b < b->num_fences; i_b++) for (; i_b < b->num_fences; i_b++)
sync_fence_add_pt(fence, &i, b->cbs[i_b].sync_pt); sync_file_add_pt(sync_file, &i, b->cbs[i_b].sync_pt);
if (num_fences > i) if (num_fences > i)
atomic_sub(num_fences - i, &fence->status); atomic_sub(num_fences - i, &sync_file->status);
fence->num_fences = i; sync_file->num_fences = i;
sync_fence_debug_add(fence); sync_file_debug_add(sync_file);
return fence; return sync_file;
} }
EXPORT_SYMBOL(sync_fence_merge); EXPORT_SYMBOL(sync_file_merge);
int sync_fence_wait(struct sync_fence *fence, long timeout) int sync_file_wait(struct sync_file *sync_file, long timeout)
{ {
long ret; long ret;
int i; int i;
...@@ -324,33 +326,33 @@ int sync_fence_wait(struct sync_fence *fence, long timeout) ...@@ -324,33 +326,33 @@ int sync_fence_wait(struct sync_fence *fence, long timeout)
else else
timeout = msecs_to_jiffies(timeout); timeout = msecs_to_jiffies(timeout);
trace_sync_wait(fence, 1); trace_sync_wait(sync_file, 1);
for (i = 0; i < fence->num_fences; ++i) for (i = 0; i < sync_file->num_fences; ++i)
trace_sync_pt(fence->cbs[i].sync_pt); trace_sync_pt(sync_file->cbs[i].sync_pt);
ret = wait_event_interruptible_timeout(fence->wq, ret = wait_event_interruptible_timeout(sync_file->wq,
atomic_read(&fence->status) <= 0, atomic_read(&sync_file->status) <= 0,
timeout); timeout);
trace_sync_wait(fence, 0); trace_sync_wait(sync_file, 0);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} else if (ret == 0) { } else if (ret == 0) {
if (timeout) { if (timeout) {
pr_info("fence timeout on [%p] after %dms\n", fence, pr_info("sync_file timeout on [%p] after %dms\n",
jiffies_to_msecs(timeout)); sync_file, jiffies_to_msecs(timeout));
sync_dump(); sync_dump();
} }
return -ETIME; return -ETIME;
} }
ret = atomic_read(&fence->status); ret = atomic_read(&sync_file->status);
if (ret) { if (ret) {
pr_info("fence error %ld on [%p]\n", ret, fence); pr_info("sync_file error %ld on [%p]\n", ret, sync_file);
sync_dump(); sync_dump();
} }
return ret; return ret;
} }
EXPORT_SYMBOL(sync_fence_wait); 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)
{ {
...@@ -459,37 +461,39 @@ static const struct fence_ops android_fence_ops = { ...@@ -459,37 +461,39 @@ static const struct fence_ops android_fence_ops = {
.timeline_value_str = android_fence_timeline_value_str, .timeline_value_str = android_fence_timeline_value_str,
}; };
static void sync_fence_free(struct kref *kref) static void sync_file_free(struct kref *kref)
{ {
struct sync_fence *fence = container_of(kref, struct sync_fence, kref); struct sync_file *sync_file = container_of(kref, struct sync_file,
kref);
int i; int i;
for (i = 0; i < fence->num_fences; ++i) { for (i = 0; i < sync_file->num_fences; ++i) {
fence_remove_callback(fence->cbs[i].sync_pt, &fence->cbs[i].cb); fence_remove_callback(sync_file->cbs[i].sync_pt,
fence_put(fence->cbs[i].sync_pt); &sync_file->cbs[i].cb);
fence_put(sync_file->cbs[i].sync_pt);
} }
kfree(fence); kfree(sync_file);
} }
static int sync_fence_release(struct inode *inode, struct file *file) static int sync_file_release(struct inode *inode, struct file *file)
{ {
struct sync_fence *fence = file->private_data; struct sync_file *sync_file = file->private_data;
sync_fence_debug_remove(fence); sync_file_debug_remove(sync_file);
kref_put(&fence->kref, sync_fence_free); kref_put(&sync_file->kref, sync_file_free);
return 0; return 0;
} }
static unsigned int sync_fence_poll(struct file *file, poll_table *wait) static unsigned int sync_file_poll(struct file *file, poll_table *wait)
{ {
struct sync_fence *fence = file->private_data; struct sync_file *sync_file = file->private_data;
int status; int status;
poll_wait(file, &fence->wq, wait); poll_wait(file, &sync_file->wq, wait);
status = atomic_read(&fence->status); status = atomic_read(&sync_file->status);
if (!status) if (!status)
return POLLIN; return POLLIN;
...@@ -498,21 +502,23 @@ static unsigned int sync_fence_poll(struct file *file, poll_table *wait) ...@@ -498,21 +502,23 @@ static unsigned int sync_fence_poll(struct file *file, poll_table *wait)
return 0; return 0;
} }
static long sync_fence_ioctl_wait(struct sync_fence *fence, unsigned long arg) static long sync_file_ioctl_wait(struct sync_file *sync_file,
unsigned long arg)
{ {
__s32 value; __s32 value;
if (copy_from_user(&value, (void __user *)arg, sizeof(value))) if (copy_from_user(&value, (void __user *)arg, sizeof(value)))
return -EFAULT; return -EFAULT;
return sync_fence_wait(fence, value); return sync_file_wait(sync_file, value);
} }
static long sync_fence_ioctl_merge(struct sync_fence *fence, unsigned long arg) static long sync_file_ioctl_merge(struct sync_file *sync_file,
unsigned long arg)
{ {
int fd = get_unused_fd_flags(O_CLOEXEC); int fd = get_unused_fd_flags(O_CLOEXEC);
int err; int err;
struct sync_fence *fence2, *fence3; struct sync_file *fence2, *fence3;
struct sync_merge_data data; struct sync_merge_data data;
if (fd < 0) if (fd < 0)
...@@ -523,14 +529,14 @@ static long sync_fence_ioctl_merge(struct sync_fence *fence, unsigned long arg) ...@@ -523,14 +529,14 @@ static long sync_fence_ioctl_merge(struct sync_fence *fence, unsigned long arg)
goto err_put_fd; goto err_put_fd;
} }
fence2 = sync_fence_fdget(data.fd2); fence2 = sync_file_fdget(data.fd2);
if (!fence2) { if (!fence2) {
err = -ENOENT; err = -ENOENT;
goto err_put_fd; goto err_put_fd;
} }
data.name[sizeof(data.name) - 1] = '\0'; data.name[sizeof(data.name) - 1] = '\0';
fence3 = sync_fence_merge(data.name, fence, fence2); fence3 = sync_file_merge(data.name, sync_file, fence2);
if (!fence3) { if (!fence3) {
err = -ENOMEM; err = -ENOMEM;
goto err_put_fence2; goto err_put_fence2;
...@@ -542,15 +548,15 @@ static long sync_fence_ioctl_merge(struct sync_fence *fence, unsigned long arg) ...@@ -542,15 +548,15 @@ static long sync_fence_ioctl_merge(struct sync_fence *fence, unsigned long arg)
goto err_put_fence3; goto err_put_fence3;
} }
sync_fence_install(fence3, fd); sync_file_install(fence3, fd);
sync_fence_put(fence2); sync_file_put(fence2);
return 0; return 0;
err_put_fence3: err_put_fence3:
sync_fence_put(fence3); sync_file_put(fence3);
err_put_fence2: err_put_fence2:
sync_fence_put(fence2); sync_file_put(fence2);
err_put_fd: err_put_fd:
put_unused_fd(fd); put_unused_fd(fd);
...@@ -589,10 +595,10 @@ static int sync_fill_pt_info(struct fence *fence, void *data, int size) ...@@ -589,10 +595,10 @@ static int sync_fill_pt_info(struct fence *fence, void *data, int size)
return info->len; return info->len;
} }
static long sync_fence_ioctl_fence_info(struct sync_fence *fence, static long sync_file_ioctl_fence_info(struct sync_file *sync_file,
unsigned long arg) unsigned long arg)
{ {
struct sync_fence_info_data *data; struct sync_file_info_data *data;
__u32 size; __u32 size;
__u32 len = 0; __u32 len = 0;
int ret, i; int ret, i;
...@@ -600,7 +606,7 @@ static long sync_fence_ioctl_fence_info(struct sync_fence *fence, ...@@ -600,7 +606,7 @@ static long sync_fence_ioctl_fence_info(struct sync_fence *fence,
if (copy_from_user(&size, (void __user *)arg, sizeof(size))) if (copy_from_user(&size, (void __user *)arg, sizeof(size)))
return -EFAULT; return -EFAULT;
if (size < sizeof(struct sync_fence_info_data)) if (size < sizeof(struct sync_file_info_data))
return -EINVAL; return -EINVAL;
if (size > 4096) if (size > 4096)
...@@ -610,15 +616,15 @@ static long sync_fence_ioctl_fence_info(struct sync_fence *fence, ...@@ -610,15 +616,15 @@ static long sync_fence_ioctl_fence_info(struct sync_fence *fence,
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
strlcpy(data->name, fence->name, sizeof(data->name)); strlcpy(data->name, sync_file->name, sizeof(data->name));
data->status = atomic_read(&fence->status); data->status = atomic_read(&sync_file->status);
if (data->status >= 0) if (data->status >= 0)
data->status = !data->status; data->status = !data->status;
len = sizeof(struct sync_fence_info_data); len = sizeof(struct sync_file_info_data);
for (i = 0; i < fence->num_fences; ++i) { for (i = 0; i < sync_file->num_fences; ++i) {
struct fence *pt = fence->cbs[i].sync_pt; struct fence *pt = sync_file->cbs[i].sync_pt;
ret = sync_fill_pt_info(pt, (u8 *)data + len, size - len); ret = sync_fill_pt_info(pt, (u8 *)data + len, size - len);
...@@ -641,30 +647,30 @@ static long sync_fence_ioctl_fence_info(struct sync_fence *fence, ...@@ -641,30 +647,30 @@ static long sync_fence_ioctl_fence_info(struct sync_fence *fence,
return ret; return ret;
} }
static long sync_fence_ioctl(struct file *file, unsigned int cmd, static long sync_file_ioctl(struct file *file, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
struct sync_fence *fence = file->private_data; struct sync_file *sync_file = file->private_data;
switch (cmd) { switch (cmd) {
case SYNC_IOC_WAIT: case SYNC_IOC_WAIT:
return sync_fence_ioctl_wait(fence, arg); return sync_file_ioctl_wait(sync_file, arg);
case SYNC_IOC_MERGE: case SYNC_IOC_MERGE:
return sync_fence_ioctl_merge(fence, arg); return sync_file_ioctl_merge(sync_file, arg);
case SYNC_IOC_FENCE_INFO: case SYNC_IOC_FENCE_INFO:
return sync_fence_ioctl_fence_info(fence, arg); return sync_file_ioctl_fence_info(sync_file, arg);
default: default:
return -ENOTTY; return -ENOTTY;
} }
} }
static const struct file_operations sync_fence_fops = { static const struct file_operations sync_file_fops = {
.release = sync_fence_release, .release = sync_file_release,
.poll = sync_fence_poll, .poll = sync_file_poll,
.unlocked_ioctl = sync_fence_ioctl, .unlocked_ioctl = sync_file_ioctl,
.compat_ioctl = sync_fence_ioctl, .compat_ioctl = sync_file_ioctl,
}; };
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
struct sync_timeline; struct sync_timeline;
struct sync_pt; struct sync_pt;
struct sync_fence; struct sync_file;
/** /**
* struct sync_timeline_ops - sync object implementation ops * struct sync_timeline_ops - sync object implementation ops
...@@ -108,36 +108,36 @@ static inline struct sync_timeline *sync_pt_parent(struct sync_pt *pt) ...@@ -108,36 +108,36 @@ static inline struct sync_timeline *sync_pt_parent(struct sync_pt *pt)
child_list_lock); child_list_lock);
} }
struct sync_fence_cb { struct sync_file_cb {
struct fence_cb cb; struct fence_cb cb;
struct fence *sync_pt; struct fence *sync_pt;
struct sync_fence *fence; struct sync_file *sync_file;
}; };
/** /**
* struct sync_fence - sync fence * struct sync_file - sync file to export to the userspace
* @file: file representing this fence * @file: file representing this fence
* @kref: reference count on fence. * @kref: reference count on fence.
* @name: name of sync_fence. Useful for debugging * @name: name of sync_file. Useful for debugging
* @sync_fence_list: membership in global fence list * @sync_file_list: membership in global file list
* @num_fences number of sync_pts in the fence * @num_fences number of sync_pts in the fence
* @wq: wait queue for fence signaling * @wq: wait queue for fence signaling
* @status: 0: signaled, >0:active, <0: error * @status: 0: signaled, >0:active, <0: error
* @cbs: sync_pts callback information * @cbs: sync_pts callback information
*/ */
struct sync_fence { struct sync_file {
struct file *file; struct file *file;
struct kref kref; struct kref kref;
char name[32]; char name[32];
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
struct list_head sync_fence_list; struct list_head sync_file_list;
#endif #endif
int num_fences; int num_fences;
wait_queue_head_t wq; wait_queue_head_t wq;
atomic_t status; atomic_t status;
struct sync_fence_cb cbs[]; struct sync_file_cb cbs[];
}; };
/* /*
...@@ -199,95 +199,95 @@ struct sync_pt *sync_pt_create(struct sync_timeline *parent, int size); ...@@ -199,95 +199,95 @@ struct sync_pt *sync_pt_create(struct sync_timeline *parent, int size);
void sync_pt_free(struct sync_pt *pt); void sync_pt_free(struct sync_pt *pt);
/** /**
* sync_fence_create() - creates a sync fence * sync_file_create() - creates a sync file
* @name: name of fence to create * @name: name of file to create
* @pt: sync_pt to add to the fence * @pt: sync_pt to add to the file
* *
* Creates a fence containg @pt. Once this is called, the fence takes * Creates a sync_file containg @pt. Once this is called, the sync_file takes
* ownership of @pt. * ownership of @pt.
*/ */
struct sync_fence *sync_fence_create(const char *name, struct sync_pt *pt); struct sync_file *sync_file_create(const char *name, struct sync_pt *pt);
/** /**
* sync_fence_create_dma() - creates a sync fence from dma-fence * sync_file_create_dma() - creates a sync file from dma-fence
* @name: name of fence to create * @name: name of file to create
* @pt: dma-fence to add to the fence * @pt: dma-fence to add to the file
* *
* Creates a fence containg @pt. Once this is called, the fence takes * Creates a sync_file containg @pt. Once this is called, the fence takes
* ownership of @pt. * ownership of @pt.
*/ */
struct sync_fence *sync_fence_create_dma(const char *name, struct fence *pt); struct sync_file *sync_file_create_dma(const char *name, struct fence *pt);
/* /*
* API for sync_fence consumers * API for sync_file consumers
*/ */
/** /**
* sync_fence_merge() - merge two fences * sync_file_merge() - merge two sync_files
* @name: name of new fence * @name: name of new fence
* @a: fence a * @a: sync_file a
* @b: fence b * @b: sync_file b
* *
* Creates a new fence which contains copies of all the sync_pts in both * Creates a new sync_file which contains copies of all the sync_pts in both
* @a and @b. @a and @b remain valid, independent fences. Returns the * @a and @b. @a and @b remain valid, independent sync_file. Returns the
* new merged fence or NULL in case of error. * new merged sync_file or NULL in case of error.
*/ */
struct sync_fence *sync_fence_merge(const char *name, struct sync_file *sync_file_merge(const char *name,
struct sync_fence *a, struct sync_fence *b); struct sync_file *a, struct sync_file *b);
/** /**
* sync_fence_fdget() - get a fence from an fd * sync_file_fdget() - get a sync_file from an fd
* @fd: fd referencing a fence * @fd: fd referencing a fence
* *
* Ensures @fd references a valid fence, increments the refcount of the backing * Ensures @fd references a valid sync_file, increments the refcount of the
* file, and returns the fence. Returns the fence or NULL in case of error. * backing file. Returns the sync_file or NULL in case of error.
*/ */
struct sync_fence *sync_fence_fdget(int fd); struct sync_file *sync_file_fdget(int fd);
/** /**
* sync_fence_put() - puts a reference of a sync fence * sync_file_put() - puts a reference of a sync_file
* @fence: fence to put * @sync_file: sync_file to put
* *
* Puts a reference on @fence. If this is the last reference, the fence and * Puts a reference on @sync_fence. If this is the last reference, the
* all it's sync_pts will be freed * sync_fil and all it's sync_pts will be freed
*/ */
void sync_fence_put(struct sync_fence *fence); void sync_file_put(struct sync_file *sync_file);
/** /**
* sync_fence_install() - installs a fence into a file descriptor * sync_file_install() - installs a sync_file into a file descriptor
* @fence: fence to install * @sync_file: sync_file to install
* @fd: file descriptor in which to install the fence * @fd: file descriptor in which to install the fence
* *
* Installs @fence into @fd. @fd's should be acquired through * Installs @sync_file into @fd. @fd's should be acquired through
* get_unused_fd_flags(O_CLOEXEC). * get_unused_fd_flags(O_CLOEXEC).
*/ */
void sync_fence_install(struct sync_fence *fence, int fd); void sync_file_install(struct sync_file *sync_file, int fd);
/** /**
* sync_fence_wait() - wait on fence * sync_file_wait() - wait on sync file
* @fence: fence to wait on * @sync_file: file to wait on
* @tiemout: timeout in ms * @tiemout: timeout in ms
* *
* Wait for @fence to be signaled or have an error. Waits indefinitely * Wait for @sync_file to be signaled or have an error. Waits indefinitely
* if @timeout < 0. * if @timeout < 0.
* *
* Returns 0 if fence signaled, > 0 if it is still active and <0 on error * Returns 0 if fence signaled, > 0 if it is still active and <0 on error
*/ */
int sync_fence_wait(struct sync_fence *fence, long timeout); int sync_file_wait(struct sync_file *sync_file, long timeout);
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
void sync_timeline_debug_add(struct sync_timeline *obj); void sync_timeline_debug_add(struct sync_timeline *obj);
void sync_timeline_debug_remove(struct sync_timeline *obj); void sync_timeline_debug_remove(struct sync_timeline *obj);
void sync_fence_debug_add(struct sync_fence *fence); void sync_file_debug_add(struct sync_file *fence);
void sync_fence_debug_remove(struct sync_fence *fence); void sync_file_debug_remove(struct sync_file *fence);
void sync_dump(void); void sync_dump(void);
#else #else
# define sync_timeline_debug_add(obj) # define sync_timeline_debug_add(obj)
# define sync_timeline_debug_remove(obj) # define sync_timeline_debug_remove(obj)
# define sync_fence_debug_add(fence) # define sync_file_debug_add(fence)
# define sync_fence_debug_remove(fence) # define sync_file_debug_remove(fence)
# define sync_dump() # define sync_dump()
#endif #endif
......
...@@ -35,8 +35,8 @@ static struct dentry *dbgfs; ...@@ -35,8 +35,8 @@ static struct dentry *dbgfs;
static LIST_HEAD(sync_timeline_list_head); static LIST_HEAD(sync_timeline_list_head);
static DEFINE_SPINLOCK(sync_timeline_list_lock); static DEFINE_SPINLOCK(sync_timeline_list_lock);
static LIST_HEAD(sync_fence_list_head); static LIST_HEAD(sync_file_list_head);
static DEFINE_SPINLOCK(sync_fence_list_lock); static DEFINE_SPINLOCK(sync_file_list_lock);
void sync_timeline_debug_add(struct sync_timeline *obj) void sync_timeline_debug_add(struct sync_timeline *obj)
{ {
...@@ -56,22 +56,22 @@ void sync_timeline_debug_remove(struct sync_timeline *obj) ...@@ -56,22 +56,22 @@ void sync_timeline_debug_remove(struct sync_timeline *obj)
spin_unlock_irqrestore(&sync_timeline_list_lock, flags); spin_unlock_irqrestore(&sync_timeline_list_lock, flags);
} }
void sync_fence_debug_add(struct sync_fence *fence) void sync_file_debug_add(struct sync_file *sync_file)
{ {
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&sync_fence_list_lock, flags); spin_lock_irqsave(&sync_file_list_lock, flags);
list_add_tail(&fence->sync_fence_list, &sync_fence_list_head); list_add_tail(&sync_file->sync_file_list, &sync_file_list_head);
spin_unlock_irqrestore(&sync_fence_list_lock, flags); spin_unlock_irqrestore(&sync_file_list_lock, flags);
} }
void sync_fence_debug_remove(struct sync_fence *fence) void sync_file_debug_remove(struct sync_file *sync_file)
{ {
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&sync_fence_list_lock, flags); spin_lock_irqsave(&sync_file_list_lock, flags);
list_del(&fence->sync_fence_list); list_del(&sync_file->sync_file_list);
spin_unlock_irqrestore(&sync_fence_list_lock, flags); spin_unlock_irqrestore(&sync_file_list_lock, flags);
} }
static const char *sync_status_str(int status) static const char *sync_status_str(int status)
...@@ -152,16 +152,17 @@ static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj) ...@@ -152,16 +152,17 @@ static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj)
spin_unlock_irqrestore(&obj->child_list_lock, flags); spin_unlock_irqrestore(&obj->child_list_lock, flags);
} }
static void sync_print_fence(struct seq_file *s, struct sync_fence *fence) static void sync_print_sync_file(struct seq_file *s,
{ struct sync_file *sync_file)
{
int i; int i;
seq_printf(s, "[%p] %s: %s\n", fence, fence->name, seq_printf(s, "[%p] %s: %s\n", sync_file, sync_file->name,
sync_status_str(atomic_read(&fence->status))); sync_status_str(atomic_read(&sync_file->status)));
for (i = 0; i < fence->num_fences; ++i) for (i = 0; i < sync_file->num_fences; ++i)
sync_print_pt(s, fence->cbs[i].sync_pt, true); sync_print_pt(s, sync_file->cbs[i].sync_pt, true);
} }
static int sync_debugfs_show(struct seq_file *s, void *unused) static int sync_debugfs_show(struct seq_file *s, void *unused)
{ {
...@@ -183,15 +184,15 @@ static int sync_debugfs_show(struct seq_file *s, void *unused) ...@@ -183,15 +184,15 @@ static int sync_debugfs_show(struct seq_file *s, void *unused)
seq_puts(s, "fences:\n--------------\n"); seq_puts(s, "fences:\n--------------\n");
spin_lock_irqsave(&sync_fence_list_lock, flags); spin_lock_irqsave(&sync_file_list_lock, flags);
list_for_each(pos, &sync_fence_list_head) { list_for_each(pos, &sync_file_list_head) {
struct sync_fence *fence = struct sync_file *sync_file =
container_of(pos, struct sync_fence, sync_fence_list); container_of(pos, struct sync_file, sync_file_list);
sync_print_fence(s, fence); sync_print_sync_file(s, sync_file);
seq_puts(s, "\n"); seq_puts(s, "\n");
} }
spin_unlock_irqrestore(&sync_fence_list_lock, flags); spin_unlock_irqrestore(&sync_file_list_lock, flags);
return 0; return 0;
} }
...@@ -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 sync_pt *pt;
struct sync_fence *fence; struct sync_file *sync_file;
struct sw_sync_create_fence_data data; struct sw_sync_create_fence_data data;
if (fd < 0) if (fd < 0)
...@@ -262,8 +263,8 @@ static long sw_sync_ioctl_create_fence(struct sw_sync_timeline *obj, ...@@ -262,8 +263,8 @@ static long sw_sync_ioctl_create_fence(struct sw_sync_timeline *obj,
} }
data.name[sizeof(data.name) - 1] = '\0'; data.name[sizeof(data.name) - 1] = '\0';
fence = sync_fence_create(data.name, pt); sync_file = sync_file_create(data.name, pt);
if (!fence) { if (!sync_file) {
sync_pt_free(pt); sync_pt_free(pt);
err = -ENOMEM; err = -ENOMEM;
goto err; goto err;
...@@ -271,12 +272,12 @@ static long sw_sync_ioctl_create_fence(struct sw_sync_timeline *obj, ...@@ -271,12 +272,12 @@ static long sw_sync_ioctl_create_fence(struct sw_sync_timeline *obj,
data.fence = fd; data.fence = fd;
if (copy_to_user((void __user *)arg, &data, sizeof(data))) { if (copy_to_user((void __user *)arg, &data, sizeof(data))) {
sync_fence_put(fence); sync_file_put(sync_file);
err = -EFAULT; err = -EFAULT;
goto err; goto err;
} }
sync_fence_install(fence, fd); sync_file_install(sync_file, fd);
return 0; return 0;
......
...@@ -33,19 +33,19 @@ TRACE_EVENT(sync_timeline, ...@@ -33,19 +33,19 @@ TRACE_EVENT(sync_timeline,
); );
TRACE_EVENT(sync_wait, TRACE_EVENT(sync_wait,
TP_PROTO(struct sync_fence *fence, int begin), TP_PROTO(struct sync_file *sync_file, int begin),
TP_ARGS(fence, begin), TP_ARGS(sync_file, begin),
TP_STRUCT__entry( TP_STRUCT__entry(
__string(name, fence->name) __string(name, sync_file->name)
__field(s32, status) __field(s32, status)
__field(u32, begin) __field(u32, begin)
), ),
TP_fast_assign( TP_fast_assign(
__assign_str(name, fence->name); __assign_str(name, sync_file->name);
__entry->status = atomic_read(&fence->status); __entry->status = atomic_read(&sync_file->status);
__entry->begin = begin; __entry->begin = begin;
), ),
......
...@@ -46,15 +46,15 @@ struct sync_pt_info { ...@@ -46,15 +46,15 @@ struct sync_pt_info {
}; };
/** /**
* struct sync_fence_info_data - data returned from fence info ioctl * struct sync_file_info_data - data returned from fence info ioctl
* @len: ioctl caller writes the size of the buffer its passing in. * @len: ioctl caller writes the size of the buffer its passing in.
* ioctl returns length of sync_fence_data returned to userspace * ioctl returns length of sync_file_info_data returned to
* including pt_info. * userspace including pt_info.
* @name: name of fence * @name: name of fence
* @status: status of fence. 1: signaled 0:active <0:error * @status: status of fence. 1: signaled 0:active <0:error
* @pt_info: a sync_pt_info struct for every sync_pt in the fence * @pt_info: a sync_pt_info struct for every sync_pt in the fence
*/ */
struct sync_fence_info_data { struct sync_file_info_data {
__u32 len; __u32 len;
char name[32]; char name[32];
__s32 status; __s32 status;
...@@ -83,15 +83,15 @@ struct sync_fence_info_data { ...@@ -83,15 +83,15 @@ struct sync_fence_info_data {
/** /**
* DOC: SYNC_IOC_FENCE_INFO - get detailed information on a fence * DOC: SYNC_IOC_FENCE_INFO - get detailed information on a fence
* *
* Takes a struct sync_fence_info_data with extra space allocated for pt_info. * Takes a struct sync_file_info_data with extra space allocated for pt_info.
* Caller should write the size of the buffer into len. On return, len is * Caller should write the size of the buffer into len. On return, len is
* updated to reflect the total size of the sync_fence_info_data including * updated to reflect the total size of the sync_file_info_data including
* pt_info. * pt_info.
* *
* pt_info is a buffer containing sync_pt_infos for every sync_pt in the fence. * pt_info is a buffer containing sync_pt_infos for every sync_pt in the fence.
* To iterate over the sync_pt_infos, use the sync_pt_info.len field. * To iterate over the sync_pt_infos, use the sync_pt_info.len field.
*/ */
#define SYNC_IOC_FENCE_INFO _IOWR(SYNC_IOC_MAGIC, 2,\ #define SYNC_IOC_FENCE_INFO _IOWR(SYNC_IOC_MAGIC, 2,\
struct sync_fence_info_data) struct sync_file_info_data)
#endif /* _UAPI_LINUX_SYNC_H */ #endif /* _UAPI_LINUX_SYNC_H */
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