[libcamera-devel,v2] libcamera: ipa_interface: Document the ownership of dmabufs passed to map_buffers()

Message ID 20200112005442.2607343-1-niklas.soderlund@ragnatech.se
State Accepted
Commit 4b9bd6c3ad94c617ac00a71d2e1ef33648afc99f
Headers show
Series
  • [libcamera-devel,v2] libcamera: ipa_interface: Document the ownership of dmabufs passed to map_buffers()
Related show

Commit Message

Niklas Söderlund Jan. 12, 2020, 12:54 a.m. UTC
The ownership of the dmabuf file handles passed to map_buffers() is not
clear. Explicitly document that they are borrowed from the callee and
only guaranteed to be valid for the duration of the map_buffers() call.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
 src/libcamera/ipa_interface.cpp | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Laurent Pinchart Jan. 12, 2020, 1:03 a.m. UTC | #1
Hi Niklas,

Thank you for the patch.

On Sun, Jan 12, 2020 at 01:54:42AM +0100, Niklas Söderlund wrote:
> The ownership of the dmabuf file handles passed to map_buffers() is not
> clear. Explicitly document that they are borrowed from the callee and

s/callee/caller/ ?

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> only guaranteed to be valid for the duration of the map_buffers() call.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> ---
>  src/libcamera/ipa_interface.cpp | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/src/libcamera/ipa_interface.cpp b/src/libcamera/ipa_interface.cpp
> index ee3e3622f39ae85f..5ca8000a253f5435 100644
> --- a/src/libcamera/ipa_interface.cpp
> +++ b/src/libcamera/ipa_interface.cpp
> @@ -258,6 +258,11 @@
>   * \param[in] buffers The buffers to map
>   * \param[in] num_buffers The number of entries in the \a buffers array
>   *
> + * The dmabuf file descriptors provided in \a buffers are borrowed from the
> + * caller and are only guaranteed to be valid during the map_buffers() call.
> + * Should the callee need to store a copy of the file descriptors, it shall
> + * duplicate them first with ::dup().
> + *
>   * \sa libcamera::IPAInterface::mapBuffers()
>   */
>
Niklas Söderlund Jan. 12, 2020, 6:18 p.m. UTC | #2
Hi Laurent,

Thanks for your feedback.

On 2020-01-12 03:03:19 +0200, Laurent Pinchart wrote:
> Hi Niklas,
> 
> Thank you for the patch.
> 
> On Sun, Jan 12, 2020 at 01:54:42AM +0100, Niklas Söderlund wrote:
> > The ownership of the dmabuf file handles passed to map_buffers() is not
> > clear. Explicitly document that they are borrowed from the callee and
> 
> s/callee/caller/ ?
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Thanks, with this fixed and your tag this patch is pushed to master.

> 
> > only guaranteed to be valid for the duration of the map_buffers() call.
> > 
> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> > ---
> >  src/libcamera/ipa_interface.cpp | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/src/libcamera/ipa_interface.cpp b/src/libcamera/ipa_interface.cpp
> > index ee3e3622f39ae85f..5ca8000a253f5435 100644
> > --- a/src/libcamera/ipa_interface.cpp
> > +++ b/src/libcamera/ipa_interface.cpp
> > @@ -258,6 +258,11 @@
> >   * \param[in] buffers The buffers to map
> >   * \param[in] num_buffers The number of entries in the \a buffers array
> >   *
> > + * The dmabuf file descriptors provided in \a buffers are borrowed from the
> > + * caller and are only guaranteed to be valid during the map_buffers() call.
> > + * Should the callee need to store a copy of the file descriptors, it shall
> > + * duplicate them first with ::dup().
> > + *
> >   * \sa libcamera::IPAInterface::mapBuffers()
> >   */
> >  
> 
> -- 
> Regards,
> 
> Laurent Pinchart

Patch

diff --git a/src/libcamera/ipa_interface.cpp b/src/libcamera/ipa_interface.cpp
index ee3e3622f39ae85f..5ca8000a253f5435 100644
--- a/src/libcamera/ipa_interface.cpp
+++ b/src/libcamera/ipa_interface.cpp
@@ -258,6 +258,11 @@ 
  * \param[in] buffers The buffers to map
  * \param[in] num_buffers The number of entries in the \a buffers array
  *
+ * The dmabuf file descriptors provided in \a buffers are borrowed from the
+ * caller and are only guaranteed to be valid during the map_buffers() call.
+ * Should the callee need to store a copy of the file descriptors, it shall
+ * duplicate them first with ::dup().
+ *
  * \sa libcamera::IPAInterface::mapBuffers()
  */