[PATCH] usb: musb: host: Unmap the buffer for PIO data transfers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Signed-off-by: Maulik Mankad <x0082077@xxxxxx>
Cc: Felipe Balbi <felipe.balbi@xxxxxxxxx>
---
Based on 2.6.36-rc1
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,15 @@ void musb_host_tx(struct musb *musb, u8 
 	 */
 	if (length > qh->maxpacket)
 		length = qh->maxpacket;
+	/* Unmap the buffer so that CPU can use it */
+	if (urb->transfer_flags & URB_DMA_MAP_PAGE) {
+		dma_unmap_page(musb->controller,
+				urb->transfer_dma,
+				urb->transfer_buffer_length,
+				DMA_FROM_DEVICE);
+
+		urb->transfer_flags &= ~URB_DMA_MAP_PAGE;
+	}
 	musb_write_fifo(hw_ep, length, urb->transfer_buffer + offset);
 	qh->segsize = length;
 
@@ -1746,6 +1756,15 @@ void musb_host_rx(struct musb *musb, u8 
 #endif	/* Mentor DMA */
 
 		if (!dma) {
+			/* Unmap the buffer so that CPU can use it */
+			if (urb->transfer_flags & URB_DMA_MAP_PAGE) {
+				dma_unmap_page(musb->controller,
+						urb->transfer_dma,
+						urb->transfer_buffer_length,
+						DMA_TO_DEVICE);
+
+				urb->transfer_flags &= ~URB_DMA_MAP_PAGE;
+			}
 			done = musb_host_packet_rx(musb, urb,
 					epnum, iso_err);
 			DBG(6, "read %spacket\n", done ? "last " : "");
--
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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux