Commit bf9c7e3d authored by Thomas Petazzoni's avatar Thomas Petazzoni Committed by Rich Felker

arch/sh: pcie-sh7786: handle non-zero DMA offset

On SuperH, the base of the physical memory might be different from
zero. In this case, PCI address zero will map to a non-zero physical
address. In order to make sure that the DMA mapping API takes care of
this DMA offset, we must fill in the dev->dma_pfn_offset field for PCI
devices. This gets done in the pcibios_bus_add_device() hook, called
for each new PCI device detected.

The dma_pfn_offset global variable is re-calculated for every PCI
controller available on the platform, but that's not an issue because
its value will each time be exactly the same, as it only depends on
the memory start address and memory size.
Signed-off-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: default avatarRich Felker <dalias@libc.org>
parent 79e1c5e7
...@@ -33,6 +33,7 @@ struct sh7786_pcie_port { ...@@ -33,6 +33,7 @@ struct sh7786_pcie_port {
static struct sh7786_pcie_port *sh7786_pcie_ports; static struct sh7786_pcie_port *sh7786_pcie_ports;
static unsigned int nr_ports; static unsigned int nr_ports;
static unsigned long dma_pfn_offset;
static struct sh7786_pcie_hwops { static struct sh7786_pcie_hwops {
int (*core_init)(void); int (*core_init)(void);
...@@ -370,6 +371,8 @@ static int __init pcie_init(struct sh7786_pcie_port *port) ...@@ -370,6 +371,8 @@ static int __init pcie_init(struct sh7786_pcie_port *port)
memstart = ALIGN_DOWN(memstart, memsize); memstart = ALIGN_DOWN(memstart, memsize);
memsize = roundup_pow_of_two(memend - memstart); memsize = roundup_pow_of_two(memend - memstart);
dma_pfn_offset = memstart >> PAGE_SHIFT;
/* /*
* If there's more than 512MB of memory, we need to roll over to * If there's more than 512MB of memory, we need to roll over to
* LAR1/LAMR1. * LAR1/LAMR1.
...@@ -485,6 +488,11 @@ int pcibios_map_platform_irq(const struct pci_dev *pdev, u8 slot, u8 pin) ...@@ -485,6 +488,11 @@ int pcibios_map_platform_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
return evt2irq(0xae0); return evt2irq(0xae0);
} }
void pcibios_bus_add_device(struct pci_dev *pdev)
{
pdev->dev.dma_pfn_offset = dma_pfn_offset;
}
static int __init sh7786_pcie_core_init(void) static int __init sh7786_pcie_core_init(void)
{ {
/* Return the number of ports */ /* Return the number of ports */
......
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