static bool amd_iommu_pre_enabled = true;
 
+static u32 amd_iommu_ivinfo __initdata;
+
 bool translation_pre_enabled(struct amd_iommu *iommu)
 {
        return (iommu->flags & AMD_IOMMU_FLAG_TRANS_PRE_ENABLED);
        return amd_iommus_present;
 }
 
+/*
+ * For IVHD type 0x11/0x40, EFR is also available via IVHD.
+ * Default to IVHD EFR since it is available sooner
+ * (i.e. before PCI init).
+ */
+static void __init early_iommu_features_init(struct amd_iommu *iommu,
+                                            struct ivhd_header *h)
+{
+       if (amd_iommu_ivinfo & IOMMU_IVINFO_EFRSUP)
+               iommu->features = h->efr_reg;
+}
+
 /* Access to l1 and l2 indexed register spaces */
 
 static u32 iommu_read_l1(struct amd_iommu *iommu, u16 l1, u8 address)
 
                if (h->efr_reg & BIT(IOMMU_EFR_XTSUP_SHIFT))
                        amd_iommu_xt_mode = IRQ_REMAP_X2APIC_MODE;
+
+               early_iommu_features_init(iommu, h);
+
                break;
        default:
                return -EINVAL;
        NULL,
 };
 
+/*
+ * Note: IVHD 0x11 and 0x40 also contains exact copy
+ * of the IOMMU Extended Feature Register [MMIO Offset 0030h].
+ * Default to EFR in IVHD since it is available sooner (i.e. before PCI init).
+ */
+static void __init late_iommu_features_init(struct amd_iommu *iommu)
+{
+       u64 features;
+
+       if (!(iommu->cap & (1 << IOMMU_CAP_EFR)))
+               return;
+
+       /* read extended feature bits */
+       features = readq(iommu->mmio_base + MMIO_EXT_FEATURES);
+
+       if (!iommu->features) {
+               iommu->features = features;
+               return;
+       }
+
+       /*
+        * Sanity check and warn if EFR values from
+        * IVHD and MMIO conflict.
+        */
+       if (features != iommu->features)
+               pr_warn(FW_WARN "EFR mismatch. Use IVHD EFR (%#llx : %#llx\n).",
+                       features, iommu->features);
+}
+
 static int __init iommu_init_pci(struct amd_iommu *iommu)
 {
        int cap_ptr = iommu->cap_ptr;
        if (!(iommu->cap & (1 << IOMMU_CAP_IOTLB)))
                amd_iommu_iotlb_sup = false;
 
-       /* read extended feature bits */
-       iommu->features = readq(iommu->mmio_base + MMIO_EXT_FEATURES);
+       late_iommu_features_init(iommu);
 
        if (iommu_feature(iommu, FEATURE_GT)) {
                int glxval;
        free_unity_maps();
 }
 
+static void __init ivinfo_init(void *ivrs)
+{
+       amd_iommu_ivinfo = *((u32 *)(ivrs + IOMMU_IVINFO_OFFSET));
+}
+
 /*
  * This is the hardware init function for AMD IOMMU in the system.
  * This function is called either from amd_iommu_init or from the interrupt
        if (ret)
                goto out;
 
+       ivinfo_init(ivrs_base);
+
        amd_iommu_target_ivhd_type = get_highest_supported_ivhd_type(ivrs_base);
        DUMP_printk("Using IVHD type %#x\n", amd_iommu_target_ivhd_type);