LKML Archive on lore.kernel.org help / color / mirror / Atom feed
From: Alex Deucher <alexdeucher@gmail.com> To: "Christian König" <ckoenig.leichtzumerken@gmail.com> Cc: Bjorn Helgaas <helgaas@kernel.org>, Linux PCI <linux-pci@vger.kernel.org>, Maling list - DRI developers <dri-devel@lists.freedesktop.org>, LKML <linux-kernel@vger.kernel.org>, amd-gfx list <amd-gfx@lists.freedesktop.org> Subject: Re: [PATCH v9 4/5] x86/PCI: Enable a 64bit BAR on AMD Family 15h (Models 30h-3fh) Processors v5 Date: Thu, 2 Nov 2017 12:43:31 -0400 [thread overview] Message-ID: <CADnq5_MOTfeck34SMpTCihVJKXupPRgLY5-m13tjB1iz8Mj=7A@mail.gmail.com> (raw) In-Reply-To: <20171018135821.3248-5-deathsimple@vodafone.de> On Wed, Oct 18, 2017 at 9:58 AM, Christian König <ckoenig.leichtzumerken@gmail.com> wrote: > From: Christian König <christian.koenig@amd.com> > > 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 <christian.koenig@amd.com> > Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> > --- > 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; > + > + 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); > + We may want to expand this to cover more host bridges. E.g., on my KV system I have these: 00:00.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) Processor Root Complex [1022:1422] 00:02.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Device [1022:1424] 00:03.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Device [1022:1424] 00:04.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Device [1022:1424] 00:18.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) Processor Function 0 [1022:141a] 00:18.1 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) Processor Function 1 [1022:141b] 00:18.2 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) Processor Function 2 [1022:141c] 00:18.3 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) Processor Function 3 [1022:141d] 00:18.4 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) Processor Function 4 [1022:141e] 00:18.5 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 30h-3fh) Processor Function 5 [1022:141f] And on my CZ system: 00:00.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Device [1022:1576] 00:02.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Device [1022:157b] 00:03.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Device [1022:157b] 00:09.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Device [1022:157d] 00:18.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Device [1022:1570] 00:18.1 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Device [1022:1571] 00:18.2 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Device [1022:1572] 00:18.3 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Device [1022:1573] 00:18.4 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Device [1022:1574] 00:18.5 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Device [1022:1575] Do you know if Zen based systems use the same registers? They have yet more set of pci ids for host bridges. Alex > +#endif > -- > 2.11.0 > > _______________________________________________ > amd-gfx mailing list > amd-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2017-11-02 16:43 UTC|newest] Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-10-18 13:58 Resizable PCI BAR support V9 Christian König 2017-10-18 13:58 ` [PATCH v9 1/5] PCI: add a define for the PCI resource type mask v2 Christian König 2017-10-18 13:58 ` [PATCH v9 2/5] PCI: add resizeable BAR infrastructure v5 Christian König 2017-10-18 13:58 ` [PATCH v9 3/5] PCI: add functionality for resizing resources v7 Christian König 2017-10-18 13:58 ` [PATCH v9 4/5] x86/PCI: Enable a 64bit BAR on AMD Family 15h (Models 30h-3fh) Processors v5 Christian König 2017-11-02 16:43 ` Alex Deucher [this message] 2017-11-20 15:51 ` Boris Ostrovsky 2017-11-20 16:07 ` Christian König 2017-11-20 16:33 ` Boris Ostrovsky 2017-11-21 13:34 ` Christian König 2017-11-21 22:26 ` Boris Ostrovsky 2017-11-22 10:09 ` Christian König 2017-11-22 16:24 ` Boris Ostrovsky 2017-11-22 16:54 ` Christian König 2017-11-22 17:27 ` Boris Ostrovsky 2017-11-23 8:11 ` Christian König 2017-11-23 14:12 ` Boris Ostrovsky 2017-11-27 18:30 ` Boris Ostrovsky 2017-11-28 9:12 ` Christian König 2017-11-28 9:46 ` [Xen-devel] " Jan Beulich 2017-11-28 10:17 ` Christian König 2017-11-28 10:53 ` Jan Beulich 2017-11-28 11:59 ` Christian König 2017-11-28 18:55 ` Boris Ostrovsky 2017-10-18 13:58 ` [PATCH v9 5/5] drm/amdgpu: resize VRAM BAR for CPU access v5 Christian König 2017-10-24 19:44 ` Resizable PCI BAR support V9 Bjorn Helgaas 2017-10-25 11:27 ` Christian König
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to='CADnq5_MOTfeck34SMpTCihVJKXupPRgLY5-m13tjB1iz8Mj=7A@mail.gmail.com' \ --to=alexdeucher@gmail.com \ --cc=amd-gfx@lists.freedesktop.org \ --cc=ckoenig.leichtzumerken@gmail.com \ --cc=dri-devel@lists.freedesktop.org \ --cc=helgaas@kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-pci@vger.kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).