Skip to contentSkip to conversation

staging/android: remove name arg from sync_file_create()

PATCH Hillf Danton 2 participants 3 messages Apr 29, 2016 – May 3, 2016 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 101 lines

From: Gustavo Padovan <[email protected]>

Simplifies the API to only receive the fence it needs to add to the sync and create a name for the sync_file based on the fence context and seqno.

---
 drivers/staging/android/sync.c       | 16 +++++++++-------
 drivers/staging/android/sync.h       |  2 +-
 drivers/staging/android/sync_debug.c |  3 +--
 3 files changed, 11 insertions(+), 10 deletions(-)
drivers/staging/android/sync.c +9 -7
index 7e0fa20..5470ae9 100644
@@ -136,7 +136,7 @@ struct fence *sync_pt_create(struct sync_timeline *obj, int size)
 }
 EXPORT_SYMBOL(sync_pt_create);
 
-static struct sync_file *sync_file_alloc(int size, const char *name)
+static struct sync_file *sync_file_alloc(int size)
 {
 	struct sync_file *sync_file;
 
@@ -150,7 +150,6 @@ static struct sync_file *sync_file_alloc(int size, const char *name)
 		goto err;
 
 	kref_init(&sync_file->kref);
-	strlcpy(sync_file->name, name, sizeof(sync_file->name));
 
 	init_waitqueue_head(&sync_file->wq);
 
@@ -175,23 +174,25 @@ static void fence_check_cb_func(struct fence *f, struct fence_cb *cb)
 
 /**
  * sync_fence_create() - creates a sync fence
- * @name:	name of fence to create
  * @fence:	fence to add to the sync_fence
  *
  * Creates a sync_file containg @fence. Once this is called, the sync_file
  * takes ownership of @fence.
  */
-struct sync_file *sync_file_create(const char *name, struct fence *fence)
+struct sync_file *sync_file_create(struct fence *fence)
 {
 	struct sync_file *sync_file;
 
-	sync_file = sync_file_alloc(offsetof(struct sync_file, cbs[1]),
-				    name);
+	sync_file = sync_file_alloc(offsetof(struct sync_file, cbs[1]));
 	if (!sync_file)
 		return NULL;
 
 	sync_file->num_fences = 1;
 	atomic_set(&sync_file->status, 1);
+	snprintf(sync_file->name, sizeof(sync_file->name), "%s-%s%d-%d",
+		 fence->ops->get_driver_name(fence),
+		 fence->ops->get_timeline_name(fence), fence->context,
+		 fence->seqno);
 
 	sync_file->cbs[0].fence = fence;
 	sync_file->cbs[0].sync_file = sync_file;
@@ -260,7 +261,7 @@ static struct sync_file *sync_file_merge(const char *name, struct sync_file *a,
 	int i, i_a, i_b;
 	unsigned long size = offsetof(struct sync_file, cbs[num_fences]);
 
-	sync_file = sync_file_alloc(size, name);
+	sync_file = sync_file_alloc(size);
 	if (!sync_file)
 		return NULL;
 
@@ -306,6 +307,7 @@ static struct sync_file *sync_file_merge(const char *name, struct sync_file *a,
 		atomic_sub(num_fences - i, &sync_file->status);
 	sync_file->num_fences = i;
 
+	strlcpy(sync_file->name, name, sizeof(sync_file->name));
 	sync_file_debug_add(sync_file);
 	return sync_file;
 }
drivers/staging/android/sync.h +1 -1
index 1f164df..7dee444 100644
@@ -167,7 +167,7 @@ void sync_timeline_signal(struct sync_timeline *obj);
  */
 struct fence *sync_pt_create(struct sync_timeline *parent, int size);
 
-struct sync_file *sync_file_create(const char *name, struct fence *fence);
+struct sync_file *sync_file_create(struct fence *fence);
 
 #ifdef CONFIG_DEBUG_FS
 
drivers/staging/android/sync_debug.c +0 -0
index e4b0e41..2cab40d 100644

drivers/staging/android/sync_debug.c static long sw_sync_ioctl_create_fence(struct sw_sync_timeline *obj, · line 265

Quoted 6 lines
drivers/staging/android/sync_debug.c +1 -2
@@ -262,8 +262,7 @@ static long sw_sync_ioctl_create_fence(struct sw_sync_timeline *obj,
 		goto err;
 	}
 
-	data.name[sizeof(data.name) - 1] = '\0';
-	sync_file = sync_file_create(data.name, fence);
+	sync_file = sync_file_create(fence);

The name injected from user spce is ignored, why?
Is it a semantic change?
Mentioned in commit message?

Quoted 7 lines
drivers/staging/android/sync_debug.c +0 -1
 	if (!sync_file) {
 		fence_put(fence);
 		err = -ENOMEM;
--

2.5.5

#2 lore raw

Hi Hillf,

(please keep the whole cc on the reply, so others can see it too)

2016-04-29 Hillf Danton <[email protected]>:

Quoted 104 lines
Quoted 104 lines

From: Gustavo Padovan <[email protected]>

Simplifies the API to only receive the fence it needs to add to the sync and create a name for the sync_file based on the fence context and seqno.

---
 drivers/staging/android/sync.c       | 16 +++++++++-------
 drivers/staging/android/sync.h       |  2 +-
 drivers/staging/android/sync_debug.c |  3 +--
 3 files changed, 11 insertions(+), 10 deletions(-)
drivers/staging/android/sync.c +9 -7
index 7e0fa20..5470ae9 100644
@@ -136,7 +136,7 @@ struct fence *sync_pt_create(struct sync_timeline *obj, int size)
 }
 EXPORT_SYMBOL(sync_pt_create);
 
-static struct sync_file *sync_file_alloc(int size, const char *name)
+static struct sync_file *sync_file_alloc(int size)
 {
 	struct sync_file *sync_file;
 
@@ -150,7 +150,6 @@ static struct sync_file *sync_file_alloc(int size, const char *name)
 		goto err;
 
 	kref_init(&sync_file->kref);
-	strlcpy(sync_file->name, name, sizeof(sync_file->name));
 
 	init_waitqueue_head(&sync_file->wq);
 
@@ -175,23 +174,25 @@ static void fence_check_cb_func(struct fence *f, struct fence_cb *cb)
 
 /**
  * sync_fence_create() - creates a sync fence
- * @name:	name of fence to create
  * @fence:	fence to add to the sync_fence
  *
  * Creates a sync_file containg @fence. Once this is called, the sync_file
  * takes ownership of @fence.
  */
-struct sync_file *sync_file_create(const char *name, struct fence *fence)
+struct sync_file *sync_file_create(struct fence *fence)
 {
 	struct sync_file *sync_file;
 
-	sync_file = sync_file_alloc(offsetof(struct sync_file, cbs[1]),
-				    name);
+	sync_file = sync_file_alloc(offsetof(struct sync_file, cbs[1]));
 	if (!sync_file)
 		return NULL;
 
 	sync_file->num_fences = 1;
 	atomic_set(&sync_file->status, 1);
+	snprintf(sync_file->name, sizeof(sync_file->name), "%s-%s%d-%d",
+		 fence->ops->get_driver_name(fence),
+		 fence->ops->get_timeline_name(fence), fence->context,
+		 fence->seqno);
 
 	sync_file->cbs[0].fence = fence;
 	sync_file->cbs[0].sync_file = sync_file;
@@ -260,7 +261,7 @@ static struct sync_file *sync_file_merge(const char *name, struct sync_file *a,
 	int i, i_a, i_b;
 	unsigned long size = offsetof(struct sync_file, cbs[num_fences]);
 
-	sync_file = sync_file_alloc(size, name);
+	sync_file = sync_file_alloc(size);
 	if (!sync_file)
 		return NULL;
 
@@ -306,6 +307,7 @@ static struct sync_file *sync_file_merge(const char *name, struct sync_file *a,
 		atomic_sub(num_fences - i, &sync_file->status);
 	sync_file->num_fences = i;
 
+	strlcpy(sync_file->name, name, sizeof(sync_file->name));
 	sync_file_debug_add(sync_file);
 	return sync_file;
 }
drivers/staging/android/sync.h +1 -1
index 1f164df..7dee444 100644
@@ -167,7 +167,7 @@ void sync_timeline_signal(struct sync_timeline *obj);
  */
 struct fence *sync_pt_create(struct sync_timeline *parent, int size);
 
-struct sync_file *sync_file_create(const char *name, struct fence *fence);
+struct sync_file *sync_file_create(struct fence *fence);
 
 #ifdef CONFIG_DEBUG_FS
 
drivers/staging/android/sync_debug.c +0 -0
index e4b0e41..2cab40d 100644
@@ -262,8 +262,7 @@ static long sw_sync_ioctl_create_fence(struct sw_sync_timeline *obj,
 		goto err;
 	}
 
Quoted 7 lines

drivers/staging/android/sync_debug.c static long sw_sync_ioctl_create_fence(struct sw_sync_timeline *obj, · line 265

Quoted 3 lines
drivers/staging/android/sync_debug.c +1 -2
-	data.name[sizeof(data.name) - 1] = '\0';
-	sync_file = sync_file_create(data.name, fence);
+	sync_file = sync_file_create(fence);

The name injected from user spce is ignored, why?
Is it a semantic change?

It is. sw_sync is only a testing API that we are not de-staging now.

I think we we will just remove the name arg from the ioctl there. SW_SYNC ioctl is only for debugging test, we don't want to publicly export its ABI in the kernel uapi headers.

Quoted 1 line

Mentioned in commit message?

Sure, I can update the commit message.

Gustavo

#3 lore raw
Quoted 5 lines

I think we we will just remove the name arg from the ioctl there. SW_SYNC ioctl is only for debugging test, we don't want to publicly export its ABI in the kernel uapi headers.

JFYI, be mindful please of removing the arg. If current uses are broken, the mainline maintainer, MM, can be stung another time.

Hillf