[PATCH 1/3] ARM: pci: make bus I/O resources optional

Russell King - ARM Linux admin linux at armlinux.org.uk
Fri Mar 26 13:39:48 GMT 2021


On Fri, Mar 26, 2021 at 02:33:15PM +0100, Arnd Bergmann wrote:
> Leaving out the lower 0x1000 port numbers in turn is required so
> legacy ISA drivers acquire the ports with request_region(). The reason
> it broke on your machine was apparently that pci_claim_resource()
> failed to assign the low port numbers to the PCI bus after that has
> explicitly set the minimum.

No, this is totally broken thinking. The 0x1000 offset is *purely* a
PCI resource *allocation* issue, nothing more nothing less. To argue
otherwise just shows a lack of understanding of what is going on here.

_All_ resources from IO port 0 to 0xffff are on the PCI bus in this
case. It makes no sense to create a PCI bus resource for 0x1000-0xffff.
That is entirely illogical and ficticious.

> Using ioport_resource as the PCI host bridge resource as you do
> is the easiest way to make it work for both ISA drivers and PCI drivers
> using low I/O ports.

The fact is, in these machines, the ISA bus is _behind_ the PCI bus,
just like it is on x86 PCs and Alpha. There's no difference here.

> > @@ -434,19 +435,25 @@ static int pcibios_init_resource(int busnr, struct pci_sys_data *sys,
> >                 if (resource_type(window->res) == IORESOURCE_IO)
> >                         return 0;
> >
> > -       sys->io_res.start = (busnr * SZ_64K) ?  : pcibios_min_io;
> > -       sys->io_res.end = (busnr + 1) * SZ_64K - 1;
> > -       sys->io_res.flags = IORESOURCE_IO;
> > -       sys->io_res.name = sys->io_res_name;
> > -       sprintf(sys->io_res_name, "PCI%d I/O", busnr);
> > +       if (bus_ioport_resource) {
> > +               sys->io_res.start = (busnr * SZ_64K) ?  : pcibios_min_io;
> > +               sys->io_res.end = (busnr + 1) * SZ_64K - 1;
> > +               sys->io_res.flags = IORESOURCE_IO;
> 
> 
> After rereading this function, I see that the function already provides
> a way to do what you want here: If the hw->setup() function inserts
> ioport_resource into sys->resources along with  the memory
> resources, it will skip the extra one, and you get the same effect.

True, but I suspect the start of the IO resource above is wrong in
any case - as I say, this is based on a misunderstanding of what
pcibios_min_io is. It is the start of the region of to be used
for resource allocation on the bus, which can be different from the
range of addresses present on the bus.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!



More information about the linux-arm-kernel mailing list