From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: "Maciej Grochowski" <Maciej.Grochowski@sony.com>,
"Geramy Loveless" <gloveless@jqluv.com>,
"Eric Auger" <eauger@redhat.com>,
"Alexey Fomenko" <alexey.fomenko@intel.com>,
"Bjorn Helgaas" <bhelgaas@google.com>,
linux-pci@vger.kernel.org,
"Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Mesih Kilinc" <Mesih.Kilinc@sony.com>,
linux-kernel@vger.kernel.org
Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Subject: [PATCH v5 12/14] PCI: Move size/align calculation fully into __pbus_size_mem()
Date: Fri, 6 Nov 2026 15:43:33 +0200 [thread overview]
Message-ID: <20261106134341.39493-13-ilpo.jarvinen@linux.intel.com> (raw)
In-Reply-To: <20261106134341.39493-1-ilpo.jarvinen@linux.intel.com>
Move entire size and alignment calculation into __pbus_size_mem()
further simplifying the caller side code.
Also fold calculate_memsize() into __pbus_size_mem() as it has become
too simple to justify a separate function.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
drivers/pci/setup-bus.c | 25 +++++++------------------
1 file changed, 7 insertions(+), 18 deletions(-)
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 6623adfdde85..b6be6cd16006 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -1011,14 +1011,6 @@ static resource_size_t calculate_iosize(resource_size_t size,
return ALIGN(max(size, old_size), align);
}
-static resource_size_t calculate_memsize(resource_size_t size,
- resource_size_t min_size,
- resource_size_t align)
-{
- size = max(size, min_size);
- return ALIGN(size, align);
-}
-
resource_size_t __weak pcibios_window_alignment(struct pci_bus *bus,
unsigned long type)
{
@@ -1269,6 +1261,7 @@ static resource_size_t __pbus_size_mem(struct pci_bus *bus,
struct resource *b_res,
resource_size_t *head_align,
bool add_optional,
+ resource_size_t min_size,
struct list_head *realloc_head)
{
struct pci_dev *dev;
@@ -1333,7 +1326,7 @@ static resource_size_t __pbus_size_mem(struct pci_bus *bus,
*head_align = calculate_head_align(aligns, max_order);
*head_align = max(*head_align, win_align);
- return winsize;
+ return ALIGN(max(winsize, min_size), win_align);
}
/**
@@ -1357,8 +1350,7 @@ static void pbus_size_mem(struct pci_bus *bus, struct resource *b_res,
resource_size_t add_size,
struct list_head *realloc_head)
{
- resource_size_t min_align, win_align, size, size0, size1 = 0;
- resource_size_t add_align = 0;
+ resource_size_t min_align, size0, size1 = 0, add_align = 0;
if (!b_res)
return;
@@ -1367,20 +1359,17 @@ static void pbus_size_mem(struct pci_bus *bus, struct resource *b_res,
if (resource_assigned(b_res))
return;
- win_align = pci_min_window_alignment(bus, b_res->flags);
- size = __pbus_size_mem(bus, b_res, &min_align, !realloc_head,
- realloc_head);
- size0 = calculate_memsize(size, realloc_head ? 0 : add_size, win_align);
-
+ size0 = __pbus_size_mem(bus, b_res, &min_align, !realloc_head,
+ realloc_head ? 0 : add_size, realloc_head);
if (size0) {
resource_set_range(b_res, min_align, size0);
b_res->flags &= ~IORESOURCE_DISABLED;
}
if (realloc_head) {
- size = __pbus_size_mem(bus, b_res, &add_align, true, realloc_head);
+ size1 = __pbus_size_mem(bus, b_res, &add_align, true,
+ add_size, realloc_head);
add_align = max(min_align, add_align);
- size1 = calculate_memsize(size, add_size, win_align);
}
if (!size0 && !size1) {
--
2.47.3
next prev parent reply other threads:[~2026-11-06 13:46 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 13:43 [PATCH v5 00/14] PCI: Resource placement algorithm fixes Ilpo Järvinen
2026-11-06 13:43 ` [PATCH v5 01/14] resource: Mark free space assigned Ilpo Järvinen
2026-11-06 13:43 ` [PATCH v5 02/14] parisc/PCI: Clean up resource debug print & use dynamic debug Ilpo Järvinen
2026-11-06 13:43 ` [PATCH v5 03/14] PCI: Don't size or assign disabled BARs Ilpo Järvinen
2026-11-06 13:43 ` [PATCH v5 04/14] PCI: Use __ffs64() for resource_size_t typed align Ilpo Järvinen
2026-11-06 13:43 ` [PATCH v5 05/14] PCI: Prevent zero align from reaching __ffs64() Ilpo Järvinen
2026-11-06 13:43 ` [PATCH v5 06/14] linux/log2.h: Add 64-bit roundup/down_pow_of_two_u64() variants Ilpo Järvinen
2026-11-06 13:43 ` [PATCH v5 07/14] PCI: Derive aligns[] array size in a define Ilpo Järvinen
2026-11-06 13:43 ` [PATCH v5 08/14] PCI: Honor alignment overrides Ilpo Järvinen
2026-11-06 13:43 ` [PATCH v5 09/14] PCI: Place resources to either edge of the window Ilpo Järvinen
2026-11-06 13:43 ` [PATCH v5 10/14] PCI: Separate align/raw size calculation from pbus_size_mem() Ilpo Järvinen
2026-11-06 13:43 ` [PATCH v5 11/14] PCI: Calculate bridge window with optional sizes from scratch Ilpo Järvinen
2026-11-06 13:43 ` Ilpo Järvinen [this message]
2026-11-06 13:43 ` [PATCH v5 13/14] PCI: Fix composite resource sizing Ilpo Järvinen
2026-11-06 13:43 ` [PATCH v5 14/14] PCI: Add debug printing to window sizing Ilpo Järvinen
2026-11-06 15:26 ` [PATCH v5 00/14] PCI: Resource placement algorithm fixes Nikolas Joshua Britton
2026-11-06 16:43 ` Ilpo Järvinen
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=20261106134341.39493-13-ilpo.jarvinen@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=Maciej.Grochowski@sony.com \
--cc=Mesih.Kilinc@sony.com \
--cc=alexey.fomenko@intel.com \
--cc=bhelgaas@google.com \
--cc=eauger@redhat.com \
--cc=gloveless@jqluv.com \
--cc=kw@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=robh@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®