Skip to content

Commit 119c850

Browse files
committed
Merge tag 'powerpc-5.15-6' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc fixes from Michael Ellerman: "Three commits fixing some issues introduced with the recent IOMMU changes we merged. Thanks to Alexey Kardashevskiy" * tag 'powerpc-5.15-6' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: powerpc/pseries/iommu: Create huge DMA window if no MMIO32 is present powerpc/pseries/iommu: Check if the default window in use before removing it powerpc/pseries/iommu: Use correct vfree for it_map
2 parents db2398a + d853adc commit 119c850

File tree

1 file changed

+14
-13
lines changed
  • arch/powerpc/platforms/pseries

1 file changed

+14
-13
lines changed

arch/powerpc/platforms/pseries/iommu.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,6 +1302,12 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)
13021302
struct property *default_win;
13031303
int reset_win_ext;
13041304

1305+
/* DDW + IOMMU on single window may fail if there is any allocation */
1306+
if (iommu_table_in_use(tbl)) {
1307+
dev_warn(&dev->dev, "current IOMMU table in use, can't be replaced.\n");
1308+
goto out_failed;
1309+
}
1310+
13051311
default_win = of_find_property(pdn, "ibm,dma-window", NULL);
13061312
if (!default_win)
13071313
goto out_failed;
@@ -1356,12 +1362,6 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)
13561362
query.largest_available_block,
13571363
1ULL << page_shift);
13581364

1359-
/* DDW + IOMMU on single window may fail if there is any allocation */
1360-
if (default_win_removed && iommu_table_in_use(tbl)) {
1361-
dev_dbg(&dev->dev, "current IOMMU table in use, can't be replaced.\n");
1362-
goto out_failed;
1363-
}
1364-
13651365
len = order_base_2(query.largest_available_block << page_shift);
13661366
win_name = DMA64_PROPNAME;
13671367
} else {
@@ -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,15 +1433,15 @@ 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

14401440
/* Keep default DMA window stuct if removed */
14411441
if (default_win_removed) {
14421442
tbl->it_size = 0;
1443-
kfree(tbl->it_map);
1443+
vfree(tbl->it_map);
1444+
tbl->it_map = NULL;
14441445
}
14451446

14461447
set_iommu_table_base(&dev->dev, newtbl);

0 commit comments

Comments
 (0)