linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] PCI: Coalesce contiguous regions for host bridges
@ 2021-04-01 13:12 Kai-Heng Feng
  2021-04-22  8:57 ` Kai-Heng Feng
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Kai-Heng Feng @ 2021-04-01 13:12 UTC (permalink / raw)
  To: bhelgaas; +Cc: Kai-Heng Feng, open list:PCI SUBSYSTEM, open list

Built-in graphics on HP EliteDesk 805 G6 doesn't work because graphics
can't get the BAR it needs:
[    0.611504] pci_bus 0000:00: root bus resource [mem 0x10020200000-0x100303fffff window]
[    0.611505] pci_bus 0000:00: root bus resource [mem 0x10030400000-0x100401fffff window]
...
[    0.638083] pci 0000:00:08.1:   bridge window [mem 0xd2000000-0xd23fffff]
[    0.638086] pci 0000:00:08.1:   bridge window [mem 0x10030000000-0x100401fffff 64bit pref]
[    0.962086] pci 0000:00:08.1: can't claim BAR 15 [mem 0x10030000000-0x100401fffff 64bit pref]: no compatible bridge window
[    0.962086] pci 0000:00:08.1: [mem 0x10030000000-0x100401fffff 64bit pref] clipped to [mem 0x10030000000-0x100303fffff 64bit pref]
[    0.962086] pci 0000:00:08.1:   bridge window [mem 0x10030000000-0x100303fffff 64bit pref]
[    0.962086] pci 0000:07:00.0: can't claim BAR 0 [mem 0x10030000000-0x1003fffffff 64bit pref]: no compatible bridge window
[    0.962086] 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 regions that can contain the
child resource requested.

Bjorn Helgaas pointed out that we can simply coalesce contiguous regions
for host bridges, since host bridge don't have _SRS. So do that
accordingly to make child resource can be contained. This change makes
the graphics works on the system in question.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=212013
Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
v2:
 - Coalesce all contiguous regresion in pci_register_host_bridge(), if
   conditions are met.

 drivers/pci/probe.c | 49 +++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 45 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 953f15abc850..3607ce7402b4 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -19,6 +19,7 @@
 #include <linux/hypervisor.h>
 #include <linux/irqdomain.h>
 #include <linux/pm_runtime.h>
+#include <linux/list_sort.h>
 #include "pci.h"
 
 #define CARDBUS_LATENCY_TIMER	176	/* secondary latency timer */
@@ -874,14 +875,30 @@ 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, *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 +976,35 @@ 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);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] PCI: Coalesce contiguous regions for host bridges
  2021-04-01 13:12 [PATCH v2] PCI: Coalesce contiguous regions for host bridges Kai-Heng Feng
@ 2021-04-22  8:57 ` Kai-Heng Feng
  2021-05-11  3:33   ` Kai-Heng Feng
  2021-05-27 22:13 ` Bjorn Helgaas
  2021-07-09 23:15 ` Guenter Roeck
  2 siblings, 1 reply; 9+ messages in thread
From: Kai-Heng Feng @ 2021-04-22  8:57 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: open list:PCI SUBSYSTEM, open list

On Thu, Apr 1, 2021 at 9:12 PM Kai-Heng Feng
<kai.heng.feng@canonical.com> wrote:
>
> Built-in graphics on HP EliteDesk 805 G6 doesn't work because graphics
> can't get the BAR it needs:
> [    0.611504] pci_bus 0000:00: root bus resource [mem 0x10020200000-0x100303fffff window]
> [    0.611505] pci_bus 0000:00: root bus resource [mem 0x10030400000-0x100401fffff window]
> ...
> [    0.638083] pci 0000:00:08.1:   bridge window [mem 0xd2000000-0xd23fffff]
> [    0.638086] pci 0000:00:08.1:   bridge window [mem 0x10030000000-0x100401fffff 64bit pref]
> [    0.962086] pci 0000:00:08.1: can't claim BAR 15 [mem 0x10030000000-0x100401fffff 64bit pref]: no compatible bridge window
> [    0.962086] pci 0000:00:08.1: [mem 0x10030000000-0x100401fffff 64bit pref] clipped to [mem 0x10030000000-0x100303fffff 64bit pref]
> [    0.962086] pci 0000:00:08.1:   bridge window [mem 0x10030000000-0x100303fffff 64bit pref]
> [    0.962086] pci 0000:07:00.0: can't claim BAR 0 [mem 0x10030000000-0x1003fffffff 64bit pref]: no compatible bridge window
> [    0.962086] 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 regions that can contain the
> child resource requested.
>
> Bjorn Helgaas pointed out that we can simply coalesce contiguous regions
> for host bridges, since host bridge don't have _SRS. So do that
> accordingly to make child resource can be contained. This change makes
> the graphics works on the system in question.
>
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=212013
> Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>

A gentle ping...

> ---
> v2:
>  - Coalesce all contiguous regresion in pci_register_host_bridge(), if
>    conditions are met.
>
>  drivers/pci/probe.c | 49 +++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 45 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 953f15abc850..3607ce7402b4 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -19,6 +19,7 @@
>  #include <linux/hypervisor.h>
>  #include <linux/irqdomain.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/list_sort.h>
>  #include "pci.h"
>
>  #define CARDBUS_LATENCY_TIMER  176     /* secondary latency timer */
> @@ -874,14 +875,30 @@ 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, *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 +976,35 @@ 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);
> --
> 2.30.2
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] PCI: Coalesce contiguous regions for host bridges
  2021-04-22  8:57 ` Kai-Heng Feng
@ 2021-05-11  3:33   ` Kai-Heng Feng
  0 siblings, 0 replies; 9+ messages in thread
From: Kai-Heng Feng @ 2021-05-11  3:33 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: open list:PCI SUBSYSTEM, open list

On Thu, Apr 22, 2021 at 4:57 PM Kai-Heng Feng
<kai.heng.feng@canonical.com> wrote:
>
> On Thu, Apr 1, 2021 at 9:12 PM Kai-Heng Feng
> <kai.heng.feng@canonical.com> wrote:
> >
> > Built-in graphics on HP EliteDesk 805 G6 doesn't work because graphics
> > can't get the BAR it needs:
> > [    0.611504] pci_bus 0000:00: root bus resource [mem 0x10020200000-0x100303fffff window]
> > [    0.611505] pci_bus 0000:00: root bus resource [mem 0x10030400000-0x100401fffff window]
> > ...
> > [    0.638083] pci 0000:00:08.1:   bridge window [mem 0xd2000000-0xd23fffff]
> > [    0.638086] pci 0000:00:08.1:   bridge window [mem 0x10030000000-0x100401fffff 64bit pref]
> > [    0.962086] pci 0000:00:08.1: can't claim BAR 15 [mem 0x10030000000-0x100401fffff 64bit pref]: no compatible bridge window
> > [    0.962086] pci 0000:00:08.1: [mem 0x10030000000-0x100401fffff 64bit pref] clipped to [mem 0x10030000000-0x100303fffff 64bit pref]
> > [    0.962086] pci 0000:00:08.1:   bridge window [mem 0x10030000000-0x100303fffff 64bit pref]
> > [    0.962086] pci 0000:07:00.0: can't claim BAR 0 [mem 0x10030000000-0x1003fffffff 64bit pref]: no compatible bridge window
> > [    0.962086] 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 regions that can contain the
> > child resource requested.
> >
> > Bjorn Helgaas pointed out that we can simply coalesce contiguous regions
> > for host bridges, since host bridge don't have _SRS. So do that
> > accordingly to make child resource can be contained. This change makes
> > the graphics works on the system in question.
> >
> > Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=212013
> > Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
> > Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
>
> A gentle ping...

Another gentle ping...

>
> > ---
> > v2:
> >  - Coalesce all contiguous regresion in pci_register_host_bridge(), if
> >    conditions are met.
> >
> >  drivers/pci/probe.c | 49 +++++++++++++++++++++++++++++++++++++++++----
> >  1 file changed, 45 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> > index 953f15abc850..3607ce7402b4 100644
> > --- a/drivers/pci/probe.c
> > +++ b/drivers/pci/probe.c
> > @@ -19,6 +19,7 @@
> >  #include <linux/hypervisor.h>
> >  #include <linux/irqdomain.h>
> >  #include <linux/pm_runtime.h>
> > +#include <linux/list_sort.h>
> >  #include "pci.h"
> >
> >  #define CARDBUS_LATENCY_TIMER  176     /* secondary latency timer */
> > @@ -874,14 +875,30 @@ 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, *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 +976,35 @@ 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);
> > --
> > 2.30.2
> >

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] PCI: Coalesce contiguous regions for host bridges
  2021-04-01 13:12 [PATCH v2] PCI: Coalesce contiguous regions for host bridges Kai-Heng Feng
  2021-04-22  8:57 ` Kai-Heng Feng
@ 2021-05-27 22:13 ` Bjorn Helgaas
  2021-07-09 23:15 ` Guenter Roeck
  2 siblings, 0 replies; 9+ messages in thread
From: Bjorn Helgaas @ 2021-05-27 22:13 UTC (permalink / raw)
  To: Kai-Heng Feng; +Cc: bhelgaas, open list:PCI SUBSYSTEM, open list

On Thu, Apr 01, 2021 at 09:12:52PM +0800, Kai-Heng Feng wrote:
> Built-in graphics on HP EliteDesk 805 G6 doesn't work because graphics
> can't get the BAR it needs:
> [    0.611504] pci_bus 0000:00: root bus resource [mem 0x10020200000-0x100303fffff window]
> [    0.611505] pci_bus 0000:00: root bus resource [mem 0x10030400000-0x100401fffff window]
> ...
> [    0.638083] pci 0000:00:08.1:   bridge window [mem 0xd2000000-0xd23fffff]
> [    0.638086] pci 0000:00:08.1:   bridge window [mem 0x10030000000-0x100401fffff 64bit pref]
> [    0.962086] pci 0000:00:08.1: can't claim BAR 15 [mem 0x10030000000-0x100401fffff 64bit pref]: no compatible bridge window
> [    0.962086] pci 0000:00:08.1: [mem 0x10030000000-0x100401fffff 64bit pref] clipped to [mem 0x10030000000-0x100303fffff 64bit pref]
> [    0.962086] pci 0000:00:08.1:   bridge window [mem 0x10030000000-0x100303fffff 64bit pref]
> [    0.962086] pci 0000:07:00.0: can't claim BAR 0 [mem 0x10030000000-0x1003fffffff 64bit pref]: no compatible bridge window
> [    0.962086] 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 regions that can contain the
> child resource requested.
> 
> Bjorn Helgaas pointed out that we can simply coalesce contiguous regions
> for host bridges, since host bridge don't have _SRS. So do that
> accordingly to make child resource can be contained. This change makes
> the graphics works on the system in question.
> 
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=212013
> Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>

Applied to pci/resource for v5.14 with subject:

  PCI: Coalesce host bridge contiguous apertures

Thanks!

> ---
> v2:
>  - Coalesce all contiguous regresion in pci_register_host_bridge(), if
>    conditions are met.
> 
>  drivers/pci/probe.c | 49 +++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 45 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 953f15abc850..3607ce7402b4 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -19,6 +19,7 @@
>  #include <linux/hypervisor.h>
>  #include <linux/irqdomain.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/list_sort.h>
>  #include "pci.h"
>  
>  #define CARDBUS_LATENCY_TIMER	176	/* secondary latency timer */
> @@ -874,14 +875,30 @@ 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, *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 +976,35 @@ 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);
> -- 
> 2.30.2
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] PCI: Coalesce contiguous regions for host bridges
  2021-04-01 13:12 [PATCH v2] PCI: Coalesce contiguous regions for host bridges Kai-Heng Feng
  2021-04-22  8:57 ` Kai-Heng Feng
  2021-05-27 22:13 ` Bjorn Helgaas
@ 2021-07-09 23:15 ` Guenter Roeck
  2021-07-09 23:43   ` Bjorn Helgaas
  2021-07-12  3:50   ` Kai-Heng Feng
  2 siblings, 2 replies; 9+ messages in thread
From: Guenter Roeck @ 2021-07-09 23:15 UTC (permalink / raw)
  To: Kai-Heng Feng; +Cc: bhelgaas, open list:PCI SUBSYSTEM, open list

Hi,

On Thu, Apr 01, 2021 at 09:12:52PM +0800, Kai-Heng Feng wrote:
> Built-in graphics on HP EliteDesk 805 G6 doesn't work because graphics
> can't get the BAR it needs:
> [    0.611504] pci_bus 0000:00: root bus resource [mem 0x10020200000-0x100303fffff window]
> [    0.611505] pci_bus 0000:00: root bus resource [mem 0x10030400000-0x100401fffff window]
> ...
> [    0.638083] pci 0000:00:08.1:   bridge window [mem 0xd2000000-0xd23fffff]
> [    0.638086] pci 0000:00:08.1:   bridge window [mem 0x10030000000-0x100401fffff 64bit pref]
> [    0.962086] pci 0000:00:08.1: can't claim BAR 15 [mem 0x10030000000-0x100401fffff 64bit pref]: no compatible bridge window
> [    0.962086] pci 0000:00:08.1: [mem 0x10030000000-0x100401fffff 64bit pref] clipped to [mem 0x10030000000-0x100303fffff 64bit pref]
> [    0.962086] pci 0000:00:08.1:   bridge window [mem 0x10030000000-0x100303fffff 64bit pref]
> [    0.962086] pci 0000:07:00.0: can't claim BAR 0 [mem 0x10030000000-0x1003fffffff 64bit pref]: no compatible bridge window
> [    0.962086] 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 regions that can contain the
> child resource requested.
> 
> Bjorn Helgaas pointed out that we can simply coalesce contiguous regions
> for host bridges, since host bridge don't have _SRS. So do that
> accordingly to make child resource can be contained. This change makes
> the graphics works on the system in question.
> 
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=212013
> Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>

With this patch in place, I can no longer boot the ppc:sam460ex
qemu emulation from nvme. I see the following boot error:

nvme nvme0: Device not ready; aborting initialisation, CSTS=0x0
nvme nvme0: Removing after probe failure status: -19

A key difference seems to be swapped region addresses:

ok:

PCI host bridge to bus 0002:00^M
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])

bad:

PCI host bridge to bus 0002:00^M
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])

and then bar address assignments are swapped/changed.

ok:

pci 0002:00:06.0: BAR 0: assigned [mem 0xd80000000-0xd83ffffff]^M
pci 0002:00:06.0: BAR 1: assigned [mem 0xd84000000-0xd841fffff]^M
pci 0002:00:02.0: BAR 0: assigned [mem 0xd84200000-0xd84203fff 64bit]^M
pci 0002:00:01.0: BAR 5: assigned [mem 0xd84204000-0xd842041ff]^M
pci 0002:00:03.0: BAR 0: assigned [io  0x1000-0x107f]^M
pci 0002:00:03.0: BAR 1: assigned [mem 0xd84204200-0xd8420427f]^M
pci 0002:00:01.0: BAR 4: assigned [io  0x1080-0x108f]^M
pci 0002:00:01.0: BAR 0: assigned [io  0x1090-0x1097]^M
pci 0002:00:01.0: BAR 2: assigned [io  0x1098-0x109f]^M
pci 0002:00:01.0: BAR 1: assigned [io  0x10a0-0x10a3]^M
pci 0002:00:01.0: BAR 3: assigned [io  0x10a4-0x10a7]^M
pci_bus 0002:00: resource 4 [io  0x0000-0xffff]^M
pci_bus 0002:00: resource 5 [mem 0xd80000000-0xdffffffff]^M
pci_bus 0002:00: resource 6 [mem 0xc0ee00000-0xc0eefffff]^M

bad:

pci 0002:00:06.0: BAR 0: assigned [mem 0xd80000000-0xd83ffffff]^M
pci 0002:00:06.0: BAR 1: assigned [mem 0xd84000000-0xd841fffff]^M
pci 0002:00:02.0: BAR 0: assigned [mem 0xc0ee00000-0xc0ee03fff 64bit]^M
pci 0002:00:01.0: BAR 5: assigned [mem 0xc0ee04000-0xc0ee041ff]^M
pci 0002:00:03.0: BAR 0: assigned [io  0x1000-0x107f]^M
pci 0002:00:03.0: BAR 1: assigned [mem 0xc0ee04200-0xc0ee0427f]^M
pci 0002:00:01.0: BAR 4: assigned [io  0x1080-0x108f]^M
pci 0002:00:01.0: BAR 0: assigned [io  0x1090-0x1097]^M
pci 0002:00:01.0: BAR 2: assigned [io  0x1098-0x109f]^M
pci 0002:00:01.0: BAR 1: assigned [io  0x10a0-0x10a3]^M
pci 0002:00:01.0: BAR 3: assigned [io  0x10a4-0x10a7]^M
pci_bus 0002:00: resource 4 [io  0x0000-0xffff]^M
pci_bus 0002:00: resource 5 [mem 0xc0ee00000-0xc0eefffff]^M
pci_bus 0002:00: resource 6 [mem 0xd80000000-0xdffffffff]^M

Reverting this patch fixes the problem.

Guenter

---
bisect log:

# bad: [f55966571d5eb2876a11e48e798b4592fa1ffbb7] Merge tag 'drm-next-2021-07-08-1' of git://anongit.freedesktop.org/drm/drm
# good: [e9f1cbc0c4114880090c7a578117d3b9cf184ad4] Merge tag 'acpi-5.14-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
git bisect start 'f55966571d5e' 'e9f1cbc0c411'
# bad: [b0dfd9af28b60d7ec42c359ae84c1ba97e093100] Merge tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux
git bisect bad b0dfd9af28b60d7ec42c359ae84c1ba97e093100
# bad: [364a716bd73e9846d3118a43f600f8f517658b38] Merge branch 'pci/host/intel-gw'
git bisect bad 364a716bd73e9846d3118a43f600f8f517658b38
# good: [c9fb9042c98df94197a1ba4cf14a77c8053b0fae] Merge branch 'pci/p2pdma'
git bisect good c9fb9042c98df94197a1ba4cf14a77c8053b0fae
# bad: [7132700067f234d37c234e5d711bb49ea06d2352] Merge branch 'pci/sysfs'
git bisect bad 7132700067f234d37c234e5d711bb49ea06d2352
# bad: [131e4f76c9ae9636046bf04d19d43af0e4ae9807] Merge branch 'pci/resource'
git bisect bad 131e4f76c9ae9636046bf04d19d43af0e4ae9807
# good: [411e2a43d210e98730713acf6d01dcf823ee35e3] PCI: Work around Huawei Intelligent NIC VF FLR erratum
git bisect good 411e2a43d210e98730713acf6d01dcf823ee35e3
# good: [e92605b0a0cdafb6c37b9d1ad24fe1cf8280eeb6] Merge branch 'pci/pm'
git bisect good e92605b0a0cdafb6c37b9d1ad24fe1cf8280eeb6
# bad: [65db04053efea3f3e412a7e0cc599962999c96b4] PCI: Coalesce host bridge contiguous apertures
git bisect bad 65db04053efea3f3e412a7e0cc599962999c96b4
# first bad commit: [65db04053efea3f3e412a7e0cc599962999c96b4] PCI: Coalesce host bridge contiguous apertures

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] PCI: Coalesce contiguous regions for host bridges
  2021-07-09 23:15 ` Guenter Roeck
