[PATCH v2 02/12] iio: buffer-dma: Enable buffer write support
Nuno Sá
noname.nuno at gmail.com
Tue Mar 29 07:11:48 UTC 2022
On Mon, 2022-03-28 at 19:39 +0100, Paul Cercueil wrote:
> Hi Jonathan,
>
> Le lun., mars 28 2022 at 18:24:09 +0100, Jonathan Cameron
> <jic23 at kernel.org> a écrit :
> > On Mon, 7 Feb 2022 12:59:23 +0000
> > Paul Cercueil <paul at crapouillou.net> wrote:
> >
> > > Adding write support to the buffer-dma code is easy - the
> > > write()
> > > function basically needs to do the exact same thing as the
> > > read()
> > > function: dequeue a block, read or write the data, enqueue the
> > > block
> > > when entirely processed.
> > >
> > > Therefore, the iio_buffer_dma_read() and the new
> > > iio_buffer_dma_write()
> > > now both call a function iio_buffer_dma_io(), which will perform
> > > this
> > > task.
> > >
> > > The .space_available() callback can return the exact same value
> > > as
> > > the
> > > .data_available() callback for input buffers, since in both
> > > cases we
> > > count the exact same thing (the number of bytes in each
> > > available
> > > block).
> > >
> > > Note that we preemptively reset block->bytes_used to the
> > > buffer's
> > > size
> > > in iio_dma_buffer_request_update(), as in the future the
> > > iio_dma_buffer_enqueue() function won't reset it.
> > >
> > > v2: - Fix block->state not being reset in
> > > iio_dma_buffer_request_update() for output buffers.
> > > - Only update block->bytes_used once and add a comment about
> > > why we
> > > update it.
> > > - Add a comment about why we're setting a different state
> > > for
> > > output
> > > buffers in iio_dma_buffer_request_update()
> > > - Remove useless cast to bool (!!) in iio_dma_buffer_io()
> > >
> > > Signed-off-by: Paul Cercueil <paul at crapouillou.net>
> > > Reviewed-by: Alexandru Ardelean <ardeleanalex at gmail.com>
> > One comment inline.
> >
> > I'd be tempted to queue this up with that fixed, but do we have
> > any users? Even though it's trivial I'm not that keen on code
> > upstream well in advance of it being used.
>
> There's a userspace user in libiio. On the kernel side we do have
> drivers that use it in ADI's downstream kernel, that we plan to
> upstream in the long term (but it can take some time, as we need to
> upstream other things first, like JESD204B support).
>
>
You mean, users for DMA output buffers? If so, I have on my queue to
add the dac counterpart of this one:
https://elixir.bootlin.com/linux/latest/source/drivers/iio/adc/adi-axi-adc.c
Which is a user of DMA buffers. Though this one does not depend on
JESD204, I suspect it will also be a tricky process mainly because I
think there are major issues on how things are done right now (on the
ADC driver).
But yeah, not a topic here and I do plan to first start the discussion
on the mailing list before starting developing (hopefully in the coming
weeks)...
- Nuno Sá
More information about the dri-devel
mailing list