The USB stack maps the buffer for DMA if the controller supports DMA. MUSB controller can perform DMA as well as PIO transfers. The buffer needs to be unmapped before CPU can perform PIO data transfers. Export unmap_urb_for_dma() so that drivers can perform the DMA unmapping in a sane way. Signed-off-by: Maulik Mankad <x0082077@xxxxxx> Cc: Felipe Balbi <felipe.balbi@xxxxxxxxx> Cc: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> --- Based on 2.6.36-rc1 drivers/usb/core/hcd.c | 3 ++- drivers/usb/musb/musb_host.c | 5 +++++ drivers/usb/musb/musb_host.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) Index: mainline/drivers/usb/core/hcd.c =================================================================== --- mainline.orig/drivers/usb/core/hcd.c +++ mainline/drivers/usb/core/hcd.c @@ -1263,7 +1263,7 @@ static void hcd_free_coherent(struct usb *dma_handle = 0; } -static void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb) +void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb) { enum dma_data_direction dir; @@ -1307,6 +1307,7 @@ static void unmap_urb_for_dma(struct usb URB_DMA_MAP_SG | URB_DMA_MAP_PAGE | URB_DMA_MAP_SINGLE | URB_MAP_LOCAL); } +EXPORT_SYMBOL(unmap_urb_for_dma); static int map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags) Index: mainline/drivers/usb/musb/musb_host.c =================================================================== --- mainline.orig/drivers/usb/musb/musb_host.c +++ mainline/drivers/usb/musb/musb_host.c @@ -41,6 +41,7 @@ #include <linux/errno.h> #include <linux/init.h> #include <linux/list.h> +#include <linux/dma-mapping.h> #include "musb_core.h" #include "musb_host.h" @@ -1326,6 +1327,8 @@ void musb_host_tx(struct musb *musb, u8 */ if (length > qh->maxpacket) length = qh->maxpacket; + /* Unmap the buffer so that CPU can use it */ + unmap_urb_for_dma(musb_to_hcd(musb), urb); musb_write_fifo(hw_ep, length, urb->transfer_buffer + offset); qh->segsize = length; @@ -1746,6 +1749,8 @@ void musb_host_rx(struct musb *musb, u8 #endif /* Mentor DMA */ if (!dma) { + /* Unmap the buffer so that CPU can use it */ + unmap_urb_for_dma(musb_to_hcd(musb), urb); done = musb_host_packet_rx(musb, urb, epnum, iso_err); DBG(6, "read %spacket\n", done ? "last " : ""); Index: mainline/drivers/usb/musb/musb_host.h =================================================================== --- mainline.orig/drivers/usb/musb/musb_host.h +++ mainline/drivers/usb/musb/musb_host.h @@ -83,6 +83,7 @@ static inline struct musb_qh *first_qh(s extern void musb_root_disconnect(struct musb *musb); +extern void unmap_urb_for_dma(struct usb_hcd *, struct urb *); struct usb_hcd; -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html