• Pali Rohár's avatar
    PCI: aardvark: Configure PCIe resources from 'ranges' DT property · 64f160e1
    Pali Rohár authored
    In commit 6df6ba97 ("PCI: aardvark: Remove PCIe outbound window
    configuration") was removed aardvark PCIe outbound window configuration and
    commit description said that was recommended solution by HW designers.
    
    But that commit completely removed support for configuring PCIe IO
    resources without removing PCIe IO 'ranges' from DTS files. After that
    commit PCIe IO space started to be treated as PCIe MEM space and accessing
    it just caused kernel crash.
    
    Moreover implementation of PCIe outbound windows prior that commit was
    incorrect. It completely ignored offset between CPU address and PCIe bus
    address and expected that in DTS is CPU address always same as PCIe bus
    address without doing any checks. Also it completely ignored size of every
    PCIe resource specified in 'ranges' DTS property and expected that every
    PCIe resource has size 128 MB (also for PCIe IO range). Again without any
    check. Apparently none of PCIe resource has in DTS specified size of 128
    MB. So it was completely broken and thanks to how aardvark mask works,
    configuration was completely ignored.
    
    This patch reverts back support for PCIe outbound window configuration but
    implementation is a new without issues mentioned above. PCIe outbound
    window is required when DTS specify in 'ranges' property non-zero offset
    between CPU and PCIe address space. To address recommendation by HW
    designers as specified in commit description of 6df6ba97, set default
    outbound parameters as PCIe MEM access without translation and therefore
    for this PCIe 'ranges' it is not needed to configure PCIe outbound window.
    For PCIe IO space is needed to configure aardvark PCIe outbound window.
    
    This patch fixes kernel crash when trying to access PCIe IO space.
    
    Link: https://lore.kernel.org/r/20210624215546.4015-2-pali@kernel.orgSigned-off-by: default avatarPali Rohár <pali@kernel.org>
    Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
    Cc: stable@vger.kernel.org # 6df6ba97 ("PCI: aardvark: Remove PCIe outbound window configuration")
    64f160e1
pci-aardvark.c 44.9 KB