mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Kai-Heng Feng <kai.heng.feng@canonical.com>, bhelgaas@google.com
Cc: "open list:PCI SUBSYSTEM" <linux-pci@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] PCI: Coalesce host bridge contiguous apertures without sorting
Date: Tue, 13 Jul 2021 01:45:54 -0700	[thread overview]
Message-ID: <f18e36f7-cb18-1a4a-e7e8-4fbb253581ae@roeck-us.net> (raw)
In-Reply-To: <20210713075726.1232938-1-kai.heng.feng@canonical.com>

On 7/13/21 12:57 AM, Kai-Heng Feng wrote:
> Commit 65db04053efe ("PCI: Coalesce host bridge contiguous apertures")
> sorts the resources by address so the resources can be swapped.
> 
> Before:
> 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])
> 
> And after:
> 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])
> 
> However, the sorted resources make NVMe stops working on QEMU ppc:sam460ex.
> 
> Resources in the original issue are already in ascending order:
> pci_bus 0000:00: root bus resource [mem 0x10020200000-0x100303fffff window]
> pci_bus 0000:00: root bus resource [mem 0x10030400000-0x100401fffff window]
> 
> So remove the sorting part to resolve the issue.
> 
> Reported-by: Guenter Roeck <linux@roeck-us.net>
> Fixes: 65db04053efe ("PCI: Coalesce host bridge contiguous apertures")
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>

I think the original commit message would make more sense here. This patch
doesn't fix 65db04053efe, it replaces it. The commit message now misses
the point, and the patch coalesces continuous apertures without explaining
the reason.

Guenter

> ---
>   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 79177ac37880..5de157600466 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;
> @@ -961,11 +961,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);
> 


  reply	other threads:[~2021-07-13  8:46 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-13  7:57 Kai-Heng Feng
2021-07-13  8:45 ` Guenter Roeck [this message]
2021-07-13  8:49   ` Kai-Heng Feng
2021-07-13  9:06     ` Guenter Roeck
2021-07-13 12:50 ` [PATCH v2] PCI: Reinstate "PCI: Coalesce host bridge contiguous apertures" Kai-Heng Feng
2021-09-29 21:25   ` Bjorn Helgaas
2021-11-17 14:12   ` Johannes Berg
2022-07-13  9:36     ` Geert Uytterhoeven
2021-08-09  4:24 ` [PATCH] PCI/portdrv: Disallow runtime suspend when waekup is required but PME service isn't supported Kai-Heng Feng
2021-08-09  9:47   ` Lukas Wunner
2021-08-09 10:40     ` Kai-Heng Feng
2021-08-09 15:00       ` Lukas Wunner
2021-08-10 15:37         ` Kai-Heng Feng
2021-08-10 16:21           ` Lukas Wunner
2021-08-11  5:06             ` Kai-Heng Feng
2021-08-11  7:11               ` Lukas Wunner
2021-08-12  5:20                 ` Kai-Heng Feng

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=f18e36f7-cb18-1a4a-e7e8-4fbb253581ae@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=bhelgaas@google.com \
    --cc=kai.heng.feng@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.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

all inboxes | Powered by JetHome®