[PATCH 10/11] PCI: Lower bound bridge window alignment

Ilpo Järvinen
2026-04-29T12:28:25Z

pci_resource_alignment() does not consider bridge windows special,
yet their alignment is subject to different requirements from BAR
alignment.

Add lower bound to bridge window alignment to help callers out to
always have large enough alignment.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
drivers/pci/setup-res.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index 18e8775ea848..c15bce20815d 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -19,7 +19,10 @@
#include <linux/errno.h>
#include <linux/ioport.h>
#include <linux/cache.h>
+#include <linux/minmax.h>
#include <linux/slab.h>
+#include <linux/types.h>
+
#include "pci.h"

static void pci_std_update_resource(struct pci_dev *dev, int resno)
@@ -250,12 +253,19 @@ resource_size_t pci_resource_alignment(const struct pci_dev *dev,
const struct resource *res)
{
int resno = pci_resource_num(dev, res);
+ resource_size_t min_align = 0;

if (pci_resource_is_iov(resno))
return pci_sriov_resource_alignment(dev, resno);
+
if (dev->class >> 8 == PCI_CLASS_BRIDGE_CARDBUS)
return pci_cardbus_resource_alignment(res);
- return resource_alignment(res);
+
+ if (pci_resource_is_bridge_win(resno) &&
+ (res->flags & (IORESOURCE_IO|IORESOURCE_MEM)))
+ min_align = pci_min_window_alignment(dev->bus, res->flags);
+
+ return max(resource_alignment(res), min_align);
}

/*
--
2.39.5