提交 64ac822f 编写于 作者: M Milton Miller 提交者: Benjamin Herrenschmidt

powerpc/pseries/iommu: Add additional checks when changing iommu mask

Do not check dma supported until we have chosen the right dma ops.
Check that the device is pci before treating it as such.

Check the mask is supported by the selected dma ops before
committing it.

We only need to set iommu ops if it is not the current ops; this
avoids searching the tree for the iommu table unnecessarily.
Signed-off-by: NMilton Miller <miltonm@bga.com>
Signed-off-by: NNishanth Aravamudan <nacc@us.ibm.com>
Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
上级 23a6c484
...@@ -1026,9 +1026,12 @@ static int dma_set_mask_pSeriesLP(struct device *dev, u64 dma_mask) ...@@ -1026,9 +1026,12 @@ static int dma_set_mask_pSeriesLP(struct device *dev, u64 dma_mask)
const void *dma_window = NULL; const void *dma_window = NULL;
u64 dma_offset; u64 dma_offset;
if (!dev->dma_mask || !dma_supported(dev, dma_mask)) if (!dev->dma_mask)
return -EIO; return -EIO;
if (!dev_is_pci(dev))
goto check_mask;
pdev = to_pci_dev(dev); pdev = to_pci_dev(dev);
/* only attempt to use a new window if 64-bit DMA is requested */ /* only attempt to use a new window if 64-bit DMA is requested */
...@@ -1059,13 +1062,17 @@ static int dma_set_mask_pSeriesLP(struct device *dev, u64 dma_mask) ...@@ -1059,13 +1062,17 @@ static int dma_set_mask_pSeriesLP(struct device *dev, u64 dma_mask)
} }
} }
/* fall-through to iommu ops */ /* fall back on iommu ops, restore table pointer with ops */
if (!ddw_enabled) { if (!ddw_enabled && get_dma_ops(dev) != &dma_iommu_ops) {
dev_info(dev, "Using 32-bit DMA via iommu\n"); dev_info(dev, "Restoring 32-bit DMA via iommu\n");
set_dma_ops(dev, &dma_iommu_ops); set_dma_ops(dev, &dma_iommu_ops);
pci_dma_dev_setup_pSeriesLP(pdev); pci_dma_dev_setup_pSeriesLP(pdev);
} }
check_mask:
if (!dma_supported(dev, dma_mask))
return -EIO;
*dev->dma_mask = dma_mask; *dev->dma_mask = dma_mask;
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册