@ 2021-07-09 23:43   ` Bjorn Helgaas
  2021-07-12  3:50   ` Kai-Heng Feng
  1 sibling, 0 replies; 9+ messages in thread
From: Bjorn Helgaas @ 2021-07-09 23:43 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: Kai-Heng Feng, bhelgaas, open list:PCI SUBSYSTEM, open list

On Fri, Jul 09, 2021 at 04:15:29PM -0700, Guenter Roeck wrote:
> Hi,
> 
> On Thu, Apr 01, 2021 at 09:12:52PM +0800, Kai-Heng Feng wrote:
> > Built-in graphics on HP EliteDesk 805 G6 doesn't work because graphics
> > can't get the BAR it needs:
> > [    0.611504] pci_bus 0000:00: root bus resource [mem 0x10020200000-0x100303fffff window]
> > [    0.611505] pci_bus 0000:00: root bus resource [mem 0x10030400000-0x100401fffff window]
> > ...
> > [    0.638083] pci 0000:00:08.1:   bridge window [mem 0xd2000000-0xd23fffff]
> > [    0.638086] pci 0000:00:08.1:   bridge window [mem 0x10030000000-0x100401fffff 64bit pref]
> > [    0.962086] pci 0000:00:08.1: can't claim BAR 15 [mem 0x10030000000-0x100401fffff 64bit pref]: no compatible bridge window
> > [    0.962086] pci 0000:00:08.1: [mem 0x10030000000-0x100401fffff 64bit pref] clipped to [mem 0x10030000000-0x100303fffff 64bit pref]
> > [    0.962086] pci 0000:00:08.1:   bridge window [mem 0x10030000000-0x100303fffff 64bit pref]
> > [    0.962086] pci 0000:07:00.0: can't claim BAR 0 [mem 0x10030000000-0x1003fffffff 64bit pref]: no compatible bridge window
> > [    0.962086] 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 regions that can contain the
> > child resource requested.
> > 
> > Bjorn Helgaas pointed out that we can simply coalesce contiguous regions
> > for host bridges, since host bridge don't have _SRS. So do that
> > accordingly to make child resource can be contained. This change makes
> > the graphics works on the system in question.
> > 
> > Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=212013
> > Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
> > Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> 
> With this patch in place, I can no longer boot the ppc:sam460ex
> qemu emulation from nvme. I see the following boot error:
> 
> nvme nvme0: Device not ready; aborting initialisation, CSTS=0x0
> nvme nvme0: Removing after probe failure status: -19

