imx.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 0/3] add dma noncoherent API
@ 2025-07-04  9:57 Xu Yang
  2025-07-04  9:57 ` [PATCH v5 1/3] usb: core: add dma-noncoherent buffer alloc and free API Xu Yang
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Xu Yang @ 2025-07-04  9:57 UTC (permalink / raw)
  To: ezequiel, mchehab, laurent.pinchart, hdegoede, gregkh, xu.yang_2,
	mingo, tglx, andriy.shevchenko, viro, thomas.weissschuh
  Cc: linux-media, linux-kernel, linux-usb, imx, jun.li

On architectures where there is no coherent caching such as ARM it's
proved that using dma_alloc_noncontiguous API and handling manually
the cache flushing will significantly improve performance.

Refer to:
commit 20e1dbf2bbe2 ("media: uvcvideo: Use dma_alloc_noncontiguous API")
commit 68d0c3311ec1 ("media: stk1160: use dma_alloc_noncontiguous API")

However, it's obvious that there is significant code duplication between
these two commits. Besides, a potential user USB Monitor may read outdated
data before the driver do DMA sync for CPU which will make the data
unreliable.

To reduce code duplication and avoid USB Monitor result unreliable, this
series will introduce DMA noncoherent API to USB core. And the USB core
layer will manage synchronization itself.

Then the last 2 patches have used the API.

I have tested uvcvideo driver. But I haven't tested stk1160 driver as I
don't have such boards. @Ezequiel Garcia, @Dafna Hirschfeld do you have
time to test it? Your support on this would be greatly appreciated.

Changes in v5:
 - improve if-else logic as suggested by Andy and Alan.
 - add Reviewed-by tag

Changes in v4:
 - https://lore.kernel.org/all/20250703103811.4048542-1-xu.yang_2@nxp.com/
 - improve if-else logic
 - remove uvc_stream_to_dmadev()

Changes in v3:
 - https://lore.kernel.org/all/20250702110222.3926355-1-xu.yang_2@nxp.com/
 - put Return section at the end of description
 - correct some abbreviations
 - remove usb_dma_noncoherent_sync_for_cpu() and
   usb_dma_noncoherent_sync_for_device()
 - do DMA sync in usb_hcd_map_urb_for_dma() and
   usb_hcd_unmap_urb_for_dma()
 - call flush_kernel_vmap_range() for OUT transfers
   and invalidate_kernel_vmap_range() for IN transfers 

Changes in v2:
 - https://lore.kernel.org/all/20250627101939.3649295-1-xu.yang_2@nxp.com/
 - handle it in USB core

v1:
 - https://lore.kernel.org/linux-usb/20250614132446.251218-1-xu.yang_2@nxp.com/

Xu Yang (3):
  usb: core: add dma-noncoherent buffer alloc and free API
  media: uvcvideo: use usb_alloc_noncoherent/usb_free_noncoherent()
  media: stk1160: use usb_alloc_noncoherent/usb_free_noncoherent()

 drivers/media/usb/stk1160/stk1160-v4l.c   |  4 --
 drivers/media/usb/stk1160/stk1160-video.c | 43 ++++--------
 drivers/media/usb/stk1160/stk1160.h       |  7 --
 drivers/media/usb/uvc/uvc_video.c         | 61 ++++-------------
 drivers/usb/core/hcd.c                    | 29 +++++---
 drivers/usb/core/usb.c                    | 80 +++++++++++++++++++++++
 include/linux/usb.h                       | 11 ++++
 7 files changed, 137 insertions(+), 98 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-07-09 10:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-04  9:57 [PATCH v5 0/3] add dma noncoherent API Xu Yang
2025-07-04  9:57 ` [PATCH v5 1/3] usb: core: add dma-noncoherent buffer alloc and free API Xu Yang
2025-07-04 13:51   ` Alan Stern
2025-07-04  9:57 ` [PATCH v5 2/3] media: uvcvideo: use usb_alloc_noncoherent/usb_free_noncoherent() Xu Yang
2025-07-07  9:50   ` Hans de Goede
2025-07-04  9:57 ` [PATCH v5 3/3] media: stk1160: " Xu Yang
2025-07-07 10:00   ` Hans de Goede
2025-07-07 10:02 ` [PATCH v5 0/3] add dma noncoherent API Hans de Goede
2025-07-09 10:12   ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).