diff mbox series

[v9,2/3] x86/PCI: Add DMI quirks to ignore E820 reserved regions on some systems

Message ID 20220519152150.6135-3-hdegoede@redhat.com
State New
Headers show
Series x86/PCI: Ignore E820 reservations for bridge windows on future systems | expand

Commit Message

Hans de Goede May 19, 2022, 3:21 p.m. UTC
Some BIOS-es contain bugs where they add addresses which are already
used in some other manner to the PCI host bridge window returned by
the ACPI _CRS method. To avoid this Linux by default excludes
E820 reserved regions when allocating addresses since 2010, see:
commit 4dc2287c1805 ("x86: avoid E820 regions when allocating address
space").

Recently (2019) some systems have shown-up with E820 reserved regions
which cover the entire _CRS returned PCI bridge memory window, causing
all attempts to assign memory to PCI BARs which have not been setup by
the BIOS to fail. For example here are the relevant dmesg bits from
a Lenovo IdeaPad 3 15IIL 81WE:

 [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]

Outright removing the code to remove E820 reserved regions when
allocating address space is known to cause regressions on various
existing systems.

Instead disable the removal of E820 reserved regions on models where
this is known to cause the above problem using DMI quirks.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=206459
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=214259
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1868899
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1871793
BugLink: https://bugs.launchpad.net/bugs/1878279
BugLink: https://bugs.launchpad.net/bugs/1880172
BugLink: https://bugs.launchpad.net/bugs/1884232
BugLink: https://bugs.launchpad.net/bugs/1921649
BugLink: https://bugs.launchpad.net/bugs/1931715
BugLink: https://bugs.launchpad.net/bugs/1932069
Cc: Benoit Grégoire <benoitg@coeus.ca>
Cc: Hui Wang <hui.wang@canonical.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Changes in v9:
- Split the addition of DMI quirks out into this new patch
- Add a DMI quirk for the TUXEDO Book XUX7 - Gen12
---
 arch/x86/pci/acpi.c | 87 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 87 insertions(+)
diff mbox series

Patch

diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 7bde3df68e4c..b88bdfba7908 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -43,6 +43,13 @@  static int __init set_ignore_seg(const struct dmi_system_id *id)
 	return 0;
 }
 
+static int __init set_no_e820(const struct dmi_system_id *id)
+{
+	printk(KERN_INFO "PCI: %s detected: ignoring e820 regions\n", id->ident);
+	pci_use_e820 = false;
+	return 0;
+}
+
 static const struct dmi_system_id pci_crs_quirks[] __initconst = {
 	/* http://bugzilla.kernel.org/show_bug.cgi?id=14183 */
 	{
@@ -137,6 +144,86 @@  static const struct dmi_system_id pci_crs_quirks[] __initconst = {
 			DMI_MATCH(DMI_PRODUCT_NAME, "HP xw9300 Workstation"),
 		},
 	},
+
+	/*
+	 * Most Lenovo models with "IIL" in their DMI_PRODUCT_VERSION have
+	 * an E820 reservation which covers the entire _CRS returned 32 bit
+	 * PCI bridge memory window, causing all attempts to assign memory to
+	 * 32 bit PCI bars which have not been setup by the BIOS to fail.
+	 * Specifically this often causes some of the I2C controllers to not
+	 * work breaking touchpad support and/or this may cause issues when
+	 * hotplugging thunderbolt connected devices.
+	 *
+	 * This DMI match entry covers the following DMI_PRODUCT_VERSION-s with
+	 * an E820 reservation which covers the entire 32 bit bridge window:
+	 * "IdeaPad 3 14IIL05", "IdeaPad 3 15IIL05", "IdeaPad 3 17IIL05",
+	 * "IdeaPad 5 14IIL05", "IdeaPad 5 15IIL05",
+	 * "IdeaPad Slim 7 14IIL05", "IdeaPad Slim 7 15IIL05",
+	 * "Lenovo BS145-15IIL",
+	 * "Lenovo IdeaPad S145-15IIL", "Lenovo IdeaPad S340-14IIL",
+	 * "Lenovo IdeaPad S340-15IIL", "Lenovo IdeaPad C340-15IIL",
+	 * "Lenovo V14-IIL", "Lenovo V15-IIL", "Lenovo V17-IIL",
+	 * "Lenovo Yoga S740-14IIL", "Lenovo Yoga C940-14IIL",
+	 * "Yoga Slim 7 14IIL05", "Yoga Slim 7 15IIL05"
+	 *
+	 * On some of these the bridge's _CRS method *sometimes* (under unknown
+	 * conditions) has a 64 bit [mem 0x4000000000-0x7fffffffff window].
+	 * This avoids some of the issues, but even then there are still issues
+	 * with assigning some 32 bit only BARs such as some Thunderbolt devs,
+	 * the 00:1f.5 BIOS SPI controller and BAR6 of some nvidia gfx.
+	 *
+	 * This entry also covers the following DMI_PRODUCT_VERSION-s which do
+	 * not need pci_use_e820=false. This quirk is a no-op for these models,
+	 * because there is no overlap between E820 regions and _CRS windows:
+	 * "IdeaPad Flex 5 14IIL05", "IdeaPad Flex 5 15IIL05",
+	 * "Lenovo ThinkBook 14-IIL", "Lenovo ThinkBook 15-IIL",
+	 * "Lenovo Yoga S940-14IIL"
+	 *
+	 * This entry fixes issues reported in the following bugs:
+	 * https://bugzilla.kernel.org/show_bug.cgi?id=206459
+	 * https://bugzilla.redhat.com/show_bug.cgi?id=1871793
+	 * https://bugzilla.redhat.com/show_bug.cgi?id=1868899
+	 * https://bugs.launchpad.net/bugs/1878279
+	 * https://bugs.launchpad.net/bugs/1880172
+	 * https://bugs.launchpad.net/bugs/1921649
+	 * https://bugs.launchpad.net/bugs/1931715
+	 * https://bugs.launchpad.net/bugs/1932069
+	 */
+	{
+		.callback = set_no_e820,
+		.ident = "Lenovo *IIL* product version",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+			DMI_MATCH(DMI_PRODUCT_VERSION, "IIL"),
+		},
+	},
+
+	/*
+	 * The Acer Spin 5 (SP513-54N) has the same E820 reservation covering
+	 * the entire _CRS 32 bit window issue as the Lenovo *IIL* models.
+	 * https://bugs.launchpad.net/bugs/1884232
+	 */
+	{
+		.callback = set_no_e820,
+		.ident = "Acer Spin 5 (SP513-54N)",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "Spin SP513-54N"),
+		},
+	},
+
+	/*
+	 * Clevo X170KM-G barebones have the same E820 reservation covering
+	 * the entire _CRS 32 bit window issue as the Lenovo *IIL* models.
+	 * https://bugzilla.kernel.org/show_bug.cgi?id=214259
+	 */
+	{
+		.callback = set_no_e820,
+		.ident = "Clevo X170KM-G Barebone",
+		.matches = {
+			DMI_MATCH(DMI_BOARD_NAME, "X170KM-G"),
+		},
+	},
 	{}
 };