Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp397661ybl; Sun, 1 Dec 2019 04:52:47 -0800 (PST) X-Google-Smtp-Source: APXvYqzy7grFvRH+tg6+GTInPwnDf2jNvoO8OW5xh0qBhYiRRj3d1riRF0fSGVynC+AxGhfpbpmx X-Received: by 2002:a17:906:80c3:: with SMTP id a3mr10647985ejx.101.1575204767294; Sun, 01 Dec 2019 04:52:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575204767; cv=none; d=google.com; s=arc-20160816; b=c7kafDXnbqMTjBqve1a9SriM6eqX7o9JdA3GZ2eZlVmnaFQGLyyNOEuQzGp4SPiofZ OZ3SF/hb7I56e+Q93+rpaiItRWL0+mJNMzvwRFhsRghyu/D+8JsZ/wyjtCBwfDmdoga7 l3qj3o3S6NL4gAdfKeSHP6McNZB3PWzGvHMW2nbgmWHrylhpC4Z8bVComr3148n8zEwT 99GN6wjqcibAvrZZxAeQpC4CJO1CeuFadyJ6Uf/vxV2AnoQNEUhFO/JagyNDyPqK7jhd e0Ty9hS8WnY83Z+izyPQhcGy0Ll+Ae9eEAjatzPf0T0VmF2pT3nCQ8sXuB4ISqDX5I1b I+cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=cS3Ylz+lsCYGaJZdPKJ0Af7pzuandhhcHCC5n30eNOM=; b=owOiAQgPghcUsBxLFL3l46xVkJCi1x2I+Lv4Eh1PpAcV/4xoJwW600xcMeZgk7Py3X +AecSt4+cHYO9Hyb/t3ZGqA2EhVtWfxPa6pL7wJCQ2WaJCCVvcdNS0POAIdXk0dudDA5 mnteWYpQ4NHZo6tYFvUeXvb30PherZVMqTx3rDvsmxnD7uJkb7J5+PGFnvxaEmx+6pBx Jk1xCDKcURLwWV4Di9lukhB6zYVUDC+mVsSxumd21Xr3EX0YZmjz9v5oLx7/dzLwqKfm gYQIUjmtI3MppxiG5PP4WFp1XgsO9e4UARQajjBUm0ABK0kPCQS8RkoUQR57xtRB+5UI pZyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t26si21261361edc.102.2019.12.01.04.52.21; Sun, 01 Dec 2019 04:52:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726793AbfLAMsT (ORCPT + 99 others); Sun, 1 Dec 2019 07:48:19 -0500 Received: from ns.lynxeye.de ([87.118.118.114]:58979 "EHLO lynxeye.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726340AbfLAMsT (ORCPT ); Sun, 1 Dec 2019 07:48:19 -0500 X-Greylist: delayed 344 seconds by postgrey-1.27 at vger.kernel.org; Sun, 01 Dec 2019 07:48:18 EST Received: by lynxeye.de (Postfix, from userid 501) id 2F953E74222; Sun, 1 Dec 2019 13:42:33 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on lynxeye.de X-Spam-Level: X-Spam-Status: No, score=-2.9 required=3.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.3.1 Received: from astat.fritz.box (a89-183-126-187.net-htp.de [89.183.126.187]) by lynxeye.de (Postfix) with ESMTPSA id 93F73E7414D; Sun, 1 Dec 2019 13:42:31 +0100 (CET) Message-ID: <5b2097e8c4172a8516fcfc8c56dc98e3d105ffe2.camel@lynxeye.de> Subject: Re: [PATCH v2] iommu/amd: Disable IOMMU on Stoney Ridge systems From: Lucas Stach To: Kai-Heng Feng , joro@8bytes.org Cc: Alex Deucher , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Date: Sun, 01 Dec 2019 13:42:31 +0100 In-Reply-To: <20191129142154.29658-1-kai.heng.feng@canonical.com> References: <20191129142154.29658-1-kai.heng.feng@canonical.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.1 (3.34.1-1.fc31) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am Freitag, den 29.11.2019, 22:21 +0800 schrieb Kai-Heng Feng: > 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. This doesn't seem like a good solution, especially if there isn't a method for the user to opt-out. Some users might prefer having the IOMMU support to 4K display output. But before using the big hammer of disabling or breaking one of those features, we should take a look at what's the issue here. Screen flickering caused by the IOMMU being active hints to the IOMMU not being able to sustain the translation bandwidth required by the high- bandwidth isochronous transfers caused by 4K scanout, most likely due to insufficient TLB space. As far as I know the framebuffer memory for the display buffers is located in stolen RAM, and thus contigous in memory. I don't know the details of the GPU integration on those APUs, but maybe there even is a way to bypass the IOMMU for the stolen VRAM regions? If there isn't and all GPU traffic passes through the IOMMU when active, we should check if the stolen RAM is mapped with hugepages on the IOMMU side. All the stolen RAM can most likely be mapped with a few hugepage mappings, which should reduce IOMMU TLB demand by a large margin. Regards, Lucas > Cc: Alex Deucher > Bug: https://gitlab.freedesktop.org/drm/amd/issues/961 > Signed-off-by: Kai-Heng Feng > --- > v2: > - Find Stoney graphics instead of host bridge. > > drivers/iommu/amd_iommu_init.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c > index 568c52317757..139aa6fdadda 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,16 @@ 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(); > @@ -2711,7 +2722,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; > }