From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id ED3BF6CFF4 for ; Thu, 12 Aug 2021 14:50:53 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id DDB0D2342A for ; Thu, 12 Aug 2021 14:50:53 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 047532341E for ; Thu, 12 Aug 2021 14:50:49 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id C6B07432F4 for ; Thu, 12 Aug 2021 14:50:49 +0200 (CEST) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pve-devel@lists.proxmox.com Date: Thu, 12 Aug 2021 14:50:41 +0200 Message-Id: <20210812125041.2222956-1-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.427 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH kernel] fix #3552: cherry-pick PCI probe fixes X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 12:50:54 -0000 breaking some NVME setups. these should be picked up by one of the next Ubuntu kernel releases, since both the breaking change and the fix are authored by Canonical devs. Signed-off-by: Fabian Grünbichler --- apply before pulling in next Ubuntu tag in case it is not contained ...sce-host-bridge-contiguous-apertures.patch | 102 ++++++++++++++++ ...I-Coalesce-host-bridge-contiguous-ap.patch | 111 ++++++++++++++++++ 2 files changed, 213 insertions(+) create mode 100644 patches/kernel/0008-Revert-PCI-Coalesce-host-bridge-contiguous-apertures.patch create mode 100644 patches/kernel/0009-PCI-Reinstate-PCI-Coalesce-host-bridge-contiguous-ap.patch diff --git a/patches/kernel/0008-Revert-PCI-Coalesce-host-bridge-contiguous-apertures.patch b/patches/kernel/0008-Revert-PCI-Coalesce-host-bridge-contiguous-apertures.patch new file mode 100644 index 0000000..a3eb9a7 --- /dev/null +++ b/patches/kernel/0008-Revert-PCI-Coalesce-host-bridge-contiguous-apertures.patch @@ -0,0 +1,102 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= +Date: Mon, 2 Aug 2021 10:22:30 +0200 +Subject: [PATCH] Revert "PCI: Coalesce host bridge contiguous apertures" +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This reverts commit c2ff8072deba40887560dc73dd2e558ec539ea09. + +was reverted upstream because of reports similar to + +Link: https://bugzilla.proxmox.com/show_bug.cgi?id=3552 +Link: https://lore.kernel.org/r/20210709231529.GA3270116@roeck-us.net +Signed-off-by: Fabian Grünbichler +--- + drivers/pci/probe.c | 49 ++++----------------------------------------- + 1 file changed, 4 insertions(+), 45 deletions(-) + +diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c +index 04664d4fe4be..be51670572fa 100644 +--- a/drivers/pci/probe.c ++++ b/drivers/pci/probe.c +@@ -19,7 +19,6 @@ + #include + #include + #include +-#include + #include "pci.h" + + #define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */ +@@ -875,30 +874,14 @@ static void pci_set_bus_msi_domain(struct pci_bus *bus) + dev_set_msi_domain(&bus->dev, d); + } + +-static int res_cmp(void *priv, struct list_head *a, struct list_head *b) +-{ +- struct resource_entry *entry1, *entry2; +- +- entry1 = container_of(a, struct resource_entry, node); +- entry2 = container_of(b, struct resource_entry, node); +- +- if (entry1->res->flags != entry2->res->flags) +- return entry1->res->flags > entry2->res->flags; +- +- if (entry1->offset != entry2->offset) +- return entry1->offset > entry2->offset; +- +- return entry1->res->start > entry2->res->start; +-} +- + static int pci_register_host_bridge(struct pci_host_bridge *bridge) + { + struct device *parent = bridge->dev.parent; +- struct resource_entry *window, *next, *n; ++ struct resource_entry *window, *n; + struct pci_bus *bus, *b; +- resource_size_t offset, next_offset; ++ resource_size_t offset; + LIST_HEAD(resources); +- struct resource *res, *next_res; ++ struct resource *res; + char addr[64], *fmt; + const char *name; + int err; +@@ -976,35 +959,11 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge) + if (nr_node_ids > 1 && pcibus_to_node(bus) == NUMA_NO_NODE) + dev_warn(&bus->dev, "Unknown NUMA node; performance will be reduced\n"); + +- /* Sort and coalesce contiguous windows */ +- list_sort(NULL, &resources, res_cmp); +- resource_list_for_each_entry_safe(window, n, &resources) { +- if (list_is_last(&window->node, &resources)) +- break; +- +- next = list_next_entry(window, node); +- offset = window->offset; +- res = window->res; +- next_offset = next->offset; +- next_res = next->res; +- +- if (res->flags != next_res->flags || offset != next_offset) +- continue; +- +- if (res->end + 1 == next_res->start) { +- next_res->start = res->start; +- res->flags = res->start = res->end = 0; +- } +- } +- + /* Add initial resources to the bus */ + resource_list_for_each_entry_safe(window, n, &resources) { ++ list_move_tail(&window->node, &bridge->windows); + offset = window->offset; + res = window->res; +- if (!res->end) +- continue; +- +- list_move_tail(&window->node, &bridge->windows); + + if (res->flags & IORESOURCE_BUS) + pci_bus_insert_busn_res(bus, bus->number, res->end); diff --git a/patches/kernel/0009-PCI-Reinstate-PCI-Coalesce-host-bridge-contiguous-ap.patch b/patches/kernel/0009-PCI-Reinstate-PCI-Coalesce-host-bridge-contiguous-ap.patch new file mode 100644 index 0000000..de41df8 --- /dev/null +++ b/patches/kernel/0009-PCI-Reinstate-PCI-Coalesce-host-bridge-contiguous-ap.patch @@ -0,0 +1,111 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Kai-Heng Feng +Date: Tue, 13 Jul 2021 20:50:07 +0800 +Subject: [PATCH] PCI: Reinstate "PCI: Coalesce host bridge contiguous + apertures" +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Built-in graphics on HP EliteDesk 805 G6 doesn't work because graphics +can't get the BAR it needs: + pci_bus 0000:00: root bus resource [mem 0x10020200000-0x100303fffff window] + pci_bus 0000:00: root bus resource [mem 0x10030400000-0x100401fffff window] + + pci 0000:00:08.1: bridge window [mem 0xd2000000-0xd23fffff] + pci 0000:00:08.1: bridge window [mem 0x10030000000-0x100401fffff 64bit pref] + pci 0000:00:08.1: can't claim BAR 15 [mem 0x10030000000-0x100401fffff 64bit pref]: no compatible bridge window + pci 0000:00:08.1: [mem 0x10030000000-0x100401fffff 64bit pref] clipped to [mem 0x10030000000-0x100303fffff 64bit pref] + pci 0000:00:08.1: bridge window [mem 0x10030000000-0x100303fffff 64bit pref] + pci 0000:07:00.0: can't claim BAR 0 [mem 0x10030000000-0x1003fffffff 64bit pref]: no compatible bridge window + pci 0000:07:00.0: can't claim BAR 2 [mem 0x10040000000-0x100401fffff 64bit pref]: no compatible bridge window + +However, the root bus has two contiguous apertures that can contain the +child resource requested. + +Coalesce contiguous apertures so we can allocate from the entire contiguous +region. + +This is the second take of commit 65db04053efe ("PCI: Coalesce host +bridge contiguous apertures"). The original approach sorts the apertures +by address, but that makes NVMe stop working on QEMU ppc:sam460ex: + PCI host bridge to bus 0002:00 + pci_bus 0002:00: root bus resource [io 0x0000-0xffff] + pci_bus 0002:00: root bus resource [mem 0xd80000000-0xdffffffff] (bus address [0x80000000-0xffffffff]) + pci_bus 0002:00: root bus resource [mem 0xc0ee00000-0xc0eefffff] (bus address [0x00000000-0x000fffff]) + +After the offending commit: + PCI host bridge to bus 0002:00 + pci_bus 0002:00: root bus resource [io 0x0000-0xffff] + pci_bus 0002:00: root bus resource [mem 0xc0ee00000-0xc0eefffff] (bus address [0x00000000-0x000fffff]) + pci_bus 0002:00: root bus resource [mem 0xd80000000-0xdffffffff] (bus address [0x80000000-0xffffffff]) + +Since the apertures on HP EliteDesk 805 G6 are already in ascending +order, doing a precautious sorting is not necessary. + +Remove the sorting part to avoid the regression on ppc:sam460ex. + +Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=212013 +Cc: Guenter Roeck +Suggested-by: Bjorn Helgaas +Signed-off-by: Kai-Heng Feng +Signed-off-by: Fabian Grünbichler +--- + drivers/pci/probe.c | 31 +++++++++++++++++++++++++++---- + 1 file changed, 27 insertions(+), 4 deletions(-) + +diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c +index be51670572fa..133f5d2b189d 100644 +--- a/drivers/pci/probe.c ++++ b/drivers/pci/probe.c +@@ -877,11 +877,11 @@ static void pci_set_bus_msi_domain(struct pci_bus *bus) + static int pci_register_host_bridge(struct pci_host_bridge *bridge) + { + struct device *parent = bridge->dev.parent; +- struct resource_entry *window, *n; ++ struct resource_entry *window, *next, *n; + struct pci_bus *bus, *b; +- resource_size_t offset; ++ resource_size_t offset, next_offset; + LIST_HEAD(resources); +- struct resource *res; ++ struct resource *res, *next_res; + char addr[64], *fmt; + const char *name; + int err; +@@ -959,11 +959,34 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge) + if (nr_node_ids > 1 && pcibus_to_node(bus) == NUMA_NO_NODE) + dev_warn(&bus->dev, "Unknown NUMA node; performance will be reduced\n"); + ++ /* Coalesce contiguous windows */ ++ resource_list_for_each_entry_safe(window, n, &resources) { ++ if (list_is_last(&window->node, &resources)) ++ break; ++ ++ next = list_next_entry(window, node); ++ offset = window->offset; ++ res = window->res; ++ next_offset = next->offset; ++ next_res = next->res; ++ ++ if (res->flags != next_res->flags || offset != next_offset) ++ continue; ++ ++ if (res->end + 1 == next_res->start) { ++ next_res->start = res->start; ++ res->flags = res->start = res->end = 0; ++ } ++ } ++ + /* Add initial resources to the bus */ + resource_list_for_each_entry_safe(window, n, &resources) { +- list_move_tail(&window->node, &bridge->windows); + offset = window->offset; + res = window->res; ++ if (!res->end) ++ continue; ++ ++ list_move_tail(&window->node, &bridge->windows); + + if (res->flags & IORESOURCE_BUS) + pci_bus_insert_busn_res(bus, bus->number, res->end); -- 2.30.2