[PATCH v2 0/3] usb: gadget: functionfs: DMABUF import interface

Paul Cercueil posted 3 patches 2 years, 10 months ago
There is a newer version of this series
drivers/usb/gadget/function/f_fs.c  | 467 ++++++++++++++++++++++++++--
drivers/usb/gadget/udc/core.c       |   7 +-
include/linux/usb/gadget.h          |   2 +
include/uapi/linux/usb/functionfs.h |  14 +-
4 files changed, 468 insertions(+), 22 deletions(-)
[PATCH v2 0/3] usb: gadget: functionfs: DMABUF import interface
Posted by Paul Cercueil 2 years, 10 months ago
Hi,

This small patchset adds three new IOCTLs that can be used to attach,
detach, or transfer from/to a DMABUF object.

Changes since v1:
- patch [2/3] is new. I had to reuse a piece of code that was already
  duplicated in the driver, so I factorized the code.
- Make ffs_dma_resv_lock() static
- Add MODULE_IMPORT_NS(DMA_BUF);
- The attach/detach functions are now performed without locking the
  eps_lock spinlock. The transfer function starts with the spinlock
  unlocked, then locks it before allocating and queueing the USB
  transfer.

Cheers,
-Paul

Paul Cercueil (3):
  usb: gadget: Support already-mapped DMA SGs
  usb: gadget: functionfs: Factorize wait-for-endpoint code
  usb: gadget: functionfs: Add DMABUF import interface

 drivers/usb/gadget/function/f_fs.c  | 467 ++++++++++++++++++++++++++--
 drivers/usb/gadget/udc/core.c       |   7 +-
 include/linux/usb/gadget.h          |   2 +
 include/uapi/linux/usb/functionfs.h |  14 +-
 4 files changed, 468 insertions(+), 22 deletions(-)

-- 
2.39.2
Re: [PATCH v2 0/3] usb: gadget: functionfs: DMABUF import interface
Posted by Andrzej Pietrasiewicz 2 years, 10 months ago
Hi Paul,

W dniu 22.03.2023 o 10:21, Paul Cercueil pisze:
> Hi,
> 
> This small patchset adds three new IOCTLs that can be used to attach,
> detach, or transfer from/to a DMABUF object.
> 
> Changes since v1:
> - patch [2/3] is new. I had to reuse a piece of code that was already
>    duplicated in the driver, so I factorized the code.
> - Make ffs_dma_resv_lock() static
> - Add MODULE_IMPORT_NS(DMA_BUF);
> - The attach/detach functions are now performed without locking the
>    eps_lock spinlock. The transfer function starts with the spinlock
>    unlocked, then locks it before allocating and queueing the USB
>    transfer.
> 

Can you share an example use case for these new features?
Is there a userspace that excercises the new ioctls?

Regards,

Andrzej
Re: [PATCH v2 0/3] usb: gadget: functionfs: DMABUF import interface
Posted by Paul Cercueil 2 years, 10 months ago
Hi Andrzej,

Le vendredi 31 mars 2023 à 11:40 +0200, Andrzej Pietrasiewicz a écrit :
> Hi Paul,
> 
> W dniu 22.03.2023 o 10:21, Paul Cercueil pisze:
> > Hi,
> > 
> > This small patchset adds three new IOCTLs that can be used to
> > attach,
> > detach, or transfer from/to a DMABUF object.
> > 
> > Changes since v1:
> > - patch [2/3] is new. I had to reuse a piece of code that was
> > already
> >    duplicated in the driver, so I factorized the code.
> > - Make ffs_dma_resv_lock() static
> > - Add MODULE_IMPORT_NS(DMA_BUF);
> > - The attach/detach functions are now performed without locking the
> >    eps_lock spinlock. The transfer function starts with the
> > spinlock
> >    unlocked, then locks it before allocating and queueing the USB
> >    transfer.
> > 
> 
> Can you share an example use case for these new features?
> Is there a userspace that excercises the new ioctls?

We use it at Analog Devices to share buffers between the IIO subsystem
and the USB stack, which makes it possible to stream data samples
between a host computer and high-speed transceivers as fast as
possible, in a zero-copy fashion.

This will be used by Libiio:
https://github.com/analogdevicesinc/libiio/pull/928/commits/dd348137ce371532fd952a2b249cfd96afaef7d1

The code that uses these IOCTLs is not yet merged to the "master"
branch, but will be as soon as this patchset is accepted.

Cheers,
-Paul