All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu/amd: Disable IOMMU on Stoney Ridge systems
@ 2019-11-24  9:42 ` Kai-Heng Feng
  0 siblings, 0 replies; 4+ messages in thread
From: Kai-Heng Feng @ 2019-11-24  9:42 UTC (permalink / raw)
  To: joro; +Cc: iommu, linux-kernel, Kai-Heng Feng, Alex Deucher

Serious screen flickering when Stoney Ridge outputs to a 4K monitor.

According to Alex Deucher, IOMMU isn't enabled on Windows, so let's do
the same here to avoid screen flickering on 4K monitor.

Cc: Alex Deucher <alexander.deucher@amd.com>
Bug: https://gitlab.freedesktop.org/drm/amd/issues/961
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
 drivers/iommu/amd_iommu_init.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 568c52317757..e05f1b269be6 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -2516,6 +2516,7 @@ static int __init early_amd_iommu_init(void)
 	struct acpi_table_header *ivrs_base;
 	acpi_status status;
 	int i, remap_cache_sz, ret = 0;
+	u32 pci_id;
 
 	if (!amd_iommu_detected)
 		return -ENODEV;
@@ -2603,6 +2604,13 @@ static int __init early_amd_iommu_init(void)
 	if (ret)
 		goto out;
 
+	/* Get the host bridge VID/PID and disable IOMMU if it's Stoney Ridge */
+	pci_id = read_pci_config(0, 0, 0, 0);
+	if ((pci_id & 0xffff) == 0x1022 && (pci_id >> 16) == 0x1576) {
+		pr_info("Disable IOMMU on Stoney Ridge\n");
+		amd_iommu_disabled = true;
+	}
+
 	/* Disable any previously enabled IOMMUs */
 	if (!is_kdump_kernel() || amd_iommu_disabled)
 		disable_iommus();
@@ -2711,7 +2719,7 @@ static int __init state_next(void)
 		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 on kernel command-line\n");
+			pr_info("AMD IOMMU disabled\n");
 			init_state = IOMMU_CMDLINE_DISABLED;
 			ret = -EINVAL;
 		}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] iommu/amd: Disable IOMMU on Stoney Ridge systems
@ 2019-11-24  9:42 ` Kai-Heng Feng
  0 siblings, 0 replies; 4+ messages in thread
From: Kai-Heng Feng @ 2019-11-24  9:42 UTC (permalink / raw)
  To: joro; +Cc: Alex Deucher, iommu, Kai-Heng Feng, linux-kernel

Serious screen flickering when Stoney Ridge outputs to a 4K monitor.

According to Alex Deucher, IOMMU isn't enabled on Windows, so let's do
the same here to avoid screen flickering on 4K monitor.

Cc: Alex Deucher <alexander.deucher@amd.com>
Bug: https://gitlab.freedesktop.org/drm/amd/issues/961
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
 drivers/iommu/amd_iommu_init.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 568c52317757..e05f1b269be6 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -2516,6 +2516,7 @@ static int __init early_amd_iommu_init(void)
 	struct acpi_table_header *ivrs_base;
 	acpi_status status;
 	int i, remap_cache_sz, ret = 0;
+	u32 pci_id;
 
 	if (!amd_iommu_detected)
 		return -ENODEV;
@@ -2603,6 +2604,13 @@ static int __init early_amd_iommu_init(void)
 	if (ret)
 		goto out;
 
+	/* Get the host bridge VID/PID and disable IOMMU if it's Stoney Ridge */
+	pci_id = read_pci_config(0, 0, 0, 0);
+	if ((pci_id & 0xffff) == 0x1022 && (pci_id >> 16) == 0x1576) {
+		pr_info("Disable IOMMU on Stoney Ridge\n");
+		amd_iommu_disabled = true;
+	}
+
 	/* Disable any previously enabled IOMMUs */
 	if (!is_kdump_kernel() || amd_iommu_disabled)
 		disable_iommus();
@@ -2711,7 +2719,7 @@ static int __init state_next(void)
 		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 on kernel command-line\n");
