IDE & byte-swapping in 2.4.21

linas at austin.ibm.com linas at austin.ibm.com
Wed May 21 06:18:58 EST 2003


Hi,

I'm trying to debug a confusing IDE byteswapping bug in 2.4.21 on ppc64,
and want to fish for some comments before I go off in the wrong direction.
If you think you understand byteswapping, please help me out!

Let me start at the begining:  IDE in 2.4.21 in ppc64 doesn't work.

I discovered that if I go into ide-iops.c and disable bytsewapping
in the ide_fix_driveid() routine, then I can get IDE to sort-of work...
it works in that I can create partions, fs, and read/write files.
Unfortunately, the resulting partition tables & etc. are byte-swapped
from 'normal': my whacked ide code cannot read ide drives from
x86 bboxes, or from 2.4.19 ppc boxes.

The 2.4.19 code uses insw() for PIO (in drivers/ide/ide.c/ide_input_data())
and both ppc and ppc64 #define insw _insw_ns with comments suggesting
that 'ns' stands for no-swap. Then routines like ppc64_ide_fix_driveid()
perform the actual swap, and everything works.

The 2.4.21 code introduces some new routines: ide_mm_insw() and its
cousins in drivers/ide/ide-iops.c.  These are similar, but crucially
different from ide_insw().  Whereas the latter call insw(), the former
call readw(), and this difference seems to be very very intentional.
On ppc and ppc64, readw map to in_le16 calls (which swap bytes), whereas
insw calls do not.   This seems to be at the root of the problem.

There's just enough mapping and redirection & etc. in this code that
I haven't quite figured out what the intent was, and therefore, haven't
really figured out what the right fix is ... is it in the ide code?
In the ppc64-specific code?  Am I the only big-endian platform with
this problem? Have other big-endian platforms tested?

--linas

** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/




More information about the Linuxppc64-dev mailing list