Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iommu/amd: Don't initialize IOMMUv2 resources when not required

Add a check to the init-path of the AMD IOMMUv2 driver if
the hardware is available in the system. Only allocate all
the resources if it is really available.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>

+13 -1
+13 -1
drivers/iommu/amd_iommu_v2.c
··· 921 921 size_t state_table_size; 922 922 int ret; 923 923 924 - pr_info("AMD IOMMUv2 driver by Joerg Roedel <joerg.roedel@amd.com>"); 924 + pr_info("AMD IOMMUv2 driver by Joerg Roedel <joerg.roedel@amd.com>\n"); 925 + 926 + if (!amd_iommu_v2_supported()) { 927 + pr_info("AMD IOMMUv2 functionality not available on this sytem\n"); 928 + /* 929 + * Load anyway to provide the symbols to other modules 930 + * which may use AMD IOMMUv2 optionally. 931 + */ 932 + return 0; 933 + } 925 934 926 935 spin_lock_init(&state_lock); 927 936 ··· 969 960 struct device_state *dev_state; 970 961 size_t state_table_size; 971 962 int i; 963 + 964 + if (!amd_iommu_v2_supported()) 965 + return; 972 966 973 967 profile_event_unregister(PROFILE_TASK_EXIT, &profile_nb); 974 968 amd_iommu_unregister_ppr_notifier(&ppr_nb);