Merge branches 'iommu/fixes', 'x86/vt-d', 'x86/amd', 'ppc/pamu', 'core' and 'arm...
[cascardo/linux.git] / drivers / iommu / intel-iommu.c
index 0099667..b4f0e28 100644 (file)
@@ -47,6 +47,7 @@
 #include <asm/iommu.h>
 
 #include "irq_remapping.h"
+#include "pci.h"
 
 #define ROOT_SIZE              VTD_PAGE_SIZE
 #define CONTEXT_SIZE           VTD_PAGE_SIZE
@@ -3665,6 +3666,7 @@ static struct notifier_block device_nb = {
 int __init intel_iommu_init(void)
 {
        int ret = 0;
+       struct dmar_drhd_unit *drhd;
 
        /* VT-d is required for a TXT/tboot launch, so enforce that */
        force_on = tboot_force_iommu();
@@ -3675,6 +3677,20 @@ int __init intel_iommu_init(void)
                return  -ENODEV;
        }
 
+       /*
+        * Disable translation if already enabled prior to OS handover.
+        */
+       for_each_drhd_unit(drhd) {
+               struct intel_iommu *iommu;
+
+               if (drhd->ignored)
+                       continue;
+
+               iommu = drhd->iommu;
+               if (iommu->gcmd & DMA_GCMD_TE)
+                       iommu_disable_translation(iommu);
+       }
+
        if (dmar_dev_scope_init() < 0) {
                if (force_on)
                        panic("tboot: Failed to initialize DMAR device scope\n");
@@ -4111,7 +4127,7 @@ static size_t intel_iommu_unmap(struct iommu_domain *domain,
 }
 
 static phys_addr_t intel_iommu_iova_to_phys(struct iommu_domain *domain,
-                                           unsigned long iova)
+                                           dma_addr_t iova)
 {
        struct dmar_domain *dmar_domain = domain->priv;
        struct dma_pte *pte;
@@ -4137,12 +4153,6 @@ static int intel_iommu_domain_has_cap(struct iommu_domain *domain,
        return 0;
 }
 
-static void swap_pci_ref(struct pci_dev **from, struct pci_dev *to)
-{
-       pci_dev_put(*from);
-       *from = to;
-}
-
 #define REQ_ACS_FLAGS  (PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF)
 
 static int intel_iommu_add_device(struct device *dev)