IDE & byte-swapping in 2.4.21

Paul Mackerras paulus at samba.org
Wed May 21 10:53:44 EST 2003


linas at austin.ibm.com writes:

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

You must be from the future, 2.4.21 hasn't been released yet in my
version of the universe. :)  Seriously, what -pre or -rc version are
you running?

> 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.

No, this isn't the right approach.

> 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 reason is that the IDE code uses the insw/insl/outsw/outsl
routines to transfer buffers of bytes.  Because we are actually
dealing with bytes at this level, rather than 16-bit or 32-bit
integers, it is not appropriate to byte-swap.

> 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.

The official 2.4.21-rc2 has ide_mm_insw calling __ide_mm_insw, which
doesn't appear to be defined for ppc64.  On ppc32, we define it to
_insw_ns, which doesn't byte-swap.  You probably want something
similar on ppc64.

> 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?

No, yes, probably, yes.  IDE works fine on ppc32 (except for the
problems with CF cards on powerbooks with IDE interfaces with no
attached drives, but that's another story).

Paul.

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





More information about the Linuxppc64-dev mailing list