diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2010-04-02 13:27:28 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-05-20 16:21:37 -0400 |
commit | ff9c895f07d36193c75533bda8193bde8ca99d02 (patch) | |
tree | 386ca8e37734c4810e59a55eaba92e4e88275d14 /include/linux/usb.h | |
parent | 0ff8d1b3c858ea7c8daa54f7577971a76d04d283 (diff) |
USB: fix usbmon and DMA mapping for scatter-gather URBs
This patch (as1368) fixes a rather obscure bug in usbmon: When tracing
URBs sent by the scatter-gather library, it accesses the data buffers
while they are still mapped for DMA.
The solution is to move the mapping and unmapping out of the s-g
library and into the usual place in hcd.c. This requires the addition
of new URB flag bits to describe the kind of mapping needed, since we
have to call dma_map_sg() if the HCD supports native scatter-gather
operation and dma_map_page() if it doesn't. The nice thing about
having the new flags is that they simplify the testing for unmapping.
The patch removes the only caller of usb_buffer_[un]map_sg(), so those
functions are #if'ed out. A later patch will remove them entirely.
As a result of this change, urb->sg will be set in situations where
it wasn't set previously. Hence the xhci and whci drivers are
adjusted to test urb->num_sgs instead, which retains its original
meaning and is nonzero only when the HCD has to handle a scatterlist.
Finally, even when a submission error occurs we don't want to hand
URBs to usbmon before they are unmapped. The submission path is
rearranged so that map_urb_for_dma() is called only for non-root-hub
URBs and unmap_urb_for_dma() is called immediately after a submission
error. This simplifies the error handling.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include/linux/usb.h')
-rw-r--r-- | include/linux/usb.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/linux/usb.h b/include/linux/usb.h index 739f1fd1cc15..99833029e5a8 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h | |||
@@ -965,10 +965,19 @@ extern int usb_disabled(void); | |||
965 | * needed */ | 965 | * needed */ |
966 | #define URB_FREE_BUFFER 0x0100 /* Free transfer buffer with the URB */ | 966 | #define URB_FREE_BUFFER 0x0100 /* Free transfer buffer with the URB */ |
967 | 967 | ||
968 | /* The following flags are used internally by usbcore and HCDs */ | ||
968 | #define URB_DIR_IN 0x0200 /* Transfer from device to host */ | 969 | #define URB_DIR_IN 0x0200 /* Transfer from device to host */ |
969 | #define URB_DIR_OUT 0 | 970 | #define URB_DIR_OUT 0 |
970 | #define URB_DIR_MASK URB_DIR_IN | 971 | #define URB_DIR_MASK URB_DIR_IN |
971 | 972 | ||
973 | #define URB_DMA_MAP_SINGLE 0x00010000 /* Non-scatter-gather mapping */ | ||
974 | #define URB_DMA_MAP_PAGE 0x00020000 /* HCD-unsupported S-G */ | ||
975 | #define URB_DMA_MAP_SG 0x00040000 /* HCD-supported S-G */ | ||
976 | #define URB_MAP_LOCAL 0x00080000 /* HCD-local-memory mapping */ | ||
977 | #define URB_SETUP_MAP_SINGLE 0x00100000 /* Setup packet DMA mapped */ | ||
978 | #define URB_SETUP_MAP_LOCAL 0x00200000 /* HCD-local setup packet */ | ||
979 | #define URB_DMA_SG_COMBINED 0x00400000 /* S-G entries were combined */ | ||
980 | |||
972 | struct usb_iso_packet_descriptor { | 981 | struct usb_iso_packet_descriptor { |
973 | unsigned int offset; | 982 | unsigned int offset; |
974 | unsigned int length; /* expected length */ | 983 | unsigned int length; /* expected length */ |