iommu/amd: Move Stoney Ridge check to detect_ivrs()

The AMD IOMMU will not be enabled on AMD Stoney Ridge systems. Bail
out even earlier and refuse to even detect the IOMMU there.

References: https://bugzilla.kernel.org/show_bug.cgi?id=212133
References: https://bugzilla.suse.com/show_bug.cgi?id=1183132
Cc: stable@vger.kernel.org # v5.11
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Link: https://lore.kernel.org/r/20210317091037.31374-2-joro@8bytes.org
Acked-by: Huang Rui <ray.huang@amd.com>
This commit is contained in:
Joerg Roedel 2021-03-17 10:10:35 +01:00
parent 1e28eed176
commit 072a03e0a0

View file

@ -2714,7 +2714,6 @@ static int __init early_amd_iommu_init(void)
struct acpi_table_header *ivrs_base; struct acpi_table_header *ivrs_base;
int i, remap_cache_sz, ret; int i, remap_cache_sz, ret;
acpi_status status; acpi_status status;
u32 pci_id;
if (!amd_iommu_detected) if (!amd_iommu_detected)
return -ENODEV; return -ENODEV;
@ -2804,16 +2803,6 @@ static int __init early_amd_iommu_init(void)
if (ret) if (ret)
goto out; goto out;
/* Disable IOMMU if there's Stoney Ridge graphics */
for (i = 0; i < 32; i++) {
pci_id = read_pci_config(0, i, 0, 0);
if ((pci_id & 0xffff) == 0x1002 && (pci_id >> 16) == 0x98e4) {
pr_info("Disable IOMMU on Stoney Ridge\n");
amd_iommu_disabled = true;
break;
}
}
/* Disable any previously enabled IOMMUs */ /* Disable any previously enabled IOMMUs */
if (!is_kdump_kernel() || amd_iommu_disabled) if (!is_kdump_kernel() || amd_iommu_disabled)
disable_iommus(); disable_iommus();
@ -2880,6 +2869,7 @@ static bool detect_ivrs(void)
{ {
struct acpi_table_header *ivrs_base; struct acpi_table_header *ivrs_base;
acpi_status status; acpi_status status;
int i;
status = acpi_get_table("IVRS", 0, &ivrs_base); status = acpi_get_table("IVRS", 0, &ivrs_base);
if (status == AE_NOT_FOUND) if (status == AE_NOT_FOUND)
@ -2892,6 +2882,17 @@ static bool detect_ivrs(void)
acpi_put_table(ivrs_base); acpi_put_table(ivrs_base);
/* Don't use IOMMU if there is Stoney Ridge graphics */
for (i = 0; i < 32; i++) {
u32 pci_id;
pci_id = read_pci_config(0, i, 0, 0);
if ((pci_id & 0xffff) == 0x1002 && (pci_id >> 16) == 0x98e4) {
pr_info("Disable IOMMU on Stoney Ridge\n");
return false;
}
}
/* Make sure ACS will be enabled during PCI probe */ /* Make sure ACS will be enabled during PCI probe */
pci_request_acs(); pci_request_acs();