iommu/vt-d: Disable translation if already enabled
[pandora-kernel.git] / drivers / iommu / dmar.c
index 97b2e21..cf065df 100644 (file)
@@ -582,7 +582,7 @@ int alloc_iommu(struct dmar_drhd_unit *drhd)
 {
        struct intel_iommu *iommu;
        int map_size;
-       u32 ver;
+       u32 ver, sts;
        static int iommu_allocated = 0;
        int agaw = 0;
        int msagaw = 0;
@@ -652,6 +652,15 @@ int alloc_iommu(struct dmar_drhd_unit *drhd)
                (unsigned long long)iommu->cap,
                (unsigned long long)iommu->ecap);
 
+       /* Reflect status in gcmd */
+       sts = readl(iommu->reg + DMAR_GSTS_REG);
+       if (sts & DMA_GSTS_IRES)
+               iommu->gcmd |= DMA_GCMD_IRE;
+       if (sts & DMA_GSTS_TES)
+               iommu->gcmd |= DMA_GCMD_TE;
+       if (sts & DMA_GSTS_QIES)
+               iommu->gcmd |= DMA_GCMD_QIE;
+
        raw_spin_lock_init(&iommu->register_lock);
 
        drhd->iommu = iommu;