Re: Problem with non aligned DMA in usbnet on ARM

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Martin Fuzzey
Date: Friday, August 13, 2010 - 3:06 am

Matthieu CASTET wrote:
The problem I see with this approach is that it requires the usb driver
to be aware of the device controller's quirks  (hence the
gadget_dma32()) your patch adds. That appears to be the norm (and maybe
unavoidable) on the gadget side but on the host side things aren't
supposed to work like that.

The expectation for USB hosts is that any properly written usb driver
will work with any properly written host controller driver. I don't
think it's reasonable to expect driver developers to test their code
with all the HCDs, nor expect HCD developers to test their code with all
the drivers.

So I think a policy needs to be defined to ensure this and enforced in
the code. I can see two possible methods:

1) Require that usb drivers submit buffers obtained from kmalloc() and
friends with no extra offsets. If they want some other alignment later
they can use memmove in the completion handler. Enforce this in the core
by checking the buffer pointers are aligned to ARCH_KMALLOC_MINALIGN

or

2) Require that usb_submit_urb() accept byte aligned buffers. Enforce
this by a new test in usbtest (which all HCDs are expected to pass).
Implement it either in individual HCDs that require it or by letting
HCDs inform the core of their requirements and have the core do the
alignment (as it already does the dma mapping). Of course HCDs that can
implement byte aligned transfers (either natively or using tricks such
as the one Russell suggested) should do so.

I think 2) is the better solution because:
a) Solution 1 will impose a runtime overhead even on platforms / HCDs
that don't need it (including the most common cases)
b) There are more drivers than HCDs

Martin


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Problem with non aligned DMA in usbnet on ARM, Martin Fuzzey, (Wed Aug 11, 2:41 am)
Re: Problem with non aligned DMA in usbnet on ARM, Russell King - ARM Linux, (Wed Aug 11, 2:54 am)
Re: Problem with non aligned DMA in usbnet on ARM, Matthieu CASTET, (Wed Aug 11, 2:59 am)
Re: Problem with non aligned DMA in usbnet on ARM, Martin Fuzzey, (Wed Aug 11, 3:11 am)
Re: Problem with non aligned DMA in usbnet on ARM, Martin Fuzzey, (Wed Aug 11, 4:38 am)
Re: Problem with non aligned DMA in usbnet on ARM, Martin Fuzzey, (Wed Aug 11, 9:08 am)
Re: Problem with non aligned DMA in usbnet on ARM, Greg KH, (Wed Aug 11, 10:42 am)
Re: Problem with non aligned DMA in usbnet on ARM, Martin Fuzzey, (Wed Aug 11, 12:07 pm)
Re: Problem with non aligned DMA in usbnet on ARM, Oliver Neukum, (Wed Aug 11, 12:10 pm)
Re: Problem with non aligned DMA in usbnet on ARM, Martin Fuzzey, (Wed Aug 11, 3:20 pm)
Re: Problem with non aligned DMA in usbnet on ARM, Martin Fuzzey, (Wed Aug 11, 3:31 pm)
Re: Problem with non aligned DMA in usbnet on ARM, Russell King - ARM Linux, (Wed Aug 11, 3:47 pm)
Re: Problem with non aligned DMA in usbnet on ARM, Matthieu CASTET, (Thu Aug 12, 10:01 am)
Re: Problem with non aligned DMA in usbnet on ARM, Matthieu CASTET, (Thu Aug 12, 10:08 am)
Re: Problem with non aligned DMA in usbnet on ARM, Martin Fuzzey, (Fri Aug 13, 3:06 am)
Re: Problem with non aligned DMA in usbnet on ARM, Oliver Neukum, (Fri Aug 13, 3:58 am)