Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp8161606ybc; Fri, 29 Nov 2019 06:26:33 -0800 (PST) X-Google-Smtp-Source: APXvYqwbDEb/zyx2OivNaQCkvSLrc7T3pNJ6y2h0v+1HaJ8a9qrm28Ktovs5oqAPOpTzXHJeVm4Q X-Received: by 2002:a17:906:27d3:: with SMTP id k19mr36892941ejc.290.1575037593361; Fri, 29 Nov 2019 06:26:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575037593; cv=none; d=google.com; s=arc-20160816; b=NSdcHlvHDvuWIphooEdnLQ9Zf9XhIY71oXp+7KBh/Jq5lggxOKYWxzPPvKSBs/yCLc aezEtoyRXN2FsjlYAtHvnItjZR93wXOMxZQRMDSonZeH+Jn3OvD4txiCJ8biU/vOYYJS 2phkAPFdsFhzsExqy/hT1FZcZBSud+ASUbfrumvmn6w7/neTrXhgWt5CZz70bU0xJ9UJ v4euBdkTdzUUMqea5szuypLRTCudEDJAaQdl+2W8tFuo0agT2mHEpt7Pr0kRX85gIKRh 4OUeY2115+BHhKuGjBbbQ653kvAXJ3wggEj0TR1DKvyilJ1KaFFeYzDUJ70tnz7/n+G7 +d2A== 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=PgYIHW6BRCqF50DhY+4mASe0sdK9ctRNd4fKvW2HnHM=; b=wcjI0rT+V8mkHsMDCScIG9G1A1GtTKN2vv6IVWwSK5pimRTlWsBffhR8547FEMoCE0 3rU/u+CJAcYWY5v2m626ElnTWj3cN8nPX3l+egT0PMwgZMIGMNY0zieCmmryGqfgZbf4 AtvPPf+4VZ/ZybeKPGe4wZCuDRotZwDKdViZOrpbi25SwWgfZUBgANpQuBgenN0MiU+d Iq+FdDusUJtb23fAfQDlbfV9ed/z640N2nEMDwm3DgIe27MwJ53mLSQ2jwsKxPthOSVH g4XlC6Q5fOIyVJgxTxooOIWpDqzIwnU7kCBsTYK8zQjNlDH+TfRlgHIoq3e1r/CfLvRv WEzA== 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 la9si14707243ejb.122.2019.11.29.06.26.08; Fri, 29 Nov 2019 06:26:33 -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 S1727117AbfK2OWD (ORCPT + 99 others); Fri, 29 Nov 2019 09:22:03 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:47469 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726808AbfK2OWD (ORCPT ); Fri, 29 Nov 2019 09:22:03 -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 1iah9j-0008Ec-Nb; Fri, 29 Nov 2019 14:22:00 +0000 From: Kai-Heng Feng To: joro@8bytes.org Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Kai-Heng Feng , Alex Deucher Subject: [PATCH v2] iommu/amd: Disable IOMMU on Stoney Ridge systems Date: Fri, 29 Nov 2019 22:21:54 +0800 Message-Id: <20191129142154.29658-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. 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 --- 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; } -- 2.17.1