Re: [GIT PULL 1/2] asm-generic: rework PCI I/O space access

From: Arnd Bergmann
Date: Tue Aug 03 2021 - 06:07:08 EST


On Tue, Aug 3, 2021 at 11:46 AM John Garry <john.garry@xxxxxxxxxx> wrote:
> On 05/07/2021 11:06, Arnd Bergmann wrote:

> >
> > Linus, if you like this approach, then I can work on splitting it up into
> > meaningful patches and submit it for a future release. I think the
> > CONFIG_LEGACY_PCI option has value on its own, but the others
> > do introduce some churn.
> >
> > Full patch (120KB): https://pastebin.com/yaFSmAuY
> >
>
> Hi Arnd,
>
> I am not sure if anything is happening here.

No, I'm not currently working on this, though I have it applied to
my randconfig tree.

> Anyway, one thing I mentioned earlier was that we could solve the
> problem of drivers accessing unmapped IO ports and crashing systems on
> archs which define PCI_IOBASE by building them under some "native port
> IO support" flag.

Right, that was part of the goal here.

> One example of such a driver was F71805F sensor. You put that under
> HAS_IOPORT, which would be available for all archs, I think. But I could
> not see where config LEGACY_PCI is introduced. Could we further refine
> that config to not build for such archs as arm64?
>
> BTW, I think that the PPC dependency was added there to stop building
> for power for that same reason, so hopefully we get rid of that.

Good point. It seems that I actually never added the LEGACY_PCI option
to my patch, so I'm just not building those drivers any more, and not
defining the inb()/outb() helpers either, causing a build failure when I'm
missing an option.

However it sounds like you are interested in a third option here, which
brings us to:

LEGACY_PCI: any PCI driver that uses inb()/outb() or is only available
on old-style PCI but not PCIe hardware without a bridge.
To be disabled for most architectures and possibly distros but can
be enabled for kernels that want to use those devices, as long as
CONFIG_HAS_IOPORT is set by the architecture.

HAS_IOPORT: not a legacy PCI device, but can only be built on
architectures that define inb()/outb(). To be disabled for s390
and any other machine that has no useful definition of those
functions.

HARDCODED_IOPORT: (or another name you might think of,) Used by
drivers that unconditionally do inb()/outb() without checking the
validity of the address using firmware or other methods first.
depends on HAS_IOPORT and possibly architecture specific
settings.

Arnd