Re: DMA alignement in hcds

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

 



On Mon, 20 Apr 2009, Martin Fuzzey wrote:

> Hi all,
> 
> I'm working on a HCD for the i.MX21 and am having problems with DMA
> alignment [my hardware requires DMA buffers to be aligned on a 4 byte
> boundary]
> 
> It seems that the usb core calls dma_map_single() from map_urb_for_dma()
> but that this only ensures the memory is is a DMAable region, not that
> it is correctly aligned.
> 
> Use case is pwc webcam driver which calls usb_control_message() with a
> non aligned stack allocated buffer pointer.

That is a no-no.  Drivers are never supposed to allocate buffers on the
stack, for precisely this reason.  They are supposed to use kmalloc or
something similar.

> Does this mean the HCD has to handle this? (I ask because a brief look
> at the existing HCDs didn't turn up anything similar).
> 
> If so there are probably two non aligned cases :
> 1) small buffers (<max packet) where the data can be written directly to
> hardware "data memory" with no DMA
> 2) large buffers where the full buffer will have to be copied to a
> suitably aligned buffer and DMA still used.
> 
> Case 2) is problematic because the buffers could be large [though in
> practice such buffers should be dynamically allocated and hence aligned].

The HCD is not supposed to handle this.  It's a bug in the pwc driver.

Alan Stern

--
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