Commit 959c9bdd authored by Gavin Shan's avatar Gavin Shan Committed by Benjamin Herrenschmidt

powerpc/powernv: Fix invalid IOMMU table

Ben found the root cause. Commit 37f02195
("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: default avatarGavin Shan <shangw@linux.vnet.ibm.com>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent 373f5657
...@@ -434,20 +434,21 @@ static void pnv_pci_ioda_setup_PEs(void) ...@@ -434,20 +434,21 @@ static void pnv_pci_ioda_setup_PEs(void)
} }
} }
static void pnv_pci_ioda_dma_dev_setup(struct pnv_phb *phb, struct pci_dev *dev) static void pnv_pci_ioda_dma_dev_setup(struct pnv_phb *phb, struct pci_dev *pdev)
{ {
/* We delay DMA setup after we have assigned all PE# */ struct pci_dn *pdn = pnv_ioda_get_pdn(pdev);
} struct pnv_ioda_pe *pe;
static void pnv_ioda_setup_bus_dma(struct pnv_ioda_pe *pe, struct pci_bus *bus) /*
{ * The function can be called while the PE#
struct pci_dev *dev; * hasn't been assigned. Do nothing for the
* case.
*/
if (!pdn || pdn->pe_number == IODA_INVALID_PE)
return;
list_for_each_entry(dev, &bus->devices, bus_list) { pe = &phb->ioda.pe_array[pdn->pe_number];
set_iommu_table_base(&dev->dev, &pe->tce32_table); set_iommu_table_base(&pdev->dev, &pe->tce32_table);
if (dev->subordinate)
pnv_ioda_setup_bus_dma(pe, dev->subordinate);
}
} }
static void pnv_pci_ioda1_tce_invalidate(struct iommu_table *tbl, 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, ...@@ -605,11 +606,6 @@ static void pnv_pci_ioda_setup_dma_pe(struct pnv_phb *phb,
} }
iommu_init_table(tbl, phb->hose->node); iommu_init_table(tbl, phb->hose->node);
if (pe->pdev)
set_iommu_table_base(&pe->pdev->dev, tbl);
else
pnv_ioda_setup_bus_dma(pe, pe->pbus);
return; return;
fail: fail:
/* XXX Failure: Try to fallback to 64-bit only ? */ /* 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, ...@@ -681,11 +677,6 @@ static void pnv_pci_ioda2_setup_dma_pe(struct pnv_phb *phb,
} }
iommu_init_table(tbl, phb->hose->node); iommu_init_table(tbl, phb->hose->node);
if (pe->pdev)
set_iommu_table_base(&pe->pdev->dev, tbl);
else
pnv_ioda_setup_bus_dma(pe, pe->pbus);
return; return;
fail: fail:
if (pe->tce32_seg >= 0) if (pe->tce32_seg >= 0)
......
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