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


Groups > linux.kernel > #1346606 > unrolled thread

[PATCH v5 1/5] staging/android: add num_fences field to struct sync_file_info

Started byGustavo Padovan <gustavo@padovan.org>
First post2016-03-01 14:20 +0100
Last post2016-03-01 14:20 +0100
Articles 6 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v5 1/5] staging/android: add num_fences field to struct sync_file_info Gustavo Padovan <gustavo@padovan.org> - 2016-03-01 14:20 +0100
    [PATCH v5 5/5] staging/android: add flags member to sync ioctl structs Gustavo Padovan <gustavo@padovan.org> - 2016-03-01 14:20 +0100
      Re: [PATCH v5 5/5] staging/android: add flags member to sync ioctl structs Emil Velikov <emil.l.velikov@gmail.com> - 2016-03-02 10:40 +0100
        Re: [PATCH v5 5/5] staging/android: add flags member to sync ioctl  structs Gustavo Padovan <gustavo@padovan.org> - 2016-03-02 21:00 +0100
    [PATCH v5 3/5] staging/android: remove redundant comments on sync_merge_data Gustavo Padovan <gustavo@padovan.org> - 2016-03-01 14:20 +0100
    [PATCH v5 2/5] staging/android: rename SYNC_IOC_FENCE_INFO Gustavo Padovan <gustavo@padovan.org> - 2016-03-01 14:20 +0100

#1346606 — [PATCH v5 1/5] staging/android: add num_fences field to struct sync_file_info

FromGustavo Padovan <gustavo@padovan.org>
Date2016-03-01 14:20 +0100
Subject[PATCH v5 1/5] staging/android: add num_fences field to struct sync_file_info
Message-ID<r7Snw-1ci-5@gated-at.bofh.it>
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

Inform userspace how many fences are in the sync_fence_info field.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/staging/android/sync.c      | 2 ++
 drivers/staging/android/uapi/sync.h | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index 3a8f210..31aa462 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -525,6 +525,8 @@ static long sync_file_ioctl_fence_info(struct sync_file *sync_file,
 	if (info->status >= 0)
 		info->status = !info->status;
 
+	info->num_fences = sync_file->num_fences;
+
 	len = sizeof(struct sync_file_info);
 
 	for (i = 0; i < sync_file->num_fences; ++i) {
diff --git a/drivers/staging/android/uapi/sync.h b/drivers/staging/android/uapi/sync.h
index a0cf357..4ffb7cc 100644
--- a/drivers/staging/android/uapi/sync.h
+++ b/drivers/staging/android/uapi/sync.h
@@ -47,12 +47,14 @@ struct sync_fence_info {
  *		userspace including pt_info.
  * @name:	name of fence
  * @status:	status of fence. 1: signaled 0:active <0:error
+ * @num_fences	number of fences in the sync_file
  * @sync_fence_info: array of sync_fence_info for every fence in the sync_file
  */
 struct sync_file_info {
 	__u32	len;
 	char	name[32];
 	__s32	status;
+	__u32	num_fences;
 
 	__u8	sync_fence_info[0];
 };
-- 
2.5.0

[toc] | [next] | [standalone]


#1346607 — [PATCH v5 5/5] staging/android: add flags member to sync ioctl structs

FromGustavo Padovan <gustavo@padovan.org>
Date2016-03-01 14:20 +0100
Subject[PATCH v5 5/5] staging/android: add flags member to sync ioctl structs
Message-ID<r7Snw-1ci-13@gated-at.bofh.it>
In reply to#1346606
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.

v2: check if flags are valid (zero, in this case)

v3: return -EINVAL if flags are not zero'ed

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

diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index 3604e453..3c265ed 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -445,6 +445,11 @@ static long sync_file_ioctl_merge(struct sync_file *sync_file,
 		goto err_put_fd;
 	}
 
+	if (data.flags) {
+		err = -EINVAL;
+		goto err_put_fd;
+	}
+
 	fence2 = sync_file_fdget(data.fd2);
 	if (!fence2) {
 		err = -ENOENT;
@@ -504,6 +509,9 @@ static long sync_file_ioctl_fence_info(struct sync_file *sync_file,
 	if (copy_from_user(&in, (void __user *)arg, sizeof(in)))
 		return -EFAULT;
 
+	if (in.flags)
+		return -EINVAL;
+
 	info = kzalloc(sizeof(*info), GFP_KERNEL);
 	if (!info)
 		return -ENOMEM;
diff --git a/drivers/staging/android/uapi/sync.h b/drivers/staging/android/uapi/sync.h
index a122bb5..11e2d28 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;
 	char	name[32];
 	__s32	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 sync_fence_info {
 	char	obj_name[32];
 	char	driver_name[32];
 	__s32	status;
+	__u32	flags;
 	__u64	timestamp_ns;
 };
 
@@ -44,6 +48,7 @@ struct sync_fence_info {
  * struct sync_file_info - data returned from fence info ioctl
  * @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
  * @sync_fence_info: pointer to array of structs sync_fence_info with all
  *		 fences in the sync_file
@@ -51,6 +56,7 @@ struct sync_fence_info {
 struct sync_file_info {
 	char	name[32];
 	__s32	status;
+	__u32	flags;
 	__u32	num_fences;
 
 	__u64	sync_fence_info;
-- 
2.5.0

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


#1347887 — Re: [PATCH v5 5/5] staging/android: add flags member to sync ioctl structs

FromEmil Velikov <emil.l.velikov@gmail.com>
Date2016-03-02 10:40 +0100
SubjectRe: [PATCH v5 5/5] staging/android: add flags member to sync ioctl structs
Message-ID<r8bqb-5KC-25@gated-at.bofh.it>
In reply to#1346607
On 1 March 2016 at 13:13, Gustavo Padovan <gustavo@padovan.org> wrote:
> 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.
>
> v2: check if flags are valid (zero, in this case)
>
> v3: return -EINVAL if flags are not zero'ed
>
> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> ---
>  drivers/staging/android/sync.c      | 8 ++++++++
>  drivers/staging/android/uapi/sync.h | 6 ++++++
>  2 files changed, 14 insertions(+)
>
> diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
> index 3604e453..3c265ed 100644
> --- a/drivers/staging/android/sync.c
> +++ b/drivers/staging/android/sync.c
> @@ -445,6 +445,11 @@ static long sync_file_ioctl_merge(struct sync_file *sync_file,
>                 goto err_put_fd;
>         }
>
> +       if (data.flags) {
> +               err = -EINVAL;
> +               goto err_put_fd;
> +       }
> +
>         fence2 = sync_file_fdget(data.fd2);
>         if (!fence2) {
>                 err = -ENOENT;
> @@ -504,6 +509,9 @@ static long sync_file_ioctl_fence_info(struct sync_file *sync_file,
>         if (copy_from_user(&in, (void __user *)arg, sizeof(in)))
>                 return -EFAULT;
>
> +       if (in.flags)
> +               return -EINVAL;
> +
>         info = kzalloc(sizeof(*info), GFP_KERNEL);
>         if (!info)
>                 return -ENOMEM;
> diff --git a/drivers/staging/android/uapi/sync.h b/drivers/staging/android/uapi/sync.h
> index a122bb5..11e2d28 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;
>         char    name[32];
>         __s32   fence;
> +       __u32   flags;
The comment from last round still stands, struct size must be multiple
of 64bits. As is the struct will be broken whenever/if we decide to
extend it. See [1] for an alternative wording.

>  };
>
>  /**
> @@ -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 sync_fence_info {
>         char    obj_name[32];
>         char    driver_name[32];
>         __s32   status;
> +       __u32   flags;
>         __u64   timestamp_ns;
>  };
>
> @@ -44,6 +48,7 @@ struct sync_fence_info {
>   * struct sync_file_info - data returned from fence info ioctl
>   * @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
>   * @sync_fence_info: pointer to array of structs sync_fence_info with all
>   *              fences in the sync_file
> @@ -51,6 +56,7 @@ struct sync_fence_info {
>  struct sync_file_info {
>         char    name[32];
>         __s32   status;
> +       __u32   flags;
>         __u32   num_fences;
>
>         __u64   sync_fence_info;
Thanks for taking my suggestion and dropping len. Although I fear that
we introduced a hole which we should be explicitly padded [2].

In both cases the pad should be checked for 0 and -EINVAL should be
returned if that's not the case. This will allow us to potentially
reuse in the future.

Other than that I believe the series looks pretty much spot on.

Cheers,
Emil

[1] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/ioctl/botching-up-ioctls.txt#n37
[2] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/ioctl/botching-up-ioctls.txt#n32

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


#1348444 — Re: [PATCH v5 5/5] staging/android: add flags member to sync ioctl structs

FromGustavo Padovan <gustavo@padovan.org>
Date2016-03-02 21:00 +0100
SubjectRe: [PATCH v5 5/5] staging/android: add flags member to sync ioctl structs
Message-ID<r8l6c-4lm-51@gated-at.bofh.it>
In reply to#1347887
Hi Emil,

2016-03-02 Emil Velikov <emil.l.velikov@gmail.com>:

> On 1 March 2016 at 13:13, Gustavo Padovan <gustavo@padovan.org> wrote:
> > 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.
> >
> > v2: check if flags are valid (zero, in this case)
> >
> > v3: return -EINVAL if flags are not zero'ed
> >
> > Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> > ---
> >  drivers/staging/android/sync.c      | 8 ++++++++
> >  drivers/staging/android/uapi/sync.h | 6 ++++++
> >  2 files changed, 14 insertions(+)
> >
> > diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
> > index 3604e453..3c265ed 100644
> > --- a/drivers/staging/android/sync.c
> > +++ b/drivers/staging/android/sync.c
> > @@ -445,6 +445,11 @@ static long sync_file_ioctl_merge(struct sync_file *sync_file,
> >                 goto err_put_fd;
> >         }
> >
> > +       if (data.flags) {
> > +               err = -EINVAL;
> > +               goto err_put_fd;
> > +       }
> > +
> >         fence2 = sync_file_fdget(data.fd2);
> >         if (!fence2) {
> >                 err = -ENOENT;
> > @@ -504,6 +509,9 @@ static long sync_file_ioctl_fence_info(struct sync_file *sync_file,
> >         if (copy_from_user(&in, (void __user *)arg, sizeof(in)))
> >                 return -EFAULT;
> >
> > +       if (in.flags)
> > +               return -EINVAL;
> > +
> >         info = kzalloc(sizeof(*info), GFP_KERNEL);
> >         if (!info)
> >                 return -ENOMEM;
> > diff --git a/drivers/staging/android/uapi/sync.h b/drivers/staging/android/uapi/sync.h
> > index a122bb5..11e2d28 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;
> >         char    name[32];
> >         __s32   fence;
> > +       __u32   flags;
> The comment from last round still stands, struct size must be multiple
> of 64bits. As is the struct will be broken whenever/if we decide to
> extend it. See [1] for an alternative wording.
> 
> >  };
> >
> >  /**
> > @@ -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 sync_fence_info {
> >         char    obj_name[32];
> >         char    driver_name[32];
> >         __s32   status;
> > +       __u32   flags;
> >         __u64   timestamp_ns;
> >  };
> >
> > @@ -44,6 +48,7 @@ struct sync_fence_info {
> >   * struct sync_file_info - data returned from fence info ioctl
> >   * @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
> >   * @sync_fence_info: pointer to array of structs sync_fence_info with all
> >   *              fences in the sync_file
> > @@ -51,6 +56,7 @@ struct sync_fence_info {
> >  struct sync_file_info {
> >         char    name[32];
> >         __s32   status;
> > +       __u32   flags;
> >         __u32   num_fences;
> >
> >         __u64   sync_fence_info;
> Thanks for taking my suggestion and dropping len. Although I fear that
> we introduced a hole which we should be explicitly padded [2].
> 
> In both cases the pad should be checked for 0 and -EINVAL should be
> returned if that's not the case. This will allow us to potentially
> reuse in the future.
> 
> Other than that I believe the series looks pretty much spot on.

I agree with both suggestions, a new version of the patches is on the
way.

	Gustavo

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


#1346609 — [PATCH v5 3/5] staging/android: remove redundant comments on sync_merge_data

FromGustavo Padovan <gustavo@padovan.org>
Date2016-03-01 14:20 +0100
Subject[PATCH v5 3/5] staging/android: remove redundant comments on sync_merge_data
Message-ID<r7Snw-1ci-15@gated-at.bofh.it>
In reply to#1346606
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

struct sync_merge_data already have documentation on top of the
struct definition. No need to duplicate it.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/staging/android/uapi/sync.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/android/uapi/sync.h b/drivers/staging/android/uapi/sync.h
index dd0dd84..f0b41ce 100644
--- a/drivers/staging/android/uapi/sync.h
+++ b/drivers/staging/android/uapi/sync.h
@@ -21,9 +21,9 @@
  * @fence:	returns the fd of the new fence to userspace
  */
 struct sync_merge_data {
-	__s32	fd2; /* fd of second fence */
-	char	name[32]; /* name of new fence */
-	__s32	fence; /* fd on newly created fence */
+	__s32	fd2;
+	char	name[32];
+	__s32	fence;
 };
 
 /**
-- 
2.5.0

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


#1346610 — [PATCH v5 2/5] staging/android: rename SYNC_IOC_FENCE_INFO

FromGustavo Padovan <gustavo@padovan.org>
Date2016-03-01 14:20 +0100
Subject[PATCH v5 2/5] staging/android: rename SYNC_IOC_FENCE_INFO
Message-ID<r7Snw-1ci-17@gated-at.bofh.it>
In reply to#1346606
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>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 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 31aa462..dc5f382 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 4ffb7cc..dd0dd84 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] | [standalone]


Back to top | Article view | linux.kernel


csiph-web