Received: by 10.223.164.202 with SMTP id h10csp3968794wrb; Mon, 20 Nov 2017 07:52:35 -0800 (PST) X-Google-Smtp-Source: AGs4zMaqxG+ia8kcnG+qQJ0wY5M/iV10OiZEqa3CkOaPGX5GEVt2q+bBiXLoBBSuj0WktYyw+QVP X-Received: by 10.101.74.73 with SMTP id a9mr3419475pgu.444.1511193155498; Mon, 20 Nov 2017 07:52:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511193155; cv=none; d=google.com; s=arc-20160816; b=FDyY7h1GbtbwRagXkpxXegslBiTdrK21SYvDPhoAJPFBvQXJTd1GmYnxXeHQvBjtKb VyERMx9bnvbTrv8Ozo/UJIZvZHNxmCeRefifzVy9rWfXwVvawwF4FSmudN9WG+DZGqv6 4aD+1Dr6SCzfYCTjJxXNLO0NnRUbwRpnGeDA2UJPMWZouMwBgmNt2+8c0XqXYdD20JEK QZrrStL/KTwgMoVNofJYIgXdpaJxF3UykxXxGO2bg5/n1gfnsJQHA3iuuQwef217/jvb p58fEnNrk1DhqfHwwMUL/+OaVgQDJalrrpP0ThGt9TWmFsmCIlTw9FZQ9k6pqqd/Vz0I hIbA== 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:in-reply-to :mime-version:user-agent:date:message-id:from:references:to:subject :arc-authentication-results; bh=Tgtxmya8bOzQ23fj0OQazNZntMYcDag7EWSEREToAYo=; b=vtDDPvwFcTZ7xbgYnZontfNvmTN9DEKXfSlcvxN6jbM1LcC5bqjbngpDCqf8lhsGYI 1BnkDxws311HjpBLIZoQ7dbOxS7y+nj6G9wkNQTXwEsYWer1vlmqaqZ7MGynE2e9wAO6 YdP55hJ9/2ln2loM6/4jJ1nzEBKpnW/C/E4fBXF9rKIr60Zkor9pqPpWWPnQgIrbaHp6 VSolaDjmpDXKKRUK0HxllqLoWScg3LqpVKqwSD3Ie4EHjJXh7iQPiNRhC2JX/CPF/ql/ FysWNSkPQrwUcW2FEGwO13e4UaQLqLLQxOs98iN+LJh+enBzJt3imKbigxmFxYvVYwh8 F+Sg== 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=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f3si8877912plf.106.2017.11.20.07.52.25; Mon, 20 Nov 2017 07:52:35 -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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751545AbdKTPvN (ORCPT + 66 others); Mon, 20 Nov 2017 10:51:13 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:41573 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751350AbdKTPvL (ORCPT ); Mon, 20 Nov 2017 10:51:11 -0500 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id vAKFp6wM015195 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Nov 2017 15:51:06 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id vAKFp54k002668 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Nov 2017 15:51:06 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id vAKFp5LZ027623; Mon, 20 Nov 2017 15:51:05 GMT Received: from bostrovs-us.us.oracle.com (/10.152.32.65) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 20 Nov 2017 07:51:04 -0800 Subject: Re: [PATCH v9 4/5] x86/PCI: Enable a 64bit BAR on AMD Family 15h (Models 30h-3fh) Processors v5 To: =?UTF-8?Q?Christian_K=c3=b6nig?= , helgaas@kernel.org, linux-pci@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org References: <20171018135821.3248-1-deathsimple@vodafone.de> <20171018135821.3248-5-deathsimple@vodafone.de> From: Boris Ostrovsky Message-ID: Date: Mon, 20 Nov 2017 10:51:02 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20171018135821.3248-5-deathsimple@vodafone.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Source-IP: aserv0021.oracle.com [141.146.126.233] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/18/2017 09:58 AM, Christian König wrote: > From: Christian König > > Most BIOS don't enable this because of compatibility reasons. > > Manually enable a 64bit BAR of 64GB size so that we have > enough room for PCI devices. > > v2: style cleanups, increase size, add resource name, set correct flags, > print message that windows was added > v3: add defines for all the magic numbers, style cleanups > v4: add some comment that the BIOS should actually allow this using > _PRS and _SRS. > v5: only enable this if CONFIG_PHYS_ADDR_T_64BIT is set > > Signed-off-by: Christian König > Reviewed-by: Andy Shevchenko > --- > arch/x86/pci/fixup.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 80 insertions(+) > > diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c > index 11e407489db0..7b6bd76713c5 100644 > --- a/arch/x86/pci/fixup.c > +++ b/arch/x86/pci/fixup.c > @@ -618,3 +618,83 @@ static void quirk_apple_mbp_poweroff(struct pci_dev *pdev) > dev_info(dev, "can't work around MacBook Pro poweroff issue\n"); > } > DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x8c10, quirk_apple_mbp_poweroff); > + > +#ifdef CONFIG_PHYS_ADDR_T_64BIT > + > +#define AMD_141b_MMIO_BASE(x) (0x80 + (x) * 0x8) > +#define AMD_141b_MMIO_BASE_RE_MASK BIT(0) > +#define AMD_141b_MMIO_BASE_WE_MASK BIT(1) > +#define AMD_141b_MMIO_BASE_MMIOBASE_MASK GENMASK(31,8) > + > +#define AMD_141b_MMIO_LIMIT(x) (0x84 + (x) * 0x8) > +#define AMD_141b_MMIO_LIMIT_MMIOLIMIT_MASK GENMASK(31,8) > + > +#define AMD_141b_MMIO_HIGH(x) (0x180 + (x) * 0x4) > +#define AMD_141b_MMIO_HIGH_MMIOBASE_MASK GENMASK(7,0) > +#define AMD_141b_MMIO_HIGH_MMIOLIMIT_SHIFT 16 > +#define AMD_141b_MMIO_HIGH_MMIOLIMIT_MASK GENMASK(23,16) > + > +/* > + * The PCI Firmware Spec, rev 3.2 notes that ACPI should optionally allow > + * configuring host bridge windows using the _PRS and _SRS methods. > + * > + * But this is rarely implemented, so we manually enable a large 64bit BAR for > + * PCIe device on AMD Family 15h (Models 30h-3fh) Processors here. > + */ > +static void pci_amd_enable_64bit_bar(struct pci_dev *dev) > +{ > + struct resource *res, *conflict; > + u32 base, limit, high; > + unsigned i; > + > + for (i = 0; i < 8; ++i) { > + pci_read_config_dword(dev, AMD_141b_MMIO_BASE(i), &base); > + pci_read_config_dword(dev, AMD_141b_MMIO_HIGH(i), &high); > + > + /* Is this slot free? */ > + if (!(base & (AMD_141b_MMIO_BASE_RE_MASK | > + AMD_141b_MMIO_BASE_WE_MASK))) > + break; > + > + base >>= 8; > + base |= high << 24; > + > + /* Abort if a slot already configures a 64bit BAR. */ > + if (base > 0x10000) > + return; > + } > + if (i == 8) > + return; > + > + res = kzalloc(sizeof(*res), GFP_KERNEL); > + if (!res) > + return; > + > + res->name = "PCI Bus 0000:00"; > + res->flags = IORESOURCE_PREFETCH | IORESOURCE_MEM | > + IORESOURCE_MEM_64 | IORESOURCE_WINDOW; > + res->start = 0x100000000ull; > + res->end = 0xfd00000000ull - 1; > + > + /* Just grab the free area behind system memory for this */ > + while ((conflict = request_resource_conflict(&iomem_resource, res))) > + res->start = conflict->end + 1; I get stuck in the infinite loop here. Presumably because on a multi-socket system we succeed for the first processor (0000:00:18.1) and add 'res' to iomem_resource. For 0000:00:19.1 we find the slot in the 'for' loop above but then we fail to find a place to add 'res'. And with final sibling being [0 - max possible addr] we are stuck here. A possible solution to get out of the loop could be if (conflict->end >= res->end) { kfree(res); return; } but I don't know whether this is what we actually want. This is a 2-socket vendor_id : AuthenticAMD cpu family : 21 model : 1 model name : AMD Opteron(TM) Processor 6272 stepping : 2 (and then it breaks differently as a Xen guest --- we hung on the last pci_read_config_dword(), I haven't looked at this at all yet) -boris > + > + dev_info(&dev->dev, "adding root bus resource %pR\n", res); > + > + base = ((res->start >> 8) & AMD_141b_MMIO_BASE_MMIOBASE_MASK) | > + AMD_141b_MMIO_BASE_RE_MASK | AMD_141b_MMIO_BASE_WE_MASK; > + limit = ((res->end + 1) >> 8) & AMD_141b_MMIO_LIMIT_MMIOLIMIT_MASK; > + high = ((res->start >> 40) & AMD_141b_MMIO_HIGH_MMIOBASE_MASK) | > + ((((res->end + 1) >> 40) << AMD_141b_MMIO_HIGH_MMIOLIMIT_SHIFT) > + & AMD_141b_MMIO_HIGH_MMIOLIMIT_MASK); > + > + pci_write_config_dword(dev, AMD_141b_MMIO_HIGH(i), high); > + pci_write_config_dword(dev, AMD_141b_MMIO_LIMIT(i), limit); > + pci_write_config_dword(dev, AMD_141b_MMIO_BASE(i), base); > + > + pci_bus_add_resource(dev->bus, res, 0); > +} > +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_AMD, 0x141b, pci_amd_enable_64bit_bar); > + > +#endif From 1582973394228178168@xxx Thu Nov 02 16:44:29 +0000 2017 X-GM-THRID: 1581604510312740883 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread