linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* Problem with non aligned DMA in usbnet on ARM
@ 2010-08-11  9:41 Martin Fuzzey
  2010-08-11  9:54 ` Russell King - ARM Linux
  2010-08-11  9:59 ` Matthieu CASTET
  0 siblings, 2 replies; 22+ messages in thread
From: Martin Fuzzey @ 2010-08-11  9:41 UTC (permalink / raw)
  To: linux-arm-kernel

Hi all,

I have a DLINK DUB-E100 USB / Ethernet adapter with using the Asix
AX88772 chipset.
This device works fine on linux x86 using the usbnet based asix driver
however on ARM (iMX21 SoC, kernel 2.6.35) transmit works but receive
fails with:
"asix_rx_fixup() Bad Header Length"

Digging a bit showed that the driver was submitting a non aligned data
pointer in the URB.
This is due to:
skb_reserve (skb, NET_IP_ALIGN);

in net/usb/usbnet.c rx_submit()

NET_IP_ALIGN is defined as 2 in skbuff.h (default value as not defined
by ARM) hence the data buffer address was offset by 2 whereas the hcd
requires 4 byte alignment to work at all and cache line (32 byte here)
alignment to work reliably.
Note that usbnet uses skb->data as the buffer submitted to USB in the URB.

Removing this call to skb_reserve() fixes the problem for me.

However the comments in skbuff.h make it clear that this is done
deliberately knowing that it will cause non aligned DMA but seem to
suggest that this should work anyway (even if less efficiently).

My understanding, based on previous discussions on -usb a year back
while I was working on the usb hcd is that the hcd does _not_ have to
support unaligned DMA.

So what is the correct fix for this problem?
The options seem to be:
1) Remove skb_reserve() from usbnet
But this will cause the ip header to be non aligned on platforms that
don't have the DMA alignment requirement.

2) Define NET_IP_ALIGN to 0 for ARM
Seems a bit intrusive to me.

3) Change the HCD to copy if not aligned
I'd like to avoid that.

4) Change usbnet to use seperate buffers for the usb side and skb.
Copy between them so both remain aligned
Seems unlikely that the gain further up the stack from ensuring the ip
header is aligned will offset the cost of the copy.

Any ideas?

On a related note, this is the second time I've run into this type of
problem.It would be much easier to debug if the HCD warned (or
refused) misaligned URBs. If HCDs provided information on their
alignment requirements then the USB core could do this in a uniform
way. For example adding an alignment field to struct hc_driver or
struct usb_hcd?

Cheers,

Martin

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2010-08-13 13:53 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-11  9:41 Problem with non aligned DMA in usbnet on ARM Martin Fuzzey
2010-08-11  9:54 ` Russell King - ARM Linux
2010-08-11 10:11   ` Martin Fuzzey
2010-08-11 15:04     ` Greg KH
2010-08-11 16:08       ` Martin Fuzzey
2010-08-11 17:42         ` Greg KH
2010-08-11 19:07           ` Martin Fuzzey
2010-08-11 20:13             ` Greg KH
2010-08-11 22:31               ` Martin Fuzzey
2010-08-12 17:01                 ` Matthieu CASTET
2010-08-11 19:10           ` Oliver Neukum
2010-08-11  9:59 ` Matthieu CASTET
2010-08-11 11:38   ` Martin Fuzzey
2010-08-11 15:54     ` Gary King
2010-08-11 20:35       ` Russell King - ARM Linux
2010-08-11 22:20         ` Martin Fuzzey
2010-08-11 22:47           ` Russell King - ARM Linux
2010-08-12 17:08           ` Matthieu CASTET
2010-08-13 10:06             ` Martin Fuzzey
2010-08-13 10:58               ` Oliver Neukum
2010-08-13 13:42                 ` David Brownell
2010-08-13 13:53                   ` Oliver Neukum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).