alistair23-linux/drivers/pci
Honghui Zhang c61df57343 PCI: mediatek: Fix memory mapped IO range size computation
Mediatek's HW assigns a MMIO address range (typically starts from
0x20000000 to 0x2fffffff for both mt2712 and mt7622) for PCI usage.

This MMIO address space represents the address space that can
be allocated to PCI devices through Base Address Registers.

Even though the full MMIO address range is available to be allocated, it
should be enabled by the PCIE_AHB_TRANS_BASE register in the host
controller and the size that is enabled is determined by AHB2PCIE_SIZE
bits in this register.

Owing to a bug in the MMIO window size computation, current code does
not enable the full size of the available MMIO address range in the
PCI host controller; if the PCI devices BARs requested size exceeds the
size enabled through the PCIE_AHB_TRANS_BASE register the requests
targeting the disabled address address space will be blocked by the root
complex causing a system error.

Existing code has never run into a system error in production because
even half of the enabled MMIO range (128MB) is big enough for typical
devices BAR requests (4MB) but the full MMIO address range should
be enabled regardless.

Fix the MMIO window size computation by using resource_size(mem) instead
of mem->end - mem->start.

Since the MMIO window size for both MT2712 and MT7622 is 0x10000000,
this change will update the parameter passed to fls() from 0xfffffff to
0x10000000 and calculate the whole memory mapped IO range size
correctly.

Detected through coccinelle semantic patch (and related warning):

scripts/coccinelle/api/resource_size.cocci:

pcie-mediatek.c:720:13-16: WARNING: Suspicious code. resource_size is maybe missing with mem

Signed-off-by: Honghui Zhang <honghui.zhang@mediatek.com>
[lorenzo.pieralisi@arm.com: rewrote the commit log]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2019-03-01 11:16:46 +00:00
..
controller PCI: mediatek: Fix memory mapped IO range size computation 2019-03-01 11:16:46 +00:00
endpoint PCI: consolidate PCI config entry in drivers/pci 2018-11-23 11:45:34 +09:00
hotplug Merge branch 'xarray' of git://git.infradead.org/users/willy/linux-dax 2018-10-28 11:35:40 -07:00
pcie pci-v4.21-changes 2019-01-05 17:57:34 -08:00
switch switchtec: Add MRPC DMA mode support 2018-12-13 09:03:32 -06:00
access.c PCI: Uninline PCI bus accessors for better ftracing 2018-10-04 16:37:37 -05:00
ats.c PCI: Enable PASID only if entire path supports End-End TLP prefixes 2018-06-30 14:10:03 -05:00
bus.c PCI: Fix is_added/is_busmaster race condition 2018-07-31 11:27:54 -05:00
ecam.c
host-bridge.c
iov.c PCI/IOV: Add flag so platforms can skip VF scanning 2019-01-01 19:04:37 -06:00
irq.c PCI: Use IRQF_ONESHOT if pci_request_irq() called with no handler 2018-07-31 10:43:43 -05:00
Kconfig pci-v4.21-changes 2019-01-05 17:57:34 -08:00
Makefile PCI/ACPI: Allow ACPI to be built without CONFIG_PCI set 2018-12-20 10:19:49 +01:00
mmap.c
msi.c genirq/core: Introduce struct irq_affinity_desc 2018-12-19 11:32:08 +01:00
of.c iommu/of: make of_pci_map_rid() available for other devices too 2018-09-25 09:47:52 +02:00
p2pdma.c pci-v4.21-changes 2019-01-05 17:57:34 -08:00
pci-acpi.c PCI / ACPI: Identify untrusted PCI devices 2018-12-05 12:01:55 +03:00
pci-bridge-emul.c PCI: Introduce PCI bridge emulated config space common logic 2018-10-18 17:50:19 +01:00
pci-bridge-emul.h PCI: Introduce PCI bridge emulated config space common logic 2018-10-18 17:50:19 +01:00
pci-driver.c pci-v4.21-changes 2019-01-05 17:57:34 -08:00
pci-label.c
pci-mid.c x86/cpu: Sanitize FAM6_ATOM naming 2018-10-02 10:14:32 +02:00
pci-pf-stub.c
pci-stub.c
pci-sysfs.c Merge branch 'pci/hotplug' 2018-08-15 14:58:52 -05:00
pci.c PCI: Fix incorrect value returned from pcie_get_speed_cap() 2018-11-30 23:42:03 -06:00
pci.h PCI: Add missing include to drivers/pci.h 2018-12-06 14:55:41 -06:00
probe.c PCI / ACPI: Identify untrusted PCI devices 2018-12-05 12:01:55 +03:00
proc.c Remove 'type' argument from access_ok() function 2019-01-03 18:57:57 -08:00
quirks.c PCI: Override Synopsys USB 3.x HAPS device class 2018-12-17 16:25:16 -06:00
remove.c PCI/ASPM: Fix link_state teardown on device removal 2018-09-17 16:32:23 -05:00
rom.c PCI: Make pci_get_rom_size() static 2018-06-29 21:17:26 -05:00
search.c
setup-bus.c PCI: Equalize hotplug memory and io for occupied and empty slots 2018-10-02 16:04:40 -05:00
setup-irq.c
setup-res.c
slot.c PCI/ERR: Use slot reset if available 2018-09-21 12:18:10 -05:00
syscall.c
vc.c
vpd.c PCI/VPD: Check for VPD access completion before checking for timeout 2018-08-14 16:04:46 -05:00
xen-pcifront.c