[parisc-linux] to swap or not to swap

Grant Grundler grundler@puffin.external.hp.com
Tue, 13 Nov 2001 13:32:08 -0700


Randolph Chung wrote:
> Grant also seems to be of the opinion that cpu data needs to be swapped
> before written to PCI devices... so does that mean that if i wrote
> something like:
> 
> writew(cpu_to_le16(foo), addr)
> 
> then on things like parisc it gets swapped once, and on things like
> sparc it gets swapped twice?

maybe that's a bug in how sparc code works?

For parisc, the above is correct for (nearly) all PCI devices.
(I hedge since odd PCI devices might want cpu_to_be16() instead).

And don't forget that control data read by the PCI device via DMA
has to be "endian corrected" too.

PA HW implements what I've heard called "address invariance".
IIRC, m700-10 (r4000 mips, Olivetti) does the same thing.
I think Dino Documentation calls this "byte is byte".
Ie byte stream offsets are the same regardless of how they
are address by either DMA or PIO from either CPU or PCI device.

The result is multi-byte data (ie short/int) has to be swapped
when read/written by the PArisc CPU and the addresses don't change.

HTH,
grant