pci: pci_mvebu: Fix PCIe MEM and IO resources assignment and mbus mapping
authorPali Rohár <pali@kernel.org>
Tue, 21 Dec 2021 11:20:13 +0000 (12:20 +0100)
committerStefan Roese <sr@denx.de>
Fri, 14 Jan 2022 06:47:57 +0000 (07:47 +0100)
commit537b0142b04de845a13cc9e2237037c53e53c016
tree159f2d9cdb35608d63b0d9d99631d955803a6b43
parent2ac06f3e66c13b793f9b0859888b7062f24910e6
pci: pci_mvebu: Fix PCIe MEM and IO resources assignment and mbus mapping

Do not call pci_set_region() for resources which were not properly mapped.
This prevents U-Boot to access unmapped memory space.

Update MBUS_PCI_MEM_SIZE and MBUS_PCI_IO_SIZE macros to cover all PCIe MEM
and IO ranges. Previously these macros covered only address ranges for the
first PCIe port. Between MBUS_PCI_IO_BASE and MBUS_PCI_MEM_BASE there is
space for six 128 MB long address ranges. So set MBUS_PCI_MEM_SIZE to value
of 6*128 MB. Similarly set MBUS_PCI_IO_SIZE to 6*64 KB.

Function resource_size() returns zero when start address is 0 and end
address is -1. So set invalid resources to these values to indicate that
resource has no mapping.

Split global PCIe MEM and IO resources (defined by MBUS_PCI_*_* macros)
into PCIe ports in mvebu_pcie_bind() function which allocates per-port
based struct mvebu_pcie, instead of using global state variables
mvebu_pcie_membase and mvebu_pcie_iobase. This makes pci_mvebu.c driver
independent of global static variables (which store the state of
allocation) and allows to bind and unbind the driver more times.

Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Behún <marek.behun@nic.cz>
arch/arm/mach-mvebu/include/mach/cpu.h
drivers/pci/pci_mvebu.c