]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
PCI: Add pbus_mem_size_optional() to handle optional sizes
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Fri, 19 Dec 2025 17:40:26 +0000 (19:40 +0200)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 27 Jan 2026 22:36:52 +0000 (16:36 -0600)
commit6a5e64c75e82953e4d6b52bba30e2e281532b386
tree8a73ae5a815dd793fb8850a8abd48bdc5d25f697
parentc10fe0c0e6977254e2b7d4fed18e71501c958d65
PCI: Add pbus_mem_size_optional() to handle optional sizes

The resource loop in pbus_size_mem() handles optional resources that are
either fully optional (SR-IOV and disabled Expansion ROMs) or bridge
windows that may be optional only for a part. The logic is a little
inconsistent when it comes to a bridge window that has only optional
children resources as it would be more natural to treat it similar to any
fully optional resource. As resource size should be zero in that case, it
shouldn't cause any bugs but it still seems useful to address the
inconsistency.

Place the optional size related code of pbus_size_mem() into
pbus_mem_size_optional() and add a check in pci_resource_is_optional()
for entirely optional bridge windows. Reorder the logic inside
pbus_mem_size_optional() such that fully optional resources are handled
the same irrespective of whether the resource is a bridge window or
not.

Additional motivation for this are the upcoming changes that add complexity
to the optional sizing logic due to Resizable BAR awareness.  The extra
logic would exceed any reasonable indentation level if the optional sizing
code is kept within the loop body.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20251219174036.16738-14-ilpo.jarvinen@linux.intel.com
drivers/pci/setup-bus.c