diff options
| author | John Baldwin <jhb@FreeBSD.org> | 2026-02-18 16:04:54 +0000 |
|---|---|---|
| committer | John Baldwin <jhb@FreeBSD.org> | 2026-02-18 16:04:54 +0000 |
| commit | 349808d8bd197165390a286bccdaa29a1d77c7ab (patch) | |
| tree | 056d15f45f43c228a9b4ff721992c92c90ae7e13 | |
| parent | 3a960425df759a7bb8f946d23f035c63f3a5de7a (diff) | |
pcib: Assume a window where both the base and limit are 0 is uninitialized
Since the low bits of a window's limit are hardwired to 1, this
configuration looks like a minimally sized window at address 0.
However, PCI resources are not generally at address 0 (see the
__PCI_BAR_ZERO_VALID macro that was only defined on sparc64), and some
PCI-PCI bridges report these register values after a reset. The
result today is a lot of spam in dmesg as the minimally-sized windows
fail to allocate. By ignoring these windows and treating them as
closed the end result is the same, but there is less spam during boot.
Reported by: jrtc27
Differential Revision: https://reviews.freebsd.org/D43922
| -rw-r--r-- | sys/dev/pci/pci_pci.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/sys/dev/pci/pci_pci.c b/sys/dev/pci/pci_pci.c index 788af7339418..5cdb1de71c3f 100644 --- a/sys/dev/pci/pci_pci.c +++ b/sys/dev/pci/pci_pci.c @@ -437,6 +437,24 @@ pcib_alloc_window(struct pcib_softc *sc, struct pcib_window *w, int type, if (!pcib_is_window_open(w)) return; + /* + * Assume that a window where both the base and limit read as + * zero is not really open, or at least not assigned a valid + * range by the firmware. This can happen if a bridge device + * is never initialized by firmware, or if a platform driver + * resets the bridge. + * + * If devices behind this bridge have firmware-assigned + * resources in this range then the window will be reallocated + * on-demand. + */ + if (w->base == 0 && w->limit == ((pci_addr_t)1 << w->step) - 1) { + w->base = max_address; + w->limit = 0; + pcib_write_windows(sc, w->mask); + return; + } + if (w->base > max_address || w->limit > max_address) { device_printf(sc->dev, "initial %s window has too many bits, ignoring\n", w->name); |
