From: Bjorn Helgaas <helgaas@kernel.org>
To: "Maciej W. Rozycki" <macro@orcam.me.uk>
Cc: Palmer Dabbelt <palmer@dabbelt.com>,
Bjorn Helgaas <bhelgaas@google.com>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PCI: Avoid handing out address 0 to devices
Date: Mon, 18 Apr 2022 22:37:52 -0500 [thread overview]
Message-ID: <20220419033752.GA1101844@bhelgaas> (raw)
In-Reply-To: <alpine.DEB.2.21.2204160049500.9383@angie.orcam.me.uk>
On Sat, Apr 16, 2022 at 03:02:35PM +0100, Maciej W. Rozycki wrote:
> On Fri, 15 Apr 2022, Bjorn Helgaas wrote:
> ...
> > Another possibility is PCIBIOS_MIN_IO. It's also kind of an ugly
> > special case, but at least it already exists. Most arches define it
> > to be non-zero, which should avoid this issue.
> >
> > Defining PCIBIOS_MIN_IO would be simple; what would we lose compared
> > to adding code in pci_bus_alloc_from_region()?
>
> As I explained in the change description:
>
> Especially I/O space ranges are particularly valuable, because
> bridges only decode bits from 12 up and consequently where 16-bit
> addressing is in effect, as few as 16 separate ranges can be
> assigned to individual buses only.
>
> Therefore avoid handing out address 0, however rather than bumping
> the lowest address available to PCI via PCIBIOS_MIN_IO and
> PCIBIOS_MIN_MEM, or doing an equivalent arrangement in
> `__pci_assign_resource', let the whole range assigned to a bus
> start from that address and instead only avoid it for actual
> devices. [...]
>
> Yes, just bumping up PCIBIOS_MIN_IO was my first thought and the
> path of least resistance. However with the strictly hierarchical
> topology of PCIe systems the limit of 16 ranges feels so
> frighteningly low to me already as to make me rather unwilling to
> reduce it even further for a system that is free from PC legacy junk
> (no southbridge let alone ISA) and therefore does not require it.
> So I've reconsidered my initial approach and came up with this
> proposal instead. I think it is a good compromise.
Sorry for being dense here, I think it's finally sinking in.
The problem is that making PCIBIOS_MIN_IO greater than zero would keep
us from assigning a [io 0x0000- ] window, so instead of 16 I/O bridge
windows, we could only have 15 (unless bridges support 32-bit I/O
windows). Right?
Are you running into that limit? Most devices don't need I/O port
space, and almost all other arches define PCIBIOS_MIN_IO, so they live
without that window today.
Sparc uses the MMIO I/O port address directly in the struct resource,
so it will never try to allocate [io 0x0000], and there's no problem
with using PCI I/O port 0:
pci_bus 0000:00: root bus resource [io 0x804000000000-0x80400fffffff] (bus address [0x0000-0xfffffff])
mpt2sas0: ioport(0x0000804000001000), size(256)
The sparc ioport interfaces are basically:
ioport_map(port) { return port; }
ioread8(addr) { return readb(addr); }
inb(addr) { return readb(addr); }
RISC-V uses the generic ones, i.e.,
ioport_map(port) { return PIO_OFFSET + port; }
ioread8(addr) { if (addr) >= PIO_RESERVED)
return readb(addr);
else
return inb(addr & PIO_MASK); }
inb(addr) { return __raw_readb(PCI_IOBASE + addr); }
Obviously RISC-V gives you prettier I/O port addresses, but at the
cost of having PCI I/O port 0 be 0 in the struct resource as well,
which makes it basically unusable. Is it worth it?
Bjorn
next prev parent reply other threads:[~2022-04-19 3:38 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-26 10:47 [PATCH] PCI: Avoid handing out address 0 to devices Maciej W. Rozycki
2022-03-31 7:11 ` [PING][PATCH] " Maciej W. Rozycki
2022-04-13 22:53 ` [PING^2][PATCH] " Maciej W. Rozycki
2022-04-14 0:06 ` [PATCH] " Bjorn Helgaas
2022-04-14 1:10 ` Maciej W. Rozycki
2022-04-14 17:07 ` Bjorn Helgaas
2022-04-14 20:22 ` Maciej W. Rozycki
2022-04-14 22:12 ` Palmer Dabbelt
2022-04-14 23:23 ` Bjorn Helgaas
2022-04-15 12:27 ` Maciej W. Rozycki
2022-04-15 18:39 ` Bjorn Helgaas
2022-04-16 14:02 ` Maciej W. Rozycki
2022-04-19 3:37 ` Bjorn Helgaas [this message]
2022-04-27 22:18 ` Maciej W. Rozycki
2022-04-28 18:55 ` Bjorn Helgaas
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=20220419033752.GA1101844@bhelgaas \
--to=helgaas@kernel.org \
--cc=bhelgaas@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=macro@orcam.me.uk \
--cc=palmer@dabbelt.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;
as well as URLs for NNTP newsgroup(s).