Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3812405pxv; Mon, 28 Jun 2021 13:33:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzI/ULMvUdUkOXIhjxlSIhF9cK2UudZIfNyXB9AxG7e4BDUFOfa5Uc8zsOVWxZesFVeDvDi X-Received: by 2002:a02:90cb:: with SMTP id c11mr1251248jag.53.1624912419407; Mon, 28 Jun 2021 13:33:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624912419; cv=none; d=google.com; s=arc-20160816; b=AN2Eag4lfSlotgqjCkiNuaXcvZCJ4smw6zZW/mhbMFLaOY9ZC02g1Pdpfdi7QkcyFY cJgGIjjJLn/TC2xKGmpr7XZ5VyrmCcq1/KUXa2ZP0Vq0YOTDs3JRBA+e8I/RU7zTl3Jh QnygBvIDpTRswT4fyZ6G68axts30PyYPEdOWCYIpdjS08KfBFF5/Wyn279opwoSgkdM5 wyaGkhvBRDL7gjQQAK4w7xRCjtOICJ/Mof50jGJqYTJksKIJTGWuv1mnDNbCgwRvZt5G ANv+3XWFE17z5kfW7s5s3FsEVh+ruVhi5iwyyuXNchKFydJju6zxYZI+ssAnaPeMdL2t Jm4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DeA2xjHQQo7+/oF1nqZ2naOBoIdZVSITOg61Epn7FpY=; b=qp8X6CQLvr1fi2xhvXwhs27PaSPAwz0YB87QKZP3n0ePxKWASj3/bYROkx1TxOMHFZ LRVEdGg1l6pjOCDXwwlgD8aVKbkcBEbn41Id/ngEGE8Ywxx0MZTYEqQE1SximU5qBN8x uleCKjtLN73l3Qv+CYQwkBb5O/E8a8csKz0hgRBnCnLxf3541pVRD/FeTpgyM9sqUP0n GDEkwpXbfoylLtK2fPJ/X3qn42WIWSpxPIurqR9EvOZfeBnhkXXGm0ZLhXTZfY+4/5zw PLlDCxN1q9t62oi9HpSjTTESsFLlMfr0ob7aBllCIhkGmL8ZUe981zIldhX6cQvGcgGu 1z7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AlxYnJbO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c26si6034828ioo.54.2021.06.28.13.33.26; Mon, 28 Jun 2021 13:33:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AlxYnJbO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237376AbhF1PFq (ORCPT + 99 others); Mon, 28 Jun 2021 11:05:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:51478 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236212AbhF1Oq1 (ORCPT ); Mon, 28 Jun 2021 10:46:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 741D461D19; Mon, 28 Jun 2021 14:34:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624890878; bh=Xg3ckCh4MrK9PKspTRjU2MM4Mq3C/p5v9MLKyXw03lI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AlxYnJbO1eA7MUKq6/S0BL1e91HVVR6ybIX+aWIlsQlX/2gHubP4ol3fk5UI1IA3A mQXCX2ZdgZhIGB4N6yNTAcbatiemxkL+PCyIYMXJ36ydJ2gZf6fTT54aDsBxJPPWxl alp7jjpPtldkS/dFTKnKRUQsmML2wBJlK+3AHvS2FgXu2zrGhoTjnTS2/VFLeaNUvC BHjhyaplotBVFwdIvfbGV3ukAA3gv9IrF9N9wYuISG6tmUtt18KaaFqd1gwo9TEY4l hHSYHau1lqFIpCSShi9qSk1dWM2ECvky8nxrscbFJuLglCqyjIz4gdkZsilgYm8Fyq ymJVoNbLHwM+w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mikel Rychliski , Bjorn Helgaas , Sasha Levin Subject: [PATCH 4.19 104/109] PCI: Add AMD RS690 quirk to enable 64-bit DMA Date: Mon, 28 Jun 2021 10:33:00 -0400 Message-Id: <20210628143305.32978-105-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210628143305.32978-1-sashal@kernel.org> References: <20210628143305.32978-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.196-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.19.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.19.196-rc1 X-KernelTest-Deadline: 2021-06-30T14:32+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mikel Rychliski [ Upstream commit cacf994a91d3a55c0c2f853d6429cd7b86113915 ] Although the AMD RS690 chipset has 64-bit DMA support, BIOS implementations sometimes fail to configure the memory limit registers correctly. The Acer F690GVM mainboard uses this chipset and a Marvell 88E8056 NIC. The sky2 driver programs the NIC to use 64-bit DMA, which will not work: sky2 0000:02:00.0: error interrupt status=0x8 sky2 0000:02:00.0 eth0: tx timeout sky2 0000:02:00.0 eth0: transmit ring 0 .. 22 report=0 done=0 Other drivers required by this mainboard either don't support 64-bit DMA, or have it disabled using driver specific quirks. For example, the ahci driver has quirks to enable or disable 64-bit DMA depending on the BIOS version (see ahci_sb600_enable_64bit() in ahci.c). This ahci quirk matches against the SB600 SATA controller, but the real issue is almost certainly with the RS690 PCI host that it was commonly attached to. To avoid this issue in all drivers with 64-bit DMA support, fix the configuration of the PCI host. If the kernel is aware of physical memory above 4GB, but the BIOS never configured the PCI host with this information, update the registers with our values. [bhelgaas: drop PCI_DEVICE_ID_ATI_RS690 definition] Link: https://lore.kernel.org/r/20210611214823.4898-1-mikel@mikelr.com Signed-off-by: Mikel Rychliski Signed-off-by: Bjorn Helgaas Signed-off-by: Sasha Levin --- arch/x86/pci/fixup.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c index 0c67a5a94de3..76959a7d88c8 100644 --- a/arch/x86/pci/fixup.c +++ b/arch/x86/pci/fixup.c @@ -779,4 +779,48 @@ DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_AMD, 0x1571, pci_amd_enable_64bit_bar); DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_AMD, 0x15b1, pci_amd_enable_64bit_bar); DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_AMD, 0x1601, pci_amd_enable_64bit_bar); +#define RS690_LOWER_TOP_OF_DRAM2 0x30 +#define RS690_LOWER_TOP_OF_DRAM2_VALID 0x1 +#define RS690_UPPER_TOP_OF_DRAM2 0x31 +#define RS690_HTIU_NB_INDEX 0xA8 +#define RS690_HTIU_NB_INDEX_WR_ENABLE 0x100 +#define RS690_HTIU_NB_DATA 0xAC + +/* + * Some BIOS implementations support RAM above 4GB, but do not configure the + * PCI host to respond to bus master accesses for these addresses. These + * implementations set the TOP_OF_DRAM_SLOT1 register correctly, so PCI DMA + * works as expected for addresses below 4GB. + * + * Reference: "AMD RS690 ASIC Family Register Reference Guide" (pg. 2-57) + * https://www.amd.com/system/files/TechDocs/43372_rs690_rrg_3.00o.pdf + */ +static void rs690_fix_64bit_dma(struct pci_dev *pdev) +{ + u32 val = 0; + phys_addr_t top_of_dram = __pa(high_memory - 1) + 1; + + if (top_of_dram <= (1ULL << 32)) + return; + + pci_write_config_dword(pdev, RS690_HTIU_NB_INDEX, + RS690_LOWER_TOP_OF_DRAM2); + pci_read_config_dword(pdev, RS690_HTIU_NB_DATA, &val); + + if (val) + return; + + pci_info(pdev, "Adjusting top of DRAM to %pa for 64-bit DMA support\n", &top_of_dram); + + pci_write_config_dword(pdev, RS690_HTIU_NB_INDEX, + RS690_UPPER_TOP_OF_DRAM2 | RS690_HTIU_NB_INDEX_WR_ENABLE); + pci_write_config_dword(pdev, RS690_HTIU_NB_DATA, top_of_dram >> 32); + + pci_write_config_dword(pdev, RS690_HTIU_NB_INDEX, + RS690_LOWER_TOP_OF_DRAM2 | RS690_HTIU_NB_INDEX_WR_ENABLE); + pci_write_config_dword(pdev, RS690_HTIU_NB_DATA, + top_of_dram | RS690_LOWER_TOP_OF_DRAM2_VALID); +} +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x7910, rs690_fix_64bit_dma); + #endif -- 2.30.2