Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1322089 > unrolled thread

[PATCH 00/10] android sync framework: clean up IOCTLs and ABI.

Started byGustavo Padovan <gustavo@padovan.org>
First post2016-01-29 22:30 +0100
Last post2016-02-01 09:50 +0100
Articles 14 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 00/10] android sync framework: clean up IOCTLs and ABI. Gustavo Padovan <gustavo@padovan.org> - 2016-01-29 22:30 +0100
    [PATCH 04/10] staging/android: remove driver_data from struct fence_info Gustavo Padovan <gustavo@padovan.org> - 2016-01-29 22:30 +0100
    [PATCH 05/10] staging/android: remove len field from struct fence_info Gustavo Padovan <gustavo@padovan.org> - 2016-01-29 22:30 +0100
    [PATCH 06/10] staging/android: turn fence_info into a __64 pointer Gustavo Padovan <gustavo@padovan.org> - 2016-01-29 22:30 +0100
      Re: [PATCH 06/10] staging/android: turn fence_info into a __64 pointer Emil Velikov <emil.l.velikov@gmail.com> - 2016-01-30 19:10 +0100
      Re: [PATCH 06/10] staging/android: turn fence_info into a __64  pointer Maarten Lankhorst <maarten.lankhorst@linux.intel.com> - 2016-02-01 09:50 +0100
        Re: [PATCH 06/10] staging/android: turn fence_info into a __64  pointer Gustavo Padovan <gustavo@padovan.org> - 2016-02-01 19:10 +0100
          Re: [PATCH 06/10] staging/android: turn fence_info into a __64  pointer Gustavo Padovan <gustavo@padovan.org> - 2016-02-02 14:10 +0100
    [PATCH 01/10] staging/android: remove SYNC_WAIT ioctl Gustavo Padovan <gustavo@padovan.org> - 2016-01-29 22:30 +0100
    [PATCH 08/10] staging/android: rename SYNC_IOC_FENCE_INFO Gustavo Padovan <gustavo@padovan.org> - 2016-01-29 22:30 +0100
    [PATCH 09/10] staging/android: add flags member to sync ioctl structs Gustavo Padovan <gustavo@padovan.org> - 2016-01-29 22:30 +0100
      Re: [PATCH 09/10] staging/android: add flags member to sync ioctl structs Emil Velikov <emil.l.velikov@gmail.com> - 2016-01-30 19:20 +0100
        Re: [PATCH 09/10] staging/android: add flags member to sync ioctl  structs Gustavo Padovan <gustavo@padovan.org> - 2016-02-01 14:30 +0100
      Re: [PATCH 09/10] staging/android: add flags member to sync ioctl  structs Maarten Lankhorst <maarten.lankhorst@linux.intel.com> - 2016-02-01 09:50 +0100

#1322089 — [PATCH 00/10] android sync framework: clean up IOCTLs and ABI.

FromGustavo Padovan <gustavo@padovan.org>
Date2016-01-29 22:30 +0100
Subject[PATCH 00/10] android sync framework: clean up IOCTLs and ABI.
Message-ID<qWoM9-IK-3@gated-at.bofh.it>
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

Hi,

This patch series clean up IOCTLs and abi of sync framework and it is a follow
up on the clean up series I've sent on Jan 21:

http://thread.gmane.org/gmane.comp.video.dri.devel/145509

The main changes here are:

 * remove of SYNC_WAIT ioctl, poll() should be used instead.
 * rename some structs and macros to better reflect the new internal names.
 * clean up and improve ABI on SYNC_IOC_FILE_INFO
 * add flags filed to all ABI structs

Please review, thanks!

Gustavo Padovan (10):
  staging/android: remove SYNC_WAIT ioctl
  staging/android: rename sync_pt_info to fence_info
  staging/android: rename sync_file_info_data to sync_file_info
  staging/android: remove driver_data from struct fence_info
  staging/android: remove len field from struct fence_info
  staging/android: turn fence_info into a __64 pointer
  staging/android: add num_fences field to struct sync_file_info
  staging/android: rename SYNC_IOC_FENCE_INFO
  staging/android: add flags member to sync ioctl structs
  staging/android: remove redundant comments on sync_merge_data

 drivers/staging/android/sw_sync.c    |  14 -----
 drivers/staging/android/sync.c       | 113 +++++++----------------------------
 drivers/staging/android/sync.h       |  20 -------
 drivers/staging/android/trace/sync.h |  44 --------------
 drivers/staging/android/uapi/sync.h  |  45 +++++++-------
 5 files changed, 40 insertions(+), 196 deletions(-)

-- 
2.5.0

[toc] | [next] | [standalone]


