Skip to content

Commit d853adc

Browse files
aikmpe
authored andcommitted
powerpc/pseries/iommu: Create huge DMA window if no MMIO32 is present
The iommu_init_table() helper takes an address range to reserve in the IOMMU table being initialized to exclude MMIO addresses, this is useful if the window stretches far beyond 4GB (although wastes some TCEs). At the moment the code searches for such MMIO32 range and fails if none found which is considered a problem while it really is not: it is actually better as this says there is no MMIO32 to reserve and we can use usually wasted TCEs. Furthermore PHYP never actually allows creating windows starting at busaddress=0 so this MMIO32 range is never useful. This removes error exit and initializes the table with zero range if no MMIO32 is detected. Fixes: 381ceda ("powerpc/pseries/iommu: Make use of DDW for indirect mapping") Signed-off-by: Alexey Kardashevskiy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 92fe01b commit d853adc

File tree

1 file changed

+6
-6
lines changed
  • arch/powerpc/platforms/pseries

1 file changed

+6
-6
lines changed

arch/powerpc/platforms/pseries/iommu.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,18 +1411,19 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)
14111411
} else {
14121412
struct iommu_table *newtbl;
14131413
int i;
1414+
unsigned long start = 0, end = 0;
14141415

14151416
for (i = 0; i < ARRAY_SIZE(pci->phb->mem_resources); i++) {
14161417
const unsigned long mask = IORESOURCE_MEM_64 | IORESOURCE_MEM;
14171418

14181419
/* Look for MMIO32 */
1419-
if ((pci->phb->mem_resources[i].flags & mask) == IORESOURCE_MEM)
1420+
if ((pci->phb->mem_resources[i].flags & mask) == IORESOURCE_MEM) {
1421+
start = pci->phb->mem_resources[i].start;
1422+
end = pci->phb->mem_resources[i].end;
14201423
break;
1424+
}
14211425
}
14221426

1423-
if (i == ARRAY_SIZE(pci->phb->mem_resources))
1424-
goto out_del_list;
1425-
14261427
/* New table for using DDW instead of the default DMA window */
14271428
newtbl = iommu_pseries_alloc_table(pci->phb->node);
14281429
if (!newtbl) {
@@ -1432,8 +1433,7 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)
14321433

14331434
iommu_table_setparms_common(newtbl, pci->phb->bus->number, create.liobn, win_addr,
14341435
1UL << len, page_shift, NULL, &iommu_table_lpar_multi_ops);
1435-
iommu_init_table(newtbl, pci->phb->node, pci->phb->mem_resources[i].start,
1436-
pci->phb->mem_resources[i].end);
1436+
iommu_init_table(newtbl, pci->phb->node, start, end);
14371437

14381438
pci->table_group->tables[1] = newtbl;
14391439

0 commit comments

Comments
 (0)