[openib-general] [PATCH 0/7] AMSO1100 RNIC Driver

Tom Tucker tom at opengridcomputing.com
Thu Mar 9 06:32:20 PST 2006


On Wed, 2006-03-08 at 22:21 -0800, Roland Dreier wrote:
> I just realized that the amso1100 driver probably won't work on a
> big-endian architecture.  This is actually because your hardware is
> itself big-endian, so you end up doing stuff like
> 
>     writel(cpu_to_be32(foo), bar);

Er... isn't cpu_to_be32 a no-op when the processor is itself big-endian?

> 
> in a lot of places.  Unfortunately, writel() operates with the assumption
> that the PCI bus is little-endian.  In other words, on x86, your writel()
> essentially becomes (because cpu_to_be32 is a swap):
> 
>     *bar = swab32(foo);
> 
> but on big-endian archs like powerpc, a byte-swap is performed by writel()
> so you still end up doing something like the following (even though
> cpu_to_be32 is a no-op on big-endian archs):
> 
>     *bar = swab32(foo);
> 
> which is wrong when foo is already big-endian.
> 
> There's not really a great solution to this.  The best I've come up with
> is to use __raw_writel() instead, but then you have to be careful, because
> in addition to not byte swapping, the __raw variants also don't have any
> implied barriers, so you need to add your own wmb()s.
> 
> You can see some examples of this in mthca, for example in the FW
> command stuff in mthca_cmd.c.
> 
>  - R.




More information about the general mailing list