Skip to content

Commit

Permalink
x86/PCI: Revert "x86/PCI: Clip only host bridge windows for E820 regi…
Browse files Browse the repository at this point in the history
…ons"

This reverts commit 4c5e242.

Prior to 4c5e242 ("x86/PCI: Clip only host bridge windows for E820
regions"), E820 regions did not affect PCI host bridge windows.  We only
looked at E820 regions and avoided them when allocating new MMIO space.
If firmware PCI bridge window and BAR assignments used E820 regions, we
left them alone.

After 4c5e242, we removed E820 regions from the PCI host bridge
windows before looking at BARs, so firmware assignments in E820 regions
looked like errors, and we moved things around to fit in the space left
(if any) after removing the E820 regions.  This unnecessary BAR
reassignment broke several machines.

Guilherme reported that Steam Deck fails to boot after 4c5e242.  We
clipped the window that contained most 32-bit BARs:

  BIOS-e820: [mem 0x00000000a0000000-0x00000000a00fffff] reserved
  acpi PNP0A08:00: clipped [mem 0x80000000-0xf7ffffff window] to [mem 0xa0100000-0xf7ffffff window] for e820 entry [mem 0xa0000000-0xa00fffff]

which forced us to reassign all those BARs, for example, this NVMe BAR:

  pci 0000:00:01.2: PCI bridge to [bus 01]
  pci 0000:00:01.2:   bridge window [mem 0x80600000-0x806fffff]
  pci 0000:01:00.0: BAR 0: [mem 0x80600000-0x80603fff 64bit]
  pci 0000:00:01.2: can't claim window [mem 0x80600000-0x806fffff]: no compatible bridge window
  pci 0000:01:00.0: can't claim BAR 0 [mem 0x80600000-0x80603fff 64bit]: no compatible bridge window

  pci 0000:00:01.2: bridge window: assigned [mem 0xa0100000-0xa01fffff]
  pci 0000:01:00.0: BAR 0: assigned [mem 0xa0100000-0xa0103fff 64bit]

All the reassignments were successful, so the devices should have been
functional at the new addresses, but some were not.

Andy reported a similar failure on an Intel MID platform.  Benjamin
reported a similar failure on a VMWare Fusion VM.

Note: this is not a clean revert; this revert keeps the later change to
make the clipping dependent on a new pci_use_e820 bool, moving the checking
of this bool to arch_remove_reservations().

[bhelgaas: commit log, add more reporters and testers]
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=216109
Reported-by: Guilherme G. Piccoli <[email protected]>
Reported-by: Andy Shevchenko <[email protected]>
Reported-by: Benjamin Coddington <[email protected]>
Reported-by: Jongman Heo <[email protected]>
Fixes: 4c5e242 ("x86/PCI: Clip only host bridge windows for E820 regions")
Link: https://lore.kernel.org/r/[email protected]
Tested-by: Guilherme G. Piccoli <[email protected]>
Tested-by: Andy Shevchenko <[email protected]>
Tested-by: Benjamin Coddington <[email protected]>
Signed-off-by: Hans de Goede <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
  • Loading branch information
jwrdegoede authored and bjorn-helgaas committed Jun 17, 2022
1 parent f2906aa commit a2b36ff
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
5 changes: 0 additions & 5 deletions arch/x86/include/asm/e820/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

#include <asm/e820/types.h>

struct device;
struct resource;

extern struct e820_table *e820_table;
extern struct e820_table *e820_table_kexec;
extern struct e820_table *e820_table_firmware;
Expand Down Expand Up @@ -46,8 +43,6 @@ extern void e820__register_nosave_regions(unsigned long limit_pfn);

extern int e820__get_entry_type(u64 start, u64 end);

extern void remove_e820_regions(struct device *dev, struct resource *avail);

/*
* Returns true iff the specified range [start,end) is completely contained inside
* the ISA region.
Expand Down
8 changes: 8 additions & 0 deletions arch/x86/include/asm/pci_x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ void pcibios_scan_specific_bus(int busn);

/* pci-irq.c */

struct pci_dev;

struct irq_info {
u8 bus, devfn; /* Bus, device and function */
struct {
Expand Down Expand Up @@ -246,3 +248,9 @@ static inline void mmio_config_writel(void __iomem *pos, u32 val)
# define x86_default_pci_init_irq NULL
# define x86_default_pci_fixup_irqs NULL
#endif

#if defined(CONFIG_PCI) && defined(CONFIG_ACPI)
extern bool pci_use_e820;
#else
#define pci_use_e820 false
#endif
14 changes: 9 additions & 5 deletions arch/x86/kernel/resource.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/dev_printk.h>
#include <linux/ioport.h>
#include <linux/printk.h>
#include <asm/e820/api.h>
#include <asm/pci_x86.h>

static void resource_clip(struct resource *res, resource_size_t start,
resource_size_t end)
Expand All @@ -24,14 +25,14 @@ static void resource_clip(struct resource *res, resource_size_t start,
res->start = end + 1;
}

void remove_e820_regions(struct device *dev, struct resource *avail)
static void remove_e820_regions(struct resource *avail)
{
int i;
struct e820_entry *entry;
u64 e820_start, e820_end;
struct resource orig = *avail;

if (!(avail->flags & IORESOURCE_MEM))
if (!pci_use_e820)
return;

for (i = 0; i < e820_table->nr_entries; i++) {
Expand All @@ -41,7 +42,7 @@ void remove_e820_regions(struct device *dev, struct resource *avail)

resource_clip(avail, e820_start, e820_end);
if (orig.start != avail->start || orig.end != avail->end) {
dev_info(dev, "clipped %pR to %pR for e820 entry [mem %#010Lx-%#010Lx]\n",
pr_info("clipped %pR to %pR for e820 entry [mem %#010Lx-%#010Lx]\n",
&orig, avail, e820_start, e820_end);
orig = *avail;
}
Expand All @@ -55,6 +56,9 @@ void arch_remove_reservations(struct resource *avail)
* the low 1MB unconditionally, as this area is needed for some ISA
* cards requiring a memory range, e.g. the i82365 PCMCIA controller.
*/
if (avail->flags & IORESOURCE_MEM)
if (avail->flags & IORESOURCE_MEM) {
resource_clip(avail, BIOS_ROM_BASE, BIOS_ROM_END);

remove_e820_regions(avail);
}
}
8 changes: 1 addition & 7 deletions arch/x86/pci/acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <linux/pci-acpi.h>
#include <asm/numa.h>
#include <asm/pci_x86.h>
#include <asm/e820/api.h>

struct pci_root_info {
struct acpi_pci_root_info common;
Expand All @@ -20,7 +19,7 @@ struct pci_root_info {
#endif
};

static bool pci_use_e820 = true;
bool pci_use_e820 = true;
static bool pci_use_crs = true;
static bool pci_ignore_seg;

Expand Down Expand Up @@ -387,11 +386,6 @@ static int pci_acpi_root_prepare_resources(struct acpi_pci_root_info *ci)

status = acpi_pci_probe_root_resources(ci);

if (pci_use_e820) {
resource_list_for_each_entry(entry, &ci->resources)
remove_e820_regions(&device->dev, entry->res);
}

if (pci_use_crs) {
resource_list_for_each_entry_safe(entry, tmp, &ci->resources)
if (resource_is_pcicfg_ioport(entry->res))
Expand Down

0 comments on commit a2b36ff

Please sign in to comment.