Pārlūkot izejas kodu

iommu/amd: Free IOMMU resources when disabled on command line

After we made sure that all IOMMUs have been disabled we
need to make sure that all resources we allocated are
released again.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
Joerg Roedel 8 gadi atpakaļ
vecāks
revīzija
7ad820e433
1 mainītis faili ar 7 papildinājumiem un 0 dzēšanām
  1. 7 0
      drivers/iommu/amd_iommu_init.c

+ 7 - 0
drivers/iommu/amd_iommu_init.c

@@ -2430,6 +2430,13 @@ static int __init state_next(void)
 	case IOMMU_IVRS_DETECTED:
 		ret = early_amd_iommu_init();
 		init_state = ret ? IOMMU_INIT_ERROR : IOMMU_ACPI_FINISHED;
+		if (init_state == IOMMU_ACPI_FINISHED && amd_iommu_disabled) {
+			pr_info("AMD-Vi: AMD IOMMU disabled on kernel command-line\n");
+			free_dma_resources();
+			free_iommu_resources();
+			init_state = IOMMU_CMDLINE_DISABLED;
+			ret = -EINVAL;
+		}
 		break;
 	case IOMMU_ACPI_FINISHED:
 		early_enable_iommus();