Re: Linux 6.4.4 on m68k - Q40 - pata_falcon causes oops at boot time

William R Sowerbutts
2023-08-14T11:19:37Z

[-- Attachment #1: Type: text/plain, Size: 2619 bytes --]

On Mon, Aug 14, 2023 at 10:54:54AM +1200, Michael Schmitz wrote:
>On 14/08/23 10:24, William R Sowerbutts wrote:
>> * 6.4.10 + Michael's RFC patch -- IDE fails (no crash, but "Bad IO
>> access")
>
>That might be fixed by my second RFC patch, just gone out today.

6.4.10 + your "RFC v2" patch boots without the "Bad IO access" errors!

Your patch looks correct to me.

>This one still byte-swaps the data from disk though. I understood that was
>always the case for Q40, but I may have been mistaken there.

It is indeed returning byte-swapped data. This is easily fixed, I'm using
the attached patch.

>> For my 6.4 patch I enabled byte swapping in the pata_falcon_data_xfer()
>> function -- this allows me to use an IDE drive with everything in the
>> normal/compatible byte ordering, which makes life much easier. I assume this
>> is the intended behaviour.
>That would be the sane behaviour, but the designers of both the Falcon and
>apparently the TiVo decided otherwise, wired up the IDE data bus byte-swapped
>and saved the byteswap operations in the driver. I'm unsure how this was
>intended to work on Q40.

The Q40 does NOT have hardware to reverse the byte-swapping. The CPU has to
byte-swap data if you want to use disks with standard/compatible data.

>Now the question is how data on legacy Q40 IDE disks have been stored. If
>it's byte-swapped, we'd better keep that byte order in the current driver
>(meaning your changes to pata_falcon_data_xfer() won't be needed, but you
>would have to swap back data on your disk). If it's always been in PC
>compatible byte order, all data (not just the identify data) must be swapped.
>
>I'd like to have Richard's opinion on this (or hear from any other former Q40
>user).

I have learned that the "standard" firmware for the Q40, SMSQ/E, does not
byte-swap data (it also uses an obscure partition scheme and filesystem).

Personally, I am strongly in favour of Linux on the Q40 using standard
byte-order disks that are compatible with other machines. This feels like the
right thing to do and it is what I think most users would expect.

Users (if there are any!) with legacy byte-swapped disks can always use the
standard tools to byte swap them into the correct, compatible format.

Thanks

Will

_________________________________________________________________________
William R Sowerbutts will@sowerbutts.com
"Carpe post meridiem" http://sowerbutts.com
main(){char*s=">#=0> ^#X@#@^7=",c=0,m;for(;c<15;c++)for
(m=-1;m<7;putchar(m++/6&c%3/2?10:s[c]-31&1<<m?42:32));}

[-- Attachment #2: pata_falcon-q40-byteswap.patch --]
[-- Type: text/x-diff, Size: 431 bytes --]

--- linux-6.4.10+michael-rfc2/drivers/ata/pata_falcon.c.orig 2023-08-14 11:21:48.636681174 +0100
+++ linux-6.4.10+michael-rfc2/drivers/ata/pata_falcon.c 2023-08-14 11:34:17.244301035 +0100
@@ -48,7 +48,7 @@
struct scsi_cmnd *cmd = qc->scsicmd;
bool swap = 1;

- if (dev->class == ATA_DEV_ATA && cmd &&
+ if (!MACH_IS_Q40 && dev->class == ATA_DEV_ATA && cmd &&
!blk_rq_is_passthrough(scsi_cmd_to_rq(cmd)))
swap = 0;