Skip to content

Commit f0228c4

Browse files
ozbenhmpe
authored andcommitted
powerpc/powernv/pci: Fallback to OPAL for TCE invalidations
If we don't find registers for the PHB or don't know the model specific invalidation method, use OPAL calls instead. Signed-off-by: Benjamin Herrenschmidt <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent fd141d1 commit f0228c4

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

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

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,6 +1861,17 @@ static void pnv_pci_phb3_tce_invalidate(struct pnv_ioda_pe *pe, bool rm,
18611861
}
18621862
}
18631863

1864+
static inline void pnv_pci_ioda2_tce_invalidate_pe(struct pnv_ioda_pe *pe)
1865+
{
1866+
struct pnv_phb *phb = pe->phb;
1867+
1868+
if (phb->model == PNV_PHB_MODEL_PHB3 && phb->regs)
1869+
pnv_pci_phb3_tce_invalidate_pe(pe);
1870+
else
1871+
opal_pci_tce_kill(phb->opal_id, OPAL_PCI_TCE_KILL_PE,
1872+
pe->pe_number, 0, 0, 0);
1873+
}
1874+
18641875
static void pnv_pci_ioda2_tce_invalidate(struct iommu_table *tbl,
18651876
unsigned long index, unsigned long npages, bool rm)
18661877
{
@@ -1869,17 +1880,31 @@ static void pnv_pci_ioda2_tce_invalidate(struct iommu_table *tbl,
18691880
list_for_each_entry_rcu(tgl, &tbl->it_group_list, next) {
18701881
struct pnv_ioda_pe *pe = container_of(tgl->table_group,
18711882
struct pnv_ioda_pe, table_group);
1872-
if (pe->phb->type == PNV_PHB_NPU) {
1883+
struct pnv_phb *phb = pe->phb;
1884+
unsigned int shift = tbl->it_page_shift;
1885+
1886+
if (phb->type == PNV_PHB_NPU) {
18731887
/*
18741888
* The NVLink hardware does not support TCE kill
18751889
* per TCE entry so we have to invalidate
18761890
* the entire cache for it.
18771891
*/
1878-
pnv_pci_phb3_tce_invalidate_entire(pe->phb, rm);
1892+
pnv_pci_phb3_tce_invalidate_entire(phb, rm);
18791893
continue;
18801894
}
1881-
pnv_pci_phb3_tce_invalidate(pe, rm, tbl->it_page_shift,
1882-
index, npages);
1895+
if (phb->model == PNV_PHB_MODEL_PHB3 && phb->regs)
1896+
pnv_pci_phb3_tce_invalidate(pe, rm, shift,
1897+
index, npages);
1898+
else if (rm)
1899+
opal_rm_pci_tce_kill(phb->opal_id,
1900+
OPAL_PCI_TCE_KILL_PAGES,
1901+
pe->pe_number, 1u << shift,
1902+
index << shift, npages);
1903+
else
1904+
opal_pci_tce_kill(phb->opal_id,
1905+
OPAL_PCI_TCE_KILL_PAGES,
1906+
pe->pe_number, 1u << shift,
1907+
index << shift, npages);
18831908
}
18841909
}
18851910

0 commit comments

Comments
 (0)