All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: "Rafael J . Wysocki" <rafael@kernel.org>,
	"Mika Westerberg" <mika.westerberg@linux.intel.com>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Myron Stowe" <myron.stowe@redhat.com>,
	"Juha-Pekka Heikkila" <juhapekka.heikkila@gmail.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Borislav Petkov" <bp@alien8.de>,
	"H . Peter Anvin" <hpa@zytor.com>
Cc: "Hans de Goede" <hdegoede@redhat.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,
	"Rafael J . Wysocki" <rafael.j.wysocki@intel.com>
Subject: [PATCH v9 2/3] x86/PCI: Add DMI quirks to ignore E820 reserved regions on some systems
Date: Thu, 19 May 2022 17:21:49 +0200	[thread overview]
Message-ID: <20220519152150.6135-3-hdegoede@redhat.com> (raw)
In-Reply-To: <20220519152150.6135-1-hdegoede@redhat.com>

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 --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"),
+		},
+	},
 	{}
 };
 
-- 
2.36.0


  parent reply	other threads:[~2022-05-19 15:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-19 15:21 [PATCH v9 0/3] x86/PCI: Ignore E820 reservations for bridge windows on future systems Hans de Goede
2022-05-19 15:21 ` [PATCH v9 1/3] x86/PCI: Add kernel cmdline options to use/ignore E820 reserved regions Hans de Goede
2022-05-19 15:21 ` Hans de Goede [this message]
2022-05-19 15:21 ` [PATCH v9 3/3] x86/PCI: Ignore E820 reserved regions for bridge windows on future systems 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=20220519152150.6135-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=rafael.j.wysocki@intel.com \
    --cc=rafael@kernel.org \
    --cc=tglx@linutronix.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.