lkml.org 
[lkml]   [2019]   [Jun]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 6/7] media: cedrus: Add infra for extra buffers connected to capture buffers
On Mon, Jun 03, 2019 at 05:48:25PM +0200, Jernej Škrabec wrote:
> Dne ponedeljek, 03. junij 2019 ob 14:18:59 CEST je Maxime Ripard napisal(a):
> > > +static void cedrus_buf_cleanup(struct vb2_buffer *vb)
> > > +{
> > > + struct vb2_queue *vq = vb->vb2_queue;
> > > +
> > > + if (!V4L2_TYPE_IS_OUTPUT(vq->type)) {
> > > + struct cedrus_ctx *ctx = vb2_get_drv_priv(vq);
> > > + struct cedrus_buffer *cedrus_buf;
> > > +
> > > + cedrus_buf = vb2_to_cedrus_buffer(vq->bufs[vb->index]);
> > > +
> > > + if (cedrus_buf->extra_buf_size)
> > > + dma_free_coherent(ctx->dev->dev,
> > > + cedrus_buf-
> >extra_buf_size,
> > > + cedrus_buf-
> >extra_buf,
> > > + cedrus_buf-
> >extra_buf_dma);
> > > + }
> > > +}
> > > +
> >
> > I'm really not a fan of allocating something somewhere, and freeing it
> > somewhere else. Making sure you don't leak something is hard enough to
> > not have some non-trivial allocation scheme.
>
> Ok, what about introducing two new optional methods in engine callbacks,
> buffer_init and buffer_destroy, which would be called from cedrus_buf_init() and
> cedrus_buf_cleanup(), respectively. That way all (de)allocation logic stays
> within the same engine.

Yep, that would work for me.

Thanks!
Maxime

--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2019-06-06 10:34    [W:0.092 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site