mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: Eric Auger <eauger@redhat.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] PCI: Do not add hotplug reservation multiple times
Date: Wed, 22 Jul 2026 15:52:42 -0500	[thread overview]
Message-ID: <20260722205242.GA779880@bhelgaas> (raw)
In-Reply-To: <20260720162416.5771-1-ilpo.jarvinen@linux.intel.com>

On Mon, Jul 20, 2026 at 07:24:15PM +0300, Ilpo Järvinen wrote:
> In nested topologies, hotplug reservations gets added multiple times
> into the bridge window higher up in the hierarchy. Adding reservation
> for intermediate level bridges does not seem very useful because the
> hotplug is going to add device at a leaf.
> 
> Accounting the hoptlug reservation multiple times results in larger
> than expected bridge window size that may lead to assignment failures
> as show in this log:
> 
> pci_bus 0000:0a: root bus resource [mem 0x10a00000-0x10c00fff window]
> pci 0000:0a:00.0: BAR 0 [mem 0x10c00000-0x10c00fff]
> pci 0000:0a:00.0:   bridge window [mem 0x10a00000-0x10bfffff]
> pci 0000:0b:00.0:   bridge window [mem 0x10a00000-0x10bfffff]
> pci 0000:0c:02.0:   bridge window [mem 0x10a00000-0x10bfffff]
> pci 0000:0c:02.0: bridge window [mem 0x00100000-0x000fffff 64bit pref] to [bus 0d] add_size 200000 add_align 100000
> pci 0000:0c:02.0: bridge window [mem 0x00100000-0x000fffff] to [bus 0d] add_size 200000 add_align 100000
> pci 0000:0b:00.0: bridge window [mem 0x00100000-0x000fffff 64bit pref] to [bus 0c-0d] add_size 200000 add_align 100000
> pci 0000:0b:00.0: bridge window [mem 0x00100000-0x000fffff] to [bus 0c-0d] add_size 200000 add_align 100000
> pci 0000:0a:00.0: bridge window [mem 0x00100000-0x000fffff 64bit pref] to [bus 0b-0d] add_size 400000 add_align 100000
> pci 0000:0a:00.0: bridge window [mem 0x00100000-0x000fffff] to [bus 0b-0d] add_size 400000 add_align 100000
> pci 0000:0a:00.0: bridge window [mem size 0x00400000]: can't assign; no space
> pci 0000:0a:00.0: bridge window [mem size 0x00400000]: failed to assign
> pci 0000:0a:00.0: bridge window [mem size 0x00400000 64bit pref]: can't assign; no space
> pci 0000:0a:00.0: bridge window [mem size 0x00400000 64bit pref]: failed to assign
> 
> The problem stems from calculate_memsize() that calculates size first
> and then adds childen size:
> 	size = max(0, 2M) + 2M
> 
> Alter the logic to first account for the children size before applying
> the hotplug reservation to not add hotplug reservation multiple times
> on different levels of a nested topology. As a result, the size
> calculation becomes:
> 	size = max(0 + 2M, 2M)
> 
> Reported-by: Eric Auger <eauger@redhat.com>
> Link: https://lore.kernel.org/linux-pci/f23946f2-06ac-4607-8f2c-3ffbc52b627a@redhat.com/
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

Applied to pci/resource for v7.3, thanks!

> ---
>  drivers/pci/setup-bus.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
> index c0a949f2c995..e8c94aa1d3c1 100644
> --- a/drivers/pci/setup-bus.c
> +++ b/drivers/pci/setup-bus.c
> @@ -1021,7 +1021,7 @@ static resource_size_t calculate_memsize(resource_size_t size,
>  					 resource_size_t children_add_size,
>  					 resource_size_t align)
>  {
> -	size = max(size, min_size) + children_add_size;
> +	size = max(size + children_add_size, min_size);
>  	return ALIGN(size, align);
>  }
>  
> 
> base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482
> -- 
> 2.47.3
> 

      reply	other threads:[~2026-07-22 20:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-20 16:24 Ilpo Järvinen
2026-07-22 20:52 ` Bjorn Helgaas [this message]

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=20260722205242.GA779880@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=eauger@redhat.com \
    --cc=ilpo.jarvinen@linux.intel.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®