#1322090 — [PATCH 04/10] staging/android: remove driver_data from struct fence_info

FromGustavo Padovan <gustavo@padovan.org>
Date2016-01-29 22:30 +0100
Subject[PATCH 04/10] staging/android: remove driver_data from struct fence_info
Message-ID<qWoMa-IK-13@gated-at.bofh.it>
In reply to#1322089
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

It is unclear in what situations driver_data should be used thus better do
not upstream it for now. If a need arises in the future a discussion can
be started to re-add it.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
 drivers/staging/android/sw_sync.c   | 14 --------------
 drivers/staging/android/sync.c      | 21 ---------------------
 drivers/staging/android/sync.h      |  7 -------
 drivers/staging/android/uapi/sync.h |  5 +----
 4 files changed, 1 insertion(+), 46 deletions(-)

diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c
index 3bee959..af39ff5 100644
--- a/drivers/staging/android/sw_sync.c
+++ b/drivers/staging/android/sw_sync.c
@@ -47,19 +47,6 @@ static int sw_sync_fence_has_signaled(struct fence *fence)
 	return (pt->value > obj->value) ? 0 : 1;
 }
 
-static int sw_sync_fill_driver_data(struct fence *fence,
-				    void *data, int size)
-{
-	struct sw_sync_pt *pt = (struct sw_sync_pt *)fence;
-
-	if (size < sizeof(pt->value))
-		return -ENOMEM;
-
-	memcpy(data, &pt->value, sizeof(pt->value));
-
-	return sizeof(pt->value);
-}
-
 static void sw_sync_timeline_value_str(struct sync_timeline *sync_timeline,
 				       char *str, int size)
 {
@@ -78,7 +65,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,
-	.fill_driver_data = sw_sync_fill_driver_data,
 	.timeline_value_str = sw_sync_timeline_value_str,
 	.fence_value_str = sw_sync_fence_value_str,
 };
diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index a1cf9fd..ced6e61 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -351,16 +351,6 @@ static bool android_fence_enable_signaling(struct fence *fence)
 	return true;
 }
 
