]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iommu/amd: Move V2 page table support check to early_amd_iommu_init()
authorVasant Hegde <vasant.hegde@amd.com>
Mon, 28 Oct 2024 09:38:04 +0000 (09:38 +0000)
committerJoerg Roedel <jroedel@suse.de>
Tue, 29 Oct 2024 09:08:20 +0000 (10:08 +0100)
amd_iommu_pgtable validation has to be done before calling
iommu_snp_enable(). It can be done immediately after reading IOMMU
features. Hence move this check to early_amd_iommu_init().

Signed-off-by: Vasant Hegde <vasant.hegde@amd.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/20241028093810.5901-7-vasant.hegde@amd.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/amd/init.c

index 7ae478d95e2bdbaf975546a06df47914532fa563..7c883be225599dc1b44421f9bbff35f4ced8c024 100644 (file)
@@ -2070,13 +2070,6 @@ static int __init iommu_init_pci(struct amd_iommu *iommu)
 
        init_iommu_perf_ctr(iommu);
 
-       if (amd_iommu_pgtable == AMD_IOMMU_V2) {
-               if (!amd_iommu_v2_pgtbl_supported()) {
-                       pr_warn("Cannot enable v2 page table for DMA-API. Fallback to v1.\n");
-                       amd_iommu_pgtable = AMD_IOMMU_V1;
-               }
-       }
-
        if (is_rd890_iommu(iommu->dev)) {
                int i, j;
 
@@ -3090,6 +3083,13 @@ static int __init early_amd_iommu_init(void)
            FIELD_GET(FEATURE_GATS, amd_iommu_efr) == GUEST_PGTABLE_5_LEVEL)
                amd_iommu_gpt_level = PAGE_MODE_5_LEVEL;
 
+       if (amd_iommu_pgtable == AMD_IOMMU_V2) {
+               if (!amd_iommu_v2_pgtbl_supported()) {
+                       pr_warn("Cannot enable v2 page table for DMA-API. Fallback to v1.\n");
+                       amd_iommu_pgtable = AMD_IOMMU_V1;
+               }
+       }
+
        /* Disable any previously enabled IOMMUs */
        if (!is_kdump_kernel() || amd_iommu_disabled)
                disable_iommus();