Thanks for the report and bisection!

I'll try to get this reverted before v5.14-rc1.

Bjorn

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] PCI: Coalesce contiguous regions for host bridges
  2021-07-09 23:15 ` Guenter Roeck
  2021-07-09 23:43   ` Bjorn Helgaas
@ 2021-07-12  3:50   ` Kai-Heng Feng
  2021-07-12  4:50     ` Guenter Roeck
  1 sibling, 1 reply; 9+ messages in thread
From: Kai-Heng Feng @ 2021-07-12  3:50 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: Bjorn Helgaas, open list:PCI SUBSYSTEM, open list

Hi Guenter,

On Sat, Jul 10, 2021 at 7:15 AM Guenter Roeck <linux@roeck-us.net> wrote:
>
> Hi,
>
> On Thu, Apr 01, 2021 at 09:12:52PM +0800, Kai-Heng Feng wrote:
> > Built-in graphics on HP EliteDesk 805 G6 doesn't work because graphics
> > can't get the BAR it needs:
> > [    0.611504] pci_bus 0000:00: root bus resource [mem 0x10020200000-0x100303fffff window]
> > [    0.611505] pci_bus 0000:00: root bus resource [mem 0x10030400000-0x100401fffff window]
> > ...
> > [    0.638083] pci 0000:00:08.1:   bridge window [mem 0xd2000000-0xd23fffff]
> > [    0.638086] pci 0000:00:08.1:   bridge window [mem 0x10030000000-0x100401fffff 64bit pref]
> > [    0.962086] pci 0000:00:08.1: can't claim BAR 15 [mem 0x10030000000-0x100401fffff 64bit pref]: no compatible bridge window
> > [    0.962086] pci 0000:00:08.1: [mem 0x10030000000-0x100401fffff 64bit pref] clipped to [mem 0x10030000000-0x100303fffff 64bit pref]
> > [    0.962086] pci 0000:00:08.1:   bridge window [mem 0x10030000000-0x100303fffff 64bit pref]
> > [    0.962086] pci 0000:07:00.0: can't claim BAR 0 [mem 0x10030000000-0x1003fffffff 64bit pref]: no compatible bridge window
> > [    0.962086] 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 regions that can contain the
> > child resource requested.
> >
> > Bjorn Helgaas pointed out that we can simply coalesce contiguous regions
> > for host bridges, since host bridge don't have _SRS. So do that
> > accordingly to make child resource can be contained. This change makes
> > the graphics works on the system in question.
> >
> > Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=212013
> > Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
> > Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
>
> With this patch in place, I can no longer boot the ppc:sam460ex
> qemu emulation from nvme. I see the following boot error:
>
> nvme nvme0: Device not ready; aborting initialisation, CSTS=0x0
> nvme nvme0: Removing after probe failure status: -19
>
> A key difference seems to be swapped region addresses:
>
> ok:
>
> PCI host bridge to bus 0002:00^M
> 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])
>
> bad:
>
> PCI host bridge to bus 0002:00^M
> 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])
>
> and then bar address assignments are swapped/changed.
>
> ok:
>
> pci 0002:00:06.0: BAR 0: assigned [mem 0xd80000000-0xd83ffffff]^M
> pci 0002:00:06.0: BAR 1: assigned [mem 0xd84000000-0xd841fffff]^M
> pci 0002:00:02.0: BAR 0: assigned [mem 0xd84200000-0xd84203fff 64bit]^M
> pci 0002:00:01.0: BAR 5: assigned [mem 0xd84204000-0xd842041ff]^M
> pci 0002:00:03.0: BAR 0: assigned [io  0x1000-0x107f]^M
> pci 0002:00:03.0: BAR 1: assigned [mem 0xd84204200-0xd8420427f]^M
> pci 0002:00:01.0: BAR 4: assigned [io  0x1080-0x108f]^M
> pci 0002:00:01.0: BAR 0: assigned [io  0x1090-0x1097]^M
> pci 0002:00:01.0: BAR 2: assigned [io  0x1098-0x109f]^M
> pci 0002:00:01.0: BAR 1: assigned [io  0x10a0-0x10a3]^M
> pci 0002:00:01.0: BAR 3: assigned [io  0x10a4-0x10a7]^M
> pci_bus 0002:00: resource 4 [io  0x0000-0xffff]^M
> pci_bus 0002:00: resource 5 [mem 0xd80000000-0xdffffffff]^M
> pci_bus 0002:00: resource 6 [mem 0xc0ee00000-0xc0eefffff]^M
>
> bad:
>
> pci 0002:00:06.0: BAR 0: assigned [mem 0xd80000000-0xd83ffffff]^M
> pci 0002:00:06.0: BAR 1: assigned [mem 0xd84000000-0xd841fffff]^M
> pci 0002:00:02.0: BAR 0: assigned [mem 0xc0ee00000-0xc0ee03fff 64bit]^M
> pci 0002:00:01.0: BAR 5: assigned [mem 0xc0ee04000-0xc0ee041ff]^M
> pci 0002:00:03.0: BAR 0: assigned [io  0x1000-0x107f]^M
> pci 0002:00:03.0: BAR 1: assigned [mem 0xc0ee04200-0xc0ee0427f]^M
> pci 0002:00:01.0: BAR 4: assigned [io  0x1080-0x108f]^M
> pci 0002:00:01.0: BAR 0: assigned [io  0x1090-0x1097]^M
> pci 0002:00:01.0: BAR 2: assigned [io  0x1098-0x109f]^M
> pci 0002:00:01.0: BAR 1: assigned [io  0x10a0-0x10a3]^M
> pci 0002:00:01.0: BAR 3: assigned [io  0x10a4-0x10a7]^M
> pci_bus 0002:00: resource 4 [io  0x0000-0xffff]^M
> pci_bus 0002:00: resource 5 [mem 0xc0ee00000-0xc0eefffff]^M
> pci_bus 0002:00: resource 6 [mem 0xd80000000-0xdffffffff]^M
>
> Reverting this patch fixes the problem.