-static int android_fence_fill_driver_data(struct fence *fence,
-					  void *data, int size)
-{
-	struct sync_timeline *parent = fence_parent(fence);
-
-	if (!parent->ops->fill_driver_data)
-		return 0;
-	return parent->ops->fill_driver_data(fence, data, size);
-}
-
 static void android_fence_value_str(struct fence *fence,
 				    char *str, int size)
 {
@@ -394,7 +384,6 @@ static const struct fence_ops android_fence_ops = {
 	.signaled = android_fence_signaled,
 	.wait = fence_default_wait,
 	.release = android_fence_release,
-	.fill_driver_data = android_fence_fill_driver_data,
 	.fence_value_str = android_fence_value_str,
 	.timeline_value_str = android_fence_timeline_value_str,
 };
@@ -493,22 +482,12 @@ err_put_fd:
 static int sync_fill_fence_info(struct fence *fence, void *data, int size)
 {
 	struct fence_info *info = data;
-	int ret;
 
 	if (size < sizeof(*info))
 		return -ENOMEM;
 
 	info->len = sizeof(struct sync_pt_info);
 
-	if (fence->ops->fill_driver_data) {
-		ret = fence->ops->fill_driver_data(fence, info->driver_data,
-						   size - sizeof(*info));
-		if (ret < 0)
-			return ret;
-
-		info->len += ret;
-	}
-
 	strlcpy(info->obj_name, fence->ops->get_timeline_name(fence),
 		sizeof(info->obj_name));
 	strlcpy(info->driver_name, fence->ops->get_driver_name(fence),
diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h
index af1af99..d2a1734 100644
--- a/drivers/staging/android/sync.h
+++ b/drivers/staging/android/sync.h
@@ -32,10 +32,6 @@ struct sync_file;
  *			  1 if pt has signaled
  *			  0 if pt has not signaled
  *			 <0 on error
- * @fill_driver_data:	write implementation specific driver data to data.
- *			  should return an error if there is not enough room
- *			  as specified by size.  This information is returned
- *			  to userspace by SYNC_IOC_FENCE_INFO.
  * @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
  */
@@ -46,9 +42,6 @@ struct sync_timeline_ops {
 	int (*has_signaled)(struct fence *fence);
 
 	/* optional */
-	int (*fill_driver_data)(struct fence *fence, void *data, int size);
-
-	/* optional */
 	void (*timeline_value_str)(struct sync_timeline *timeline, char *str,
 				   int size);
 
diff --git a/drivers/staging/android/uapi/sync.h b/drivers/staging/android/uapi/sync.h
index 70d05ad..cdc0f04 100644
--- a/drivers/staging/android/uapi/sync.h
+++ b/drivers/staging/android/uapi/sync.h
@@ -28,12 +28,11 @@ struct sync_merge_data {
 
 /**
  * struct fence_info - detailed fence information
- * @len:		length of fence_info including any driver_data
+ * @len:		length of fence_info
  * @obj_name:		name of parent sync_timeline
  * @driver_name:	name of driver implementing the parent
  * @status:		status of the fence 0:active 1:signaled <0:error
  * @timestamp_ns:	timestamp of status change in nanoseconds
- * @driver_data:	any driver dependent data
  */
 struct fence_info {
 	__u32	len;
@@ -41,8 +40,6 @@ struct fence_info {
 	char	driver_name[32];
 	__s32	status;
 	__u64	timestamp_ns;
-
-	__u8	driver_data[0];
 };
 
 /**
-- 
2.5.0

[toc] | [prev] | [next] | [standalone]


#1322094 — [PATCH 05/10] staging/android: remove len field from struct fence_info

FromGustavo Padovan <gustavo@padovan.org>
Date2016-01-29 22:30 +0100
Subject[PATCH 05/10] staging/android: remove len field from struct fence_info
Message-ID<qWoMb-IK-23@gated-at.bofh.it>
In reply to#1322089
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

After removing driver_data struct fence_info has now a fixed size,
thus it doesn't need any field to tell its size, it is already known.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
 drivers/staging/android/sync.c      | 4 +---
 drivers/staging/android/uapi/sync.h | 2 --
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index ced6e61..f7530f0 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -486,8 +486,6 @@ static int sync_fill_fence_info(struct fence *fence, void *data, int size)
 	if (size < sizeof(*info))
 		return -ENOMEM;
 
-	info->len = sizeof(struct sync_pt_info);
-
 	strlcpy(info->obj_name, fence->ops->get_timeline_name(fence),
 		sizeof(info->obj_name));
 	strlcpy(info->driver_name, fence->ops->get_driver_name(fence),
@@ -498,7 +496,7 @@ static int sync_fill_fence_info(struct fence *fence, void *data, int size)
 		info->status = 0;
 	info->timestamp_ns = ktime_to_ns(fence->timestamp);
 
-	return info->len;
+	return sizeof(*info);
 }
 
 static long sync_file_ioctl_fence_info(struct sync_file *sync_file,
diff --git a/drivers/staging/android/uapi/sync.h b/drivers/staging/android/uapi/sync.h
index cdc0f04..ed281fc 100644
--- a/drivers/staging/android/uapi/sync.h
+++ b/drivers/staging/android/uapi/sync.h
@@ -28,14 +28,12 @@ struct sync_merge_data {
 
 /**
  * struct fence_info - detailed fence information
- * @len:		length of fence_info
  * @obj_name:		name of parent sync_timeline
  * @driver_name:	name of driver implementing the parent
  * @status:		status of the fence 0:active 1:signaled <0:error
  * @timestamp_ns:	timestamp of status change in nanoseconds
  */
 struct fence_info {
-	__u32	len;
 	char	obj_name[32];
 	char	driver_name[32];
 	__s32	status;
-- 
2.5.0

[toc] | [prev] | [next] | [standalone]


#1322098 — [PATCH 06/10] staging/android: turn fence_info into a __64 pointer

FromGustavo Padovan <gustavo@padovan.org>
Date2016-01-29 22:30 +0100
Subject[PATCH 06/10] staging/android: turn fence_info into a __64 pointer
Message-ID<qWoMb-IK-31@gated-at.bofh.it>
In reply to#1322089
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

Making fence_info a pointer enables us to extend the struct in the future
without breaking the ABI.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
 drivers/staging/android/sync.c      | 2 +-
 drivers/staging/android/uapi/sync.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index f7530f0..51d4f47 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -525,7 +525,7 @@ static long sync_file_ioctl_fence_info(struct sync_file *sync_file,
 	if (info->status >= 0)
 		info->status = !info->status;
 
-	len = sizeof(struct sync_file_info);
+	len = sizeof(struct sync_file_info) - sizeof(__u64 *);
 
 	for (i = 0; i < sync_file->num_fences; ++i) {
 		struct fence *fence = sync_file->cbs[i].fence;
diff --git a/drivers/staging/android/uapi/sync.h b/drivers/staging/android/uapi/sync.h
index ed281fc..9f07aa7 100644
--- a/drivers/staging/android/uapi/sync.h
+++ b/drivers/staging/android/uapi/sync.h
@@ -54,7 +54,7 @@ struct sync_file_info {
 	char	name[32];
 	__s32	status;
 
-	__u8	fence_info[0];
+	__u64	*fence_info;
 };
 
 #define SYNC_IOC_MAGIC		'>'
-- 
2.5.0

[toc] | [prev] | [next] | [standalone]


#1322476 — Re: [PATCH 06/10] staging/android: turn fence_info into a __64 pointer

FromEmil Velikov <emil.l.velikov@gmail.com>
Date2016-01-30 19:10 +0100
SubjectRe: [PATCH 06/10] staging/android: turn fence_info into a __64 pointer
Message-ID<qWI8a-7MQ-7@gated-at.bofh.it>
In reply to#1322098
Hi Gustavo,

s/__64/__u64/ in the commit message.

On 29 January 2016 at 23:20, Gustavo Padovan <gustavo@padovan.org> wrote:
> From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
>
> Making fence_info a pointer enables us to extend the struct in the future
> without breaking the ABI.
>
> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

> diff --git a/drivers/staging/android/uapi/sync.h b/drivers/staging/android/uapi/sync.h
> index ed281fc..9f07aa7 100644
> --- a/drivers/staging/android/uapi/sync.h
> +++ b/drivers/staging/android/uapi/sync.h
> @@ -54,7 +54,7 @@ struct sync_file_info {
>         char    name[32];
>         __s32   status;
>
> -       __u8    fence_info[0];
> +       __u64   *fence_info;
I believe you misinterpreted what was meant with "_u64 pointer". As
the storage use for of a pointer varies across 32/64 bit arch, we
explicitly use a variable type that is large enough (and consistent)
for both cases. Thus the above should be

+       __u64   fence_info;

Hope this clarifies things.

-Emil

[toc] | [prev] | [next] | [standalone]


#1322910 — Re: [PATCH 06/10] staging/android: turn fence_info into a __64 pointer

FromMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Date2016-02-01 09:50 +0100
SubjectRe: [PATCH 06/10] staging/android: turn fence_info into a __64 pointer
Message-ID<qXilk-8sL-9@gated-at.bofh.it>
In reply to#1322098
Op 29-01-16 om 22:20 schreef Gustavo Padovan:
> From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
>
> Making fence_info a pointer enables us to extend the struct in the future
> without breaking the ABI.
>
> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> ---
>  drivers/staging/android/sync.c      | 2 +-
>  drivers/staging/android/uapi/sync.h | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
> index f7530f0..51d4f47 100644
> --- a/drivers/staging/android/sync.c
> +++ b/drivers/staging/android/sync.c
> @@ -525,7 +525,7 @@ static long sync_file_ioctl_fence_info(struct sync_file *sync_file,
>  	if (info->status >= 0)
>  		info->status = !info->status;
>  
> -	len = sizeof(struct sync_file_info);
> +	len = sizeof(struct sync_file_info) - sizeof(__u64 *);
>  
>  	for (i = 0; i < sync_file->num_fences; ++i) {
>  		struct fence *fence = sync_file->cbs[i].fence;
> diff --git a/drivers/staging/android/uapi/sync.h b/drivers/staging/android/uapi/sync.h
> index ed281fc..9f07aa7 100644
> --- a/drivers/staging/android/uapi/sync.h
> +++ b/drivers/staging/android/uapi/sync.h
> @@ -54,7 +54,7 @@ struct sync_file_info {
>  	char	name[32];
>  	__s32	status;
>  
> -	__u8	fence_info[0];
> +	__u64	*fence_info;
>  };
>
Pointers are awful, it should be a __u64 since it's a pointer type. Userspace should cast it to a uintptr_t in userspace.
This structure also won't work on 64-bits systems, there may be a hole between fence_info and status (or num_fences in next patch).

It's probably best to move it to the top and ensure the struct is 64-bits aligned.

[toc] | [prev] | [next] | [standalone]


#1323376 — Re: [PATCH 06/10] staging/android: turn fence_info into a __64 pointer

FromGustavo Padovan <gustavo@padovan.org>
Date2016-02-01 19:10 +0100
SubjectRe: [PATCH 06/10] staging/android: turn fence_info into a __64 pointer
Message-ID<qXr5g-6K9-21@gated-at.bofh.it>
In reply to#1322910
Hi Maarten,

2016-02-01 Maarten Lankhorst <maarten.lankhorst@linux.intel.com>:

> Op 29-01-16 om 22:20 schreef Gustavo Padovan:
> > From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> >
> > Making fence_info a pointer enables us to extend the struct in the future
> > without breaking the ABI.
> >
> > Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> > ---
> >  drivers/staging/android/sync.c      | 2 +-
> >  drivers/staging/android/uapi/sync.h | 2 +-
> >  2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
> > index f7530f0..51d4f47 100644
> > --- a/drivers/staging/android/sync.c
> > +++ b/drivers/staging/android/sync.c
> > @@ -525,7 +525,7 @@ static long sync_file_ioctl_fence_info(struct sync_file *sync_file,
> >  	if (info->status >= 0)
> >  		info->status = !info->status;
> >  
> > -	len = sizeof(struct sync_file_info);
> > +	len = sizeof(struct sync_file_info) - sizeof(__u64 *);
> >  
> >  	for (i = 0; i < sync_file->num_fences; ++i) {
> >  		struct fence *fence = sync_file->cbs[i].fence;
> > diff --git a/drivers/staging/android/uapi/sync.h b/drivers/staging/android/uapi/sync.h
> > index ed281fc..9f07aa7 100644
> > --- a/drivers/staging/android/uapi/sync.h
> > +++ b/drivers/staging/android/uapi/sync.h
> > @@ -54,7 +54,7 @@ struct sync_file_info {
> >  	char	name[32];
> >  	__s32	status;
> >  
> > -	__u8	fence_info[0];
> > +	__u64	*fence_info;
> >  };
> >
> Pointers are awful, it should be a __u64 since it's a pointer type. Userspace should cast it to a uintptr_t in userspace.

Oh, I made a mistake. I'll fix this.


> This structure also won't work on 64-bits systems, there may be a hole between fence_info and status (or num_fences in next patch).
> 
> It's probably best to move it to the top and ensure the struct is 64-bits aligned.

That is not possible because we are not allocating only 64bits there but
a array of struct fence_info, so it needs to be the last one. Maybe we
can add some sort of padding?


	Gustavo

[toc] | [prev] | [next] | [standalone]


#1324057 — Re: [PATCH 06/10] staging/android: turn fence_info into a __64 pointer

FromGustavo Padovan <gustavo@padovan.org>
Date2016-02-02 14:10 +0100
SubjectRe: [PATCH 06/10] staging/android: turn fence_info into a __64 pointer
Message-ID<qXISu-3ne-5@gated-at.bofh.it>
In reply to#1323376
2016-02-01 Gustavo Padovan <gustavo@padovan.org>:

> Hi Maarten,
> 
> 2016-02-01 Maarten Lankhorst <maarten.lankhorst@linux.intel.com>:
> 
> > Op 29-01-16 om 22:20 schreef Gustavo Padovan:
> > > From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> > >
> > > Making fence_info a pointer enables us to extend the struct in the future
> > > without breaking the ABI.
> > >
> > > Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> > > ---
> > >  drivers/staging/android/sync.c      | 2 +-
> > >  drivers/staging/android/uapi/sync.h | 2 +-
> > >  2 files changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
> > > index f7530f0..51d4f47 100644
> > > --- a/drivers/staging/android/sync.c
> > > +++ b/drivers/staging/android/sync.c
> > > @@ -525,7 +525,7 @@ static long sync_file_ioctl_fence_info(struct sync_file *sync_file,
> > >  	if (info->status >= 0)
> > >  		info->status = !info->status;
> > >  
> > > -	len = sizeof(struct sync_file_info);
> > > +	len = sizeof(struct sync_file_info) - sizeof(__u64 *);
> > >  
> > >  	for (i = 0; i < sync_file->num_fences; ++i) {
> > >  		struct fence *fence = sync_file->cbs[i].fence;
> > > diff --git a/drivers/staging/android/uapi/sync.h b/drivers/staging/android/uapi/sync.h
> > > index ed281fc..9f07aa7 100644
> > > --- a/drivers/staging/android/uapi/sync.h
> > > +++ b/drivers/staging/android/uapi/sync.h
> > > @@ -54,7 +54,7 @@ struct sync_file_info {
> > >  	char	name[32];
> > >  	__s32	status;
> > >  
> > > -	__u8	fence_info[0];
> > > +	__u64	*fence_info;
> > >  };
> > >
> > Pointers are awful, it should be a __u64 since it's a pointer type. Userspace should cast it to a uintptr_t in userspace.
> 
> Oh, I made a mistake. I'll fix this.
> 
> 
> > This structure also won't work on 64-bits systems, there may be a hole between fence_info and status (or num_fences in next patch).
> > 
> > It's probably best to move it to the top and ensure the struct is 64-bits aligned.
> 
> That is not possible because we are not allocating only 64bits there but
> a array of struct fence_info, so it needs to be the last one. Maybe we
> can add some sort of padding?

Actually it is 64bits aligned:

struct sync_file_info {                                                         
        char    name[32];                                                       
        __s32   status;                                                         
        __u32   flags;                                                          
        __u32   num_fences;                                                     
        __u32   len;                                                            
                                                                                
        __u64   fence_info;                                                     
};

So nothing to worry here.

	Gustavo

[toc] | [prev] | [next] | [standalone]


#1322100 — [PATCH 01/10] staging/android: remove SYNC_WAIT ioctl

FromGustavo Padovan <gustavo@padovan.org>
Date2016-01-29 22:30 +0100
Subject[PATCH 01/10] staging/android: remove SYNC_WAIT ioctl
Message-ID<qWoMb-IK-35@gated-at.bofh.it>
In reply to#1322089
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

This ioctl is replicating the work of poll() syscall so let's take the
opportunity that this is still on staging tree and remove the duplication
and force new users to use the poll() standard interface.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
 drivers/staging/android/sync.c       | 52 ------------------------------------
 drivers/staging/android/sync.h       | 13 ---------
 drivers/staging/android/trace/sync.h | 44 ------------------------------
 drivers/staging/android/uapi/sync.h  |  7 -----
 4 files changed, 116 deletions(-)

diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index 5fa4779..381209a 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -300,44 +300,6 @@ struct sync_file *sync_file_merge(const char *name,
 }
 EXPORT_SYMBOL(sync_file_merge);
 
-int sync_file_wait(struct sync_file *sync_file, long timeout)
-{
-	long ret;
-	int i;
-
-	if (timeout < 0)
-		timeout = MAX_SCHEDULE_TIMEOUT;
-	else
-		timeout = msecs_to_jiffies(timeout);
-
-	trace_sync_wait(sync_file, 1);
-	for (i = 0; i < sync_file->num_fences; ++i)
-		trace_fence(sync_file->cbs[i].fence);
-	ret = wait_event_interruptible_timeout(sync_file->wq,
-					       atomic_read(&sync_file->status) <= 0,
-					       timeout);
-	trace_sync_wait(sync_file, 0);
-
-	if (ret < 0) {
-		return ret;
-	} else if (ret == 0) {
-		if (timeout) {
-			pr_info("sync_file timeout on [%p] after %dms\n",
-				sync_file, jiffies_to_msecs(timeout));
-			sync_dump();
-		}
-		return -ETIME;
-	}
-
-	ret = atomic_read(&sync_file->status);
-	if (ret) {
-		pr_info("sync_file error %ld on [%p]\n", ret, sync_file);
-		sync_dump();
-	}
-	return ret;
-}
-EXPORT_SYMBOL(sync_file_wait);
-
 static const char *android_fence_get_driver_name(struct fence *fence)
 {
 	struct sync_timeline *parent = fence_parent(fence);
@@ -478,17 +440,6 @@ static unsigned int sync_file_poll(struct file *file, poll_table *wait)
 	return 0;
 }
 
-static long sync_file_ioctl_wait(struct sync_file *sync_file,
-				  unsigned long arg)
-{
-	__s32 value;
-
-	if (copy_from_user(&value, (void __user *)arg, sizeof(value)))
-		return -EFAULT;
-
-	return sync_file_wait(sync_file, value);
-}
-
 static long sync_file_ioctl_merge(struct sync_file *sync_file,
 				   unsigned long arg)
 {
@@ -629,9 +580,6 @@ static long sync_file_ioctl(struct file *file, unsigned int cmd,
 	struct sync_file *sync_file = file->private_data;
 
 	switch (cmd) {
-	case SYNC_IOC_WAIT:
-		return sync_file_ioctl_wait(sync_file, arg);
-
 	case SYNC_IOC_MERGE:
 		return sync_file_ioctl_merge(sync_file, arg);
 
diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h
index 8980b55..af1af99 100644
--- a/drivers/staging/android/sync.h
+++ b/drivers/staging/android/sync.h
@@ -18,7 +18,6 @@
 #include <linux/ktime.h>
 #include <linux/list.h>
 #include <linux/spinlock.h>
-#include <linux/wait.h>
 #include <linux/fence.h>
 
 #include "uapi/sync.h"
@@ -230,18 +229,6 @@ void sync_file_put(struct sync_file *sync_file);
  */
 void sync_file_install(struct sync_file *sync_file, int fd);
 
-/**
- * sync_file_wait() - wait on sync file
- * @sync_file:	file to wait on
- * @tiemout:	timeout in ms
- *
- * Wait for @sync_file to be signaled or have an error. Waits indefinitely
- * if @timeout < 0.
- *
- * Returns 0 if fence signaled, > 0 if it is still active and <0 on error
- */
-int sync_file_wait(struct sync_file *sync_file, long timeout);
-
 #ifdef CONFIG_DEBUG_FS
 
 void sync_timeline_debug_add(struct sync_timeline *obj);
diff --git a/drivers/staging/android/trace/sync.h b/drivers/staging/android/trace/sync.h
index 87c60e9..a0f80f4 100644
--- a/drivers/staging/android/trace/sync.h
+++ b/drivers/staging/android/trace/sync.h
@@ -32,50 +32,6 @@ TRACE_EVENT(sync_timeline,
 	TP_printk("name=%s value=%s", __get_str(name), __entry->value)
 );
 
-TRACE_EVENT(sync_wait,
-	TP_PROTO(struct sync_file *sync_file, int begin),
-
-	TP_ARGS(sync_file, begin),
-
-	TP_STRUCT__entry(
-			__string(name, sync_file->name)
-			__field(s32, status)
-			__field(u32, begin)
-	),
-
-	TP_fast_assign(
-			__assign_str(name, sync_file->name);
-			__entry->status = atomic_read(&sync_file->status);
-			__entry->begin = begin;
-	),
-
-	TP_printk("%s name=%s state=%d", __entry->begin ? "begin" : "end",
-			__get_str(name), __entry->status)
-);
-
-TRACE_EVENT(fence,
-	TP_PROTO(struct fence *fence),
-
-	TP_ARGS(fence),
-
-	TP_STRUCT__entry(
-		__string(timeline, fence->ops->get_timeline_name(fence))
-		__array(char, value, 32)
-	),
-
-	TP_fast_assign(
-		__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';
-		}
-	),
-
-	TP_printk("name=%s value=%s", __get_str(timeline), __entry->value)
-);
-
 #endif /* if !defined(_TRACE_SYNC_H) || defined(TRACE_HEADER_MULTI_READ) */
 
 /* This part must be outside protection */
diff --git a/drivers/staging/android/uapi/sync.h b/drivers/staging/android/uapi/sync.h
index 73deb69..6c88c80 100644
--- a/drivers/staging/android/uapi/sync.h
+++ b/drivers/staging/android/uapi/sync.h
@@ -65,13 +65,6 @@ struct sync_file_info_data {
 #define SYNC_IOC_MAGIC		'>'
 
 /**
- * DOC: SYNC_IOC_WAIT - wait for a fence to signal
- *
- * pass timeout in milliseconds.  Waits indefinitely timeout < 0.
- */
-#define SYNC_IOC_WAIT		_IOW(SYNC_IOC_MAGIC, 0, __s32)
-
-/**
  * DOC: SYNC_IOC_MERGE - merge two fences
  *
  * Takes a struct sync_merge_data.  Creates a new fence containing copies of
-- 
2.5.0

[toc] | [prev] | [next] | [standalone]


#1322103 — [PATCH 08/10] staging/android: rename SYNC_IOC_FENCE_INFO

FromGustavo Padovan <gustavo@padovan.org>
Date2016-01-29 22:30 +0100
Subject[PATCH 08/10] staging/android: rename SYNC_IOC_FENCE_INFO
Message-ID<qWoMc-IK-47@gated-at.bofh.it>
In reply to#1322089
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

We don't use the 'fence' name to refer to sync_file anymore. So rename it
to SYNC_IOC_FILE_INFO.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
 drivers/staging/android/sync.c      | 2 +-
 drivers/staging/android/uapi/sync.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index ae42810..e1d4fcb 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -562,7 +562,7 @@ static long sync_file_ioctl(struct file *file, unsigned int cmd,
 	case SYNC_IOC_MERGE:
 		return sync_file_ioctl_merge(sync_file, arg);
 
-	case SYNC_IOC_FENCE_INFO:
+	case SYNC_IOC_FILE_INFO:
 		return sync_file_ioctl_fence_info(sync_file, arg);
 
 	default:
diff --git a/drivers/staging/android/uapi/sync.h b/drivers/staging/android/uapi/sync.h
index 9a607ea..b00f0eb 100644
--- a/drivers/staging/android/uapi/sync.h
+++ b/drivers/staging/android/uapi/sync.h
@@ -81,6 +81,6 @@ struct sync_file_info {
  * 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.
  */
-#define SYNC_IOC_FENCE_INFO	_IOWR(SYNC_IOC_MAGIC, 2, struct sync_file_info)
+#define SYNC_IOC_FILE_INFO	_IOWR(SYNC_IOC_MAGIC, 2, struct sync_file_info)
 
 #endif /* _UAPI_LINUX_SYNC_H */
-- 
2.5.0

[toc] | [prev] | [next] | [standalone]


#1322104 — [PATCH 09/10] staging/android: add flags member to sync ioctl structs

FromGustavo Padovan <gustavo@padovan.org>
Date2016-01-29 22:30 +0100
Subject[PATCH 09/10] staging/android: add flags member to sync ioctl structs
Message-ID<qWoMc-IK-49@gated-at.bofh.it>
In reply to#1322089
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

Play safe and add flags member to all structs. So we don't need to
break API or create new IOCTL in the future if new features that requires
flags arises.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
 drivers/staging/android/uapi/sync.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/staging/android/uapi/sync.h b/drivers/staging/android/uapi/sync.h
index b00f0eb..45921f6 100644
--- a/drivers/staging/android/uapi/sync.h
+++ b/drivers/staging/android/uapi/sync.h
@@ -19,11 +19,13 @@
  * @fd2:	file descriptor of second fence
  * @name:	name of new fence
  * @fence:	returns the fd of the new fence to userspace
+ * @flags:	merge_data flags
  */
 struct sync_merge_data {
 	__s32	fd2; /* fd of second fence */
 	char	name[32]; /* name of new fence */
 	__s32	fence; /* fd on newly created fence */
+	__u32	flags;
 };
 
 /**
@@ -31,12 +33,14 @@ struct sync_merge_data {
  * @obj_name:		name of parent sync_timeline
  * @driver_name:	name of driver implementing the parent
  * @status:		status of the fence 0:active 1:signaled <0:error
+ * @flags:		fence_info flags
  * @timestamp_ns:	timestamp of status change in nanoseconds
  */
 struct fence_info {
 	char	obj_name[32];
 	char	driver_name[32];
 	__s32	status;
+	__u32	flags;
 	__u64	timestamp_ns;
 };
 
@@ -47,6 +51,7 @@ struct fence_info {
  *		userspace including pt_info.
  * @name:	name of fence
  * @status:	status of fence. 1: signaled 0:active <0:error
+ * @flags:	sync_file_info flags
  * @num_fences	number of fences in the sync_file
  * @fence_info:	a fence_info struct for every fence in the sync_file
  */
@@ -54,6 +59,7 @@ struct sync_file_info {
 	__u32	len;
 	char	name[32];
 	__s32	status;
+	__u32	flags;
 	__u32	num_fences;
 
 	__u64	*fence_info;
-- 
2.5.0

[toc] | [prev] | [next] | [standalone]


#1322482 — Re: [PATCH 09/10] staging/android: add flags member to sync ioctl structs

FromEmil Velikov <emil.l.velikov@gmail.com>
Date2016-01-30 19:20 +0100
SubjectRe: [PATCH 09/10] staging/android: add flags member to sync ioctl structs
Message-ID<qWIhQ-7Qz-25@gated-at.bofh.it>
In reply to#1322104
Hi Gustavo,

> @@ -54,6 +59,7 @@ struct sync_file_info {
>         __u32   len;
As mentioned previously - can we rework this variable to indicate the
total length (or the number) of fence_info struct instances. It seems
to be the more common approach afaict. Might also want to move it just
above the fence_into?

-Emil

[toc] | [prev] | [next] | [standalone]


#1323101 — Re: [PATCH 09/10] staging/android: add flags member to sync ioctl structs

FromGustavo Padovan <gustavo@padovan.org>
Date2016-02-01 14:30 +0100
SubjectRe: [PATCH 09/10] staging/android: add flags member to sync ioctl structs
Message-ID<qXmIi-3oo-9@gated-at.bofh.it>
In reply to#1322482
2016-01-30 Emil Velikov <emil.l.velikov@gmail.com>:

> Hi Gustavo,
> 
> > @@ -54,6 +59,7 @@ struct sync_file_info {
> >         __u32   len;
> As mentioned previously - can we rework this variable to indicate the
> total length (or the number) of fence_info struct instances. It seems
> to be the more common approach afaict. Might also want to move it just
> above the fence_into?

Sure, I think this is a good idea.

	Gustavo

[toc] | [prev] | [next] | [standalone]


#1322908 — Re: [PATCH 09/10] staging/android: add flags member to sync ioctl structs

FromMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Date2016-02-01 09:50 +0100
SubjectRe: [PATCH 09/10] staging/android: add flags member to sync ioctl structs
Message-ID<qXilk-8sL-3@gated-at.bofh.it>
In reply to#1322104
Op 29-01-16 om 22:20 schreef Gustavo Padovan:
> From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
>
> Play safe and add flags member to all structs. So we don't need to
> break API or create new IOCTL in the future if new features that requires
> flags arises.
>
This only helps if you reject flags != 0 in the ioctl, else when you extend the abi userspace might initialize it with garbage.

~Maarten

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web