From: Michael Schmitz <schmitzmic@gmail.com>
To: sergei.shtylyov@gmail.com, dlemoal@kernel.org,
linux-ide@vger.kernel.org, linux-m68k@vger.kernel.org
Cc: will@sowerbutts.com, rz@linux-m68k.org, geert@linux-m68k.org,
Michael Schmitz <schmitzmic@gmail.com>,
Finn Thain <fthain@linux-m68k.org>
Subject: [PATCH v4 2/2] ata: pata_falcon: add data_swab option to byte-swap disk data
Date: Wed, 23 Aug 2023 10:13:59 +1200 [thread overview]
Message-ID: <20230822221359.31024-3-schmitzmic@gmail.com> (raw)
In-Reply-To: <20230822221359.31024-1-schmitzmic@gmail.com>
Some users of pata_falcon on Q40 have IDE disks in default
IDE little endian byte order, whereas legacy disks use
host-native big-endian byte order as on the Atari Falcon.
Add module parameter 'data_swab' to allow connecting drives
with non-native data byte order. Drives selected by the
data_swap bit mask will have their user data byte-swapped to
host byte order, i.e. 'pata_falcon.data_swab=2' will byte-swap
all user data on drive B, leaving data on drive A in native
byte order. On Q40, drives on a second IDE interface may be
added to the bit mask as bits 2 and 3.
Default setting is no byte swapping, i.e. compatibility with
the native Falcon or Q40 operating system disk format.
Cc: William R Sowerbutts <will@sowerbutts.com>
Cc: Finn Thain <fthain@linux-m68k.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Tested-by: William R Sowerbutts <will@sowerbutts.com>
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
---
Changes since v2:
Geert Uytterhoeven:
- only shift swap bitmask if pdev->id > 0
Finn Thain:
- use pdev->devno directly for byte swap check
Changes since v1:
Damien Le Moal:
- change patch title
- drop swap_data flag
Finn Thain:
- drop allocation of ap->private struct, use field as bitmask
Changes since RFC v4:
Geert Uytterhoeven:
- don't shift static module parameter for drive 3/4 bitmask
- simplify bit mask calculation to always use pdev->id
Finn Thain:
- correct bit numbers for drive 3/4
Changes since RFC v3:
- split off this byte swap handling into separate patch
- add hint regarding third and fourth drive on Q40
Finn Thain:
- rename module parameter to 'data_swab' to better reflect its use
William Sowerbutts:
- correct IDE drive number used in data swap conditional
---
drivers/ata/pata_falcon.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/ata/pata_falcon.c b/drivers/ata/pata_falcon.c
index 3841ea200bcb..7cf15bd9764a 100644
--- a/drivers/ata/pata_falcon.c
+++ b/drivers/ata/pata_falcon.c
@@ -33,6 +33,11 @@
#define DRV_NAME "pata_falcon"
#define DRV_VERSION "0.1.0"
+static int pata_falcon_swap_mask;
+
+module_param_named(data_swab, pata_falcon_swap_mask, int, 0444);
+MODULE_PARM_DESC(data_swab, "Data byte swap enable/disable bitmap (0x1==drive1, 0x2==drive2, 0x4==drive3, 0x8==drive4, default==0)");
+
static const struct scsi_host_template pata_falcon_sht = {
ATA_PIO_SHT(DRV_NAME),
};
@@ -50,7 +55,7 @@ static unsigned int pata_falcon_data_xfer(struct ata_queued_cmd *qc,
if (dev->class == ATA_DEV_ATA && cmd &&
!blk_rq_is_passthrough(scsi_cmd_to_rq(cmd)))
- swap = 0;
+ swap = (uintptr_t)ap->private_data & BIT(dev->devno);
/* Transfer multiple of 2 bytes */
if (rw == READ) {
@@ -194,6 +199,9 @@ static int __init pata_falcon_init_one(struct platform_device *pdev)
ata_port_desc(ap, "cmd %px ctl %px data %pa",
base, ctl_base, &ap->ioaddr.data_addr);
+ ap->private_data = (void *)(uintptr_t)(pdev->id > 0 ?
+ pata_falcon_swap_mask >> 2 : pata_falcon_swap_mask);
+
irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (irq_res && irq_res->start > 0) {
irq = irq_res->start;
--
2.17.1
next prev parent reply other threads:[~2023-08-22 22:14 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-22 22:13 [PATCH v4 0/2] Q40 IDE fixes Michael Schmitz
2023-08-22 22:13 ` [PATCH v4 1/2] ata: pata_falcon: fix IO base selection for Q40 Michael Schmitz
2023-08-23 9:05 ` Geert Uytterhoeven
2023-08-24 1:54 ` Michael Schmitz
2023-08-23 16:05 ` Sergey Shtylyov
2023-08-24 1:56 ` Michael Schmitz
2023-08-24 10:00 ` Sergey Shtylyov
2023-08-25 1:07 ` Michael Schmitz
2023-08-22 22:13 ` Michael Schmitz [this message]
2023-08-23 9:10 ` [PATCH v4 2/2] ata: pata_falcon: add data_swab option to byte-swap disk data Geert Uytterhoeven
2023-08-23 9:10 ` Geert Uytterhoeven
2023-08-24 1:57 ` Michael Schmitz
2023-08-23 16:35 ` Sergey Shtylyov
2023-08-23 23:03 ` Damien Le Moal
2023-08-24 1:49 ` Michael Schmitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230822221359.31024-3-schmitzmic@gmail.com \
--to=schmitzmic@gmail.com \
--cc=dlemoal@kernel.org \
--cc=fthain@linux-m68k.org \
--cc=geert@linux-m68k.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-m68k@vger.kernel.org \
--cc=rz@linux-m68k.org \
--cc=sergei.shtylyov@gmail.com \
--cc=will@sowerbutts.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox