Received: by 10.223.164.202 with SMTP id h10csp3988057wrb; Mon, 20 Nov 2017 08:08:11 -0800 (PST) X-Google-Smtp-Source: AGs4zMaY5XrjAE2uXyAkkvCUD+tLJipUSLdwRjmgAOTZfYI5Rkwq7SmPCx7JeMNJMNY10mFjwcl6 X-Received: by 10.98.38.66 with SMTP id m63mr2136852pfm.0.1511194091847; Mon, 20 Nov 2017 08:08:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511194091; cv=none; d=google.com; s=arc-20160816; b=w36M45Hr4NaoNSwucr7E24jc6Vbdb1WGzfMmsTRqjCkIV6IttlCQ5GfjBnFtrFr73U qQE2LX83/jNvJCq4QZUIuKxKLpU7Kzh+uF2QTnDkV3jI3TXe7G5Dq2mSSeEK9skWGT3o fuGXrNyjtLYWYKyqSCB4leoVt/Id9hByNvl33pMZJ3vjJlw8JbtFOHFn+Zhb5lLfO2Z+ zs+5GgaRGlWKPgs+vV4OJEHB50Xg0WTnuklk2pptbXox1XYoz6j/e8grc4DIewSUYVmU pVWUgsOGdSbVYaq7yTLIhTwNnbi3bL8Xv3KFPq3VGxHXJ+79hkRzHSbLWMFU2ocer1DB zxBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:reply-to:dkim-signature :arc-authentication-results; bh=rbUxEo35zj7mCzR1Tcc3uNRmvEuaLKLaHktgIDZEWvk=; b=cA184miCqN3SKTzTiBEDZTDeZvdhfAPkNNDjCLW9Vf5l472BkmGOvBw6ZgjzKkMvFQ gtxlY7N97FpMVJhIJdi1NJ8MraikE1+ij+bDmDZNQX2WnpRDoehz3fuKLewk87taJ6BK /E0N8mzI0rOobzzrf0wV8EjoMA1i6WvU3w/M4XiOhnzTGldQ4cQdJ2gfuOKxzeC5KFBN wugwBdrhdyNKSjbjRUmweIIaFB8LtbyjsyjdoOmoxVhmonbzORckgBxVzAFaLbD2xZ3c aYBF5TbT77yGqJx6GRih/xXIszus38vznkZ+eXz/8Y27ctRK0UhOYFWW2E1f7uQiC/HW ycOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=e6uwASsF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a13si8236657pgt.35.2017.11.20.08.08.01; Mon, 20 Nov 2017 08:08:11 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=e6uwASsF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751555AbdKTQHZ (ORCPT + 66 others); Mon, 20 Nov 2017 11:07:25 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:45944 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751364AbdKTQHW (ORCPT ); Mon, 20 Nov 2017 11:07:22 -0500 Received: by mail-wm0-f66.google.com with SMTP id 9so19832397wme.4; Mon, 20 Nov 2017 08:07:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=reply-to:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=rbUxEo35zj7mCzR1Tcc3uNRmvEuaLKLaHktgIDZEWvk=; b=e6uwASsFYiPTAb/9T1pf1smKAXAawo6+uESwAMywvqOisEc7AD+hU3Hqg+tiwDF4Y8 x0AMtJDuYis8JXqCAvDPFak7C9Vh7XctonlRR00kS2Sf4xxlzByqoHqUaLqJqpTdCqyI 4f+N1G+BjHoMnejoIQexKPxEGrnTfOcd/fyH/KDC7OOhpyOzjJ2aB/MOvHoixW1v+Ct8 1aTGL07+sH9Xjbltdw33u0e9cuJOiimaVyDepME2g3NRmbzEHM8Dw2PiC/oF6hxEXc81 4lOOKY1a71Eh3R9Mdq8YoB1sZ8QaLaQDsnMVZ/rK1QCBLx80S10ypfGhpxkSSH4tl07R I7cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=rbUxEo35zj7mCzR1Tcc3uNRmvEuaLKLaHktgIDZEWvk=; b=mgbTJ3snyTIrCY69PnHSnrfNq//bFLwZubf2C2s14xYBk0z6afiBymrb81D3KrUXGR h9G8sL0PPYqGB22vIZe6x33e3DKeUIgLDsaeVczFyoqHG8oTTCl/Loh6HZ3Jx77S2ObG 0ZZLsSt4pNvsxLynxtWDBlmc1a5ezLsPPP83BDmXn1JwopZkgsMYjRIysHBcbb6EDBhk e4MPxxSuQuHlXadqMwBGEnQQbNBLmnR4HE8hy3HDmn4b38BzZAchBVcZkOqNaQyDuKEs YOuMVZ73wThjmWxzyW51PH4dbTKGK74BcqAR0sPJgKfSq7Z69/BgU3cU0vDasSZRW5ay iA0g== X-Gm-Message-State: AJaThX7TYGFdftS8VEZWmI9cUEFoYaWJGnUUwnwcsZ3AvLd5WDU9uB98 kFohGayu+Ox5si6E41Zx0264TESe X-Received: by 10.80.138.34 with SMTP id i31mr20351845edi.8.1511194041438; Mon, 20 Nov 2017 08:07:21 -0800 (PST) Received: from ?IPv6:2a02:908:1251:7981:fcc0:d6fe:33e7:da04? ([2a02:908:1251:7981:fcc0:d6fe:33e7:da04]) by smtp.gmail.com with ESMTPSA id j39sm4628572ede.38.2017.11.20.08.07.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Nov 2017 08:07:20 -0800 (PST) Reply-To: christian.koenig@amd.com Subject: Re: [PATCH v9 4/5] x86/PCI: Enable a 64bit BAR on AMD Family 15h (Models 30h-3fh) Processors v5 To: Boris Ostrovsky , 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: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: Date: Mon, 20 Nov 2017 17:07:19 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 20.11.2017 um 16:51 schrieb Boris Ostrovsky: > 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; > } Ah, sorry for that. Yes problem is obvious now. > but I don't know whether this is what we actually want. Actually we would probably want to add the range to all cores at the same time. > > 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) Hui? How does this fix applies to a Xen guest in the first place? Please provide the output of "lspci -nn" and explain further what is your config with Xen. Regards, Christian. > > > > -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 1584600873974193645@xxx Mon Nov 20 15:52:35 +0000 2017 X-GM-THRID: 1581604510312740883 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread