Skip to content

Commit 92fe01b

Browse files
aikmpe
authored andcommitted
powerpc/pseries/iommu: Check if the default window in use before removing it
At the moment this check is performed after we remove the default window which is late and disallows to revert whatever changes enable_ddw() has made to DMA windows. This moves the check and error exit before removing the window. This raised the message severity from "debug" to "warning" as this should not happen in practice and cannot be triggered by the userspace. 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 41ee723 commit 92fe01b

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
@@ -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 {

0 commit comments

Comments
 (0)