Skip to content

Commit 5aee87c

Browse files
author
David S. Miller
committed
[SPARC64]: Fix PCI memory space root resource on Hummingbird.
For Hummingbird PCI controllers, we should create the root PCI memory space resource as the full 4GB area, and then allocate the IOMMU DMA translation window out of there. The old code just assumed that the IOMMU DMA translation base to the top of the 4GB area was unusable. This is not true on many systems such as SB100 and SB150, where the IOMMU DMA translation window sits at 0xc0000000->0xdfffffff. So what would happen is that any device mapped by the firmware at the top section 0xe0000000->0xffffffff would get remapped by Linux somewhere else leading to all kinds of problems and boot failures. While we're here, report more cases of OBP resource assignment conflicts. The only truly valid ones are ROM resource conflicts. Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7341df1 commit 5aee87c

2 files changed

Lines changed: 29 additions & 23 deletions

File tree

‎arch/sparc64/kernel/pci_common.c‎

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -330,19 +330,6 @@ __init get_device_resource(struct linux_prom_pci_registers *ap,
330330
return res;
331331
}
332332

333-
static int __init pdev_resource_collisions_expected(struct pci_dev *pdev)
334-
{
335-
if (pdev->vendor != PCI_VENDOR_ID_SUN)
336-
return 0;
337-
338-
if (pdev->device == PCI_DEVICE_ID_SUN_RIO_EBUS ||
339-
pdev->device == PCI_DEVICE_ID_SUN_RIO_1394 ||
340-
pdev->device == PCI_DEVICE_ID_SUN_RIO_USB)
341-
return 1;
342-
343-
return 0;
344-
}
345-
346333
static void __init pdev_record_assignments(struct pci_pbm_info *pbm,
347334
struct pci_dev *pdev)
348335
{
@@ -400,19 +387,23 @@ static void __init pdev_record_assignments(struct pci_pbm_info *pbm,
400387
pbm->parent->resource_adjust(pdev, res, root);
401388

402389
if (request_resource(root, res) < 0) {
390+
int rnum;
391+
403392
/* OK, there is some conflict. But this is fine
404393
* since we'll reassign it in the fixup pass.
405394
*
406-
* We notify the user that OBP made an error if it
407-
* is a case we don't expect.
395+
* Do not print the warning for ROM resources
396+
* as such a conflict is quite common and
397+
* harmless as the ROM bar is disabled.
408398
*/
409-
if (!pdev_resource_collisions_expected(pdev)) {
410-
printk(KERN_ERR "PCI: Address space collision on region %ld "
399+
rnum = (res - &pdev->resource[0]);
400+
if (rnum != PCI_ROM_RESOURCE)
401+
printk(KERN_ERR "PCI: Resource collision, "
402+
"region %d "
411403
"[%016lx:%016lx] of device %s\n",
412-
(res - &pdev->resource[0]),
404+
rnum,
413405
res->start, res->end,
414406
pci_name(pdev));
415-
}
416407
}
417408
}
418409
}

‎arch/sparc64/kernel/pci_sabre.c‎

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,7 @@ static void pbm_register_toplevel_resources(struct pci_controller_info *p,
11961196
&pbm->mem_space);
11971197
}
11981198

1199-
static void sabre_pbm_init(struct pci_controller_info *p, struct device_node *dp, u32 dma_begin)
1199+
static void sabre_pbm_init(struct pci_controller_info *p, struct device_node *dp, u32 dma_start, u32 dma_end)
12001200
{
12011201
struct pci_pbm_info *pbm;
12021202
struct device_node *node;
@@ -1261,6 +1261,8 @@ static void sabre_pbm_init(struct pci_controller_info *p, struct device_node *dp
12611261
node = node->sibling;
12621262
}
12631263
if (simbas_found == 0) {
1264+
struct resource *rp;
1265+
12641266
/* No APBs underneath, probably this is a hummingbird
12651267
* system.
12661268
*/
@@ -1302,8 +1304,10 @@ static void sabre_pbm_init(struct pci_controller_info *p, struct device_node *dp
13021304
pbm->io_space.end = pbm->io_space.start + (1UL << 24) - 1UL;
13031305
pbm->io_space.flags = IORESOURCE_IO;
13041306

1305-
pbm->mem_space.start = p->pbm_A.controller_regs + SABRE_MEMSPACE;
1306-
pbm->mem_space.end = pbm->mem_space.start + (unsigned long)dma_begin - 1UL;
1307+
pbm->mem_space.start =
1308+
(p->pbm_A.controller_regs + SABRE_MEMSPACE);
1309+
pbm->mem_space.end =
1310+
(pbm->mem_space.start + ((1UL << 32UL) - 1UL));
13071311
pbm->mem_space.flags = IORESOURCE_MEM;
13081312

13091313
if (request_resource(&ioport_resource, &pbm->io_space) < 0) {
@@ -1315,6 +1319,17 @@ static void sabre_pbm_init(struct pci_controller_info *p, struct device_node *dp
13151319
prom_halt();
13161320
}
13171321

1322+
rp = kmalloc(sizeof(*rp), GFP_KERNEL);
1323+
if (!rp) {
1324+
prom_printf("Cannot allocate IOMMU resource.\n");
1325+
prom_halt();
1326+
}
1327+
rp->name = "IOMMU";
1328+
rp->start = pbm->mem_space.start + (unsigned long) dma_start;
1329+
rp->end = pbm->mem_space.start + (unsigned long) dma_end - 1UL;
1330+
rp->flags = IORESOURCE_BUSY;
1331+
request_resource(&pbm->mem_space, rp);
1332+
13181333
pci_register_legacy_regions(&pbm->io_space,
13191334
&pbm->mem_space);
13201335
}
@@ -1450,5 +1465,5 @@ void sabre_init(struct device_node *dp, char *model_name)
14501465
/*
14511466
* Look for APB underneath.
14521467
*/
1453-
sabre_pbm_init(p, dp, vdma[0]);
1468+
sabre_pbm_init(p, dp, vdma[0], vdma[1]);
14541469
}

0 commit comments

Comments
 (0)