Re: [PATCH] usb: dwc3: gadget: fix up DMA direction

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

 



On Tue, Dec 20, 2011 at 05:23:58PM +0100, Sebastian Andrzej Siewior wrote:
> * Alan Stern | 2011-12-20 10:54:41 [-0500]:
> 
> >On Tue, 20 Dec 2011, Felipe Balbi wrote:
> >
> >> If we're using an IN endpoint, the DMA direction
> >> is DMA_FROM_DEVICE, rather than DMA_TO_DEVICE.
> >
> >Are you sure you haven't got this backward?
> >
> >For DMA operations, the device is the thing doing the direct memory
> >access -- in this case, the UDC controller.  With IN endpoints, data
> >goes from the gadget's memory, though the UDC controller, and over the
> >USB bus to the host.  That is _from_ memory _to_ UDC; hence the
> >direction is DMA_TO_DEVICE.
> 
> The spec says:
>  DMA_TO_DEVICE           data is going from the memory to the device
>  DMA_FROM_DEVICE         data is coming from the device to the memory
> 
> So for IN endpoint we need DMA_TO_DEVICE because it goes from memory to
> device.
> Thanks Alan.

Yeah, I went read the Documentation too and found out the same. Dropped
the patch from my list.

Does it mean we have a bug on Renesas' driver ?

diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c
index 7f4e803..991c29c 100644
--- a/drivers/usb/renesas_usbhs/mod_gadget.c
+++ b/drivers/usb/renesas_usbhs/mod_gadget.c
@@ -232,7 +232,7 @@ static int usbhsg_dma_map_ctrl(struct usbhs_pkt *pkt, int map)
 	struct device *dev = usbhsg_gpriv_to_dev(gpriv);
 	enum dma_data_direction dir;
 
-	dir = usbhs_pipe_is_dir_in(pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
+	dir = usbhs_pipe_is_dir_in(pipe) ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
 
 	if (map)
 		return usbhsg_dma_map(dev, pkt, dir);

Kuninori, can you comment ?

-- 
balbi

Attachment: signature.asc
Description: Digital signature


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

  Powered by Linux