aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/sysdev
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2013-05-05 23:40:40 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2013-05-05 23:40:40 -0400
commit3fd47f063b17692e843128e2abda3e697df42198 (patch)
treed90a5bdd247b0cc5af7cf78cd18cf6e27a884f00 /arch/powerpc/sysdev
parent342d6666f7276723e418b91c885b0c03f02eeaaf (diff)
powerpc/pci: Support per-aperture memory offset
The PCI core supports an offset per aperture nowadays but our arch code still has a single offset per host bridge representing the difference betwen CPU memory addresses and PCI MMIO addresses. This is a problem as new machines and hypervisor versions are coming out where the 64-bit windows will have a different offset (basically mapped 1:1) from the 32-bit windows. This fixes it by using separate offsets. In the long run, we probably want to get rid of that intermediary struct pci_controller and have those directly stored into the pci_host_bridge as they are parsed but this will be a more invasive change. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/sysdev')
-rw-r--r--arch/powerpc/sysdev/fsl_pci.c11
-rw-r--r--arch/powerpc/sysdev/ppc4xx_pci.c15
2 files changed, 15 insertions, 11 deletions
diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
index cffe7edac858..028ac1f71b51 100644
--- a/arch/powerpc/sysdev/fsl_pci.c
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -178,7 +178,7 @@ static void setup_pci_atmu(struct pci_controller *hose)
178 struct ccsr_pci __iomem *pci = hose->private_data; 178 struct ccsr_pci __iomem *pci = hose->private_data;
179 int i, j, n, mem_log, win_idx = 3, start_idx = 1, end_idx = 4; 179 int i, j, n, mem_log, win_idx = 3, start_idx = 1, end_idx = 4;
180 u64 mem, sz, paddr_hi = 0; 180 u64 mem, sz, paddr_hi = 0;
181 u64 paddr_lo = ULLONG_MAX; 181 u64 offset = 0, paddr_lo = ULLONG_MAX;
182 u32 pcicsrbar = 0, pcicsrbar_sz; 182 u32 pcicsrbar = 0, pcicsrbar_sz;
183 u32 piwar = PIWAR_EN | PIWAR_PF | PIWAR_TGI_LOCAL | 183 u32 piwar = PIWAR_EN | PIWAR_PF | PIWAR_TGI_LOCAL |
184 PIWAR_READ_SNOOP | PIWAR_WRITE_SNOOP; 184 PIWAR_READ_SNOOP | PIWAR_WRITE_SNOOP;
@@ -208,8 +208,9 @@ static void setup_pci_atmu(struct pci_controller *hose)
208 paddr_lo = min(paddr_lo, (u64)hose->mem_resources[i].start); 208 paddr_lo = min(paddr_lo, (u64)hose->mem_resources[i].start);
209 paddr_hi = max(paddr_hi, (u64)hose->mem_resources[i].end); 209 paddr_hi = max(paddr_hi, (u64)hose->mem_resources[i].end);
210 210
211 n = setup_one_atmu(pci, j, &hose->mem_resources[i], 211 /* We assume all memory resources have the same offset */
212 hose->pci_mem_offset); 212 offset = hose->mem_offset[i];
213 n = setup_one_atmu(pci, j, &hose->mem_resources[i], offset);
213 214
214 if (n < 0 || j >= 5) { 215 if (n < 0 || j >= 5) {
215 pr_err("Ran out of outbound PCI ATMUs for resource %d!\n", i); 216 pr_err("Ran out of outbound PCI ATMUs for resource %d!\n", i);
@@ -239,8 +240,8 @@ static void setup_pci_atmu(struct pci_controller *hose)
239 } 240 }
240 241
241 /* convert to pci address space */ 242 /* convert to pci address space */
242 paddr_hi -= hose->pci_mem_offset; 243 paddr_hi -= offset;
243 paddr_lo -= hose->pci_mem_offset; 244 paddr_lo -= offset;
244 245
245 if (paddr_hi == paddr_lo) { 246 if (paddr_hi == paddr_lo) {
246 pr_err("%s: No outbound window space\n", name); 247 pr_err("%s: No outbound window space\n", name);
diff --git a/arch/powerpc/sysdev/ppc4xx_pci.c b/arch/powerpc/sysdev/ppc4xx_pci.c
index 56e8b3c3c890..64603a10b863 100644
--- a/arch/powerpc/sysdev/ppc4xx_pci.c
+++ b/arch/powerpc/sysdev/ppc4xx_pci.c
@@ -257,6 +257,7 @@ static void __init ppc4xx_configure_pci_PMMs(struct pci_controller *hose,
257 /* Setup outbound memory windows */ 257 /* Setup outbound memory windows */
258 for (i = j = 0; i < 3; i++) { 258 for (i = j = 0; i < 3; i++) {
259 struct resource *res = &hose->mem_resources[i]; 259 struct resource *res = &hose->mem_resources[i];
260 resource_size_t offset = hose->mem_offset[i];
260 261
261 /* we only care about memory windows */ 262 /* we only care about memory windows */
262 if (!(res->flags & IORESOURCE_MEM)) 263 if (!(res->flags & IORESOURCE_MEM))
@@ -270,7 +271,7 @@ static void __init ppc4xx_configure_pci_PMMs(struct pci_controller *hose,
270 /* Configure the resource */ 271 /* Configure the resource */
271 if (ppc4xx_setup_one_pci_PMM(hose, reg, 272 if (ppc4xx_setup_one_pci_PMM(hose, reg,
272 res->start, 273 res->start,
273 res->start - hose->pci_mem_offset, 274 res->start - offset,
274 resource_size(res), 275 resource_size(res),
275 res->flags, 276 res->flags,
276 j) == 0) { 277 j) == 0) {
@@ -279,7 +280,7 @@ static void __init ppc4xx_configure_pci_PMMs(struct pci_controller *hose,
279 /* If the resource PCI address is 0 then we have our 280 /* If the resource PCI address is 0 then we have our
280 * ISA memory hole 281 * ISA memory hole
281 */ 282 */
282 if (res->start == hose->pci_mem_offset) 283 if (res->start == offset)
283 found_isa_hole = 1; 284 found_isa_hole = 1;
284 } 285 }
285 } 286 }
@@ -457,6 +458,7 @@ static void __init ppc4xx_configure_pcix_POMs(struct pci_controller *hose,
457 /* Setup outbound memory windows */ 458 /* Setup outbound memory windows */
458 for (i = j = 0; i < 3; i++) { 459 for (i = j = 0; i < 3; i++) {
459 struct resource *res = &hose->mem_resources[i]; 460 struct resource *res = &hose->mem_resources[i];
461 resource_size_t offset = hose->mem_offset[i];
460 462
461 /* we only care about memory windows */ 463 /* we only care about memory windows */
462 if (!(res->flags & IORESOURCE_MEM)) 464 if (!(res->flags & IORESOURCE_MEM))
@@ -470,7 +472,7 @@ static void __init ppc4xx_configure_pcix_POMs(struct pci_controller *hose,
470 /* Configure the resource */ 472 /* Configure the resource */
471 if (ppc4xx_setup_one_pcix_POM(hose, reg, 473 if (ppc4xx_setup_one_pcix_POM(hose, reg,
472 res->start, 474 res->start,
473 res->start - hose->pci_mem_offset, 475 res->start - offset,
474 resource_size(res), 476 resource_size(res),
475 res->flags, 477 res->flags,
476 j) == 0) { 478 j) == 0) {
@@ -479,7 +481,7 @@ static void __init ppc4xx_configure_pcix_POMs(struct pci_controller *hose,
479 /* If the resource PCI address is 0 then we have our 481 /* If the resource PCI address is 0 then we have our
480 * ISA memory hole 482 * ISA memory hole
481 */ 483 */
482 if (res->start == hose->pci_mem_offset) 484 if (res->start == offset)
483 found_isa_hole = 1; 485 found_isa_hole = 1;
484 } 486 }
485 } 487 }
@@ -1792,6 +1794,7 @@ static void __init ppc4xx_configure_pciex_POMs(struct ppc4xx_pciex_port *port,
1792 /* Setup outbound memory windows */ 1794 /* Setup outbound memory windows */
1793 for (i = j = 0; i < 3; i++) { 1795 for (i = j = 0; i < 3; i++) {
1794 struct resource *res = &hose->mem_resources[i]; 1796 struct resource *res = &hose->mem_resources[i];
1797 resource_size_t offset = hose->mem_offset[i];
1795 1798
1796 /* we only care about memory windows */ 1799 /* we only care about memory windows */
1797 if (!(res->flags & IORESOURCE_MEM)) 1800 if (!(res->flags & IORESOURCE_MEM))
@@ -1805,7 +1808,7 @@ static void __init ppc4xx_configure_pciex_POMs(struct ppc4xx_pciex_port *port,
1805 /* Configure the resource */ 1808 /* Configure the resource */
1806 if (ppc4xx_setup_one_pciex_POM(port, hose, mbase, 1809 if (ppc4xx_setup_one_pciex_POM(port, hose, mbase,
1807 res->start, 1810 res->start,
1808 res->start - hose->pci_mem_offset, 1811 res->start - offset,
1809 resource_size(res), 1812 resource_size(res),
1810 res->flags, 1813 res->flags,
1811 j) == 0) { 1814 j) == 0) {
@@ -1814,7 +1817,7 @@ static void __init ppc4xx_configure_pciex_POMs(struct ppc4xx_pciex_port *port,
1814 /* If the resource PCI address is 0 then we have our 1817 /* If the resource PCI address is 0 then we have our
1815 * ISA memory hole 1818 * ISA memory hole
1816 */ 1819 */
1817 if (res->start == hose->pci_mem_offset) 1820 if (res->start == offset)
1818 found_isa_hole = 1; 1821 found_isa_hole = 1;
1819 } 1822 }
1820 } 1823 }