All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging/ion: Add support to get ion handle from dma buf
@ 2016-01-05 13:03 Rohit kumar
  2016-01-05 18:12 ` Laura Abbott
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Rohit kumar @ 2016-01-05 13:03 UTC (permalink / raw)
  To: gregkh, arve, riandrews, labbott, dan.carpenter, gioh.kim,
	sumit.semwal, mitchelh, paul.gortmaker, linux, shawn.lin, sriram,
	devel, linux-kernel, pintu.k, rohit.kr, vishnu.ps
  Cc: sreenathd, pintu_agarwal, me.rohit, cpgs

Currently we can only import dma buf fd's to get ion_handle.
Adding support to import dma buf handles to support kernel
specific use cases.

Signed-off-by: Rohit kumar <rohit.kr@samsung.com>
---
Currently, ION is the memory manager for graphics in android. However,
in other linux platforms such as Tizen, DRM-GEM is used for buffer 
management for graphics. It has gem_handle corresponding to a buffer
and uses gem_name for sharing the buffer with other processes. However,
it also uses dma_buf fd for 3d operations. For wayland, there are
multiple calls for gem_handle to dma_buf fd conversion. So, we store
dma_buf associated with buffer. But, there is no api for getting
ion_handle from dma_buf. This patch exposes api to retrieve the ion
handle from dma_buf for similar use cases. With this patch, we can
integrate ION within DRM-GEM for buffer management and dma_buf sharing.

 drivers/staging/android/ion/ion.c |   21 +++++++++++++++------
 drivers/staging/android/ion/ion.h |   20 ++++++++++++++++----
 2 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index e237e9f..5509716 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -1151,16 +1151,13 @@ int ion_share_dma_buf_fd(struct ion_client *client, struct ion_handle *handle)
 }
 EXPORT_SYMBOL(ion_share_dma_buf_fd);
 
-struct ion_handle *ion_import_dma_buf(struct ion_client *client, int fd)
+struct ion_handle *ion_import_dma_buf(struct ion_client *client,
+				      struct dma_buf *dmabuf)
 {
-	struct dma_buf *dmabuf;
 	struct ion_buffer *buffer;
 	struct ion_handle *handle;
 	int ret;
 
-	dmabuf = dma_buf_get(fd);
-	if (IS_ERR(dmabuf))
-		return ERR_CAST(dmabuf);
 	/* if this memory came from ion */
 
 	if (dmabuf->ops != &dma_buf_ops) {
@@ -1199,6 +1196,18 @@ end:
 }
 EXPORT_SYMBOL(ion_import_dma_buf);
 
+struct ion_handle *ion_import_dma_buf_fd(struct ion_client *client, int fd)
+{
+	struct dma_buf *dmabuf;
+
+	dmabuf = dma_buf_get(fd);
+	if (IS_ERR(dmabuf))
+		return ERR_CAST(dmabuf);
+
+	return ion_import_dma_buf(client, dmabuf);
+}
+EXPORT_SYMBOL(ion_import_dma_buf_fd);
+
 static int ion_sync_for_device(struct ion_client *client, int fd)
 {
 	struct dma_buf *dmabuf;
@@ -1306,7 +1315,7 @@ static long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 	{
 		struct ion_handle *handle;
 
-		handle = ion_import_dma_buf(client, data.fd.fd);
+		handle = ion_import_dma_buf_fd(client, data.fd.fd);
 		if (IS_ERR(handle))
 			ret = PTR_ERR(handle);
 		else
diff --git a/drivers/staging/android/ion/ion.h b/drivers/staging/android/ion/ion.h
index b860c5f..a1331fc 100644
--- a/drivers/staging/android/ion/ion.h
+++ b/drivers/staging/android/ion/ion.h
@@ -192,14 +192,26 @@ struct dma_buf *ion_share_dma_buf(struct ion_client *client,
 int ion_share_dma_buf_fd(struct ion_client *client, struct ion_handle *handle);
 
 /**
- * ion_import_dma_buf() - given an dma-buf fd from the ion exporter get handle
+ * ion_import_dma_buf() - get ion_handle from dma-buf
+ * @client:	the client
+ * @dmabuf:	the dma-buf
+ *
+ * Get the ion_buffer associated with the dma-buf and return the ion_handle.
+ * If no ion_handle exists for this buffer, return newly created ion_handle.
+ * If dma-buf from another exporter is passed, return ERR_PTR(-EINVAL)
+ */
+struct ion_handle *ion_import_dma_buf(struct ion_client *client,
+				      struct dma_buf *dmabuf);
+
+/**
+ * ion_import_dma_buf_fd() - given a dma-buf fd from the ion exporter get handle
  * @client:	the client
  * @fd:		the dma-buf fd
  *
- * Given an dma-buf fd that was allocated through ion via ion_share_dma_buf,
- * import that fd and return a handle representing it.  If a dma-buf from
+ * Given an dma-buf fd that was allocated through ion via ion_share_dma_buf_fd,
+ * import that fd and return a handle representing it. If a dma-buf from
  * another exporter is passed in this function will return ERR_PTR(-EINVAL)
  */
-struct ion_handle *ion_import_dma_buf(struct ion_client *client, int fd);
+struct ion_handle *ion_import_dma_buf_fd(struct ion_client *client, int fd);
 
 #endif /* _LINUX_ION_H */
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH] staging/ion: Add support to get ion handle from dma buf
  2016-01-05 13:03 [PATCH] staging/ion: Add support to get ion handle from dma buf Rohit kumar
@ 2016-01-05 18:12 ` Laura Abbott
  2016-01-06  5:25   ` Rohit
  2016-01-06  7:11 ` [PATCHv2 1/1] " Rohit kumar
  2016-01-12  4:01 ` [PATCHv3 " Rohit kumar
  2 siblings, 1 reply; 15+ messages in thread
From: Laura Abbott @ 2016-01-05 18:12 UTC (permalink / raw)
  To: Rohit kumar, gregkh, arve, riandrews, dan.carpenter, gioh.kim,
	sumit.semwal, mitchelh, paul.gortmaker, linux, shawn.lin, sriram,
	devel, linux-kernel, pintu.k, vishnu.ps
  Cc: sreenathd, pintu_agarwal, me.rohit, cpgs

On 01/05/2016 05:03 AM, Rohit kumar wrote:
> Currently we can only import dma buf fd's to get ion_handle.
> Adding support to import dma buf handles to support kernel
> specific use cases.
>
> Signed-off-by: Rohit kumar <rohit.kr@samsung.com>
> ---
> Currently, ION is the memory manager for graphics in android. However,
> in other linux platforms such as Tizen, DRM-GEM is used for buffer
> management for graphics. It has gem_handle corresponding to a buffer
> and uses gem_name for sharing the buffer with other processes. However,
> it also uses dma_buf fd for 3d operations. For wayland, there are
> multiple calls for gem_handle to dma_buf fd conversion. So, we store
> dma_buf associated with buffer. But, there is no api for getting
> ion_handle from dma_buf. This patch exposes api to retrieve the ion
> handle from dma_buf for similar use cases. With this patch, we can
> integrate ION within DRM-GEM for buffer management and dma_buf sharing.
>

Is this the same patch that was sent on 12/29? In general it's best to
wait a bit longer before resending, especially with lots of people
being off for the holidays. Please also tag your patch with [RESEND]
so it's easier to tell that this is the same patch being sent again.

This is also a good explanation that should be included in the commit
text as well. It gives a much more thorough explanation why this
API is needed. The substance of the patch looks okay to me.

Thanks,
Laura

>   drivers/staging/android/ion/ion.c |   21 +++++++++++++++------
>   drivers/staging/android/ion/ion.h |   20 ++++++++++++++++----
>   2 files changed, 31 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
> index e237e9f..5509716 100644
> --- a/drivers/staging/android/ion/ion.c
> +++ b/drivers/staging/android/ion/ion.c
> @@ -1151,16 +1151,13 @@ int ion_share_dma_buf_fd(struct ion_client *client, struct ion_handle *handle)
>   }
>   EXPORT_SYMBOL(ion_share_dma_buf_fd);
>
> -struct ion_handle *ion_import_dma_buf(struct ion_client *client, int fd)
> +struct ion_handle *ion_import_dma_buf(struct ion_client *client,
> +				      struct dma_buf *dmabuf)
>   {
> -	struct dma_buf *dmabuf;
>   	struct ion_buffer *buffer;
>   	struct ion_handle *handle;
>   	int ret;
>
> -	dmabuf = dma_buf_get(fd);
> -	if (IS_ERR(dmabuf))
> -		return ERR_CAST(dmabuf);
>   	/* if this memory came from ion */
>
>   	if (dmabuf->ops != &dma_buf_ops) {
> @@ -1199,6 +1196,18 @@ end:
>   }
>   EXPORT_SYMBOL(ion_import_dma_buf);
>
> +struct ion_handle *ion_import_dma_buf_fd(struct ion_client *client, int fd)
> +{
> +	struct dma_buf *dmabuf;
> +
> +	dmabuf = dma_buf_get(fd);
> +	if (IS_ERR(dmabuf))
> +		return ERR_CAST(dmabuf);
> +
> +	return ion_import_dma_buf(client, dmabuf);
> +}
> +EXPORT_SYMBOL(ion_import_dma_buf_fd);
> +
>   static int ion_sync_for_device(struct ion_client *client, int fd)
>   {
>   	struct dma_buf *dmabuf;
> @@ -1306,7 +1315,7 @@ static long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
>   	{
>   		struct ion_handle *handle;
>
> -		handle = ion_import_dma_buf(client, data.fd.fd);
> +		handle = ion_import_dma_buf_fd(client, data.fd.fd);
>   		if (IS_ERR(handle))
>   			ret = PTR_ERR(handle);
>   		else
> diff --git a/drivers/staging/android/ion/ion.h b/drivers/staging/android/ion/ion.h
> index b860c5f..a1331fc 100644
> --- a/drivers/staging/android/ion/ion.h
> +++ b/drivers/staging/android/ion/ion.h
> @@ -192,14 +192,26 @@ struct dma_buf *ion_share_dma_buf(struct ion_client *client,
>   int ion_share_dma_buf_fd(struct ion_client *client, struct ion_handle *handle);
>
>   /**
> - * ion_import_dma_buf() - given an dma-buf fd from the ion exporter get handle
> + * ion_import_dma_buf() - get ion_handle from dma-buf
> + * @client:	the client
> + * @dmabuf:	the dma-buf
> + *
> + * Get the ion_buffer associated with the dma-buf and return the ion_handle.
> + * If no ion_handle exists for this buffer, return newly created ion_handle.
> + * If dma-buf from another exporter is passed, return ERR_PTR(-EINVAL)
> + */
> +struct ion_handle *ion_import_dma_buf(struct ion_client *client,
> +				      struct dma_buf *dmabuf);
> +
> +/**
> + * ion_import_dma_buf_fd() - given a dma-buf fd from the ion exporter get handle
>    * @client:	the client
>    * @fd:		the dma-buf fd
>    *
> - * Given an dma-buf fd that was allocated through ion via ion_share_dma_buf,
> - * import that fd and return a handle representing it.  If a dma-buf from
> + * Given an dma-buf fd that was allocated through ion via ion_share_dma_buf_fd,
> + * import that fd and return a handle representing it. If a dma-buf from
>    * another exporter is passed in this function will return ERR_PTR(-EINVAL)
>    */
> -struct ion_handle *ion_import_dma_buf(struct ion_client *client, int fd);
> +struct ion_handle *ion_import_dma_buf_fd(struct ion_client *client, int fd);
>
>   #endif /* _LINUX_ION_H */
>


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] staging/ion: Add support to get ion handle from dma buf
  2016-01-05 18:12 ` Laura Abbott
@ 2016-01-06  5:25   ` Rohit
  2016-01-06  9:06     ` Dan Carpenter
  0 siblings, 1 reply; 15+ messages in thread
From: Rohit @ 2016-01-06  5:25 UTC (permalink / raw)
  To: Laura Abbott, gregkh, arve, riandrews, dan.carpenter, gioh.kim,
	sumit.semwal, mitchelh, paul.gortmaker, linux, shawn.lin, sriram,
	devel, linux-kernel, pintu.k, vishnu.ps
  Cc: sreenathd, pintu_agarwal, me.rohit, cpgs

Sorry to resend the patch without [RESEND] tag. Actually I had missed
to add  devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org in
mail last time.

I will update the commit message with the explanation and send the
PATCHv2 soon.

Thanks,
Rohit

On Tue, 05 Jan 2016 10:12:39 -0800
Laura Abbott <labbott@redhat.com> wrote:

> On 01/05/2016 05:03 AM, Rohit kumar wrote:
> > Currently we can only import dma buf fd's to get ion_handle.
> > Adding support to import dma buf handles to support kernel
> > specific use cases.
> >
> > Signed-off-by: Rohit kumar <rohit.kr@samsung.com>
> > ---
> > Currently, ION is the memory manager for graphics in android.
> > However, in other linux platforms such as Tizen, DRM-GEM is used
> > for buffer management for graphics. It has gem_handle corresponding
> > to a buffer and uses gem_name for sharing the buffer with other
> > processes. However, it also uses dma_buf fd for 3d operations. For
> > wayland, there are multiple calls for gem_handle to dma_buf fd
> > conversion. So, we store dma_buf associated with buffer. But, there
> > is no api for getting ion_handle from dma_buf. This patch exposes
> > api to retrieve the ion handle from dma_buf for similar use cases.
> > With this patch, we can integrate ION within DRM-GEM for buffer
> > management and dma_buf sharing.
> >
> 
> Is this the same patch that was sent on 12/29? In general it's best to
> wait a bit longer before resending, especially with lots of people
> being off for the holidays. Please also tag your patch with [RESEND]
> so it's easier to tell that this is the same patch being sent again.
> 
> This is also a good explanation that should be included in the commit
> text as well. It gives a much more thorough explanation why this
> API is needed. The substance of the patch looks okay to me.
> 
> Thanks,
> Laura
> 
> >   drivers/staging/android/ion/ion.c |   21 +++++++++++++++------
> >   drivers/staging/android/ion/ion.h |   20 ++++++++++++++++----
> >   2 files changed, 31 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/staging/android/ion/ion.c
> > b/drivers/staging/android/ion/ion.c index e237e9f..5509716 100644
> > --- a/drivers/staging/android/ion/ion.c
> > +++ b/drivers/staging/android/ion/ion.c
> > @@ -1151,16 +1151,13 @@ int ion_share_dma_buf_fd(struct ion_client
> > *client, struct ion_handle *handle) }
> >   EXPORT_SYMBOL(ion_share_dma_buf_fd);
> >
> > -struct ion_handle *ion_import_dma_buf(struct ion_client *client,
> > int fd) +struct ion_handle *ion_import_dma_buf(struct ion_client
> > *client,
> > +				      struct dma_buf *dmabuf)
> >   {
> > -	struct dma_buf *dmabuf;
> >   	struct ion_buffer *buffer;
> >   	struct ion_handle *handle;
> >   	int ret;
> >
> > -	dmabuf = dma_buf_get(fd);
> > -	if (IS_ERR(dmabuf))
> > -		return ERR_CAST(dmabuf);
> >   	/* if this memory came from ion */
> >
> >   	if (dmabuf->ops != &dma_buf_ops) {
> > @@ -1199,6 +1196,18 @@ end:
> >   }
> >   EXPORT_SYMBOL(ion_import_dma_buf);
> >
> > +struct ion_handle *ion_import_dma_buf_fd(struct ion_client
> > *client, int fd) +{
> > +	struct dma_buf *dmabuf;
> > +
> > +	dmabuf = dma_buf_get(fd);
> > +	if (IS_ERR(dmabuf))
> > +		return ERR_CAST(dmabuf);
> > +
> > +	return ion_import_dma_buf(client, dmabuf);
> > +}
> > +EXPORT_SYMBOL(ion_import_dma_buf_fd);
> > +
> >   static int ion_sync_for_device(struct ion_client *client, int fd)
> >   {
> >   	struct dma_buf *dmabuf;
> > @@ -1306,7 +1315,7 @@ static long ion_ioctl(struct file *filp,
> > unsigned int cmd, unsigned long arg) {
> >   		struct ion_handle *handle;
> >
> > -		handle = ion_import_dma_buf(client, data.fd.fd);
> > +		handle = ion_import_dma_buf_fd(client, data.fd.fd);
> >   		if (IS_ERR(handle))
> >   			ret = PTR_ERR(handle);
> >   		else
> > diff --git a/drivers/staging/android/ion/ion.h
> > b/drivers/staging/android/ion/ion.h index b860c5f..a1331fc 100644
> > --- a/drivers/staging/android/ion/ion.h
> > +++ b/drivers/staging/android/ion/ion.h
> > @@ -192,14 +192,26 @@ struct dma_buf *ion_share_dma_buf(struct
> > ion_client *client, int ion_share_dma_buf_fd(struct ion_client
> > *client, struct ion_handle *handle);
> >
> >   /**
> > - * ion_import_dma_buf() - given an dma-buf fd from the ion
> > exporter get handle
> > + * ion_import_dma_buf() - get ion_handle from dma-buf
> > + * @client:	the client
> > + * @dmabuf:	the dma-buf
> > + *
> > + * Get the ion_buffer associated with the dma-buf and return the
> > ion_handle.
> > + * If no ion_handle exists for this buffer, return newly created
> > ion_handle.
> > + * If dma-buf from another exporter is passed, return
> > ERR_PTR(-EINVAL)
> > + */
> > +struct ion_handle *ion_import_dma_buf(struct ion_client *client,
> > +				      struct dma_buf *dmabuf);
> > +
> > +/**
> > + * ion_import_dma_buf_fd() - given a dma-buf fd from the ion
> > exporter get handle
> >    * @client:	the client
> >    * @fd:		the dma-buf fd
> >    *
> > - * Given an dma-buf fd that was allocated through ion via
> > ion_share_dma_buf,
> > - * import that fd and return a handle representing it.  If a
> > dma-buf from
> > + * Given an dma-buf fd that was allocated through ion via
> > ion_share_dma_buf_fd,
> > + * import that fd and return a handle representing it. If a
> > dma-buf from
> >    * another exporter is passed in this function will return
> > ERR_PTR(-EINVAL) */
> > -struct ion_handle *ion_import_dma_buf(struct ion_client *client,
> > int fd); +struct ion_handle *ion_import_dma_buf_fd(struct
> > ion_client *client, int fd);
> >
> >   #endif /* _LINUX_ION_H */
> >
> 
> 


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCHv2 1/1] staging/ion: Add support to get ion handle from dma buf
  2016-01-05 13:03 [PATCH] staging/ion: Add support to get ion handle from dma buf Rohit kumar
  2016-01-05 18:12 ` Laura Abbott
@ 2016-01-06  7:11 ` Rohit kumar
  2016-01-06 18:26   ` Laura Abbott
  2016-01-07 14:13   ` Sumit Semwal
  2016-01-12  4:01 ` [PATCHv3 " Rohit kumar
  2 siblings, 2 replies; 15+ messages in thread
From: Rohit kumar @ 2016-01-06  7:11 UTC (permalink / raw)
  To: gregkh, arve, riandrews, labbott, dan.carpenter, gioh.kim,
	sumit.semwal, mitchelh, paul.gortmaker, linux, shawn.lin, sriram,
	devel, linux-kernel, pintu.k, rohit.kr, vishnu.ps
  Cc: sreenathd, pintu_agarwal, me.rohit, cpgs

Currently we can only import dma buf fd's to get ion_handle.
Adding support to import dma buf handles to support kernel
specific use cases.

An example use case is in linux platforms such as Tizen, in which
DRM-GEM is used for buffer management for graphics. It has gem_handle
corresponding to a buffer and uses gem_name for sharing the buffer
with other processes. However,it also uses dma_buf fd for 3d operations.
For wayland, there are multiple calls for gem_handle to dma_buf fd
conversion. So, we store dma_buf associated with buffer. But, there is
no api for getting ion_handle from dma_buf. This patch exposes api to
retrieve the ion handle from dma_buf for similar use cases. With this
patch, we can integrate ION within DRM-GEM for buffer management and
dma_buf sharing.

Signed-off-by: Rohit kumar <rohit.kr@samsung.com>
---
v2: Updated commit message with use case explanation, as suggested by
    Laura Abbott<labbott@redhat.com>

 drivers/staging/android/ion/ion.c |   21 +++++++++++++++------
 drivers/staging/android/ion/ion.h |   20 ++++++++++++++++----
 2 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index e237e9f..5509716 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -1151,16 +1151,13 @@ int ion_share_dma_buf_fd(struct ion_client *client, struct ion_handle *handle)
 }
 EXPORT_SYMBOL(ion_share_dma_buf_fd);
 
-struct ion_handle *ion_import_dma_buf(struct ion_client *client, int fd)
+struct ion_handle *ion_import_dma_buf(struct ion_client *client,
+				      struct dma_buf *dmabuf)
 {
-	struct dma_buf *dmabuf;
 	struct ion_buffer *buffer;
 	struct ion_handle *handle;
 	int ret;
 
-	dmabuf = dma_buf_get(fd);
-	if (IS_ERR(dmabuf))
-		return ERR_CAST(dmabuf);
 	/* if this memory came from ion */
 
 	if (dmabuf->ops != &dma_buf_ops) {
@@ -1199,6 +1196,18 @@ end:
 }
 EXPORT_SYMBOL(ion_import_dma_buf);
 
+struct ion_handle *ion_import_dma_buf_fd(struct ion_client *client, int fd)
+{
+	struct dma_buf *dmabuf;
+
+	dmabuf = dma_buf_get(fd);
+	if (IS_ERR(dmabuf))
+		return ERR_CAST(dmabuf);
+
+	return ion_import_dma_buf(client, dmabuf);
+}
+EXPORT_SYMBOL(ion_import_dma_buf_fd);
+
 static int ion_sync_for_device(struct ion_client *client, int fd)
 {
 	struct dma_buf *dmabuf;
@@ -1306,7 +1315,7 @@ static long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 	{
 		struct ion_handle *handle;
 
-		handle = ion_import_dma_buf(client, data.fd.fd);
+		handle = ion_import_dma_buf_fd(client, data.fd.fd);
 		if (IS_ERR(handle))
 			ret = PTR_ERR(handle);
 		else
diff --git a/drivers/staging/android/ion/ion.h b/drivers/staging/android/ion/ion.h
index b860c5f..a1331fc 100644
--- a/drivers/staging/android/ion/ion.h
+++ b/drivers/staging/android/ion/ion.h
@@ -192,14 +192,26 @@ struct dma_buf *ion_share_dma_buf(struct ion_client *client,
 int ion_share_dma_buf_fd(struct ion_client *client, struct ion_handle *handle);
 
 /**
- * ion_import_dma_buf() - given an dma-buf fd from the ion exporter get handle
+ * ion_import_dma_buf() - get ion_handle from dma-buf
+ * @client:	the client
+ * @dmabuf:	the dma-buf
+ *
+ * Get the ion_buffer associated with the dma-buf and return the ion_handle.
+ * If no ion_handle exists for this buffer, return newly created ion_handle.
+ * If dma-buf from another exporter is passed, return ERR_PTR(-EINVAL)
+ */
+struct ion_handle *ion_import_dma_buf(struct ion_client *client,
+				      struct dma_buf *dmabuf);
+
+/**
+ * ion_import_dma_buf_fd() - given a dma-buf fd from the ion exporter get handle
  * @client:	the client
  * @fd:		the dma-buf fd
  *
- * Given an dma-buf fd that was allocated through ion via ion_share_dma_buf,
- * import that fd and return a handle representing it.  If a dma-buf from
+ * Given an dma-buf fd that was allocated through ion via ion_share_dma_buf_fd,
+ * import that fd and return a handle representing it. If a dma-buf from
  * another exporter is passed in this function will return ERR_PTR(-EINVAL)
  */
-struct ion_handle *ion_import_dma_buf(struct ion_client *client, int fd);
+struct ion_handle *ion_import_dma_buf_fd(struct ion_client *client, int fd);
 
 #endif /* _LINUX_ION_H */
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH] staging/ion: Add support to get ion handle from dma buf
  2016-01-06  5:25   ` Rohit
@ 2016-01-06  9:06     ` Dan Carpenter
  2016-01-06 18:21       ` Linus Torvalds
  2016-01-06 21:38       ` Jonathan Corbet
  0 siblings, 2 replies; 15+ messages in thread
From: Dan Carpenter @ 2016-01-06  9:06 UTC (permalink / raw)
  To: Rohit
  Cc: Laura Abbott, gregkh, arve, riandrews, gioh.kim, sumit.semwal,
	mitchelh, paul.gortmaker, linux, shawn.lin, sriram, devel,
	linux-kernel, pintu.k, vishnu.ps, sreenathd, pintu_agarwal, cpgs,
	me.rohit

It's not really necessary to CC linux-kernel.  No one reads it.
I only send patches there when there isn't another public mailing
list available.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] staging/ion: Add support to get ion handle from dma buf
  2016-01-06  9:06     ` Dan Carpenter
@ 2016-01-06 18:21       ` Linus Torvalds
  2016-01-06 18:24         ` Al Viro
  2016-01-06 21:38       ` Jonathan Corbet
  1 sibling, 1 reply; 15+ messages in thread
From: Linus Torvalds @ 2016-01-06 18:21 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Rohit, Laura Abbott, Greg Kroah-Hartman,
	Arve Hjønnevåg, riandrews, gioh.kim, Sumit Semwal,
	mitchelh, Paul Gortmaker, Rasmus Villemoes, shawn.lin, sriram,
	Staging subsystem List, Linux Kernel Mailing List, pintu.k,
	vishnu.ps, sreenathd, pintu_agarwal, cpgs, me.rohit

On Wed, Jan 6, 2016 at 1:06 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> It's not really necessary to CC linux-kernel.  No one reads it.
> I only send patches there when there isn't another public mailing
> list available.

Actually, cc'ing lkml is still often a good idea, because it's a great
archiving point.

I know lots o people (and I am one) who are *not* on random mailing
lists that discuss particular subsystems, but that get lkml as an
auto-archived thing. Then, when cc'd, you see the back story - in a
way that you do *not* see with the random mailing list that was
specific to a particular subsystem.

There are also tools like patchworks that follow mailing lists - and
yes, it follows many different sublists, but not necessarily all.

Don't get me wrong: lkml is seldom - if ever - the _primary_ list. But
I would violently disagree with some kind of blanket "not really
necessary to CC linux-kernel" statement. It's still very useful
indeed, and it doesn't hurt to cc it for valid patches.

              Linus

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] staging/ion: Add support to get ion handle from dma buf
  2016-01-06 18:21       ` Linus Torvalds
@ 2016-01-06 18:24         ` Al Viro
  0 siblings, 0 replies; 15+ messages in thread
From: Al Viro @ 2016-01-06 18:24 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Dan Carpenter, Rohit, Laura Abbott, Greg Kroah-Hartman,
	Arve Hjønnevåg, riandrews, gioh.kim, Sumit Semwal,
	mitchelh, Paul Gortmaker, Rasmus Villemoes, shawn.lin, sriram,
	Staging subsystem List, Linux Kernel Mailing List, pintu.k,
	vishnu.ps, sreenathd, pintu_agarwal, cpgs, me.rohit

On Wed, Jan 06, 2016 at 10:21:33AM -0800, Linus Torvalds wrote:
> On Wed, Jan 6, 2016 at 1:06 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > It's not really necessary to CC linux-kernel.  No one reads it.

Some of us still do.

> > I only send patches there when there isn't another public mailing
> > list available.
> 
> Actually, cc'ing lkml is still often a good idea, because it's a great
> archiving point.

*nod*

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCHv2 1/1] staging/ion: Add support to get ion handle from dma buf
  2016-01-06  7:11 ` [PATCHv2 1/1] " Rohit kumar
@ 2016-01-06 18:26   ` Laura Abbott
  2016-01-07 14:13   ` Sumit Semwal
  1 sibling, 0 replies; 15+ messages in thread
From: Laura Abbott @ 2016-01-06 18:26 UTC (permalink / raw)
  To: Rohit kumar, gregkh, arve, riandrews, dan.carpenter, gioh.kim,
	sumit.semwal, mitchelh, paul.gortmaker, linux, shawn.lin, sriram,
	devel, linux-kernel, pintu.k, vishnu.ps
  Cc: sreenathd, pintu_agarwal, me.rohit, cpgs

On 01/05/2016 11:11 PM, Rohit kumar wrote:
> Currently we can only import dma buf fd's to get ion_handle.
> Adding support to import dma buf handles to support kernel
> specific use cases.
>
> An example use case is in linux platforms such as Tizen, in which
> DRM-GEM is used for buffer management for graphics. It has gem_handle
> corresponding to a buffer and uses gem_name for sharing the buffer
> with other processes. However,it also uses dma_buf fd for 3d operations.
> For wayland, there are multiple calls for gem_handle to dma_buf fd
> conversion. So, we store dma_buf associated with buffer. But, there is
> no api for getting ion_handle from dma_buf. This patch exposes api to
> retrieve the ion handle from dma_buf for similar use cases. With this
> patch, we can integrate ION within DRM-GEM for buffer management and
> dma_buf sharing.
>
> Signed-off-by: Rohit kumar <rohit.kr@samsung.com>

Reviewed-by: Laura Abbott <labbott@redhat.com>

> ---
> v2: Updated commit message with use case explanation, as suggested by
>      Laura Abbott<labbott@redhat.com>
>
>   drivers/staging/android/ion/ion.c |   21 +++++++++++++++------
>   drivers/staging/android/ion/ion.h |   20 ++++++++++++++++----
>   2 files changed, 31 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
> index e237e9f..5509716 100644
> --- a/drivers/staging/android/ion/ion.c
> +++ b/drivers/staging/android/ion/ion.c
> @@ -1151,16 +1151,13 @@ int ion_share_dma_buf_fd(struct ion_client *client, struct ion_handle *handle)
>   }
>   EXPORT_SYMBOL(ion_share_dma_buf_fd);
>
> -struct ion_handle *ion_import_dma_buf(struct ion_client *client, int fd)
> +struct ion_handle *ion_import_dma_buf(struct ion_client *client,
> +				      struct dma_buf *dmabuf)
>   {
> -	struct dma_buf *dmabuf;
>   	struct ion_buffer *buffer;
>   	struct ion_handle *handle;
>   	int ret;
>
> -	dmabuf = dma_buf_get(fd);
> -	if (IS_ERR(dmabuf))
> -		return ERR_CAST(dmabuf);
>   	/* if this memory came from ion */
>
>   	if (dmabuf->ops != &dma_buf_ops) {
> @@ -1199,6 +1196,18 @@ end:
>   }
>   EXPORT_SYMBOL(ion_import_dma_buf);
>
> +struct ion_handle *ion_import_dma_buf_fd(struct ion_client *client, int fd)
> +{
> +	struct dma_buf *dmabuf;
> +
> +	dmabuf = dma_buf_get(fd);
> +	if (IS_ERR(dmabuf))
> +		return ERR_CAST(dmabuf);
> +
> +	return ion_import_dma_buf(client, dmabuf);
> +}
> +EXPORT_SYMBOL(ion_import_dma_buf_fd);
> +
>   static int ion_sync_for_device(struct ion_client *client, int fd)
>   {
>   	struct dma_buf *dmabuf;
> @@ -1306,7 +1315,7 @@ static long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
>   	{
>   		struct ion_handle *handle;
>
> -		handle = ion_import_dma_buf(client, data.fd.fd);
> +		handle = ion_import_dma_buf_fd(client, data.fd.fd);
>   		if (IS_ERR(handle))
>   			ret = PTR_ERR(handle);
>   		else
> diff --git a/drivers/staging/android/ion/ion.h b/drivers/staging/android/ion/ion.h
> index b860c5f..a1331fc 100644
> --- a/drivers/staging/android/ion/ion.h
> +++ b/drivers/staging/android/ion/ion.h
> @@ -192,14 +192,26 @@ struct dma_buf *ion_share_dma_buf(struct ion_client *client,
>   int ion_share_dma_buf_fd(struct ion_client *client, struct ion_handle *handle);
>
>   /**
> - * ion_import_dma_buf() - given an dma-buf fd from the ion exporter get handle
> + * ion_import_dma_buf() - get ion_handle from dma-buf
> + * @client:	the client
> + * @dmabuf:	the dma-buf
> + *
> + * Get the ion_buffer associated with the dma-buf and return the ion_handle.
> + * If no ion_handle exists for this buffer, return newly created ion_handle.
> + * If dma-buf from another exporter is passed, return ERR_PTR(-EINVAL)
> + */
> +struct ion_handle *ion_import_dma_buf(struct ion_client *client,
> +				      struct dma_buf *dmabuf);
> +
> +/**
> + * ion_import_dma_buf_fd() - given a dma-buf fd from the ion exporter get handle
>    * @client:	the client
>    * @fd:		the dma-buf fd
>    *
> - * Given an dma-buf fd that was allocated through ion via ion_share_dma_buf,
> - * import that fd and return a handle representing it.  If a dma-buf from
> + * Given an dma-buf fd that was allocated through ion via ion_share_dma_buf_fd,
> + * import that fd and return a handle representing it. If a dma-buf from
>    * another exporter is passed in this function will return ERR_PTR(-EINVAL)
>    */
> -struct ion_handle *ion_import_dma_buf(struct ion_client *client, int fd);
> +struct ion_handle *ion_import_dma_buf_fd(struct ion_client *client, int fd);
>
>   #endif /* _LINUX_ION_H */
>


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] staging/ion: Add support to get ion handle from dma buf
  2016-01-06  9:06     ` Dan Carpenter
  2016-01-06 18:21       ` Linus Torvalds
@ 2016-01-06 21:38       ` Jonathan Corbet
  2016-01-07  8:57         ` Dan Carpenter
  1 sibling, 1 reply; 15+ messages in thread
From: Jonathan Corbet @ 2016-01-06 21:38 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Rohit, Laura Abbott, gregkh, arve, riandrews, gioh.kim,
	sumit.semwal, mitchelh, paul.gortmaker, linux, shawn.lin, sriram,
	devel, linux-kernel, pintu.k, vishnu.ps, sreenathd,
	pintu_agarwal, cpgs, me.rohit

On Wed, 6 Jan 2016 12:06:22 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:

> It's not really necessary to CC linux-kernel.  No one reads it.

I have to take issue with this too; more of us read it than you might
think.  The fact that we're probably all crazy doesn't really figure into
it.  Think of linux-kernel as the blockchain of kernel development; it's
a messy thing that takes a lot of resources to maintain (and keep up
with), but when you need to see what happened (or is happening) it's
invaluable.

jon

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] staging/ion: Add support to get ion handle from dma buf
  2016-01-06 21:38       ` Jonathan Corbet
@ 2016-01-07  8:57         ` Dan Carpenter
  2016-01-09  4:44           ` Sudip Mukherjee
  0 siblings, 1 reply; 15+ messages in thread
From: Dan Carpenter @ 2016-01-07  8:57 UTC (permalink / raw)
  To: Jonathan Corbet
  Cc: devel, pintu.k, sriram, linux, gregkh, shawn.lin, Rohit,
	riandrews, linux-kernel, paul.gortmaker, arve, pintu_agarwal,
	cpgs, gioh.kim, me.rohit, sreenathd, sumit.semwal, vishnu.ps

Hm...  Perhaps I should be CC'ing LKML more often.  What's the rule on
this, should I just send bugfixes to LKML and whitespace changes to only
subsystem list?

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCHv2 1/1] staging/ion: Add support to get ion handle from dma buf
  2016-01-06  7:11 ` [PATCHv2 1/1] " Rohit kumar
  2016-01-06 18:26   ` Laura Abbott
@ 2016-01-07 14:13   ` Sumit Semwal
  2016-01-08  7:51     ` Rohit
  1 sibling, 1 reply; 15+ messages in thread
From: Sumit Semwal @ 2016-01-07 14:13 UTC (permalink / raw)
  To: Rohit kumar
  Cc: Greg Kroah-Hartman, Arve Hj�nnev�g, riandrews,
	Laura Abbott, Dan Carpenter, 기오김,
	mitchelh, paul.gortmaker, linux, shawn.lin, sriram, devel, LKML,
	pintu.k, vishnu.ps, sreenathd, pintu_agarwal, me.rohit, cpgs

Hi Rohit,

On 6 January 2016 at 12:41, Rohit kumar <rohit.kr@samsung.com> wrote:
> Currently we can only import dma buf fd's to get ion_handle.
> Adding support to import dma buf handles to support kernel
> specific use cases.
>
> An example use case is in linux platforms such as Tizen, in which
> DRM-GEM is used for buffer management for graphics. It has gem_handle
> corresponding to a buffer and uses gem_name for sharing the buffer
> with other processes. However,it also uses dma_buf fd for 3d operations.
> For wayland, there are multiple calls for gem_handle to dma_buf fd
> conversion. So, we store dma_buf associated with buffer. But, there is
> no api for getting ion_handle from dma_buf. This patch exposes api to
> retrieve the ion handle from dma_buf for similar use cases. With this
> patch, we can integrate ION within DRM-GEM for buffer management and
> dma_buf sharing.
>
> Signed-off-by: Rohit kumar <rohit.kr@samsung.com>
> ---
> v2: Updated commit message with use case explanation, as suggested by
>     Laura Abbott<labbott@redhat.com>
>
Thanks for this patch.

In general it looks good to me, but perhaps you should add related ION
tests for this as well? Once you add that and share for review, feel
free to add
Reviewed-by: Sumit Semwal <sumit.semwal@linaro.org>

>  drivers/staging/android/ion/ion.c |   21 +++++++++++++++------
>  drivers/staging/android/ion/ion.h |   20 ++++++++++++++++----
>  2 files changed, 31 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
> index e237e9f..5509716 100644
> --- a/drivers/staging/android/ion/ion.c
> +++ b/drivers/staging/android/ion/ion.c
> @@ -1151,16 +1151,13 @@ int ion_share_dma_buf_fd(struct ion_client *client, struct ion_handle *handle)
>  }
>  EXPORT_SYMBOL(ion_share_dma_buf_fd);
>
> -struct ion_handle *ion_import_dma_buf(struct ion_client *client, int fd)
> +struct ion_handle *ion_import_dma_buf(struct ion_client *client,
> +                                     struct dma_buf *dmabuf)
>  {
> -       struct dma_buf *dmabuf;
>         struct ion_buffer *buffer;
>         struct ion_handle *handle;
>         int ret;
>
> -       dmabuf = dma_buf_get(fd);
> -       if (IS_ERR(dmabuf))
> -               return ERR_CAST(dmabuf);
>         /* if this memory came from ion */
>
>         if (dmabuf->ops != &dma_buf_ops) {
> @@ -1199,6 +1196,18 @@ end:
>  }
>  EXPORT_SYMBOL(ion_import_dma_buf);
>
> +struct ion_handle *ion_import_dma_buf_fd(struct ion_client *client, int fd)
> +{
> +       struct dma_buf *dmabuf;
> +
> +       dmabuf = dma_buf_get(fd);
> +       if (IS_ERR(dmabuf))
> +               return ERR_CAST(dmabuf);
> +
> +       return ion_import_dma_buf(client, dmabuf);
> +}
> +EXPORT_SYMBOL(ion_import_dma_buf_fd);
> +
>  static int ion_sync_for_device(struct ion_client *client, int fd)
>  {
>         struct dma_buf *dmabuf;
> @@ -1306,7 +1315,7 @@ static long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
>         {
>                 struct ion_handle *handle;
>
> -               handle = ion_import_dma_buf(client, data.fd.fd);
> +               handle = ion_import_dma_buf_fd(client, data.fd.fd);
>                 if (IS_ERR(handle))
>                         ret = PTR_ERR(handle);
>                 else
> diff --git a/drivers/staging/android/ion/ion.h b/drivers/staging/android/ion/ion.h
> index b860c5f..a1331fc 100644
> --- a/drivers/staging/android/ion/ion.h
> +++ b/drivers/staging/android/ion/ion.h
> @@ -192,14 +192,26 @@ struct dma_buf *ion_share_dma_buf(struct ion_client *client,
>  int ion_share_dma_buf_fd(struct ion_client *client, struct ion_handle *handle);
>
>  /**
> - * ion_import_dma_buf() - given an dma-buf fd from the ion exporter get handle
> + * ion_import_dma_buf() - get ion_handle from dma-buf
> + * @client:    the client
> + * @dmabuf:    the dma-buf
> + *
> + * Get the ion_buffer associated with the dma-buf and return the ion_handle.
> + * If no ion_handle exists for this buffer, return newly created ion_handle.
> + * If dma-buf from another exporter is passed, return ERR_PTR(-EINVAL)
> + */
> +struct ion_handle *ion_import_dma_buf(struct ion_client *client,
> +                                     struct dma_buf *dmabuf);
> +
> +/**
> + * ion_import_dma_buf_fd() - given a dma-buf fd from the ion exporter get handle
>   * @client:    the client
>   * @fd:                the dma-buf fd
>   *
> - * Given an dma-buf fd that was allocated through ion via ion_share_dma_buf,
> - * import that fd and return a handle representing it.  If a dma-buf from
> + * Given an dma-buf fd that was allocated through ion via ion_share_dma_buf_fd,
> + * import that fd and return a handle representing it. If a dma-buf from
>   * another exporter is passed in this function will return ERR_PTR(-EINVAL)
>   */
> -struct ion_handle *ion_import_dma_buf(struct ion_client *client, int fd);
> +struct ion_handle *ion_import_dma_buf_fd(struct ion_client *client, int fd);
>
>  #endif /* _LINUX_ION_H */
> --
> 1.7.9.5
>



-- 
Thanks and regards,

Sumit Semwal
Linaro Mobile Group - Kernel Team Lead
Linaro.org │ Open source software for ARM SoCs

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCHv2 1/1] staging/ion: Add support to get ion handle from dma buf
  2016-01-07 14:13   ` Sumit Semwal
@ 2016-01-08  7:51     ` Rohit
  0 siblings, 0 replies; 15+ messages in thread
From: Rohit @ 2016-01-08  7:51 UTC (permalink / raw)
  To: Sumit Semwal
  Cc: Greg Kroah-Hartman, Arve Hj�nnev�g, riandrews,
	Laura Abbott, Dan Carpenter, 기오김,
	mitchelh, paul.gortmaker, linux, shawn.lin, sriram, devel, LKML,
	pintu.k, vishnu.ps, sreenathd, pintu_agarwal, me.rohit, cpgs

Hi Sumit,

On Thu, 07 Jan 2016 19:43:09 +0530
Sumit Semwal <sumit.semwal@linaro.org> wrote:

> Hi Rohit,
> 
> On 6 January 2016 at 12:41, Rohit kumar <rohit.kr@samsung.com> wrote:
> > Currently we can only import dma buf fd's to get ion_handle.
> > Adding support to import dma buf handles to support kernel
> > specific use cases.
> >
> > An example use case is in linux platforms such as Tizen, in which
> > DRM-GEM is used for buffer management for graphics. It has
> > gem_handle corresponding to a buffer and uses gem_name for sharing
> > the buffer with other processes. However,it also uses dma_buf fd
> > for 3d operations. For wayland, there are multiple calls for
> > gem_handle to dma_buf fd conversion. So, we store dma_buf
> > associated with buffer. But, there is no api for getting ion_handle
> > from dma_buf. This patch exposes api to retrieve the ion handle
> > from dma_buf for similar use cases. With this patch, we can
> > integrate ION within DRM-GEM for buffer management and dma_buf
> > sharing.
> >
> > Signed-off-by: Rohit kumar <rohit.kr@samsung.com>
> > ---
> > v2: Updated commit message with use case explanation, as suggested
> > by Laura Abbott<labbott@redhat.com>
> >
> Thanks for this patch.
> 
> In general it looks good to me, but perhaps you should add related ION
> tests for this as well? Once you add that and share for review, feel
> free to add
Thanks for the suggestion. I would add related ION test and share for
review sooner.
> Reviewed-by: Sumit Semwal <sumit.semwal@linaro.org>
> 
> >  drivers/staging/android/ion/ion.c |   21 +++++++++++++++------
> >  drivers/staging/android/ion/ion.h |   20 ++++++++++++++++----
> >  2 files changed, 31 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/staging/android/ion/ion.c
> > b/drivers/staging/android/ion/ion.c index e237e9f..5509716 100644
> > --- a/drivers/staging/android/ion/ion.c
> > +++ b/drivers/staging/android/ion/ion.c
> > @@ -1151,16 +1151,13 @@ int ion_share_dma_buf_fd(struct ion_client
> > *client, struct ion_handle *handle) }
> >  EXPORT_SYMBOL(ion_share_dma_buf_fd);
> >
> > -struct ion_handle *ion_import_dma_buf(struct ion_client *client,
> > int fd) +struct ion_handle *ion_import_dma_buf(struct ion_client
> > *client,
> > +                                     struct dma_buf *dmabuf)
> >  {
> > -       struct dma_buf *dmabuf;
> >         struct ion_buffer *buffer;
> >         struct ion_handle *handle;
> >         int ret;
> >
> > -       dmabuf = dma_buf_get(fd);
> > -       if (IS_ERR(dmabuf))
> > -               return ERR_CAST(dmabuf);
> >         /* if this memory came from ion */
> >
> >         if (dmabuf->ops != &dma_buf_ops) {
> > @@ -1199,6 +1196,18 @@ end:
> >  }
> >  EXPORT_SYMBOL(ion_import_dma_buf);
> >
> > +struct ion_handle *ion_import_dma_buf_fd(struct ion_client
> > *client, int fd) +{
> > +       struct dma_buf *dmabuf;
> > +
> > +       dmabuf = dma_buf_get(fd);
> > +       if (IS_ERR(dmabuf))
> > +               return ERR_CAST(dmabuf);
> > +
> > +       return ion_import_dma_buf(client, dmabuf);
> > +}
> > +EXPORT_SYMBOL(ion_import_dma_buf_fd);
> > +
> >  static int ion_sync_for_device(struct ion_client *client, int fd)
> >  {
> >         struct dma_buf *dmabuf;
> > @@ -1306,7 +1315,7 @@ static long ion_ioctl(struct file *filp,
> > unsigned int cmd, unsigned long arg) {
> >                 struct ion_handle *handle;
> >
> > -               handle = ion_import_dma_buf(client, data.fd.fd);
> > +               handle = ion_import_dma_buf_fd(client, data.fd.fd);
> >                 if (IS_ERR(handle))
> >                         ret = PTR_ERR(handle);
> >                 else
> > diff --git a/drivers/staging/android/ion/ion.h
> > b/drivers/staging/android/ion/ion.h index b860c5f..a1331fc 100644
> > --- a/drivers/staging/android/ion/ion.h
> > +++ b/drivers/staging/android/ion/ion.h
> > @@ -192,14 +192,26 @@ struct dma_buf *ion_share_dma_buf(struct
> > ion_client *client, int ion_share_dma_buf_fd(struct ion_client
> > *client, struct ion_handle *handle);
> >
> >  /**
> > - * ion_import_dma_buf() - given an dma-buf fd from the ion
> > exporter get handle
> > + * ion_import_dma_buf() - get ion_handle from dma-buf
> > + * @client:    the client
> > + * @dmabuf:    the dma-buf
> > + *
> > + * Get the ion_buffer associated with the dma-buf and return the
> > ion_handle.
> > + * If no ion_handle exists for this buffer, return newly created
> > ion_handle.
> > + * If dma-buf from another exporter is passed, return
> > ERR_PTR(-EINVAL)
> > + */
> > +struct ion_handle *ion_import_dma_buf(struct ion_client *client,
> > +                                     struct dma_buf *dmabuf);
> > +
> > +/**
> > + * ion_import_dma_buf_fd() - given a dma-buf fd from the ion
> > exporter get handle
> >   * @client:    the client
> >   * @fd:                the dma-buf fd
> >   *
> > - * Given an dma-buf fd that was allocated through ion via
> > ion_share_dma_buf,
> > - * import that fd and return a handle representing it.  If a
> > dma-buf from
> > + * Given an dma-buf fd that was allocated through ion via
> > ion_share_dma_buf_fd,
> > + * import that fd and return a handle representing it. If a
> > dma-buf from
> >   * another exporter is passed in this function will return
> > ERR_PTR(-EINVAL) */
> > -struct ion_handle *ion_import_dma_buf(struct ion_client *client,
> > int fd); +struct ion_handle *ion_import_dma_buf_fd(struct
> > ion_client *client, int fd);
> >
> >  #endif /* _LINUX_ION_H */
> > --
> > 1.7.9.5
> >
> 
> 
> 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] staging/ion: Add support to get ion handle from dma buf
  2016-01-07  8:57         ` Dan Carpenter
@ 2016-01-09  4:44           ` Sudip Mukherjee
  0 siblings, 0 replies; 15+ messages in thread
From: Sudip Mukherjee @ 2016-01-09  4:44 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Jonathan Corbet, devel, pintu.k, me.rohit, paul.gortmaker,
	gregkh, shawn.lin, linux, riandrews, linux-kernel, Rohit, sriram,
	arve, cpgs, gioh.kim, sreenathd, pintu_agarwal, sumit.semwal,
	vishnu.ps

On Thu, Jan 07, 2016 at 11:57:34AM +0300, Dan Carpenter wrote:
> Hm...  Perhaps I should be CC'ing LKML more often.  What's the rule on
> this, should I just send bugfixes to LKML and whitespace changes to only
> subsystem list?

All my patches (whitespace, bugfix, build fail) always has CC to lkml.
Infact, I have setup an alias for that so that i don't have to add lkml
manually everytime.

sm = send-email --cc=linux-kernel@vger.kernel.org

regards
sudip

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCHv3 1/1] staging/ion: Add support to get ion handle from dma buf
  2016-01-05 13:03 [PATCH] staging/ion: Add support to get ion handle from dma buf Rohit kumar
  2016-01-05 18:12 ` Laura Abbott
  2016-01-06  7:11 ` [PATCHv2 1/1] " Rohit kumar
@ 2016-01-12  4:01 ` Rohit kumar
  2016-02-01  7:59   ` Rohit
  2 siblings, 1 reply; 15+ messages in thread
From: Rohit kumar @ 2016-01-12  4:01 UTC (permalink / raw)
  To: gregkh, arve, riandrews, labbott, dan.carpenter, gioh.kim,
	sumit.semwal, mitchelh, paul.gortmaker, linux, shawn.lin, sriram,
	devel, linux-kernel, pintu.k, rohit.kr, vishnu.ps
  Cc: sreenathd, pintu_agarwal, me.rohit, cpgs

Currently we can only import dma buf fd's to get ion_handle.
Adding support to import dma buf handles to support kernel
specific use cases.

An example use case is in linux platforms such as Tizen, in which
DRM-GEM is used for buffer management for graphics. It has gem_handle
corresponding to a buffer and uses gem_name for sharing the buffer
with other processes. However,it also uses dma_buf fd for 3d operations.
For wayland, there are multiple calls for gem_handle to dma_buf fd
conversion. So, we store dma_buf associated with buffer. But, there is
no api for getting ion_handle from dma_buf. This patch exposes api to
retrieve the ion handle from dma_buf for similar use cases. With this
patch, we can integrate ION within DRM-GEM for buffer management and
dma_buf sharing.

Signed-off-by: Rohit kumar <rohit.kr@samsung.com>
---
v2: Updated commit message with use case explanation, as suggested by
    Laura Abbott<labbott@redhat.com>
v3: Fixed dmabuf refcount issue in ion_import_dma_buf. dma_buf_put()
    was being called without dma_buf_get(), so moving it to
    ion_import_dma_buf_fd().

 drivers/staging/android/ion/ion.c |   26 ++++++++++++++++++--------
 drivers/staging/android/ion/ion.h |   20 ++++++++++++++++----
 2 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index e237e9f..7e86e18 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -1151,22 +1151,18 @@ int ion_share_dma_buf_fd(struct ion_client *client, struct ion_handle *handle)
 }
 EXPORT_SYMBOL(ion_share_dma_buf_fd);
 
-struct ion_handle *ion_import_dma_buf(struct ion_client *client, int fd)
+struct ion_handle *ion_import_dma_buf(struct ion_client *client,
+				      struct dma_buf *dmabuf)
 {
-	struct dma_buf *dmabuf;
 	struct ion_buffer *buffer;
 	struct ion_handle *handle;
 	int ret;
 
-	dmabuf = dma_buf_get(fd);
-	if (IS_ERR(dmabuf))
-		return ERR_CAST(dmabuf);
 	/* if this memory came from ion */
 
 	if (dmabuf->ops != &dma_buf_ops) {
 		pr_err("%s: can not import dmabuf from another exporter\n",
 		       __func__);
-		dma_buf_put(dmabuf);
 		return ERR_PTR(-EINVAL);
 	}
 	buffer = dmabuf->priv;
@@ -1194,11 +1190,25 @@ struct ion_handle *ion_import_dma_buf(struct ion_client *client, int fd)
 	}
 
 end:
-	dma_buf_put(dmabuf);
 	return handle;
 }
 EXPORT_SYMBOL(ion_import_dma_buf);
 
+struct ion_handle *ion_import_dma_buf_fd(struct ion_client *client, int fd)
+{
+	struct dma_buf *dmabuf;
+	struct ion_handle *handle;
+
+	dmabuf = dma_buf_get(fd);
+	if (IS_ERR(dmabuf))
+		return ERR_CAST(dmabuf);
+
+	handle = ion_import_dma_buf(client, dmabuf);
+	dma_buf_put(dmabuf);
+	return handle;
+}
+EXPORT_SYMBOL(ion_import_dma_buf_fd);
+
 static int ion_sync_for_device(struct ion_client *client, int fd)
 {
 	struct dma_buf *dmabuf;
@@ -1306,7 +1316,7 @@ static long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 	{
 		struct ion_handle *handle;
 
-		handle = ion_import_dma_buf(client, data.fd.fd);
+		handle = ion_import_dma_buf_fd(client, data.fd.fd);
 		if (IS_ERR(handle))
 			ret = PTR_ERR(handle);
 		else
diff --git a/drivers/staging/android/ion/ion.h b/drivers/staging/android/ion/ion.h
index b860c5f..a1331fc 100644
--- a/drivers/staging/android/ion/ion.h
+++ b/drivers/staging/android/ion/ion.h
@@ -192,14 +192,26 @@ struct dma_buf *ion_share_dma_buf(struct ion_client *client,
 int ion_share_dma_buf_fd(struct ion_client *client, struct ion_handle *handle);
 
 /**
- * ion_import_dma_buf() - given an dma-buf fd from the ion exporter get handle
+ * ion_import_dma_buf() - get ion_handle from dma-buf
+ * @client:	the client
+ * @dmabuf:	the dma-buf
+ *
+ * Get the ion_buffer associated with the dma-buf and return the ion_handle.
+ * If no ion_handle exists for this buffer, return newly created ion_handle.
+ * If dma-buf from another exporter is passed, return ERR_PTR(-EINVAL)
+ */
+struct ion_handle *ion_import_dma_buf(struct ion_client *client,
+				      struct dma_buf *dmabuf);
+
+/**
+ * ion_import_dma_buf_fd() - given a dma-buf fd from the ion exporter get handle
  * @client:	the client
  * @fd:		the dma-buf fd
  *
- * Given an dma-buf fd that was allocated through ion via ion_share_dma_buf,
- * import that fd and return a handle representing it.  If a dma-buf from
+ * Given an dma-buf fd that was allocated through ion via ion_share_dma_buf_fd,
+ * import that fd and return a handle representing it. If a dma-buf from
  * another exporter is passed in this function will return ERR_PTR(-EINVAL)
  */
-struct ion_handle *ion_import_dma_buf(struct ion_client *client, int fd);
+struct ion_handle *ion_import_dma_buf_fd(struct ion_client *client, int fd);
 
 #endif /* _LINUX_ION_H */
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCHv3 1/1] staging/ion: Add support to get ion handle from dma buf
  2016-01-12  4:01 ` [PATCHv3 " Rohit kumar
@ 2016-02-01  7:59   ` Rohit
  0 siblings, 0 replies; 15+ messages in thread
From: Rohit @ 2016-02-01  7:59 UTC (permalink / raw)
  To: Rohit kumar
  Cc: gregkh, arve, riandrews, labbott, dan.carpenter, gioh.kim,
	sumit.semwal, mitchelh, paul.gortmaker, linux, shawn.lin, sriram,
	devel, linux-kernel, pintu.k, vishnu.ps, sreenathd,
	pintu_agarwal, me.rohit, cpgs

Kindly review the patch. Patchv2 had refcount issue which is fixed here.

On Tue, 12 Jan 2016 09:31:46 +0530
Rohit kumar <rohit.kr@samsung.com> wrote:

> Currently we can only import dma buf fd's to get ion_handle.
> Adding support to import dma buf handles to support kernel
> specific use cases.
> 
> An example use case is in linux platforms such as Tizen, in which
> DRM-GEM is used for buffer management for graphics. It has gem_handle
> corresponding to a buffer and uses gem_name for sharing the buffer
> with other processes. However,it also uses dma_buf fd for 3d
> operations. For wayland, there are multiple calls for gem_handle to
> dma_buf fd conversion. So, we store dma_buf associated with buffer.
> But, there is no api for getting ion_handle from dma_buf. This patch
> exposes api to retrieve the ion handle from dma_buf for similar use
> cases. With this patch, we can integrate ION within DRM-GEM for
> buffer management and dma_buf sharing.
> 
> Signed-off-by: Rohit kumar <rohit.kr@samsung.com>
> ---
> v2: Updated commit message with use case explanation, as suggested by
>     Laura Abbott<labbott@redhat.com>
> v3: Fixed dmabuf refcount issue in ion_import_dma_buf. dma_buf_put()
>     was being called without dma_buf_get(), so moving it to
>     ion_import_dma_buf_fd().
> 
>  drivers/staging/android/ion/ion.c |   26 ++++++++++++++++++--------
>  drivers/staging/android/ion/ion.h |   20 ++++++++++++++++----
>  2 files changed, 34 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/staging/android/ion/ion.c
> b/drivers/staging/android/ion/ion.c index e237e9f..7e86e18 100644
> --- a/drivers/staging/android/ion/ion.c
> +++ b/drivers/staging/android/ion/ion.c
> @@ -1151,22 +1151,18 @@ int ion_share_dma_buf_fd(struct ion_client
> *client, struct ion_handle *handle) }
>  EXPORT_SYMBOL(ion_share_dma_buf_fd);
>  
> -struct ion_handle *ion_import_dma_buf(struct ion_client *client, int
> fd) +struct ion_handle *ion_import_dma_buf(struct ion_client *client,
> +				      struct dma_buf *dmabuf)
>  {
> -	struct dma_buf *dmabuf;
>  	struct ion_buffer *buffer;
>  	struct ion_handle *handle;
>  	int ret;
>  
> -	dmabuf = dma_buf_get(fd);
> -	if (IS_ERR(dmabuf))
> -		return ERR_CAST(dmabuf);
>  	/* if this memory came from ion */
>  
>  	if (dmabuf->ops != &dma_buf_ops) {
>  		pr_err("%s: can not import dmabuf from another
> exporter\n", __func__);
> -		dma_buf_put(dmabuf);
>  		return ERR_PTR(-EINVAL);
>  	}
>  	buffer = dmabuf->priv;
> @@ -1194,11 +1190,25 @@ struct ion_handle *ion_import_dma_buf(struct
> ion_client *client, int fd) }
>  
>  end:
> -	dma_buf_put(dmabuf);
>  	return handle;
>  }
>  EXPORT_SYMBOL(ion_import_dma_buf);
>  
> +struct ion_handle *ion_import_dma_buf_fd(struct ion_client *client,
> int fd) +{
> +	struct dma_buf *dmabuf;
> +	struct ion_handle *handle;
> +
> +	dmabuf = dma_buf_get(fd);
> +	if (IS_ERR(dmabuf))
> +		return ERR_CAST(dmabuf);
> +
> +	handle = ion_import_dma_buf(client, dmabuf);
> +	dma_buf_put(dmabuf);
> +	return handle;
> +}
> +EXPORT_SYMBOL(ion_import_dma_buf_fd);
> +
>  static int ion_sync_for_device(struct ion_client *client, int fd)
>  {
>  	struct dma_buf *dmabuf;
> @@ -1306,7 +1316,7 @@ static long ion_ioctl(struct file *filp,
> unsigned int cmd, unsigned long arg) {
>  		struct ion_handle *handle;
>  
> -		handle = ion_import_dma_buf(client, data.fd.fd);
> +		handle = ion_import_dma_buf_fd(client, data.fd.fd);
>  		if (IS_ERR(handle))
>  			ret = PTR_ERR(handle);
>  		else
> diff --git a/drivers/staging/android/ion/ion.h
> b/drivers/staging/android/ion/ion.h index b860c5f..a1331fc 100644
> --- a/drivers/staging/android/ion/ion.h
> +++ b/drivers/staging/android/ion/ion.h
> @@ -192,14 +192,26 @@ struct dma_buf *ion_share_dma_buf(struct
> ion_client *client, int ion_share_dma_buf_fd(struct ion_client
> *client, struct ion_handle *handle); 
>  /**
> - * ion_import_dma_buf() - given an dma-buf fd from the ion exporter
> get handle
> + * ion_import_dma_buf() - get ion_handle from dma-buf
> + * @client:	the client
> + * @dmabuf:	the dma-buf
> + *
> + * Get the ion_buffer associated with the dma-buf and return the
> ion_handle.
> + * If no ion_handle exists for this buffer, return newly created
> ion_handle.
> + * If dma-buf from another exporter is passed, return
> ERR_PTR(-EINVAL)
> + */
> +struct ion_handle *ion_import_dma_buf(struct ion_client *client,
> +				      struct dma_buf *dmabuf);
> +
> +/**
> + * ion_import_dma_buf_fd() - given a dma-buf fd from the ion
> exporter get handle
>   * @client:	the client
>   * @fd:		the dma-buf fd
>   *
> - * Given an dma-buf fd that was allocated through ion via
> ion_share_dma_buf,
> - * import that fd and return a handle representing it.  If a dma-buf
> from
> + * Given an dma-buf fd that was allocated through ion via
> ion_share_dma_buf_fd,
> + * import that fd and return a handle representing it. If a dma-buf
> from
>   * another exporter is passed in this function will return
> ERR_PTR(-EINVAL) */
> -struct ion_handle *ion_import_dma_buf(struct ion_client *client, int
> fd); +struct ion_handle *ion_import_dma_buf_fd(struct ion_client
> *client, int fd); 
>  #endif /* _LINUX_ION_H */

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2016-02-01  7:52 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-05 13:03 [PATCH] staging/ion: Add support to get ion handle from dma buf Rohit kumar
2016-01-05 18:12 ` Laura Abbott
2016-01-06  5:25   ` Rohit
2016-01-06  9:06     ` Dan Carpenter
2016-01-06 18:21       ` Linus Torvalds
2016-01-06 18:24         ` Al Viro
2016-01-06 21:38       ` Jonathan Corbet
2016-01-07  8:57         ` Dan Carpenter
2016-01-09  4:44           ` Sudip Mukherjee
2016-01-06  7:11 ` [PATCHv2 1/1] " Rohit kumar
2016-01-06 18:26   ` Laura Abbott
2016-01-07 14:13   ` Sumit Semwal
2016-01-08  7:51     ` Rohit
2016-01-12  4:01 ` [PATCHv3 " Rohit kumar
2016-02-01  7:59   ` Rohit

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.