x86/PCI: Move and shrink AMD 64-bit window to avoid conflict

Avoid problems with BIOS implementations which don't report all used
resources to the OS by only allocating a 256GB window directly below the
hardware limit (from the BKDG, sec 2.4.6).

Fixes a silent reboot loop reported by Aaro Koskinen <aaro.koskinen@iki.fi>
on an AMD-based MSI MS-7699/760GA-P43(FX) system. This was apparently
caused by RAM or other unreported hardware that conflicted with the new
window.

Link: https://support.amd.com/TechDocs/49125_15h_Models_30h-3Fh_BKDG.pdf
Link: https://lkml.kernel.org/r/20180105220412.fzpwqe4zljdawr36@darkstar.musicnaut.iki.fi
Fixes: fa564ad96366 ("x86/PCI: Enable a 64bit BAR on AMD Family 15h (Models 00-1f, 30-3f, 60-7f)")
Reported-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Christian König <christian.koenig@amd.com>
[bhelgaas: changelog, comment, Fixes:]
Signed-off-by: Bjorn Helgaas <helgaas@kernel.org>

authored by =?UTF-8?q?Christian=20K=C3=B6nig?= and committed by Bjorn Helgaas 03a55173 f32ab754

Changed files
+12 -10
arch
x86
pci
+12 -10
arch/x86/pci/fixup.c
··· 662 662 */ 663 663 static void pci_amd_enable_64bit_bar(struct pci_dev *dev) 664 664 { 665 - unsigned i; 666 665 u32 base, limit, high; 667 - struct resource *res, *conflict; 668 666 struct pci_dev *other; 667 + struct resource *res; 668 + unsigned i; 669 + int r; 669 670 670 671 if (!(pci_probe & PCI_BIG_ROOT_WINDOW)) 671 672 return; ··· 703 702 if (!res) 704 703 return; 705 704 705 + /* 706 + * Allocate a 256GB window directly below the 0xfd00000000 hardware 707 + * limit (see AMD Family 15h Models 30h-3Fh BKDG, sec 2.4.6). 708 + */ 706 709 res->name = "PCI Bus 0000:00"; 707 710 res->flags = IORESOURCE_PREFETCH | IORESOURCE_MEM | 708 711 IORESOURCE_MEM_64 | IORESOURCE_WINDOW; 709 - res->start = 0x100000000ull; 712 + res->start = 0xbd00000000ull; 710 713 res->end = 0xfd00000000ull - 1; 711 714 712 - /* Just grab the free area behind system memory for this */ 713 - while ((conflict = request_resource_conflict(&iomem_resource, res))) { 714 - if (conflict->end >= res->end) { 715 - kfree(res); 716 - return; 717 - } 718 - res->start = conflict->end + 1; 715 + r = request_resource(&iomem_resource, res); 716 + if (r) { 717 + kfree(res); 718 + return; 719 719 } 720 720 721 721 dev_info(&dev->dev, "adding root bus resource %pR (tainting kernel)\n",