Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3455206ybv; Sun, 9 Feb 2020 23:52:15 -0800 (PST) X-Google-Smtp-Source: APXvYqzpN9IDr8AjYK3rAs1axU28K0HboTPnl0/SzRYs/59wgDiow0n74bD090lqVKSkPaPat7l3 X-Received: by 2002:a05:6830:43:: with SMTP id d3mr152796otp.259.1581321135115; Sun, 09 Feb 2020 23:52:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581321135; cv=none; d=google.com; s=arc-20160816; b=RDqU7BkWHEx8NVyBbHetCSS1XLZ5uw1kDS7R2G4V/rEDL/ka/x7a84+Re5tU8yprVZ r1bihFEfMxjmKMhiQWKE+g8bbou1MiXCCa+llUfKm6bM64KoHNVFIZh4Tirf/QSeZ6JF 7onEqL08at6C/FUMSoSXxHyVD40xW+wg8MpuJ3AJCdLjLUyMJJ9sOt6dhyxM2btuc81S gxEag/3CnhKSV1OlY0ak1CGKuIMhR15m9tjWvBt412nJHCbiElGnwhOqAK+JSyRZjo0F ms/fZwqsHGVEL0GzfT5SkbhXCEt5zwbqO1S0xxPrUQUoTNK7sDmhXthoJIuZgkZyKdEH 9ZXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=DXpXClIt4BdPOzeWSR73aDYNoohhECo9fL6PDVsmS0U=; b=IP2bqlEbgNARDhsRB/8ngy9qLsPHF9mVJGZ7hDxonVQyGq2nkDVjpcsTSqDMThsVW0 4ZoAkqI+Pa2VjUfqTTT4yTLY3N4IIa7H6sqW7GGZjwYy0uk1j7TT7nBPQE0bDFPo8RtK eEp9IRWZmUA4fzJXY0NPpOlsZz1J10p9RYbM/OvY/OPV/UYYpLR3+0ejv8eYhXEEdHkj 5ADZzzskfuUikLbhfJRpTGQ4PoOrmENy24gJOV7CquZjxznkWD0XFDeT5tPiuk/7I6FH Z/d8XmV3amWhQ1ZMtri66T7F0BLSrCsxDbb+P0AkJFhnuFMRz4DI2J4BRLCOFX175c+m HH7w== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z25si8361899oid.275.2020.02.09.23.52.02; Sun, 09 Feb 2020 23:52:15 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727436AbgBJHv2 (ORCPT + 99 others); Mon, 10 Feb 2020 02:51:28 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:58744 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726061AbgBJHv2 (ORCPT ); Mon, 10 Feb 2020 02:51:28 -0500 Received: from 61-220-137-37.hinet-ip.hinet.net ([61.220.137.37] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1j13qk-0008DR-0d; Mon, 10 Feb 2020 07:51:22 +0000 From: Kai-Heng Feng To: joro@8bytes.org Cc: Kai-Heng Feng , Alex Deucher , iommu@lists.linux-foundation.org (open list:AMD IOMMU (AMD-VI)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3] iommu/amd: Disable IOMMU on Stoney Ridge systems Date: Mon, 10 Feb 2020 15:51:15 +0800 Message-Id: <20200210075115.14838-1-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Serious screen flickering when Stoney Ridge outputs to a 4K monitor. Use identity-mapping and PCI ATS doesn't help this issue. 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 Bug: https://gitlab.freedesktop.org/drm/amd/issues/961 Signed-off-by: Kai-Heng Feng --- v3: - Update commit message to mention identity-mapping and ATS don't help. 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 2759a8d57b7f..6be3853a5d97 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c @@ -2523,6 +2523,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; @@ -2610,6 +2611,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(); @@ -2718,7 +2729,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