Commit 63f1de88 authored by Scott Wood's avatar Scott Wood

powerpc/fsl_pci: Size upper inbound window based on RAM size

This allows PCI devices that can only address (e.g.) 36 or 40 bit DMA to
use direct DMA, at the cost of not being able to DMA to non-RAM addresses
(this doesn't affect MSIs as there is a separate dedicated window for
that) which we wouldn't have been able to do anyway if the RAM size didn't
trigger the creation of the second inbound window.

It also fixes an off-by-one error that set dma_direct_ops on PCI devices
whose dma mask could address all the space below the DMA offset
(previously 40 bits), but not the window that starts at the DMA offset.
Signed-off-by: default avatarScott Wood <oss@buserror.net>
Cc: Tillmann Heidsieck <theidsieck@leenox.de>
Tested-by: default avatarTillmann Heidsieck <theidsieck@leenox.de>
parent 834e5a69
...@@ -111,8 +111,7 @@ static struct pci_ops fsl_indirect_pcie_ops = ...@@ -111,8 +111,7 @@ static struct pci_ops fsl_indirect_pcie_ops =
.write = indirect_write_config, .write = indirect_write_config,
}; };
#define MAX_PHYS_ADDR_BITS 40 static u64 pci64_dma_offset;
static u64 pci64_dma_offset = 1ull << MAX_PHYS_ADDR_BITS;
#ifdef CONFIG_SWIOTLB #ifdef CONFIG_SWIOTLB
static void setup_swiotlb_ops(struct pci_controller *hose) static void setup_swiotlb_ops(struct pci_controller *hose)
...@@ -132,12 +131,10 @@ static int fsl_pci_dma_set_mask(struct device *dev, u64 dma_mask) ...@@ -132,12 +131,10 @@ static int fsl_pci_dma_set_mask(struct device *dev, u64 dma_mask)
return -EIO; return -EIO;
/* /*
* Fixup PCI devices that are able to DMA to above the physical * Fix up PCI devices that are able to DMA to the large inbound
* address width of the SoC such that we can address any internal * mapping that allows addressing any RAM address from across PCI.
* SoC address from across PCI if needed
*/ */
if ((dev_is_pci(dev)) && if (dev_is_pci(dev) && dma_mask >= pci64_dma_offset * 2 - 1) {
dma_mask >= DMA_BIT_MASK(MAX_PHYS_ADDR_BITS)) {
set_dma_ops(dev, &dma_direct_ops); set_dma_ops(dev, &dma_direct_ops);
set_dma_offset(dev, pci64_dma_offset); set_dma_offset(dev, pci64_dma_offset);
} }
...@@ -387,6 +384,7 @@ static void setup_pci_atmu(struct pci_controller *hose) ...@@ -387,6 +384,7 @@ static void setup_pci_atmu(struct pci_controller *hose)
mem_log++; mem_log++;
piwar = (piwar & ~PIWAR_SZ_MASK) | (mem_log - 1); piwar = (piwar & ~PIWAR_SZ_MASK) | (mem_log - 1);
pci64_dma_offset = 1ULL << mem_log;
if (setup_inbound) { if (setup_inbound) {
/* Setup inbound memory window */ /* Setup inbound memory window */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment