From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752140AbcAHHoj (ORCPT ); Fri, 8 Jan 2016 02:44:39 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:58887 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750794AbcAHHoi (ORCPT ); Fri, 8 Jan 2016 02:44:38 -0500 X-AuditID: cbfee690-f79646d000001316-aa-568f68e33428 Date: Fri, 08 Jan 2016 13:21:15 +0530 From: Rohit To: Sumit Semwal Cc: Greg Kroah-Hartman , Arve =?UTF-8?B?SGo=?= =?UTF-8?B?77+9bm5ldu+/vWc=?= , riandrews@android.com, Laura Abbott , Dan Carpenter , =?UTF-8?B?6riw7Jik6rmA?= , mitchelh@codeaurora.org, paul.gortmaker@windriver.com, linux@rasmusvillemoes.dk, shawn.lin@rock-chips.com, sriram@marirs.net.in, devel@driverdev.osuosl.org, LKML , pintu.k@samsung.com, vishnu.ps@samsung.com, sreenathd@samsung.com, pintu_agarwal@yahoo.com, me.rohit@live.com, "cpgs@samsung.com" Subject: Re: [PATCHv2 1/1] staging/ion: Add support to get ion handle from dma buf Message-id: <20160108132115.312160be@rohitk-ubuntu.sisodomain.com> In-reply-to: References: <1451998982-15654-1-git-send-email-rohit.kr@samsung.com> <1452064269-18601-1-git-send-email-rohit.kr@samsung.com> Organization: Samsung X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.10; i686-pc-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGKsWRmVeSWpSXmKPExsWyRsSkVvdxRn+YwbqF/Bbv/95ns3h5SNPi 9b/pLBZ7zvxit3jW9IXRonnxejaLlXt+MFlc3jWHzeLxrHlsFtfv2Vusnb+NzeLa3uPMFn3f D7NbfHt7m93i9aa/jBZ3nqxnteh+3MxiMffIZzaLU3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aPr7RUmjzvX9rB57J+7ht2j41YDq8eXh38YPT4+vcXicaEr2+P9vqtsHn9n7Wfx6Nuy itHj8yY5j/VbtjJ5zJp1mClAIKqB0SYjNTEltUghNS85PyUzL91WyTs43jne1MzAUNfQ0sJc SSEvMTfVVsnFJ0DXLTMH6HklhbLEnFKgUEBicbGSvh2mCaEhbroWMI0Rur4hQXA9RgZoIGEN Y0bLg42MBdN0KhqvLmdpYFyn2MXIySEhYCJx4NlHJghbTOLCvfVsXYxcHEICSxklft8+xQLh NDFJ/Hq4jx2kikVAVeLI8YeMIDabgJLE/1dz2UBsEQEtiUnb5oM1MAt8ZZGYcH0r2FhhgRCJ l+f+gTXzCjhJ7D39CKyZUyBY4trHZcwgtpDAMUaJRy31IDa/gKjE4YXbmSFOspFYvXMdM0Sv oMSPyfdYQGxmoGWbtzWxQtjyEpvXvGWewCg4C0nZLCRls5CULWBkXsUokVqQXFCclJ5rmJda rlecmFtcmpeul5yfu4kRnOCeSe1gPLjL/RCjAAejEg9vwq6+MCHWxLLiytxDjBIczEoivBLy /WFCvCmJlVWpRfnxRaU5qcWHGE2BoTORWUo0OR+YfPNK4g2NTcxNjU0tTSxMzCyVxHlrL0WG CQmkJ5akZqemFqQWwfQxcXBKNTBOPx15OfnztGYObUeOW+WXkm70zvC+eDQq62bw5oR5j9cw zp4y8X1sbNVRthfpHSzVFS8O/F26qXJxdq1L7R/RH7fbhSynWM3fa1izJf7vbgOu88+UVJTf nPwZ9XbLn+1KPywUM9SF9gYZ2WTof7O28fa/aunccW4DT6/DmrSdxxpOdV1SKzNVYinOSDTU Yi4qTgQAuvNEr4YDAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sumit, On Thu, 07 Jan 2016 19:43:09 +0530 Sumit Semwal wrote: > Hi Rohit, > > On 6 January 2016 at 12:41, 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 > > --- > > v2: Updated commit message with use case explanation, as suggested > > by Laura Abbott > > > 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 > > > 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 > > > > >