• Kumar Gala's avatar
    powerpc/fsl-pci: Allow 64-bit PCIe devices to DMA to any memory address · 96ea3b4a
    Kumar Gala authored
    There is an issue on FSL-BookE 64-bit devices (P5020) in which PCIe
    devices that are capable of doing 64-bit DMAs (like an Intel e1000) do
    not function and crash the kernel if we have >4G of memory in the system.
    
    The reason is that the existing code only sets up one inbound window for
    access to system memory across PCIe.  That window is limited to a 32-bit
    address space.  So on systems we'll end up utilizing SWIOTLB for dma
    mappings.  However SWIOTLB dma ops implement dma_alloc_coherent() as
    dma_direct_alloc_coherent().  Thus we can end up with dma addresses that
    are not accessible because of the inbound window limitation.
    
    We could possibly set the SWIOTLB alloc_coherent op to
    swiotlb_alloc_coherent() however that does not address the issue since
    the swiotlb_alloc_coherent() will behave almost identical to
    dma_direct_alloc_coherent() since the devices coherent_dma_mask will be
    greater than any address allocated by swiotlb_alloc_coherent() and thus
    we'll never bounce buffer it into a range that would be dma-able.
    
    The easiest and best solution is to just make it so that a 64-bit
    capable device is able to DMA to any internal system address.
    
    We accomplish this by opening up a second inbound window that maps all
    of memory above the internal SoC address width so we can set it up to
    access all of the internal SoC address space if needed.
    
    We than fixup the dma_ops and dma_offset for PCIe devices with a dma
    mask greater than the maximum internal SoC address.
    Signed-off-by: default avatarKumar Gala <galak@kernel.crashing.org>
    96ea3b4a
fsl_pci.c 19.9 KB