Can you please comment out the list_sort()? Seems like the precaution
breaks your system...

Kai-Heng

>
> Guenter
>
> ---
> bisect log:
>
> # bad: [f55966571d5eb2876a11e48e798b4592fa1ffbb7] Merge tag 'drm-next-2021-07-08-1' of git://anongit.freedesktop.org/drm/drm
> # good: [e9f1cbc0c4114880090c7a578117d3b9cf184ad4] Merge tag 'acpi-5.14-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
> git bisect start 'f55966571d5e' 'e9f1cbc0c411'
> # bad: [b0dfd9af28b60d7ec42c359ae84c1ba97e093100] Merge tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux
> git bisect bad b0dfd9af28b60d7ec42c359ae84c1ba97e093100
> # bad: [364a716bd73e9846d3118a43f600f8f517658b38] Merge branch 'pci/host/intel-gw'
> git bisect bad 364a716bd73e9846d3118a43f600f8f517658b38
> # good: [c9fb9042c98df94197a1ba4cf14a77c8053b0fae] Merge branch 'pci/p2pdma'
> git bisect good c9fb9042c98df94197a1ba4cf14a77c8053b0fae
> # bad: [7132700067f234d37c234e5d711bb49ea06d2352] Merge branch 'pci/sysfs'
> git bisect bad 7132700067f234d37c234e5d711bb49ea06d2352
> # bad: [131e4f76c9ae9636046bf04d19d43af0e4ae9807] Merge branch 'pci/resource'
> git bisect bad 131e4f76c9ae9636046bf04d19d43af0e4ae9807
> # good: [411e2a43d210e98730713acf6d01dcf823ee35e3] PCI: Work around Huawei Intelligent NIC VF FLR erratum
> git bisect good 411e2a43d210e98730713acf6d01dcf823ee35e3
> # good: [e92605b0a0cdafb6c37b9d1ad24fe1cf8280eeb6] Merge branch 'pci/pm'
> git bisect good e92605b0a0cdafb6c37b9d1ad24fe1cf8280eeb6
> # bad: [65db04053efea3f3e412a7e0cc599962999c96b4] PCI: Coalesce host bridge contiguous apertures
> git bisect bad 65db04053efea3f3e412a7e0cc599962999c96b4
> # first bad commit: [65db04053efea3f3e412a7e0cc599962999c96b4] PCI: Coalesce host bridge contiguous apertures

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] PCI: Coalesce contiguous regions for host bridges
  2021-07-12  3:50   ` Kai-Heng Feng
@ 2021-07-12  4:50     ` Guenter Roeck
  2021-07-12  4:52       ` Kai-Heng Feng
  0 siblings, 1 reply; 9+ messages in thread
From: Guenter Roeck @ 2021-07-12  4:50 UTC (permalink / raw)
  To: Kai-Heng Feng; +Cc: Bjorn Helgaas, open list:PCI SUBSYSTEM, open list

On 7/11/21 8:50 PM, Kai-Heng Feng wrote:
> Hi Guenter,
> 
> On Sat, Jul 10, 2021 at 7:15 AM Guenter Roeck <linux@roeck-us.net> wrote:
>>
>> Hi,
>>
>> On Thu, Apr 01, 2021 at 09:12:52PM +0800, Kai-Heng Feng wrote:
>>> Built-in graphics on HP EliteDesk 805 G6 doesn't work because graphics
>>> can't get the BAR it needs:
>>> [    0.611504] pci_bus 0000:00: root bus resource [mem 0x10020200000-0x100303fffff window]
>>> [    0.611505] pci_bus 0000:00: root bus resource [mem 0x10030400000-0x100401fffff window]
>>> ...
>>> [    0.638083] pci 0000:00:08.1:   bridge window [mem 0xd2000000-0xd23fffff]
>>> [    0.638086] pci 0000:00:08.1:   bridge window [mem 0x10030000000-0x100401fffff 64bit pref]
>>> [    0.962086] pci 0000:00:08.1: can't claim BAR 15 [mem 0x10030000000-0x100401fffff 64bit pref]: no compatible bridge window
>>> [    0.962086] pci 0000:00:08.1: [mem 0x10030000000-0x100401fffff 64bit pref] clipped to [mem 0x10030000000-0x100303fffff 64bit pref]
>>> [    0.962086] pci 0000:00:08.1:   bridge window [mem 0x10030000000-0x100303fffff 64bit pref]
>>> [    0.962086] pci 0000:07:00.0: can't claim BAR 0 [mem 0x10030000000-0x1003fffffff 64bit pref]: no compatible bridge window
>>> [    0.962086] 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 regions that can contain the
>>> child resource requested.
>>>
>>> Bjorn Helgaas pointed out that we can simply coalesce contiguous regions
>>> for host bridges, since host bridge don't have _SRS. So do that
>>> accordingly to make child resource can be contained. This change makes
>>> the graphics works on the system in question.
>>>
>>> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=212013
>>> Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
>>> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
>>
>> With this patch in place, I can no longer boot the ppc:sam460ex
>> qemu emulation from nvme. I see the following boot error:
>>
>> nvme nvme0: Device not ready; aborting initialisation, CSTS=0x0
>> nvme nvme0: Removing after probe failure status: -19
>>
>> A key difference seems to be swapped region addresses:
>>
>> ok:
>>
>> PCI host bridge to bus 0002:00^M
>> 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])
>>
>> bad:
>>
>> PCI host bridge to bus 0002:00^M
>> 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])
>>
>> and then bar address assignments are swapped/changed.
>>
>> ok:
>>
>> pci 0002:00:06.0: BAR 0: assigned [mem 0xd80000000-0xd83ffffff]^M
>> pci 0002:00:06.0: BAR 1: assigned [mem 0xd84000000-0xd841fffff]^M
>> pci 0002:00:02.0: BAR 0: assigned [mem 0xd84200000-0xd84203fff 64bit]^M
>> pci 0002:00:01.0: BAR 5: assigned [mem 0xd84204000-0xd842041ff]^M
>> pci 0002:00:03.0: BAR 0: assigned [io  0x1000-0x107f]^M
>> pci 0002:00:03.0: BAR 1: assigned [mem 0xd84204200-0xd8420427f]^M
>> pci 0002:00:01.0: BAR 4: assigned [io  0x1080-0x108f]^M
>> pci 0002:00:01.0: BAR 0: assigned [io  0x1090-0x1097]^M
>> pci 0002:00:01.0: BAR 2: assigned [io  0x1098-0x109f]^M
>> pci 0002:00:01.0: BAR 1: assigned [io  0x10a0-0x10a3]^M
>> pci 0002:00:01.0: BAR 3: assigned [io  0x10a4-0x10a7]^M
>> pci_bus 0002:00: resource 4 [io  0x0000-0xffff]^M
>> pci_bus 0002:00: resource 5 [mem 0xd80000000-0xdffffffff]^M
>> pci_bus 0002:00: resource 6 [mem 0xc0ee00000-0xc0eefffff]^M
>>
>> bad:
>>
>> pci 0002:00:06.0: BAR 0: assigned [mem 0xd80000000-0xd83ffffff]^M
>> pci 0002:00:06.0: BAR 1: assigned [mem 0xd84000000-0xd841fffff]^M
>> pci 0002:00:02.0: BAR 0: assigned [mem 0xc0ee00000-0xc0ee03fff 64bit]^M
>> pci 0002:00:01.0: BAR 5: assigned [mem 0xc0ee04000-0xc0ee041ff]^M
>> pci 0002:00:03.0: BAR 0: assigned [io  0x1000-0x107f]^M
>> pci 0002:00:03.0: BAR 1: assigned [mem 0xc0ee04200-0xc0ee0427f]^M
>> pci 0002:00:01.0: BAR 4: assigned [io  0x1080-0x108f]^M
>> pci 0002:00:01.0: BAR 0: assigned [io  0x1090-0x1097]^M
>> pci 0002:00:01.0: BAR 2: assigned [io  0x1098-0x109f]^M
>> pci 0002:00:01.0: BAR 1: assigned [io  0x10a0-0x10a3]^M
>> pci 0002:00:01.0: BAR 3: assigned [io  0x10a4-0x10a7]^M
>> pci_bus 0002:00: resource 4 [io  0x0000-0xffff]^M
>> pci_bus 0002:00: resource 5 [mem 0xc0ee00000-0xc0eefffff]^M
>> pci_bus 0002:00: resource 6 [mem 0xd80000000-0xdffffffff]^M
>>
>> Reverting this patch fixes the problem.
> 
> Can you please comment out the list_sort()? Seems like the precaution
> breaks your system...
> 

Yes, everything works if I re-apply your patch and comment out the
call to list_sort().

Guenter

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] PCI: Coalesce contiguous regions for host bridges
  2021-07-12  4:50     ` Guenter Roeck
