diff options
author | Arvind Sankar <nivedita@alum.mit.edu> | 2019-10-08 10:33:57 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2019-10-18 11:19:20 -0400 |
commit | 9c24eaf81cc44d4bb38081c99eafd72ed85cf7f3 (patch) | |
tree | c7308459daee66e24068e6b1bd9e685553e36dd9 /drivers/iommu/intel-iommu.c | |
parent | 0e2adab6cf285c41e825b6c74a3aa61324d1132c (diff) |
iommu/vt-d: Return the correct dma mask when we are bypassing the IOMMU
We must return a mask covering the full physical RAM when bypassing the
IOMMU mapping. Also, in iommu_need_mapping, we need to check using
dma_direct_get_required_mask to ensure that the device's dma_mask can
cover physical RAM before deciding to bypass IOMMU mapping.
Based on an earlier patch from Christoph Hellwig.
Fixes: 249baa547901 ("dma-mapping: provide a better default ->get_required_mask")
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Acked-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/iommu/intel-iommu.c')
-rw-r--r-- | drivers/iommu/intel-iommu.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 3f974919d3bd..79e35b3180ac 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c | |||
@@ -3471,7 +3471,7 @@ static bool iommu_need_mapping(struct device *dev) | |||
3471 | if (dev->coherent_dma_mask && dev->coherent_dma_mask < dma_mask) | 3471 | if (dev->coherent_dma_mask && dev->coherent_dma_mask < dma_mask) |
3472 | dma_mask = dev->coherent_dma_mask; | 3472 | dma_mask = dev->coherent_dma_mask; |
3473 | 3473 | ||
3474 | if (dma_mask >= dma_get_required_mask(dev)) | 3474 | if (dma_mask >= dma_direct_get_required_mask(dev)) |
3475 | return false; | 3475 | return false; |
3476 | 3476 | ||
3477 | /* | 3477 | /* |
@@ -3775,6 +3775,13 @@ static int intel_map_sg(struct device *dev, struct scatterlist *sglist, int nele | |||
3775 | return nelems; | 3775 | return nelems; |
3776 | } | 3776 | } |
3777 | 3777 | ||
3778 | static u64 intel_get_required_mask(struct device *dev) | ||
3779 | { | ||
3780 | if (!iommu_need_mapping(dev)) | ||
3781 | return dma_direct_get_required_mask(dev); | ||
3782 | return DMA_BIT_MASK(32); | ||
3783 | } | ||
3784 | |||
3778 | static const struct dma_map_ops intel_dma_ops = { | 3785 | static const struct dma_map_ops intel_dma_ops = { |
3779 | .alloc = intel_alloc_coherent, | 3786 | .alloc = intel_alloc_coherent, |
3780 | .free = intel_free_coherent, | 3787 | .free = intel_free_coherent, |
@@ -3787,6 +3794,7 @@ static const struct dma_map_ops intel_dma_ops = { | |||
3787 | .dma_supported = dma_direct_supported, | 3794 | .dma_supported = dma_direct_supported, |
3788 | .mmap = dma_common_mmap, | 3795 | .mmap = dma_common_mmap, |
3789 | .get_sgtable = dma_common_get_sgtable, | 3796 | .get_sgtable = dma_common_get_sgtable, |
3797 | .get_required_mask = intel_get_required_mask, | ||
3790 | }; | 3798 | }; |
3791 | 3799 | ||
3792 | static void | 3800 | static void |