aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorMilton Miller <miltonm@bga.com>2011-05-11 08:24:57 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2011-05-19 03:25:27 -0400
commit64ac822fb4554fb516bce123a38b35e04e41fff5 (patch)
tree85cc5cfa796ae856213c46ba1817399d7beb5009 /arch
parent23a6c484047bb8ac50e6d5bb718f8d178a4bf32e (diff)
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: Milton Miller <miltonm@bga.com> Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/platforms/pseries/iommu.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index 44d47ac552a9..05c101e7dcd7 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -1026,9 +1026,12 @@ static int dma_set_mask_pSeriesLP(struct device *dev, u64 dma_mask)
1026 const void *dma_window = NULL; 1026 const void *dma_window = NULL;
1027 u64 dma_offset; 1027 u64 dma_offset;
1028 1028
1029 if (!dev->dma_mask || !dma_supported(dev, dma_mask)) 1029 if (!dev->dma_mask)
1030 return -EIO; 1030 return -EIO;
1031 1031
1032 if (!dev_is_pci(dev))
1033 goto check_mask;
1034
1032 pdev = to_pci_dev(dev); 1035 pdev = to_pci_dev(dev);
1033 1036
1034 /* only attempt to use a new window if 64-bit DMA is requested */ 1037 /* 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 } 1062 }
1060 } 1063 }
1061 1064
1062 /* fall-through to iommu ops */ 1065 /* fall back on iommu ops, restore table pointer with ops */
1063 if (!ddw_enabled) { 1066 if (!ddw_enabled && get_dma_ops(dev) != &dma_iommu_ops) {
1064 dev_info(dev, "Using 32-bit DMA via iommu\n"); 1067 dev_info(dev, "Restoring 32-bit DMA via iommu\n");
1065 set_dma_ops(dev, &dma_iommu_ops); 1068 set_dma_ops(dev, &dma_iommu_ops);
1066 pci_dma_dev_setup_pSeriesLP(pdev); 1069 pci_dma_dev_setup_pSeriesLP(pdev);
1067 } 1070 }
1068 1071
1072check_mask:
1073 if (!dma_supported(dev, dma_mask))
1074 return -EIO;
1075
1069 *dev->dma_mask = dma_mask; 1076 *dev->dma_mask = dma_mask;
1070 return 0; 1077 return 0;
1071} 1078}