pci_dw: Trim ATU windows bigger than 4GB

The size of the ATU MEM/IO windows is implicitly casted to uint32_t.
Because of that some window sizes were silently demoted to 0 and ignored.
Check the size if its too large, trim it to 4GB and print a warning message.

Submitted by: Kornel Duleba <mindal@semihalf.com>
Reviewed by: mw
Obtained from: Semihalf
Sponsored by: Marvell
Differential revision: https://reviews.freebsd.org/D29625
This commit is contained in:
Wojciech Macek 2021-04-09 09:28:44 +02:00
parent 6dadf78f11
commit 243000b19f

View File

@ -342,6 +342,18 @@ pci_dw_decode_ranges(struct pci_dw_softc *sc, struct ofw_pci_range *ranges,
" Not all required ranges are found in DT\n");
return (ENXIO);
}
if (sc->io_range.size > UINT32_MAX) {
device_printf(sc->dev,
"ATU IO window size is too large. Up to 4GB windows "
"are supported, trimming window size to 4GB\n");
sc->io_range.size = UINT32_MAX;
}
if (sc->mem_range.size > UINT32_MAX) {
device_printf(sc->dev,
"ATU MEM window size is too large. Up to 4GB windows "
"are supported, trimming window size to 4GB\n");
sc->mem_range.size = UINT32_MAX;
}
return (0);
}