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