[RFC 12/29] staging/android: remove struct sync_pt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Gustavo Padovan <gustavo.padovan@xxxxxxxxxxxxxxx>

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: Gustavo Padovan <gustavo.padovan@xxxxxxxxxxxxxxx>
---
 drivers/staging/android/sw_sync.c    |  7 +++---
 drivers/staging/android/sw_sync.h    |  8 +++----
 drivers/staging/android/sync.c       | 33 ++++++++++++-----------------
 drivers/staging/android/sync.h       | 21 ++++--------------
 drivers/staging/android/sync_debug.c | 41 ++++++++++++++++++------------------
 drivers/staging/android/trace/sync.h | 14 ++++++------
 6 files changed, 53 insertions(+), 71 deletions(-)

diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c
index 98f9a29..9d6a5bd 100644
--- a/drivers/staging/android/sw_sync.c
+++ b/drivers/staging/android/sw_sync.c
@@ -25,7 +25,7 @@
 
 #include "sw_sync.h"
 
-struct sync_pt *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value)
+struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value)
 {
 	struct sw_sync_pt *pt;
 
@@ -34,7 +34,7 @@ struct sync_pt *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value)
 
 	pt->value = value;
 
-	return (struct sync_pt *)pt;
+	return (struct fence *)pt;
 }
 EXPORT_SYMBOL(sw_sync_pt_create);
 
@@ -50,8 +50,7 @@ static int sw_sync_fence_has_signaled(struct fence *fence)
 static int sw_sync_fill_driver_data(struct fence *fence,
 				    void *data, int size)
 {
-	struct sync_pt *sync_pt = (struct sync_pt *)fence;
-	struct sw_sync_pt *pt = (struct sw_sync_pt *)sync_pt;
+	struct sw_sync_pt *pt = (struct sw_sync_pt *)fence;
 
 	if (size < sizeof(pt->value))
 		return -ENOMEM;
diff --git a/drivers/staging/android/sw_sync.h b/drivers/staging/android/sw_sync.h
index cb62298..85ef780 100644
--- a/drivers/staging/android/sw_sync.h
+++ b/drivers/staging/android/sw_sync.h
@@ -29,7 +29,7 @@ struct sw_sync_timeline {
 };
 
 struct sw_sync_pt {
-	struct sync_pt		pt;
+	struct fence		pt;
 
 	u32			value;
 };
@@ -38,7 +38,7 @@ struct sw_sync_pt {
 struct sw_sync_timeline *sw_sync_timeline_create(const char *name);
 void sw_sync_timeline_inc(struct sw_sync_timeline *obj, u32 inc);
 
-struct sync_pt *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value);
+struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value);
 #else
 static inline struct sw_sync_timeline *sw_sync_timeline_create(const char *name)
 {
@@ -49,8 +49,8 @@ static inline void sw_sync_timeline_inc(struct sw_sync_timeline *obj, u32 inc)
 {
 }
 
-static inline struct sync_pt *sw_sync_pt_create(struct sw_sync_timeline *obj,
-						u32 value)
+static inline struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj,
+					      u32 value)
 {
 	return NULL;
 }
diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index b07bc24..417cf9f 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -39,7 +39,7 @@ struct fence *sync_pt_create(struct fence_timeline *obj, int size)
 	unsigned long flags;
 	struct fence *fence;
 
-	if (size < sizeof(struct sync_pt))
+	if (size < sizeof(*fence))
 		return NULL;
 
 	fence = kzalloc(size, GFP_KERNEL);
@@ -57,12 +57,6 @@ struct fence *sync_pt_create(struct fence_timeline *obj, int size)
 }
 EXPORT_SYMBOL(sync_pt_create);
 
-void sync_pt_free(struct sync_pt *pt)
-{
-	fence_put(&pt->base);
-}
-EXPORT_SYMBOL(sync_pt_free);
-
 static struct sync_fence *sync_fence_alloc(int size, const char *name)
 {
 	struct sync_fence *sync_fence;
@@ -101,7 +95,7 @@ static void fence_check_cb_func(struct fence *f, struct fence_cb *cb)
 }
 
 /* TODO: implement a create which takes more that one sync_pt */
-struct sync_fence *sync_fence_create_dma(const char *name, struct fence *pt)
+struct sync_fence *sync_fence_create_dma(const char *name, struct fence *fence)
 {
 	struct sync_fence *sync_fence;
 
@@ -113,9 +107,10 @@ struct sync_fence *sync_fence_create_dma(const char *name, struct fence *pt)
 	sync_fence->num_fences = 1;
 	atomic_set(&sync_fence->status, 1);
 
-	sync_fence->cbs[0].fence = pt;
+	sync_fence->cbs[0].fence = fence;
 	sync_fence->cbs[0].sync_fence = sync_fence;
-	if (fence_add_callback(pt, &sync_fence->cbs[0].cb, fence_check_cb_func))
+	if (fence_add_callback(fence, &sync_fence->cbs[0].cb,
+			       fence_check_cb_func))
 		atomic_dec(&sync_fence->status);
 
 	sync_fence_debug_add(sync_fence);
@@ -124,9 +119,9 @@ struct sync_fence *sync_fence_create_dma(const char *name, struct fence *pt)
 }
 EXPORT_SYMBOL(sync_fence_create_dma);
 
