Skip to content

Commit 959c9bd

Browse files
shangwozbenh
authored andcommitted
powerpc/powernv: Fix invalid IOMMU table
Ben found the root cause. Commit 37f0219 ("powerpc/pci: fix PCI-e devices rescan issue on powerpc platform") overwrites the IOMMU table of PCI device while enabling PCI device. The patch intends to fix the IOMMU table after that point. Signed-off-by: Gavin Shan <[email protected]> Signed-off-by: Benjamin Herrenschmidt <[email protected]>
1 parent 373f565 commit 959c9bd

File tree

1 file changed

+12
-21
lines changed

1 file changed

+12
-21
lines changed

arch/powerpc/platforms/powernv/pci-ioda.c

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -434,20 +434,21 @@ static void pnv_pci_ioda_setup_PEs(void)
434434
}
435435
}
436436

437-
static void pnv_pci_ioda_dma_dev_setup(struct pnv_phb *phb, struct pci_dev *dev)
437+
static void pnv_pci_ioda_dma_dev_setup(struct pnv_phb *phb, struct pci_dev *pdev)
438438
{
439-
/* We delay DMA setup after we have assigned all PE# */
440-
}
439+
struct pci_dn *pdn = pnv_ioda_get_pdn(pdev);
440+
struct pnv_ioda_pe *pe;
441441

442-
static void pnv_ioda_setup_bus_dma(struct pnv_ioda_pe *pe, struct pci_bus *bus)
443-
{
444-
struct pci_dev *dev;
442+
/*
443+
* The function can be called while the PE#
444+
* hasn't been assigned. Do nothing for the
445+
* case.
446+
*/
447+
if (!pdn || pdn->pe_number == IODA_INVALID_PE)
448+
return;
445449

446-
list_for_each_entry(dev, &bus->devices, bus_list) {
447-
set_iommu_table_base(&dev->dev, &pe->tce32_table);
448-
if (dev->subordinate)
449-
pnv_ioda_setup_bus_dma(pe, dev->subordinate);
450-
}
450+
pe = &phb->ioda.pe_array[pdn->pe_number];
451+
set_iommu_table_base(&pdev->dev, &pe->tce32_table);
451452
}
452453

453454
static void pnv_pci_ioda1_tce_invalidate(struct iommu_table *tbl,
@@ -605,11 +606,6 @@ static void pnv_pci_ioda_setup_dma_pe(struct pnv_phb *phb,
605606
}
606607
iommu_init_table(tbl, phb->hose->node);
607608

608-
if (pe->pdev)
609-
set_iommu_table_base(&pe->pdev->dev, tbl);
610-
else
611-
pnv_ioda_setup_bus_dma(pe, pe->pbus);
612-
613609
return;
614610
fail:
615611
/* XXX Failure: Try to fallback to 64-bit only ? */
@@ -681,11 +677,6 @@ static void pnv_pci_ioda2_setup_dma_pe(struct pnv_phb *phb,
681677
}
682678
iommu_init_table(tbl, phb->hose->node);
683679

684-
if (pe->pdev)
685-
set_iommu_table_base(&pe->pdev->dev, tbl);
686-
else
687-
pnv_ioda_setup_bus_dma(pe, pe->pbus);
688-
689680
return;
690681
fail:
691682
if (pe->tce32_seg >= 0)

0 commit comments

Comments
 (0)