+			pr_info("AMD IOMMU disabled\n");
 			init_state = IOMMU_CMDLINE_DISABLED;
 			ret = -EINVAL;
 		}
-- 
2.17.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH] iommu/amd: Disable IOMMU on Stoney Ridge systems
  2019-11-24  9:42 ` Kai-Heng Feng
@ 2019-11-25 19:51   ` Deucher, Alexander
  -1 siblings, 0 replies; 4+ messages in thread
From: Deucher, Alexander @ 2019-11-25 19:51 UTC (permalink / raw)
  To: Kai-Heng Feng, joro, Suthikulpanit, Suravee; +Cc: iommu, linux-kernel

> -----Original Message-----
> From: Kai-Heng Feng <kai.heng.feng@canonical.com>
> Sent: Sunday, November 24, 2019 4:43 AM
> To: joro@8bytes.org
> Cc: iommu@lists.linux-foundation.org; linux-kernel@vger.kernel.org; Kai-
> Heng Feng <kai.heng.feng@canonical.com>; Deucher, Alexander
> <Alexander.Deucher@amd.com>
> Subject: [PATCH] iommu/amd: Disable IOMMU on Stoney Ridge systems
> 
> Serious screen flickering when Stoney Ridge outputs to a 4K monitor.
> 
> According to Alex Deucher, IOMMU isn't enabled on Windows, so let's do the
> same here to avoid screen flickering on 4K monitor.
> 
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Bug:
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitla
> b.freedesktop.org%2Fdrm%2Famd%2Fissues%2F961&amp;data=02%7C01%7
> Calexander.deucher%40amd.com%7C75a108e9888645728fc208d770c2b418%
> 7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637101853875648481
> &amp;sdata=eQ%2FmiFfy%2FHRJSVurfdnvT%2FLdNMYetIPQdFgnU93l%2Fks
> %3D&amp;reserved=0
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> ---
>  drivers/iommu/amd_iommu_init.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/amd_iommu_init.c
> b/drivers/iommu/amd_iommu_init.c index 568c52317757..e05f1b269be6
> 100644
> --- a/drivers/iommu/amd_iommu_init.c
> +++ b/drivers/iommu/amd_iommu_init.c
> @@ -2516,6 +2516,7 @@ static int __init early_amd_iommu_init(void)
>  	struct acpi_table_header *ivrs_base;
>  	acpi_status status;
>  	int i, remap_cache_sz, ret = 0;
> +	u32 pci_id;
> 
>  	if (!amd_iommu_detected)
>  		return -ENODEV;
> @@ -2603,6 +2604,13 @@ static int __init early_amd_iommu_init(void)
>  	if (ret)
>  		goto out;
> 
> +	/* Get the host bridge VID/PID and disable IOMMU if it's Stoney
> Ridge */
> +	pci_id = read_pci_config(0, 0, 0, 0);
> +	if ((pci_id & 0xffff) == 0x1022 && (pci_id >> 16) == 0x1576) {

I'm not sure if the IOMMU device id is unique to stoney.  I think it's the same DID for the entire APU generation.   I think it would be better to walk the bus and try and find the stoney GPU and only in that case, disable the IOMMU.  E.g., if the user has disabled the GPU portion of the APU or has a dGPU installed, they may will want to use the IOMMU.  It's only the integrated GPU that has a problem when trying to display high res modes out of system memory with the IOMMU due to the added latency.
The stoney GPU is VID 0x1002, DID 0x98E4.

Alex

> +		pr_info("Disable IOMMU on Stoney Ridge\n");
> +		amd_iommu_disabled = true;
> +	}
> +
>  	/* Disable any previously enabled IOMMUs */
>  	if (!is_kdump_kernel() || amd_iommu_disabled)
>  		disable_iommus();
> @@ -2711,7 +2719,7 @@ static int __init state_next(void)
>  		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 on kernel command-
> line\n");
> +			pr_info("AMD IOMMU disabled\n");
>  			init_state = IOMMU_CMDLINE_DISABLED;
>  			ret = -EINVAL;
>  		}
> --
> 2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] iommu/amd: Disable IOMMU on Stoney Ridge systems
@ 2019-11-25 19:51   ` Deucher, Alexander
  0 siblings, 0 replies; 4+ messages in thread
From: Deucher, Alexander @ 2019-11-25 19:51 UTC (permalink / raw)
  To: Kai-Heng Feng, joro, Suthikulpanit, Suravee; +Cc: iommu, linux-kernel

> -----Original Message-----
> From: Kai-Heng Feng <kai.heng.feng@canonical.com>
> Sent: Sunday, November 24, 2019 4:43 AM
> To: joro@8bytes.org
> Cc: iommu@lists.linux-foundation.org; linux-kernel@vger.kernel.org; Kai-
> Heng Feng <kai.heng.feng@canonical.com>; Deucher, Alexander
> <Alexander.Deucher@amd.com>
> Subject: [PATCH] iommu/amd: Disable IOMMU on Stoney Ridge systems
> 
> Serious screen flickering when Stoney Ridge outputs to a 4K monitor.
> 
> According to Alex Deucher, IOMMU isn't enabled on Windows, so let's do the
> same here to avoid screen flickering on 4K monitor.
> 
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Bug:
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitla
> b.freedesktop.org%2Fdrm%2Famd%2Fissues%2F961&amp;data=02%7C01%7
> Calexander.deucher%40amd.com%7C75a108e9888645728fc208d770c2b418%
> 7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637101853875648481
> &amp;sdata=eQ%2FmiFfy%2FHRJSVurfdnvT%2FLdNMYetIPQdFgnU93l%2Fks
> %3D&amp;reserved=0
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> ---
>  drivers/iommu/amd_iommu_init.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/amd_iommu_init.c
> b/drivers/iommu/amd_iommu_init.c index 568c52317757..e05f1b269be6
> 100644
> --- a/drivers/iommu/amd_iommu_init.c
> +++ b/drivers/iommu/amd_iommu_init.c
> @@ -2516,6 +2516,7 @@ static int __init early_amd_iommu_init(void)
>  	struct acpi_table_header *ivrs_base;
>  	acpi_status status;
>  	int i, remap_cache_sz, ret = 0;
> +	u32 pci_id;
> 
>  	if (!amd_iommu_detected)
>  		return -ENODEV;
> @@ -2603,6 +2604,13 @@ static int __init early_amd_iommu_init(void)
>  	if (ret)
>  		goto out;
> 
> +	/* Get the host bridge VID/PID and disable IOMMU if it's Stoney
> Ridge */
> +	pci_id = read_pci_config(0, 0, 0, 0);
> +	if ((pci_id & 0xffff) == 0x1022 && (pci_id >> 16) == 0x1576) {

I'm not sure if the IOMMU device id is unique to stoney.  I think it's the same DID for the entire APU generation.   I think it would be better to walk the bus and try and find the stoney GPU and only in that case, disable the IOMMU.  E.g., if the user has disabled the GPU portion of the APU or has a dGPU installed, they may will want to use the IOMMU.  It's only the integrated GPU that has a problem when trying to display high res modes out of system memory with the IOMMU due to the added latency.
The stoney GPU is VID 0x1002, DID 0x98E4.

Alex

> +		pr_info("Disable IOMMU on Stoney Ridge\n");
> +		amd_iommu_disabled = true;
> +	}
> +
>  	/* Disable any previously enabled IOMMUs */
>  	if (!is_kdump_kernel() || amd_iommu_disabled)
>  		disable_iommus();
> @@ -2711,7 +2719,7 @@ static int __init state_next(void)
>  		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 on kernel command-
> line\n");
> +			pr_info("AMD IOMMU disabled\n");
>  			init_state = IOMMU_CMDLINE_DISABLED;
>  			ret = -EINVAL;
>  		}
> --
> 2.17.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-11-25 23:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-24  9:42 [PATCH] iommu/amd: Disable IOMMU on Stoney Ridge systems Kai-Heng Feng
2019-11-24  9:42 ` Kai-Heng Feng
2019-11-25 19:51 ` Deucher, Alexander
2019-11-25 19:51   ` Deucher, Alexander

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.