-struct sync_fence *sync_fence_create(const char *name, struct sync_pt *pt)
+struct sync_fence *sync_fence_create(const char *name, struct fence *fence)
 {
-	return sync_fence_create_dma(name, &pt->base);
+	return sync_fence_create_dma(name, fence);
 }
 EXPORT_SYMBOL(sync_fence_create);
 
@@ -161,14 +156,14 @@ void sync_fence_install(struct sync_fence *sync_fence, int fd)
 EXPORT_SYMBOL(sync_fence_install);
 
 static void sync_fence_add_pt(struct sync_fence *sync_fence,
-			      int *i, struct fence *pt)
+			      int *i, struct fence *fence)
 {
-	sync_fence->cbs[*i].fence = pt;
+	sync_fence->cbs[*i].fence = fence;
 	sync_fence->cbs[*i].sync_fence = sync_fence;
 
-	if (!fence_add_callback(pt, &sync_fence->cbs[*i].cb,
+	if (!fence_add_callback(fence, &sync_fence->cbs[*i].cb,
 				fence_check_cb_func)) {
-		fence_get(pt);
+		fence_get(fence);
 		(*i)++;
 	}
 }
@@ -300,7 +295,7 @@ int sync_fence_wait(struct sync_fence *sync_fence, long timeout)
 
 	trace_sync_wait(sync_fence, 1);
 	for (i = 0; i < sync_fence->num_fences; ++i)
-		trace_sync_pt(sync_fence->cbs[i].fence);
+		trace_fence(sync_fence->cbs[i].fence);
 	ret = wait_event_interruptible_timeout(sync_fence->wq,
 					       atomic_read(&sync_fence->status) <= 0,
 					       timeout);
@@ -589,9 +584,9 @@ static long sync_fence_ioctl_fence_info(struct sync_fence *sync_fence,
 	len = sizeof(struct sync_fence_info_data);
 
 	for (i = 0; i < sync_fence->num_fences; ++i) {
-		struct fence *pt = sync_fence->cbs[i].fence;
+		struct fence *fence = sync_fence->cbs[i].fence;
 
-		ret = sync_fill_pt_info(pt, (u8 *)data + len, size - len);
+		ret = sync_fill_pt_info(fence, (u8 *)data + len, size - len);
 
 		if (ret < 0)
 			goto out;
diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h
index 53658cc..e011111 100644
--- a/drivers/staging/android/sync.h
+++ b/drivers/staging/android/sync.h
@@ -25,10 +25,6 @@
 
 struct sync_fence;
 
-struct sync_pt {
-	struct fence base;
-};
-
 struct sync_fence_cb {
 	struct fence_cb cb;
 	struct fence *fence;
@@ -89,23 +85,14 @@ static inline void sync_fence_waiter_init(struct sync_fence_waiter *waiter,
 struct fence *sync_pt_create(struct fence_timeline *parent, int size);
 
 /**
- * sync_pt_free() - frees a sync pt
- * @pt:		sync_pt to free
- *
- * This should only be called on sync_pts which have been created but
- * not added to a fence.
- */
-void sync_pt_free(struct sync_pt *pt);
-
-/**
  * sync_fence_create() - creates a sync fence
  * @name:	name of fence to create
- * @pt:		sync_pt to add to the fence
+ * @fence:	fence to add to the sync_fence
  *
- * Creates a fence containg @pt.  Once this is called, the fence takes
- * ownership of @pt.
+ * Creates a fence containg @fence.  Once this is called, the fence takes
+ * ownership of @fence.
  */
-struct sync_fence *sync_fence_create(const char *name, struct sync_pt *pt);
+struct sync_fence *sync_fence_create(const char *name, struct fence *fence);
 
 /**
  * sync_fence_create_dma() - creates a sync fence from dma-fence
diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c
index f5fd8c3..b8602d2 100644
--- a/drivers/staging/android/sync_debug.c
+++ b/drivers/staging/android/sync_debug.c
@@ -85,39 +85,40 @@ static const char *sync_status_str(int status)
 	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;
+	struct fence_timeline *parent = fence_parent(fence);
 
-	if (fence_is_signaled_locked(pt))
-		status = pt->status;
+	if (fence_is_signaled_locked(fence))
+		status = fence->status;
 
-	seq_printf(s, "  %s%spt %s",
-		   fence && pt->ops->get_timeline_name ?
-		   pt->ops->get_timeline_name(pt) : "",
-		   fence ? "_" : "",
+	seq_printf(s, "  %s%sfence %s",
+		   show ? parent->name : "",
+		   show ? "_" : "",
 		   sync_status_str(status));
 
 	if (status <= 0) {
 		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);
 	}
 
-	if ((!fence || pt->ops->timeline_value_str) &&
-	    pt->ops->fence_value_str) {
+	if ((!fence || fence->ops->timeline_value_str) &&
+		fence->ops->fence_value_str) {
 		char value[64];
 		bool success;
 
-		pt->ops->fence_value_str(pt, value, sizeof(value));
+		fence->ops->fence_value_str(fence, value, sizeof(value));
 		success = strlen(value);
 
 		if (success)
 			seq_printf(s, ": %s", value);
 
 		if (success && fence) {
-			pt->ops->timeline_value_str(pt, value, sizeof(value));
+			fence->ops->timeline_value_str(fence, value,
+						       sizeof(value));
 
 			if (strlen(value))
 				seq_printf(s, " / %s", value);
@@ -145,9 +146,9 @@ static void sync_print_obj(struct seq_file *s, struct fence_timeline *obj)
 
 	spin_lock_irqsave(&obj->lock, flags);
 	list_for_each(pos, &obj->child_list_head) {
-		struct sync_pt *pt = (struct sync_pt *)
+		struct fence *fence =
 			container_of(pos, struct fence, child_list);
-		sync_print_pt(s, &pt->base, false);
+		sync_print_fence(s, fence, false);
 	}
 	spin_unlock_irqrestore(&obj->lock, flags);
 }
@@ -163,7 +164,7 @@ static void sync_print_sync_fence(struct seq_file *s,
 		   sync_status_str(atomic_read(&sync_fence->status)));
 
 	for (i = 0; i < sync_fence->num_fences; ++i) {
-		sync_print_pt(s, sync_fence->cbs[i].fence, true);
+		sync_print_fence(s, sync_fence->cbs[i].fence, true);
 	}
 
 	spin_lock_irqsave(&sync_fence->wq.lock, flags);
@@ -260,7 +261,7 @@ static long sw_sync_ioctl_create_fence(struct sw_sync_timeline *obj,
 {
 	int fd = get_unused_fd_flags(O_CLOEXEC);
 	int err;
-	struct sync_pt *pt;
+	struct fence *fence;
 	struct sync_fence *sync_fence;
 	struct sw_sync_create_fence_data data;
 
@@ -272,16 +273,16 @@ static long sw_sync_ioctl_create_fence(struct sw_sync_timeline *obj,
 		goto err;
 	}
 
-	pt = sw_sync_pt_create(obj, data.value);
-	if (!pt) {
+	fence = sw_sync_pt_create(obj, data.value);
+	if (!fence) {
 		err = -ENOMEM;
 		goto err;
 	}
 
 	data.name[sizeof(data.name) - 1] = '\0';
-	sync_fence = sync_fence_create(data.name, pt);
+	sync_fence = sync_fence_create(data.name, fence);
 	if (!sync_fence) {
-		sync_pt_free(pt);
+		fence_put(fence);
 		err = -ENOMEM;
 		goto err;
 	}
diff --git a/drivers/staging/android/trace/sync.h b/drivers/staging/android/trace/sync.h
index 59c337f..4f68515 100644
--- a/drivers/staging/android/trace/sync.h
+++ b/drivers/staging/android/trace/sync.h
@@ -29,20 +29,20 @@ TRACE_EVENT(sync_wait,
 			__get_str(name), __entry->status)
 );
 
-TRACE_EVENT(sync_pt,
-	TP_PROTO(struct fence *pt),
+TRACE_EVENT(fence,
+	TP_PROTO(struct fence *fence),
 
-	TP_ARGS(pt),
+	TP_ARGS(fence),
 
 	TP_STRUCT__entry(
-		__string(timeline, pt->ops->get_timeline_name(pt))
+		__string(timeline, fence->ops->get_timeline_name(fence))
 		__array(char, value, 32)
 	),
 
 	TP_fast_assign(
-		__assign_str(timeline, pt->ops->get_timeline_name(pt));
-		if (pt->ops->fence_value_str) {
-			pt->ops->fence_value_str(pt, __entry->value,
+		__assign_str(timeline, fence->ops->get_timeline_name(fence));
+		if (fence->ops->fence_value_str) {
+			fence->ops->fence_value_str(fence, __entry->value,
 							sizeof(__entry->value));
 		} else {
 			__entry->value[0] = '\0';
-- 
2.5.0

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux