diff options
-rw-r--r-- | Documentation/usb/dma.txt | 18 | ||||
-rw-r--r-- | drivers/staging/usbip/usbip_common.c | 2 | ||||
-rw-r--r-- | drivers/usb/core/hcd.c | 3 | ||||
-rw-r--r-- | include/linux/usb.h | 28 |
4 files changed, 19 insertions, 32 deletions
diff --git a/Documentation/usb/dma.txt b/Documentation/usb/dma.txt index a37e59cf2786..84ef865237db 100644 --- a/Documentation/usb/dma.txt +++ b/Documentation/usb/dma.txt | |||
@@ -16,11 +16,11 @@ OR: they can now be DMA-aware. | |||
16 | manage dma mappings for existing dma-ready buffers (see below). | 16 | manage dma mappings for existing dma-ready buffers (see below). |
17 | 17 | ||
18 | - URBs have an additional "transfer_dma" field, as well as a transfer_flags | 18 | - URBs have an additional "transfer_dma" field, as well as a transfer_flags |
19 | bit saying if it's valid. (Control requests also have "setup_dma" and a | 19 | bit saying if it's valid. (Control requests also have "setup_dma", but |
20 | corresponding transfer_flags bit.) | 20 | drivers must not use it.) |
21 | 21 | ||
22 | - "usbcore" will map those DMA addresses, if a DMA-aware driver didn't do | 22 | - "usbcore" will map this DMA address, if a DMA-aware driver didn't do |
23 | it first and set URB_NO_TRANSFER_DMA_MAP or URB_NO_SETUP_DMA_MAP. HCDs | 23 | it first and set URB_NO_TRANSFER_DMA_MAP. HCDs |
24 | don't manage dma mappings for URBs. | 24 | don't manage dma mappings for URBs. |
25 | 25 | ||
26 | - There's a new "generic DMA API", parts of which are usable by USB device | 26 | - There's a new "generic DMA API", parts of which are usable by USB device |
@@ -53,12 +53,6 @@ and effects like cache-trashing can impose subtle penalties. | |||
53 | to use this type of memory ("dma-coherent"), and memory returned from | 53 | to use this type of memory ("dma-coherent"), and memory returned from |
54 | kmalloc() will work just fine. | 54 | kmalloc() will work just fine. |
55 | 55 | ||
56 | For control transfers you can use the buffer primitives or not for each | ||
57 | of the transfer buffer and setup buffer independently. Set the flag bits | ||
58 | URB_NO_TRANSFER_DMA_MAP and URB_NO_SETUP_DMA_MAP to indicate which | ||
59 | buffers you have prepared. For non-control transfers URB_NO_SETUP_DMA_MAP | ||
60 | is ignored. | ||
61 | |||
62 | The memory buffer returned is "dma-coherent"; sometimes you might need to | 56 | The memory buffer returned is "dma-coherent"; sometimes you might need to |
63 | force a consistent memory access ordering by using memory barriers. It's | 57 | force a consistent memory access ordering by using memory barriers. It's |
64 | not using a streaming DMA mapping, so it's good for small transfers on | 58 | not using a streaming DMA mapping, so it's good for small transfers on |
@@ -130,8 +124,8 @@ of Documentation/PCI/PCI-DMA-mapping.txt, titled "What memory is DMA-able?") | |||
130 | void usb_buffer_unmap (struct urb *urb); | 124 | void usb_buffer_unmap (struct urb *urb); |
131 | 125 | ||
132 | The calls manage urb->transfer_dma for you, and set URB_NO_TRANSFER_DMA_MAP | 126 | The calls manage urb->transfer_dma for you, and set URB_NO_TRANSFER_DMA_MAP |
133 | so that usbcore won't map or unmap the buffer. The same goes for | 127 | so that usbcore won't map or unmap the buffer. They cannot be used for |
134 | urb->setup_dma and URB_NO_SETUP_DMA_MAP for control requests. | 128 | setup_packet buffers in control requests. |
135 | 129 | ||
136 | Note that several of those interfaces are currently commented out, since | 130 | Note that several of those interfaces are currently commented out, since |
137 | they don't have current users. See the source code. Other than the dmasync | 131 | they don't have current users. See the source code. Other than the dmasync |
diff --git a/drivers/staging/usbip/usbip_common.c b/drivers/staging/usbip/usbip_common.c index e3fa4216c1cd..52408164036f 100644 --- a/drivers/staging/usbip/usbip_common.c +++ b/drivers/staging/usbip/usbip_common.c | |||
@@ -562,7 +562,7 @@ EXPORT_SYMBOL_GPL(sockfd_to_socket); | |||
562 | /* there may be more cases to tweak the flags. */ | 562 | /* there may be more cases to tweak the flags. */ |
563 | static unsigned int tweak_transfer_flags(unsigned int flags) | 563 | static unsigned int tweak_transfer_flags(unsigned int flags) |
564 | { | 564 | { |
565 | flags &= ~(URB_NO_TRANSFER_DMA_MAP|URB_NO_SETUP_DMA_MAP); | 565 | flags &= ~URB_NO_TRANSFER_DMA_MAP; |
566 | return flags; | 566 | return flags; |
567 | } | 567 | } |
568 | 568 | ||
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 3aaee2811f01..0abc5c537f39 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
@@ -1316,8 +1316,7 @@ static int map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb, | |||
1316 | * or uses the provided scatter gather list for bulk. | 1316 | * or uses the provided scatter gather list for bulk. |
1317 | */ | 1317 | */ |
1318 | 1318 | ||
1319 | if (usb_endpoint_xfer_control(&urb->ep->desc) | 1319 | if (usb_endpoint_xfer_control(&urb->ep->desc)) { |
1320 | && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP)) { | ||
1321 | if (hcd->self.uses_dma) { | 1320 | if (hcd->self.uses_dma) { |
1322 | urb->setup_dma = dma_map_single( | 1321 | urb->setup_dma = dma_map_single( |
1323 | hcd->self.controller, | 1322 | hcd->self.controller, |
diff --git a/include/linux/usb.h b/include/linux/usb.h index a748815ee629..1eb4762d9ea8 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h | |||
@@ -953,7 +953,6 @@ extern int usb_disabled(void); | |||
953 | #define URB_ISO_ASAP 0x0002 /* iso-only, urb->start_frame | 953 | #define URB_ISO_ASAP 0x0002 /* iso-only, urb->start_frame |
954 | * ignored */ | 954 | * ignored */ |
955 | #define URB_NO_TRANSFER_DMA_MAP 0x0004 /* urb->transfer_dma valid on submit */ | 955 | #define URB_NO_TRANSFER_DMA_MAP 0x0004 /* urb->transfer_dma valid on submit */ |
956 | #define URB_NO_SETUP_DMA_MAP 0x0008 /* urb->setup_dma valid on submit */ | ||
957 | #define URB_NO_FSBR 0x0020 /* UHCI-specific */ | 956 | #define URB_NO_FSBR 0x0020 /* UHCI-specific */ |
958 | #define URB_ZERO_PACKET 0x0040 /* Finish bulk OUT with short packet */ | 957 | #define URB_ZERO_PACKET 0x0040 /* Finish bulk OUT with short packet */ |
959 | #define URB_NO_INTERRUPT 0x0080 /* HINT: no non-error interrupt | 958 | #define URB_NO_INTERRUPT 0x0080 /* HINT: no non-error interrupt |
@@ -1049,12 +1048,8 @@ typedef void (*usb_complete_t)(struct urb *); | |||
1049 | * @setup_packet: Only used for control transfers, this points to eight bytes | 1048 | * @setup_packet: Only used for control transfers, this points to eight bytes |
1050 | * of setup data. Control transfers always start by sending this data | 1049 | * of setup data. Control transfers always start by sending this data |
1051 | * to the device. Then transfer_buffer is read or written, if needed. | 1050 | * to the device. Then transfer_buffer is read or written, if needed. |
1052 | * @setup_dma: For control transfers with URB_NO_SETUP_DMA_MAP set, the | 1051 | * @setup_dma: DMA pointer for the setup packet. The caller must not use |
1053 | * device driver has provided this DMA address for the setup packet. | 1052 | * this field; setup_packet must point to a valid buffer. |
1054 | * The host controller driver should use this in preference to | ||
1055 | * setup_packet, but the HCD may chose to ignore the address if it must | ||
1056 | * copy the setup packet into internal structures. Therefore, setup_packet | ||
1057 | * must always point to a valid buffer. | ||
1058 | * @start_frame: Returns the initial frame for isochronous transfers. | 1053 | * @start_frame: Returns the initial frame for isochronous transfers. |
1059 | * @number_of_packets: Lists the number of ISO transfer buffers. | 1054 | * @number_of_packets: Lists the number of ISO transfer buffers. |
1060 | * @interval: Specifies the polling interval for interrupt or isochronous | 1055 | * @interval: Specifies the polling interval for interrupt or isochronous |
@@ -1086,13 +1081,14 @@ typedef void (*usb_complete_t)(struct urb *); | |||
1086 | * bounce buffer or talking to an IOMMU), | 1081 | * bounce buffer or talking to an IOMMU), |
1087 | * although they're cheap on commodity x86 and ppc hardware. | 1082 | * although they're cheap on commodity x86 and ppc hardware. |
1088 | * | 1083 | * |
1089 | * Alternatively, drivers may pass the URB_NO_xxx_DMA_MAP transfer flags, | 1084 | * Alternatively, drivers may pass the URB_NO_TRANSFER_DMA_MAP transfer flag, |
1090 | * which tell the host controller driver that no such mapping is needed since | 1085 | * which tells the host controller driver that no such mapping is needed for |
1086 | * the transfer_buffer since | ||
1091 | * the device driver is DMA-aware. For example, a device driver might | 1087 | * the device driver is DMA-aware. For example, a device driver might |
1092 | * allocate a DMA buffer with usb_alloc_coherent() or call usb_buffer_map(). | 1088 | * allocate a DMA buffer with usb_alloc_coherent() or call usb_buffer_map(). |
1093 | * When these transfer flags are provided, host controller drivers will | 1089 | * When this transfer flag is provided, host controller drivers will |
1094 | * attempt to use the dma addresses found in the transfer_dma and/or | 1090 | * attempt to use the dma address found in the transfer_dma |
1095 | * setup_dma fields rather than determining a dma address themselves. | 1091 | * field rather than determining a dma address themselves. |
1096 | * | 1092 | * |
1097 | * Note that transfer_buffer must still be set if the controller | 1093 | * Note that transfer_buffer must still be set if the controller |
1098 | * does not support DMA (as indicated by bus.uses_dma) and when talking | 1094 | * does not support DMA (as indicated by bus.uses_dma) and when talking |
@@ -1115,11 +1111,9 @@ typedef void (*usb_complete_t)(struct urb *); | |||
1115 | * should always terminate with a short packet, even if it means adding an | 1111 | * should always terminate with a short packet, even if it means adding an |
1116 | * extra zero length packet. | 1112 | * extra zero length packet. |
1117 | * | 1113 | * |
1118 | * Control URBs must provide a setup_packet. The setup_packet and | 1114 | * Control URBs must provide a valid pointer in the setup_packet field. |
1119 | * transfer_buffer may each be mapped for DMA or not, independently of | 1115 | * Unlike the transfer_buffer, the setup_packet may not be mapped for DMA |
1120 | * the other. The transfer_flags bits URB_NO_TRANSFER_DMA_MAP and | 1116 | * beforehand. |
1121 | * URB_NO_SETUP_DMA_MAP indicate which buffers have already been mapped. | ||
1122 | * URB_NO_SETUP_DMA_MAP is ignored for non-control URBs. | ||
1123 | * | 1117 | * |
1124 | * Interrupt URBs must provide an interval, saying how often (in milliseconds | 1118 | * Interrupt URBs must provide an interval, saying how often (in milliseconds |
1125 | * or, for highspeed devices, 125 microsecond units) | 1119 | * or, for highspeed devices, 125 microsecond units) |