Linux Documentation
 help / color / mirror / Atom feed
* [PATCH 0/2] USB: DMA: point out recommend APIs
@ 2023-09-14 17:23 Randy Li
  2023-09-14 17:23 ` [PATCH 1/2] USB: dma: remove unused function prototype Randy Li
  2023-09-14 17:23 ` [PATCH 2/2] docs: driver-api: usb: update dma info Randy Li
  0 siblings, 2 replies; 3+ messages in thread
From: Randy Li @ 2023-09-14 17:23 UTC (permalink / raw)
  To: linux-usb; +Cc: Randy Li, stern, gregkh, linux-kernel, corbet, linux-doc

Although I submit these patches as the previous reply suggestion, I
am stilling wondering the IOMMU with USB controller. I think the most
of USB controller didn't need to create entities in IOMMU to support
scatterlist. Once the hcd supports that(sg_tablesize > 0), it could
support infinite scatter pages?

Randy Li (2):
  USB: dma: remove unused function prototype
  docs: driver-api: usb: update dma info

 Documentation/driver-api/usb/dma.rst | 48 +++++++---------------------
 include/linux/usb.h                  | 16 ----------
 2 files changed, 11 insertions(+), 53 deletions(-)

-- 
2.41.0


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

* [PATCH 1/2] USB: dma: remove unused function prototype
  2023-09-14 17:23 [PATCH 0/2] USB: DMA: point out recommend APIs Randy Li
@ 2023-09-14 17:23 ` Randy Li
  2023-09-14 17:23 ` [PATCH 2/2] docs: driver-api: usb: update dma info Randy Li
  1 sibling, 0 replies; 3+ messages in thread
From: Randy Li @ 2023-09-14 17:23 UTC (permalink / raw)
  To: linux-usb; +Cc: Randy Li, stern, gregkh, linux-kernel, corbet, linux-doc

usb_buffer_map_sg() and usb_buffer_unmap_sg() have no definition
since the beginning of v5.4. The rest are gone from 2.6.12.

Signed-off-by: Randy Li <ayaka@soulik.info>
---
 include/linux/usb.h | 16 ----------------
 1 file changed, 16 deletions(-)

diff --git a/include/linux/usb.h b/include/linux/usb.h
index a21074861f91..8c61643acd49 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -1823,22 +1823,6 @@ void *usb_alloc_coherent(struct usb_device *dev, size_t size,
 void usb_free_coherent(struct usb_device *dev, size_t size,
 	void *addr, dma_addr_t dma);
 
-#if 0
-struct urb *usb_buffer_map(struct urb *urb);
-void usb_buffer_dmasync(struct urb *urb);
-void usb_buffer_unmap(struct urb *urb);
-#endif
-
-struct scatterlist;
-int usb_buffer_map_sg(const struct usb_device *dev, int is_in,
-		      struct scatterlist *sg, int nents);
-#if 0
-void usb_buffer_dmasync_sg(const struct usb_device *dev, int is_in,
-			   struct scatterlist *sg, int n_hw_ents);
-#endif
-void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
-			 struct scatterlist *sg, int n_hw_ents);
-
 /*-------------------------------------------------------------------*
  *                         SYNCHRONOUS CALL SUPPORT                  *
  *-------------------------------------------------------------------*/
-- 
2.41.0


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

* [PATCH 2/2] docs: driver-api: usb: update dma info
  2023-09-14 17:23 [PATCH 0/2] USB: DMA: point out recommend APIs Randy Li
  2023-09-14 17:23 ` [PATCH 1/2] USB: dma: remove unused function prototype Randy Li
@ 2023-09-14 17:23 ` Randy Li
  1 sibling, 0 replies; 3+ messages in thread
From: Randy Li @ 2023-09-14 17:23 UTC (permalink / raw)
  To: linux-usb; +Cc: Randy Li, stern, gregkh, linux-kernel, corbet, linux-doc

We should not hide the recommend APIs in a obscure place.

Signed-off-by: Randy Li <ayaka@soulik.info>
---
 Documentation/driver-api/usb/dma.rst | 48 +++++++---------------------
 1 file changed, 11 insertions(+), 37 deletions(-)

diff --git a/Documentation/driver-api/usb/dma.rst b/Documentation/driver-api/usb/dma.rst
index d32c27e11b90..02f6825ff830 100644
--- a/Documentation/driver-api/usb/dma.rst
+++ b/Documentation/driver-api/usb/dma.rst
@@ -93,44 +93,18 @@ DMA address space of the device.  However, most buffers passed to your
 driver can safely be used with such DMA mapping.  (See the first section
 of Documentation/core-api/dma-api-howto.rst, titled "What memory is DMA-able?")
 
-- When you're using scatterlists, you can map everything at once.  On some
-  systems, this kicks in an IOMMU and turns the scatterlists into single
-  DMA transactions::
+- When you have the scatterlists which have been mapped for the USB controller,
+  you could use the new ``usb_sg_*()`` calls, which would turn scatterlist
+  into URBs::
 
-	int usb_buffer_map_sg (struct usb_device *dev, unsigned pipe,
-		struct scatterlist *sg, int nents);
+	int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev,
+		unsigned pipe, unsigned	period, struct scatterlist *sg,
+		int nents, size_t length, gfp_t mem_flags);
 
-	void usb_buffer_dmasync_sg (struct usb_device *dev, unsigned pipe,
-		struct scatterlist *sg, int n_hw_ents);
+	void usb_sg_wait(struct usb_sg_request *io);
 
-	void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe,
-		struct scatterlist *sg, int n_hw_ents);
+	void usb_sg_cancel(struct usb_sg_request *io);
 
-  It's probably easier to use the new ``usb_sg_*()`` calls, which do the DMA
-  mapping and apply other tweaks to make scatterlist i/o be fast.
-
-- Some drivers may prefer to work with the model that they're mapping large
-  buffers, synchronizing their safe re-use.  (If there's no re-use, then let
-  usbcore do the map/unmap.)  Large periodic transfers make good examples
-  here, since it's cheaper to just synchronize the buffer than to unmap it
-  each time an urb completes and then re-map it on during resubmission.
-
-  These calls all work with initialized urbs:  ``urb->dev``, ``urb->pipe``,
-  ``urb->transfer_buffer``, and ``urb->transfer_buffer_length`` must all be
-  valid when these calls are used (``urb->setup_packet`` must be valid too
-  if urb is a control request)::
-
-	struct urb *usb_buffer_map (struct urb *urb);
-
-	void usb_buffer_dmasync (struct urb *urb);
-
-	void usb_buffer_unmap (struct urb *urb);
-
-  The calls manage ``urb->transfer_dma`` for you, and set
-  ``URB_NO_TRANSFER_DMA_MAP`` so that usbcore won't map or unmap the buffer.
-  They cannot be used for setup_packet buffers in control requests.
-
-Note that several of those interfaces are currently commented out, since
-they don't have current users.  See the source code.  Other than the dmasync
-calls (where the underlying DMA primitives have changed), most of them can
-easily be commented back in if you want to use them.
+  When the USB controller doesn't support DMA, the ``usb_sg_init()`` would try
+  to submit URBs in PIO way as long as the page in scatterlists is not in the
+  Highmem, which could be very rare in modern architectures.
-- 
2.41.0


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

end of thread, other threads:[~2023-09-14 17:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-14 17:23 [PATCH 0/2] USB: DMA: point out recommend APIs Randy Li
2023-09-14 17:23 ` [PATCH 1/2] USB: dma: remove unused function prototype Randy Li
2023-09-14 17:23 ` [PATCH 2/2] docs: driver-api: usb: update dma info Randy Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox