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

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

 



On Fri, Aug 20, 2010 at 7:59 PM, Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:
> On Fri, 20 Aug 2010, Maulik Mankad wrote:
>
>> 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;
>> +     }
>
> I can't tell if it would be correct here, but have you considered just
> calling unmap_urb_for_dma() instead?  (You'd have to make that routine
> non-static and EXPORT it first.)
>

Yes I did exactly that as a first step. It worked.

Then found that only dma_unmap_page() is necessary since the
map_urb_for_dma() function
does a page mapping using dma_map_page() at least for Storage and HID use cases.

I tested this with Storage and HID classes.

What I may be missing is some class driver which might be using dma_map_sg() or
other such routine to map the DMA buffers. Is there such a possibility?

Thanks,
Maulik
--
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