Re: [PATCH v3 3/3] iommu/amd: Remove ad-hoc checks that are never true
From: Ankit Soni
Date: Fri Aug 28 2026 - 11:57:07 EST
On Sun, Aug 23, 2026 at 06:20:17AM +0800, Rong Zhang wrote:
> The state transitions of the AMD IOMMU Initialization State Machine
> imply that some ad-hoc checks will never be true. In detail, they are
> only reachable if the previous state transitions have succeeded, but the
> conditions are only true if the previous state transitions have failed.
>
> Therefore, remove the redundant ad-hoc checks.
>
> Signed-off-by: Rong Zhang <i@xxxxxxxx>
Reviewed-by: Ankit Soni <Ankit.Soni@xxxxxxx>
> ---
> drivers/iommu/amd/init.c | 13 +------------
> 1 file changed, 1 insertion(+), 12 deletions(-)
>
> diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
> index 72b5b11b9d75..d81adb8efe0e 100644
> --- a/drivers/iommu/amd/init.c
> +++ b/drivers/iommu/amd/init.c
> @@ -163,7 +163,6 @@ int amd_iommu_gpt_level = PAGE_MODE_4_LEVEL;
> int amd_iommu_guest_ir = AMD_IOMMU_GUEST_IR_VAPIC;
> static int amd_iommu_xt_mode = IRQ_REMAP_XAPIC_MODE;
>
> -static bool amd_iommu_detected;
> static bool amd_iommu_disabled __initdata;
> static bool amd_iommu_force_enable __initdata;
> static bool amd_iommu_irtcachedis;
> @@ -3222,9 +3221,6 @@ static int __init early_amd_iommu_init(void)
> acpi_status status;
> u8 efr_hats, max_vasize;
>
> - if (!amd_iommu_detected)
> - return -ENODEV;
> -
> status = acpi_get_table("IVRS", 0, &ivrs_base);
> if (status == AE_NOT_FOUND)
> return -ENODEV;
> @@ -3303,7 +3299,7 @@ static int __init early_amd_iommu_init(void)
> }
>
> /* Disable any previously enabled IOMMUs */
> - if (!is_kdump_kernel() || amd_iommu_disabled)
> + if (!is_kdump_kernel())
> disable_iommus();
>
> if (amd_iommu_irq_remap)
> @@ -3398,12 +3394,6 @@ static __init void iommu_snp_enable(void)
> if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP))
> return;
>
> - /* SNP support required IOMMU to be ON */
> - if (no_iommu) {
> - pr_warn("SNP: IOMMU disabled, SNP cannot be supported.\n");
> - goto disable_snp;
> - }
> -
> amd_iommu_snp_mode0_sup = check_feature2(FEATURE_SNP_PAGE_MODE0_SUP);
> /*
> * If SNP page mode 0 is not enabled, then SNP support requires that IOMMU
> @@ -3716,7 +3706,6 @@ void __init amd_iommu_detect(void)
> if (ret)
> goto disable_snp;
>
> - amd_iommu_detected = true;
> iommu_detected = 1;
> x86_init.iommu.iommu_init = amd_iommu_init;
> return;
>
> --
> 2.55.0
>