Skip to content

Commit b592643

Browse files
aikmpe
authored andcommitted
powerpc/iommu/ioda2: Enable compile with IOV=on and IOMMU_API=off
The pnv_pci_ioda2_unset_window() function is used to do the final cleanup of a DMA window being released: - via VFIO ioctl by the guest request; - via unplugging a virtual PCI function. However the function was under #ifdef CONFIG_IOMMU_API and was missing. This moves the helper outside of IOMMU_API block and enables it for either or both IOMMU_API and PCI_IOV. Signed-off-by: Alexey Kardashevskiy <[email protected]> Reviewed-by: David Gibson <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent cdf2bc1 commit b592643

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

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

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,6 +2116,32 @@ static long pnv_pci_ioda2_setup_default_config(struct pnv_ioda_pe *pe)
21162116
return 0;
21172117
}
21182118

2119+
#if defined(CONFIG_IOMMU_API) || defined(CONFIG_PCI_IOV)
2120+
static long pnv_pci_ioda2_unset_window(struct iommu_table_group *table_group,
2121+
int num)
2122+
{
2123+
struct pnv_ioda_pe *pe = container_of(table_group, struct pnv_ioda_pe,
2124+
table_group);
2125+
struct pnv_phb *phb = pe->phb;
2126+
long ret;
2127+
2128+
pe_info(pe, "Removing DMA window #%d\n", num);
2129+
2130+
ret = opal_pci_map_pe_dma_window(phb->opal_id, pe->pe_number,
2131+
(pe->pe_number << 1) + num,
2132+
0/* levels */, 0/* table address */,
2133+
0/* table size */, 0/* page size */);
2134+
if (ret)
2135+
pe_warn(pe, "Unmapping failed, ret = %ld\n", ret);
2136+
else
2137+
pnv_pci_ioda2_tce_invalidate_entire(pe);
2138+
2139+
pnv_pci_unlink_table_and_group(table_group->tables[num], table_group);
2140+
2141+
return ret;
2142+
}
2143+
#endif
2144+
21192145
#ifdef CONFIG_IOMMU_API
21202146
static unsigned long pnv_pci_ioda2_get_table_size(__u32 page_shift,
21212147
__u64 window_size, __u32 levels)
@@ -2149,30 +2175,6 @@ static unsigned long pnv_pci_ioda2_get_table_size(__u32 page_shift,
21492175
return bytes;
21502176
}
21512177

2152-
static long pnv_pci_ioda2_unset_window(struct iommu_table_group *table_group,
2153-
int num)
2154-
{
2155-
struct pnv_ioda_pe *pe = container_of(table_group, struct pnv_ioda_pe,
2156-
table_group);
2157-
struct pnv_phb *phb = pe->phb;
2158-
long ret;
2159-
2160-
pe_info(pe, "Removing DMA window #%d\n", num);
2161-
2162-
ret = opal_pci_map_pe_dma_window(phb->opal_id, pe->pe_number,
2163-
(pe->pe_number << 1) + num,
2164-
0/* levels */, 0/* table address */,
2165-
0/* table size */, 0/* page size */);
2166-
if (ret)
2167-
pe_warn(pe, "Unmapping failed, ret = %ld\n", ret);
2168-
else
2169-
pnv_pci_ioda2_tce_invalidate_entire(pe);
2170-
2171-
pnv_pci_unlink_table_and_group(table_group->tables[num], table_group);
2172-
2173-
return ret;
2174-
}
2175-
21762178
static void pnv_ioda2_take_ownership(struct iommu_table_group *table_group)
21772179
{
21782180
struct pnv_ioda_pe *pe = container_of(table_group, struct pnv_ioda_pe,

0 commit comments

Comments
 (0)