Re: [RFC 1/7] iommu/vt-d: Set the dma_ops per device so we can remove the iommu_no_mapping code

From
Tom Murphy <hidden>
Date
2019-05-06 15:27:25
Also in
kvm, linux-arm-msm, linux-iommu, linux-mediatek, linux-rockchip, linux-s390, linux-samsung-soc, linux-tegra, lkml
Reply to
Lu Baolu, 2019-05-06
On Mon, May 6, 2019 at 2:48 AM Lu Baolu [off-list ref] wrote:
Hi,

On 5/4/19 9:23 PM, Tom Murphy wrote:
quoted
Set the dma_ops per device so we can remove the iommu_no_mapping code.

Signed-off-by: Tom Murphy<redacted>
---
  drivers/iommu/intel-iommu.c | 85 +++----------------------------------
  1 file changed, 6 insertions(+), 79 deletions(-)
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index eace915602f0..2db1dc47e7e4 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -2622,17 +2622,6 @@ static int __init si_domain_init(int hw)
      return 0;
  }

-static int identity_mapping(struct device *dev)
-{
-     struct device_domain_info *info;
-
-     info = dev->archdata.iommu;
-     if (info && info != DUMMY_DEVICE_DOMAIN_INFO)
-             return (info->domain == si_domain);
-
-     return 0;
-}
-
  static int domain_add_dev_info(struct dmar_domain *domain, struct device *dev)
  {
      struct dmar_domain *ndomain;
@@ -3270,43 +3259,6 @@ static unsigned long intel_alloc_iova(struct device *dev,
      return iova_pfn;
  }

-/* Check if the dev needs to go through non-identity map and unmap process.*/
-static int iommu_no_mapping(struct device *dev)
-{
-     int found;
-
-     if (iommu_dummy(dev))
-             return 1;
-
-     found = identity_mapping(dev);
-     if (found) {
-             /*
-              * If the device's dma_mask is less than the system's memory
-              * size then this is not a candidate for identity mapping.
-              */
-             u64 dma_mask = *dev->dma_mask;
-
-             if (dev->coherent_dma_mask &&
-                 dev->coherent_dma_mask < dma_mask)
-                     dma_mask = dev->coherent_dma_mask;
-
-             if (dma_mask < dma_get_required_mask(dev)) {
-                     /*
-                      * 32 bit DMA is removed from si_domain and fall back
-                      * to non-identity mapping.
-                      */
-                     dmar_remove_one_dev_info(dev);
-                     dev_warn(dev, "32bit DMA uses non-identity mapping\n");
-
-                     return 0;
-             }
The iommu_no_mapping() also checks whether any 32bit DMA device uses
identity mapping. The device might not work if the system memory space
is bigger than 4G.
It looks like their is actually a bug in the v3 of the "iommu/vt-d:
Delegate DMA domain to generic iommu" patch set. I will leave a
message in that email thread. Fixing that bug should also fix this
issue.

Will you add this to other place, or it's unnecessary?

Best regards,
Lu Baolu
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Thread (15 messages) 15 messages, 2 authors, last reply 2019-05-06
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help