>-----Original Message----- >From: linux-usb-owner@xxxxxxxxxxxxxxx [mailto:linux-usb-owner@xxxxxxxxxxxxxxx] On Behalf Of Gadiyar, >Anand >Sent: Tuesday, December 15, 2009 10:10 AM >To: Alan Stern; Matthieu CASTET >Cc: linux-usb@xxxxxxxxxxxxxxx; David Brownell >Subject: RE: gadget framework data alignment > >Alan Stern wrote: >> On Tue, 15 Dec 2009, Matthieu CASTET wrote: >> >> > Hi, >> > >> > >> > I am wondering about using dma with gadget. >> > >> > From what I understand gadget function can put anything in req->buf. >> > That is the case for u_ether that puts skb->data. >> > >> > But if the driver wants to do dma they need a buffer aligned on a cache >> > boundary (to clean/invalidate/flush buffer). >> > >> > Who should do the job ? >> > - Gadget function should provide "provide DMA-safe buffers" like in spi >> > subsystem ? >> > - Driver need to copy the data in a safe buffer. >> >> Buffers should be allocated by calling kmalloc() or equivalent >> functions. These routines always return addresses that are >> cacheline-aligned on architectures which require it. >> > >For g_ether, the buffers are allocated using kmalloc(), but the >networking code seems to move the data in the buffer out by 2 >bytes, and passes this unaligned address down to the gadget driver. > >The MUSB controller in the beagleboard could handle these unaligned >DMA address, but looks like newer MUSB controllers don't seem to >like this. I would split this problem into two parts: RX g-ether buffers: The offset by 2 gets taken care if we override NET_IP_ALIGN to 4. (Refer: include/linux/skbuff.h) Seems this macro is for this specific purpose and works, it's a different thing where to override in code (probably in arch specific system.h file) TX g-ether buffers Tx buffers still come unaligned by offset 2 and just changing NET_IP_ALIGN to 4 does not help. > >- Anand >-- >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 -- 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