Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3729669pxv; Mon, 28 Jun 2021 11:20:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhLu8fVoAFcRR1llbEactiIgKhuu4KXy2Tdz9pyFby/4eEnyJLGX5WN8A8/fmR66S+AiwW X-Received: by 2002:a17:906:6d97:: with SMTP id h23mr25200465ejt.467.1624904417787; Mon, 28 Jun 2021 11:20:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624904417; cv=none; d=google.com; s=arc-20160816; b=gPZsKHLL3hOrdaF1ywn9JCn34kXq+WHdZeytQJphEeyotm5fi3p/x0ap5uteqg3COF g2euhZu/dBxhuX+VUWcY/tAZwGJfRoI537IM5JNbBqgo+fpyMJmjqB7TSLqQzQYg8jBF 3Y51yQwAbeAbXNw8HlETJptwJdzL8m4kfAEU8asvNvjDLVgjbz3MdSg3sH9YNYdzU1xk H5cZl4n3k92dGmXfXC8uVOxLefdcGzPT6qgdcu1qXlkt7k6eSGVXZYNBMItgGXUPpAYj OfKJZtqrRACDpEpofPgmGEnWbEFYvdnjAOZOlObhUAD79R3pjQ13Nf67Jx3AkSsiaiUU FKaQ== 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=sZUQ4QDfKYlxHZmh3rx4m7ISK1JsZc+TnvBPo+y2ZUw=; b=kWUs1kf0If8FXVns9ekMbV5QS90dyUwbYYW/MeRPYVtmO/V1cWhQh2P5JFFYatkHt6 bDdU+NUXcdXSb/5bnMo2hGlR92J6nN44BYvmUwEh1qA+BKU0R/M+uBveBkmzSSNKgpiT F1nj3xs0r+Cyd0kBMufxOXbMr64a8bzJzCexCV/4MHV0eG8d0y27wNx0zf28Fhpf5fMp WbVVY0h25d7Bkdf6ekHfRzVj24lNXBYWlqOHHu1QDKQJR/IjWh25MK2qxrt7gdLftyAz 9q0LEZLwdbFlRDaKEScG7M5+xPAQY9IEFTft3Z2+8V6DTBpZpnjT9TYlTNJXW++TFc+F oZ1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DYWESUBm; 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 f23si14722625ejj.531.2021.06.28.11.19.52; Mon, 28 Jun 2021 11:20:17 -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=DYWESUBm; 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 S234546AbhF1OgD (ORCPT + 99 others); Mon, 28 Jun 2021 10:36:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:36914 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234824AbhF1Oab (ORCPT ); Mon, 28 Jun 2021 10:30:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2708461CC3; Mon, 28 Jun 2021 14:26:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624890414; bh=mhDHTAAZ4nKLxUl2wPcuv746/b/8WFTJ+qLnCbvApbI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DYWESUBmBG7J0wEKvIKq4ZxUTMd5iuMYUPbBe5iLjORkSFZuZ0moPhHkhEeSOpcHn 3UOBDcwPpbsn293upRz1tSp2eMgIF+U2KsaC7wGzVaQv0yLrxXdWVCzHzEVpyjc2BK gEtqOttKYEwyNVnYftDE0SxihlysBFircNzLtdjIxvx3zalIKhKgEGbzSykwcpnn9R Iy5bwp139TPxFui/+SC4EtSQ+d20tPn22UBNZx+wZIFIwqQnmjjAxD5R91SheShUFS 75IGBXn4wCu4mAvBTK1qgVaJOKwNs1/z1MI+DTzeVm8mZfuEabU9GQhg+0USFqZCc7 U/2+gUt89wCiw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mikel Rychliski , Bjorn Helgaas , Sasha Levin Subject: [PATCH 5.10 054/101] PCI: Add AMD RS690 quirk to enable 64-bit DMA Date: Mon, 28 Jun 2021 10:25:20 -0400 Message-Id: <20210628142607.32218-55-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210628142607.32218-1-sashal@kernel.org> References: <20210628142607.32218-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.10.47-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.10.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.10.47-rc1 X-KernelTest-Deadline: 2021-06-30T14:25+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 0a0e168be1cb..9b0e771302ce 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