1
0
Fork 0

IOMMU Fixes for Linux v5.12-rc3

Including:
 
 	- Three AMD IOMMU patches to fix a boot crash on AMD Stoney
 	  systems and every other AMD IOMMU system booted with
 	  'amd_iommu=off'. This is a v5.11 regression.
 
 	- A Fix for the Tegra IOMMU driver to make sure it detects all
 	  IOMMUs
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEr9jSbILcajRFYWYyK/BELZcBGuMFAmBUhvoACgkQK/BELZcB
 GuMsWg//ZKqUb2tzOHnlrHk9kUqOZ9tm0e+PQuG3G22VvB7RKR1jhkodVDpAlJwA
 k57S7ij/5r6xTyhpyKvHr2KC0Ms/TEhPflB8Tf0xiG3rKnks0vLETWSBnhgZFblo
 g0hJ/ZeuBElgcy/SJSz1p44+HHBmDEDpFGuv8QuY1fy2vg3MoVvxoYnM1SSToF3m
 xtR2zZ1QE1eRfkq9MNnB1HdYA8PwF4E0ISY5eYFTyX+x56TYSqFkqLcWPX0qqUX1
 AwjPRWjKzw8hOFOecwMdSq3IfT7aupio7QISZ8WfoDz9CPKg2RCpRaovSeyVgPCN
 Gm0uRXoQkjcZCgiIB0wwBsFQKuR6tkhltmqD8qIj2xopa2/uqF0DZ759o3qF7+Cy
 xgGALJNO77+zYeGO5ms9WeiJf3l0AFHolYLPaFxjrp5uKU8BWoGmR+LKZy3MEcmD
 6MAqAF18lr5pYrNsY8t/u6e9yxeQFdqzWKBCH6JIQimNG2HgY0lgcRYXrH9fb41d
 YzLtpY6ZjncMaOOKHMoBc3TOZ2mC4/6jsQdgJSHK+Ji75B9eUrW24k9mvrU91kgj
 Di9pM1ACQeeDN8rEbiQNdiF4AbhIpQktHkHyd0eMfxFl/W/O8StZfODQi7RM94u8
 h43dAIti2bDU+51f7a66QIpjOyQZFcnE9waUAdwneO7Vg6mBiIk=
 =PJvl
 -----END PGP SIGNATURE-----

Merge tag 'iommu-fixes-v5.12-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu

Pull iommu fixes from Joerg Roedel:

 - Three AMD IOMMU patches to fix a boot crash on AMD Stoney systems and
   every other AMD IOMMU system booted with 'amd_iommu=off'.

   This is a v5.11 regression.

 - A Fix for the Tegra IOMMU driver to make sure it detects all IOMMUs

* tag 'iommu-fixes-v5.12-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu:
  iommu/tegra-smmu: Make tegra_smmu_probe_device() to handle all IOMMU phandles
  iommu/amd: Keep track of amd_iommu_irq_remap state
  iommu/amd: Don't call early_amd_iommu_init() when AMD IOMMU is disabled
  iommu/amd: Move Stoney Ridge check to detect_ivrs()
rM2-mainline
Linus Torvalds 2021-03-19 09:56:04 -07:00
commit 65a1037471
2 changed files with 23 additions and 20 deletions

View File

@ -2714,7 +2714,6 @@ static int __init early_amd_iommu_init(void)
struct acpi_table_header *ivrs_base;
int i, remap_cache_sz, ret;
acpi_status status;
u32 pci_id;
if (!amd_iommu_detected)
return -ENODEV;
@ -2804,16 +2803,6 @@ static int __init early_amd_iommu_init(void)
if (ret)
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 */
if (!is_kdump_kernel() || amd_iommu_disabled)
disable_iommus();
@ -2880,6 +2869,7 @@ static bool detect_ivrs(void)
{
struct acpi_table_header *ivrs_base;
acpi_status status;
int i;
status = acpi_get_table("IVRS", 0, &ivrs_base);
if (status == AE_NOT_FOUND)
@ -2892,6 +2882,17 @@ static bool detect_ivrs(void)
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 */
pci_request_acs();
@ -2918,12 +2919,12 @@ static int __init state_next(void)
}
break;
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 IOMMU disabled\n");
if (amd_iommu_disabled) {
init_state = IOMMU_CMDLINE_DISABLED;
ret = -EINVAL;
} else {
ret = early_amd_iommu_init();
init_state = ret ? IOMMU_INIT_ERROR : IOMMU_ACPI_FINISHED;
}
break;
case IOMMU_ACPI_FINISHED:
@ -3001,8 +3002,11 @@ int __init amd_iommu_prepare(void)
amd_iommu_irq_remap = true;
ret = iommu_go_to_state(IOMMU_ACPI_FINISHED);
if (ret)
if (ret) {
amd_iommu_irq_remap = false;
return ret;
}
return amd_iommu_irq_remap ? 0 : -ENODEV;
}

View File

@ -849,12 +849,11 @@ static struct iommu_device *tegra_smmu_probe_device(struct device *dev)
smmu = tegra_smmu_find(args.np);
if (smmu) {
err = tegra_smmu_configure(smmu, dev, &args);
of_node_put(args.np);
if (err < 0)
if (err < 0) {
of_node_put(args.np);
return ERR_PTR(err);
break;
}
}
of_node_put(args.np);