Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 496dda70 authored by Maulik Mankad's avatar Maulik Mankad Committed by Greg Kroah-Hartman
Browse files

usb: musb: host: unmap the buffer for PIO data transfers



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: default avatarMaulik Mankad <x0082077@ti.com>
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 6587cc0f
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -1263,7 +1263,7 @@ static void hcd_free_coherent(struct usb_bus *bus, dma_addr_t *dma_handle,
	*dma_handle = 0;
	*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;
	enum dma_data_direction dir;


@@ -1307,6 +1307,7 @@ static void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
			URB_DMA_MAP_SG | URB_DMA_MAP_PAGE |
			URB_DMA_MAP_SG | URB_DMA_MAP_PAGE |
			URB_DMA_MAP_SINGLE | URB_MAP_LOCAL);
			URB_DMA_MAP_SINGLE | URB_MAP_LOCAL);
}
}
EXPORT_SYMBOL_GPL(unmap_urb_for_dma);


static int map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb,
static int map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb,
			   gfp_t mem_flags)
			   gfp_t mem_flags)
+5 −0
Original line number Original line Diff line number Diff line
@@ -41,6 +41,7 @@
#include <linux/errno.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/init.h>
#include <linux/list.h>
#include <linux/list.h>
#include <linux/dma-mapping.h>


#include "musb_core.h"
#include "musb_core.h"
#include "musb_host.h"
#include "musb_host.h"
@@ -1332,6 +1333,8 @@ void musb_host_tx(struct musb *musb, u8 epnum)
	 */
	 */
	if (length > qh->maxpacket)
	if (length > qh->maxpacket)
		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);
	musb_write_fifo(hw_ep, length, urb->transfer_buffer + offset);
	qh->segsize = length;
	qh->segsize = length;


@@ -1752,6 +1755,8 @@ void musb_host_rx(struct musb *musb, u8 epnum)
#endif	/* Mentor DMA */
#endif	/* Mentor DMA */


		if (!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,
			done = musb_host_packet_rx(musb, urb,
					epnum, iso_err);
					epnum, iso_err);
			DBG(6, "read %spacket\n", done ? "last " : "");
			DBG(6, "read %spacket\n", done ? "last " : "");
+1 −0
Original line number Original line Diff line number Diff line
@@ -329,6 +329,7 @@ extern int usb_hcd_submit_urb(struct urb *urb, gfp_t mem_flags);
extern int usb_hcd_unlink_urb(struct urb *urb, int status);
extern int usb_hcd_unlink_urb(struct urb *urb, int status);
extern void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb,
extern void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb,
		int status);
		int status);
extern void unmap_urb_for_dma(struct usb_hcd *, struct urb *);
extern void usb_hcd_flush_endpoint(struct usb_device *udev,
extern void usb_hcd_flush_endpoint(struct usb_device *udev,
		struct usb_host_endpoint *ep);
		struct usb_host_endpoint *ep);
extern void usb_hcd_disable_endpoint(struct usb_device *udev,
extern void usb_hcd_disable_endpoint(struct usb_device *udev,