[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdXy-XyR5PtczK9J1p_i=jugp4yq6JF8_MhVC1FMK5dtPw@mail.gmail.com>
Date: Thu, 25 Nov 2021 08:39:52 +0100
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Finn Thain <fthain@...ux-m68k.org>
Cc: Damien Le Moal <damien.lemoal@...nsource.wdc.com>,
Michael Schmitz <schmitzmic@...il.com>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>,
Jens Axboe <axboe@...nel.dk>, linux-ide@...r.kernel.org,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] pata_falcon: Add missing __iomem annotations
Hi Finn,
On Thu, Nov 25, 2021 at 2:06 AM Finn Thain <fthain@...ux-m68k.org> wrote:
> On Wed, 24 Nov 2021, Geert Uytterhoeven wrote:
> > > --- a/drivers/ata/pata_falcon.c
> > > +++ b/drivers/ata/pata_falcon.c
> > > @@ -55,14 +55,14 @@ static unsigned int pata_falcon_data_xfer(struct ata_queued_cmd *qc,
> > > /* Transfer multiple of 2 bytes */
> > > if (rw == READ) {
> > > if (swap)
> > > - raw_insw_swapw((u16 *)data_addr, (u16 *)buf, words);
> > > + raw_insw_swapw((u16 __iomem *)data_addr, (u16 *)buf, words);
> > > else
> > > - raw_insw((u16 *)data_addr, (u16 *)buf, words);
> > > + raw_insw((u16 __iomem *)data_addr, (u16 *)buf, words);
> > > } else {
> > > if (swap)
> > > - raw_outsw_swapw((u16 *)data_addr, (u16 *)buf, words);
> > > + raw_outsw_swapw((u16 __iomem *)data_addr, (u16 *)buf, words);
> > > else
> > > - raw_outsw((u16 *)data_addr, (u16 *)buf, words);
> > > + raw_outsw((u16 __iomem *)data_addr, (u16 *)buf, words);
> >
> > Can't you just drop the casts? data_addr is an __iomem void *.
>
> Yes, that works here (i.e. removing the data_addr casts and not the buf
> casts). But is it prudent?
>
> Given the implementation of raw_in/out is subject to change, it seems like
> the original casts were defensive programming.
>
> Here's an example of a recent regression that was fixed by casting a macro
> argument to a specific width:
>
> https://lore.kernel.org/linuxppc-dev/79ae1f49-f6b1-e9ad-977d-0cc7e553c7b9@csgroup.eu/
> https://lore.kernel.org/linuxppc-dev/08bbe7240b384016e0b2912ecf3bf5e2d25ef2c6.1636501628.git.fthain@linux-m68k.org/
Yeah, you do have to be careful with macros that derive a size from
the type of the passed data. The *{in,out}sw() functions do not suffer
from that: they are defined to operate on a 16-bit I/O register.
It is very unlikely these semantics will ever change.
Here I'm more worried about the other danger: keeping casts will
silence any warning that may be introduced in a future change to the
driver code.
BTW, insw() and readsw() in asm-generic take void *.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Powered by blists - more mailing lists