From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751777AbcAFFSe (ORCPT ); Wed, 6 Jan 2016 00:18:34 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:37423 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750845AbcAFFSb (ORCPT ); Wed, 6 Jan 2016 00:18:31 -0500 X-AuditID: cbfee68f-f793a6d000001364-76-568ca3a4ed91 Date: Wed, 06 Jan 2016 10:55:23 +0530 From: Rohit To: Laura Abbott , gregkh@linuxfoundation.org, arve@android.com, riandrews@android.com, dan.carpenter@oracle.com, gioh.kim@lge.com, sumit.semwal@linaro.org, mitchelh@codeaurora.org, paul.gortmaker@windriver.com, linux@rasmusvillemoes.dk, shawn.lin@rock-chips.com, sriram@marirs.net.in, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, pintu.k@samsung.com, vishnu.ps@samsung.com Cc: sreenathd@samsung.com, pintu_agarwal@yahoo.com, me.rohit@live.com, cpgs@samsung.com Subject: Re: [PATCH] staging/ion: Add support to get ion handle from dma buf Message-id: <20160106105523.10be1f56@rohitk-ubuntu.sisodomain.com> In-reply-to: <568C0797.9010606@redhat.com> References: <1451998982-15654-1-git-send-email-rohit.kr@samsung.com> <568C0797.9010606@redhat.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: H4sIAAAAAAAAA02Sa0iTURjHO+/77t1mSqfl5bTKYhWl5f12orIbxAnCNFMyKJv6ouGVbYpR H0w/eG0lBsVMU4Zh5iWnzdTlZSuKTBEsNXMz8wIlYrUuJqltrsBvv8Pzf37n/+ER0KIqnlhw KUXByVKkSRLWjql19L/iUaUuivTW5NJ4bnGMxZ/0bnhm6TaDda8X+Hg6+zvAOeoGFj/QzVN4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DbtHx60GVo8vD/8wenx8eovF40JXtsf7fVfZPP7O2s/i0bdl FaPH501yHuu3bGXymDXrMFOAQFQDo01GamJKapFCal5yfkpmXrqtkndwvHO8qZmBoa6hpYW5 kkJeYm6qrZKLT4CuW2YO0PNKCmWJOaVAoYDE4mIlfTtME0JD3HQtYBojdH1DguB6jAzQQMIa xoyND7+yFJzWqeho383cwDhbuYuRk0NCwETiRPdSJghbTOLCvfVsXYxcHEICSxklNi1bwQrh NDFJbFv8lx2kikVAVWL75MNgHWwCShL/X81lA7FFBBYwS5w9LAliMwtESjzs/MwMYgsL+Eg8 3bWdBcTmFXCSuLZiMSuIzSmgJbFn8VqwGiGBFIl9226AzecXEJU4vHA7M8RFNhKrd65jhugV lPgx+R4LxHwtic3bmlghbHmJzWveMk9gFJyFpGwWkrJZSMoWMDKvYpRILUguKE5KzzXMSy3X K07MLS7NS9dLzs/dxAhOb8+kdjAe3OV+iFGAg1GJh1dApidMiDWxrLgy9xCjBAezkghvSDFQ iDclsbIqtSg/vqg0J7X4EKMpMHAmMkuJJucDU29eSbyhsYm5qbGppYmFiZmlkjhv7aXIMCGB 9MSS1OzU1ILUIpg+Jg5OqQbGnVqLD1+q0eTrW3lzm559jG+Edv/FV37PMo5an79evWBL49kW tjVTPR7GqIil+4U3npzE1Rzobma0faP0fIVE5WPRKhemG3m/WvDuJFu79KNjpreWuVZuTtVz 7+lTvZJxxfhsXdnMAN6AZJ9V/ZG5QSn3Kx02cX0WvfL0fo6dypJwi4ibN6YrsRRnJBpqMRcV JwIA0b/zWoUDAAA= 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 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 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 > > --- > > 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 */ > > > >