From: Hans de Goede <hdegoede@redhat.com>
To: "Rafael J . Wysocki" <rjw@rjwysocki.net>,
Bjorn Helgaas <bhelgaas@google.com>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
"H . Peter Anvin" <hpa@zytor.com>
Cc: "Hans de Goede" <hdegoede@redhat.com>,
"Mika Westerberg" <mika.westerberg@linux.intel.com>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Myron Stowe" <myron.stowe@redhat.com>,
"Juha-Pekka Heikkila" <juhapekka.heikkila@gmail.com>,
"Benoit Grégoire" <benoitg@coeus.ca>,
"Hui Wang" <hui.wang@canonical.com>,
linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [RFC 2/2] x86/PCI: Ignore EFI memmap MMIO entries
Date: Mon, 14 Feb 2022 16:17:59 +0100 [thread overview]
Message-ID: <20220214151759.98267-3-hdegoede@redhat.com> (raw)
In-Reply-To: <20220214151759.98267-1-hdegoede@redhat.com>
Linux excludes E820 reserved addresses when allocating addresses from the
PCI host bridge window. This behavior is needed for at least 2 reasons:
1. Some BIOS-es contain a bug where they add addresses which map to system
RAM in the PCI host bridge window returned by the ACPI _CRS method, see
commit 4dc2287c1805 ("x86: avoid E820 regions when allocating address
space").
2. At least the Lenovo X1 carbon gen 2 BIOS has an overlap between an
E820 reserved range and the ACPI _CRS providing the PCI bridge windows:
BIOS-e820: [mem 0x00000000dceff000-0x00000000dfa0ffff] reserved
pci_bus 0000:00: root bus resource [mem 0xdfa00000-0xfebfffff window]
If Linux assigns the overlapping 0xdfa00000-0xdfa0ffff range to a PCI BAR
then the system fails to resume after a suspend.
Recently (2019) some systems have shown-up with EFI memmap MMIO entries
covering the entire _CRS returned PCI bridge memory window. These memmap
entries get converted into e820_table entries, causing all attempts to
assign memory to PCI BARs which have not been setup by the BIOS to fail.
For example see these dmesg snippets from a Lenovo IdeaPad 3 15IIL 81WE:
efi: mem63: [MMIO |RUN| | | | | | | | | | | | |UC] range=
[0x0000000065400000-0x00000000cfffffff] (1708MB)
[mem 0x000000004bc50000-0x00000000cfffffff] reserved
pci_bus 0000:00: root bus resource [mem 0x65400000-0xbfffffff window]
pci 0000:00:15.0: BAR 0: no space for [mem size 0x00001000 64bit]
pci 0000:00:15.0: BAR 0: failed to assign [mem size 0x00001000 64bit]
Since the problem is specifically caused by EFI memmap entries with
a MMIO type, use the new E820_TYPE_MMIO marking of e820 entries
translated from MMIO EFI memmap entries to skip these entries when
excluding e820 reservations in arch_remove_reservations(), fixing the
problem of not being able to find free space for unassigned BARs.
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=206459
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1868899
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1871793
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=2029207
BugLink: https://bugs.launchpad.net/bugs/1878279
BugLink: https://bugs.launchpad.net/bugs/1931715
BugLink: https://bugs.launchpad.net/bugs/1932069
BugLink: https://bugs.launchpad.net/bugs/1921649
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
arch/x86/kernel/resource.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/x86/kernel/resource.c b/arch/x86/kernel/resource.c
index 9b9fb7882c20..bd501f787a10 100644
--- a/arch/x86/kernel/resource.c
+++ b/arch/x86/kernel/resource.c
@@ -31,6 +31,10 @@ static void remove_e820_regions(struct resource *avail)
for (i = 0; i < e820_table->nr_entries; i++) {
entry = &e820_table->entries[i];
+ /* Some fw reserves the entire PCI bridge window as MMIO */
+ if (entry->type == E820_TYPE_MMIO)
+ continue;
+
resource_clip(avail, entry->addr,
entry->addr + entry->size - 1);
}
--
2.33.1
next prev parent reply other threads:[~2022-02-14 15:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-14 15:17 [RFC 0/2] x86/PCI: Ignore EFI memmap MMIO entries Hans de Goede
2022-02-14 15:17 ` [RFC 1/2] x86/e820: Map EFI_MEMORY_MAPPED_IO to a new E820_TYPE_MMIO type Hans de Goede
2022-02-14 15:17 ` Hans de Goede [this message]
2022-02-15 16:12 ` [RFC 0/2] x86/PCI: Ignore EFI memmap MMIO entries Hans de Goede
2022-02-15 17:20 ` Rafael J. Wysocki
2022-02-15 20:20 ` Hans de Goede
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=20220214151759.98267-3-hdegoede@redhat.com \
--to=hdegoede@redhat.com \
--cc=benoitg@coeus.ca \
--cc=bhelgaas@google.com \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=hui.wang@canonical.com \
--cc=juhapekka.heikkila@gmail.com \
--cc=kw@linux.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=mingo@redhat.com \
--cc=myron.stowe@redhat.com \
--cc=rjw@rjwysocki.net \
--cc=x86@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: link
Be 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