Re: [PATCH 1/2] usb: dwc2: Use platform endianness when accessing registers

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

 



Hello,

On Tue, 10 Mar 2015 16:05:36 -0500, Felipe Balbi <balbi@xxxxxx> wrote:
> I don't get it, why is it so that only mips needs this ? What's special
> about mips' writel/readl implementation that it can't be used here ?
> 
> This works for everybody else.

Would it be a design oddity of this SoC that device registers do match
CPU endianness, instead of matching implementations used in other SoCs ?

This is the first time I ever get to debug some endianness issue in
a driver, let alone on a SoC. I have extremely little knowledge of how
this is expected to happen in general. Please pardon my naivety.

AFAIK the Raspberry Pi is another SoC where this device is present, and
the RPi is little endian. As this driver works there, it suggests the
registers are little-endian too. I think proposed change will not break
this, as discussed with John Youn on previous submission. I couldn't
get a reasonable RPi kernel build environment (because of the lack of
working kernel .config for a recent kernel) to verify this though.

> Is it so that dwc2 and cpu endianness don't match here ?

They do match actually. It's readl/writel internal byte swapping
happening on big-endian archs which breaks this. Once straightened as
per Antti's patch, the driver detects the HCD and USB devices work fine.

Well, actually there is one out-of-driver (platform-specific) register
to set so DMA transfers match CPU endianness (I have no idea why it
doesn't default to the working setting).

> weren't readl() and writel() already supposed to handle endianness for
> us?

If asm-generic implementation is representative of the intent, then the
intent is clearly to read little-endian values from memory and convert
to CPU endianness.

http://lxr.free-electrons.com/source/include/asm-generic/io.h#L127
http://lxr.free-electrons.com/source/include/asm-generic/io.h#L161

Which brings me back to my original questions: Is SoC hardware expected
to expose registers in cpu-consistent endianness (or maybe even
"default-cpu-endianness") ?

> wrong comment style.

Expected style is to prefix lines with * and to end block below these,
right ?
Nice catch, thanks.

Regards,
-- 
Vincent Pelletier
--
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