x86/amd-iommu: Set iommu configuration flags in enable-loop

This patch moves the setting of the configuration and
feature flags out out the acpi table parsing path and moves
it into the iommu-enable path. This is needed to reliably
fix resume-from-s3.

Cc: stable@kernel.org
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>

+30 -22
+3
arch/x86/include/asm/amd_iommu_types.h
··· 368 368 /* capabilities of that IOMMU read from ACPI */ 369 369 u32 cap; 370 370 371 + /* flags read from acpi table */ 372 + u8 acpi_flags; 373 + 371 374 /* 372 375 * Capability pointer. There could be more than one IOMMU per PCI 373 376 * device function if there are more than one AMD IOMMU capability
+27 -22
arch/x86/kernel/amd_iommu_init.c
··· 649 649 struct ivhd_entry *e; 650 650 651 651 /* 652 - * First set the recommended feature enable bits from ACPI 653 - * into the IOMMU control registers 652 + * First save the recommended feature enable bits from ACPI 654 653 */ 655 - h->flags & IVHD_FLAG_HT_TUN_EN_MASK ? 656 - iommu_feature_enable(iommu, CONTROL_HT_TUN_EN) : 657 - iommu_feature_disable(iommu, CONTROL_HT_TUN_EN); 658 - 659 - h->flags & IVHD_FLAG_PASSPW_EN_MASK ? 660 - iommu_feature_enable(iommu, CONTROL_PASSPW_EN) : 661 - iommu_feature_disable(iommu, CONTROL_PASSPW_EN); 662 - 663 - h->flags & IVHD_FLAG_RESPASSPW_EN_MASK ? 664 - iommu_feature_enable(iommu, CONTROL_RESPASSPW_EN) : 665 - iommu_feature_disable(iommu, CONTROL_RESPASSPW_EN); 666 - 667 - h->flags & IVHD_FLAG_ISOC_EN_MASK ? 668 - iommu_feature_enable(iommu, CONTROL_ISOC_EN) : 669 - iommu_feature_disable(iommu, CONTROL_ISOC_EN); 670 - 671 - /* 672 - * make IOMMU memory accesses cache coherent 673 - */ 674 - iommu_feature_enable(iommu, CONTROL_COHERENT_EN); 654 + iommu->acpi_flags = h->flags; 675 655 676 656 /* 677 657 * Done. Now parse the device entries ··· 1096 1116 } 1097 1117 } 1098 1118 1119 + static void iommu_init_flags(struct amd_iommu *iommu) 1120 + { 1121 + iommu->acpi_flags & IVHD_FLAG_HT_TUN_EN_MASK ? 1122 + iommu_feature_enable(iommu, CONTROL_HT_TUN_EN) : 1123 + iommu_feature_disable(iommu, CONTROL_HT_TUN_EN); 1124 + 1125 + iommu->acpi_flags & IVHD_FLAG_PASSPW_EN_MASK ? 1126 + iommu_feature_enable(iommu, CONTROL_PASSPW_EN) : 1127 + iommu_feature_disable(iommu, CONTROL_PASSPW_EN); 1128 + 1129 + iommu->acpi_flags & IVHD_FLAG_RESPASSPW_EN_MASK ? 1130 + iommu_feature_enable(iommu, CONTROL_RESPASSPW_EN) : 1131 + iommu_feature_disable(iommu, CONTROL_RESPASSPW_EN); 1132 + 1133 + iommu->acpi_flags & IVHD_FLAG_ISOC_EN_MASK ? 1134 + iommu_feature_enable(iommu, CONTROL_ISOC_EN) : 1135 + iommu_feature_disable(iommu, CONTROL_ISOC_EN); 1136 + 1137 + /* 1138 + * make IOMMU memory accesses cache coherent 1139 + */ 1140 + iommu_feature_enable(iommu, CONTROL_COHERENT_EN); 1141 + } 1142 + 1099 1143 /* 1100 1144 * This function finally enables all IOMMUs found in the system after 1101 1145 * they have been initialized ··· 1130 1126 1131 1127 for_each_iommu(iommu) { 1132 1128 iommu_disable(iommu); 1129 + iommu_init_flags(iommu); 1133 1130 iommu_set_device_table(iommu); 1134 1131 iommu_enable_command_buffer(iommu); 1135 1132 iommu_enable_event_buffer(iommu);