@ 2021-07-12  4:52       ` Kai-Heng Feng
  0 siblings, 0 replies; 9+ messages in thread
From: Kai-Heng Feng @ 2021-07-12  4:52 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: Bjorn Helgaas, open list:PCI SUBSYSTEM, open list

On Mon, Jul 12, 2021 at 12:50 PM Guenter Roeck <linux@roeck-us.net> wrote:
>
> On 7/11/21 8:50 PM, Kai-Heng Feng wrote:
> > Hi Guenter,
> >
> > On Sat, Jul 10, 2021 at 7:15 AM Guenter Roeck <linux@roeck-us.net> wrote:
> >>
> >> Hi,
> >>
> >> On Thu, Apr 01, 2021 at 09:12:52PM +0800, Kai-Heng Feng wrote:
> >>> Built-in graphics on HP EliteDesk 805 G6 doesn't work because graphics
> >>> can't get the BAR it needs:
> >>> [    0.611504] pci_bus 0000:00: root bus resource [mem 0x10020200000-0x100303fffff window]
> >>> [    0.611505] pci_bus 0000:00: root bus resource [mem 0x10030400000-0x100401fffff window]
> >>> ...
> >>> [    0.638083] pci 0000:00:08.1:   bridge window [mem 0xd2000000-0xd23fffff]
> >>> [    0.638086] pci 0000:00:08.1:   bridge window [mem 0x10030000000-0x100401fffff 64bit pref]
> >>> [    0.962086] pci 0000:00:08.1: can't claim BAR 15 [mem 0x10030000000-0x100401fffff 64bit pref]: no compatible bridge window
> >>> [    0.962086] pci 0000:00:08.1: [mem 0x10030000000-0x100401fffff 64bit pref] clipped to [mem 0x10030000000-0x100303fffff 64bit pref]
> >>> [    0.962086] pci 0000:00:08.1:   bridge window [mem 0x10030000000-0x100303fffff 64bit pref]
> >>> [    0.962086] pci 0000:07:00.0: can't claim BAR 0 [mem 0x10030000000-0x1003fffffff 64bit pref]: no compatible bridge window
> >>> [    0.962086] 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 regions that can contain the
> >>> child resource requested.
> >>>
> >>> Bjorn Helgaas pointed out that we can simply coalesce contiguous regions
> >>> for host bridges, since host bridge don't have _SRS. So do that
> >>> accordingly to make child resource can be contained. This change makes
> >>> the graphics works on the system in question.
> >>>
> >>> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=212013
> >>> Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
> >>> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> >>
> >> With this patch in place, I can no longer boot the ppc:sam460ex
> >> qemu emulation from nvme. I see the following boot error:
> >>
> >> nvme nvme0: Device not ready; aborting initialisation, CSTS=0x0
> >> nvme nvme0: Removing after probe failure status: -19
> >>
> >> A key difference seems to be swapped region addresses:
> >>
> >> ok:
> >>
> >> PCI host bridge to bus 0002:00^M
> >> 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])
> >>
> >> bad:
> >>
> >> PCI host bridge to bus 0002:00^M
> >> 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])
> >>
> >> and then bar address assignments are swapped/changed.
> >>
> >> ok:
> >>
> >> pci 0002:00:06.0: BAR 0: assigned [mem 0xd80000000-0xd83ffffff]^M
> >> pci 0002:00:06.0: BAR 1: assigned [mem 0xd84000000-0xd841fffff]^M
> >> pci 0002:00:02.0: BAR 0: assigned [mem 0xd84200000-0xd84203fff 64bit]^M
> >> pci 0002:00:01.0: BAR 5: assigned [mem 0xd84204000-0xd842041ff]^M
> >> pci 0002:00:03.0: BAR 0: assigned [io  0x1000-0x107f]^M
> >> pci 0002:00:03.0: BAR 1: assigned [mem 0xd84204200-0xd8420427f]^M
> >> pci 0002:00:01.0: BAR 4: assigned [io  0x1080-0x108f]^M
> >> pci 0002:00:01.0: BAR 0: assigned [io  0x1090-0x1097]^M
> >> pci 0002:00:01.0: BAR 2: assigned [io  0x1098-0x109f]^M
> >> pci 0002:00:01.0: BAR 1: assigned [io  0x10a0-0x10a3]^M
> >> pci 0002:00:01.0: BAR 3: assigned [io  0x10a4-0x10a7]^M
> >> pci_bus 0002:00: resource 4 [io  0x0000-0xffff]^M
> >> pci_bus 0002:00: resource 5 [mem 0xd80000000-0xdffffffff]^M
> >> pci_bus 0002:00: resource 6 [mem 0xc0ee00000-0xc0eefffff]^M
> >>
> >> bad:
> >>
> >> pci 0002:00:06.0: BAR 0: assigned [mem 0xd80000000-0xd83ffffff]^M
> >> pci 0002:00:06.0: BAR 1: assigned [mem 0xd84000000-0xd841fffff]^M
> >> pci 0002:00:02.0: BAR 0: assigned [mem 0xc0ee00000-0xc0ee03fff 64bit]^M
> >> pci 0002:00:01.0: BAR 5: assigned [mem 0xc0ee04000-0xc0ee041ff]^M
> >> pci 0002:00:03.0: BAR 0: assigned [io  0x1000-0x107f]^M
> >> pci 0002:00:03.0: BAR 1: assigned [mem 0xc0ee04200-0xc0ee0427f]^M
> >> pci 0002:00:01.0: BAR 4: assigned [io  0x1080-0x108f]^M
> >> pci 0002:00:01.0: BAR 0: assigned [io  0x1090-0x1097]^M
> >> pci 0002:00:01.0: BAR 2: assigned [io  0x1098-0x109f]^M
> >> pci 0002:00:01.0: BAR 1: assigned [io  0x10a0-0x10a3]^M
> >> pci 0002:00:01.0: BAR 3: assigned [io  0x10a4-0x10a7]^M
> >> pci_bus 0002:00: resource 4 [io  0x0000-0xffff]^M
> >> pci_bus 0002:00: resource 5 [mem 0xc0ee00000-0xc0eefffff]^M
> >> pci_bus 0002:00: resource 6 [mem 0xd80000000-0xdffffffff]^M
> >>
> >> Reverting this patch fixes the problem.
> >
> > Can you please comment out the list_sort()? Seems like the precaution
> > breaks your system...
> >
>
> Yes, everything works if I re-apply your patch and comment out the
> call to list_sort().

Thanks for your testing!
I'll send a new patch that doesn't have list_sort().

Kai-Heng

>
> Guenter

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-07-12  4:52 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-01 13:12 [PATCH v2] PCI: Coalesce contiguous regions for host bridges Kai-Heng Feng
2021-04-22  8:57 ` Kai-Heng Feng
2021-05-11  3:33   ` Kai-Heng Feng
2021-05-27 22:13 ` Bjorn Helgaas
2021-07-09 23:15 ` Guenter Roeck
2021-07-09 23:43   ` Bjorn Helgaas
2021-07-12  3:50   ` Kai-Heng Feng
2021-07-12  4:50     ` Guenter Roeck
2021-07-12  4:52       ` Kai-Heng Feng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).