public inbox for linux-ide@vger.kernel.org
 help / color / mirror / Atom feed
From: Michael Schmitz <schmitzmic@gmail.com>
To: Sergey Shtylyov <s.shtylyov@omp.ru>,
	linux-ide@vger.kernel.org, linux-m68k@vger.kernel.org
Cc: will@sowerbutts.com, rz@linux-m68k.org, geert@linux-m68k.org,
	Finn Thain <fthain@linux-m68k.org>
Subject: Re: [PATCH 2/3] m68k/q40: add data_swab option for pata_falcon to byte-swap disk data
Date: Mon, 21 Aug 2023 07:27:23 +1200	[thread overview]
Message-ID: <5e5217a4-837c-fac8-246c-15f8a2d46bfe@gmail.com> (raw)
In-Reply-To: <3af82526-1b8f-87bd-b936-9171e4d821df@omp.ru>

Hi Sergey,

thanks for reviewing - this has mostly been addressed in v2 or v3 (which 
I forgot to send to you, sorry). Damien asked for the patch title to be 
changed (now 'ata: pata_falcon: add data_swab option to byte-swap disk 
data) so you might have missed it on the list.

On 21/08/23 06:07, Sergey Shtylyov wrote:
> On 8/18/23 1:12 AM, Michael Schmitz wrote:
>
>> 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>
>> Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
>>
>> ---
>>
>> 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 | 26 +++++++++++++++++++++++++-
>>   1 file changed, 25 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/ata/pata_falcon.c b/drivers/ata/pata_falcon.c
>> index 346259e3bbc8..90488f565d6f 100644
>> --- a/drivers/ata/pata_falcon.c
>> +++ b/drivers/ata/pata_falcon.c
>> @@ -33,6 +33,16 @@
>>   #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)");
>     Hm, Greg KH keeps saying us that the module parameters belong to '90s. :-)
What else can I use that would allow setting a driver parameter at boot 
time? This driver will be built-in pretty much all the time.
>
> [...]
>> @@ -44,13 +54,15 @@ static unsigned int pata_falcon_data_xfer(struct ata_queued_cmd *qc,
>>   	struct ata_device *dev = qc->dev;
>>   	struct ata_port *ap = dev->link->ap;
>>   	void __iomem *data_addr = ap->ioaddr.data_addr;
>> +	struct pata_falcon_priv *priv = ap->private_data;
>>   	unsigned int words = buflen >> 1;
>>   	struct scsi_cmnd *cmd = qc->scsicmd;
>> +	int dev_id = dev->devno;
>     You hardly need this variable...
Fixed in v3.
>
>>   	bool swap = 1;
>>   
>>   	if (dev->class == ATA_DEV_ATA && cmd &&
>>   	    !blk_rq_is_passthrough(scsi_cmd_to_rq(cmd)))
>> -		swap = 0;
>> +		swap = priv->swap_data && (priv->swap_mask & BIT(dev_id));
>     This looks convoluted -- only the 2nd subexpression should be enough...
Pointless attempt at optimizing this for the default case. Gone now.
>
> [...]
>> @@ -165,6 +178,13 @@ static int __init pata_falcon_init_one(struct platform_device *pdev)
>>   	ap->pio_mask = ATA_PIO4;
>>   	ap->flags |= ATA_FLAG_SLAVE_POSS | ATA_FLAG_NO_IORDY;
>>   
>> +	priv = devm_kzalloc(&pdev->dev,
>> +		sizeof(struct pata_falcon_priv), GFP_KERNEL);
>     sizeof(*priv) is preferred IIRC...
>
>> +	if (!priv)
>> +		return -ENOMEM;
>> +
>> +	ap->private_data = priv;
>     Also you hardly need a heap allocation -- encoding your couple flags
> could use the ap->private_data itself...

That's what Finn suggested as well - changed in v2.

Cheers,

     Michael

>
> [...]
>
> MBR, Sergey

  reply	other threads:[~2023-08-20 19:32 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-17 22:12 [PATCH 0/3] Q40 IDE fixes Michael Schmitz
2023-08-17 22:12 ` [PATCH 1/3] m68k/q40: fix IO base selection for Q40 in pata_falcon.c Michael Schmitz
2023-08-18  0:42   ` Damien Le Moal
2023-08-18  2:53     ` Michael Schmitz
2023-08-18  5:33       ` Finn Thain
2023-08-19 20:29   ` Sergey Shtylyov
2023-08-20 19:19     ` Michael Schmitz
2023-08-21  7:46       ` Michael Schmitz
2023-08-17 22:12 ` [PATCH 2/3] m68k/q40: add data_swab option for pata_falcon to byte-swap disk data Michael Schmitz
2023-08-18  0:51   ` Damien Le Moal
2023-08-18  3:08     ` Michael Schmitz
2023-08-18  3:15       ` Damien Le Moal
2023-08-18  4:01         ` Michael Schmitz
2023-08-20 18:07   ` Sergey Shtylyov
2023-08-20 19:27     ` Michael Schmitz [this message]
2023-08-22 19:10       ` Sergei Shtylyov
2023-08-22 19:44         ` Sergei Shtylyov
2023-08-22 20:21           ` Michael Schmitz
2023-08-17 22:12 ` [PATCH 3/3] m68k/atari: change Falcon IDE platform device to id 0 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=5e5217a4-837c-fac8-246c-15f8a2d46bfe@gmail.com \
    --to=schmitzmic@gmail.com \
    --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=s.shtylyov@omp.ru \
    --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