PERFORCE change 152649 for review

Hans Petter Selasky hselasky at freebsd.org
Sat Nov 8 06:38:43 PST 2008


On Saturday 08 November 2008, Alexander Motin wrote:
> Hans Petter Selasky wrote:
> > On Saturday 08 November 2008, Alexander Motin wrote:
> >> Hans Petter Selasky wrote:
> >>> http://perforce.freebsd.org/chv.cgi?CH=152649
> >>>
>
> > I'm not saying that my patch is fully correct for all cases, but at least
> > it solves the USB case. USB uses an alignment of 1-byte for data.
> >
> > Probably someone needs to sit down a think this through. Like it is now,
> > it is very scary with regard to USB!
>
> This is a change to the one of basic kernel subsystems. Any change there
> will affect ton's of drivers and may cause issues with too many of
> broken/specific hardware. It should be done with maximum care without
> quick fixes!
>
> > Maybe it is time to create a new busdma tag flag? BUS_DMA_NOREALIGN?
> >
> > If this flag is set, busdma should refuse to load the memory if the
> > memory is not aligned already to the given aligment in the DMA tag ?
>
> What is the real reason to do that? If you are saying that you uses
> 1-byte alignment then you should be able to accept _any_ address that
> busdma will allocate to you! Why original data alignment should so
> strictly affect hardware operation?

Hi,

The real reason is that the EHCI and OHCI only takes the full physical address 
of the _first_ page, and then for the subsequent pages only stores the upper 
bits of the physical address, leaving it impossible to program a per-page 
data start offset. The hardware assumes that the lower part of the physical 
address wraps modulo PAGE_SIZE, and that's it. Don't ask me why they designed 
it like that. Currently USB is broken on all architectures where bouncing is 
used. I see no other way around this than to change busdma.

--HPS


More information about the p4-projects mailing list