[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20250822145605.18172-7-ilpo.jarvinen@linux.intel.com>
Date: Fri, 22 Aug 2025 17:55:47 +0300
From: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
To: Andreas Larsson <andreas@...sler.com>,
Bjorn Helgaas <bhelgaas@...gle.com>,
"David S. Miller" <davem@...emloft.net>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
linux-m68k@...ts.linux-m68k.org,
linux-mips@...r.kernel.org,
linux-pci@...r.kernel.org,
sparclinux@...r.kernel.org,
Thomas Bogendoerfer <tsbogend@...ha.franken.de>,
Christian König <christian.koenig@....com>,
Yinghai Lu <yinghai@...nel.org>,
Igor Mammedov <imammedo@...hat.com>,
"Rafael J . Wysocki" <rafael@...nel.org>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>,
Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
Krzysztof Wilczyński <kw@...ux.com>,
linux-kernel@...r.kernel.org
Cc: Michał Winiarski <michal.winiarski@...el.com>,
linuxppc-dev@...ts.ozlabs.org,
Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
Subject: [PATCH 06/24] PCI: Always claim bridge window before its setup
When the claim of a resource fails for the full range in
pci_claim_bridge_resource(), clipping the resource to a smaller size is
attempted. If the clipping successful, the new bridge window is
programmed and only as the last step the code attempts to claim the
resource again. The order of the last two steps is slightly illogical
and inconsistent with the assignment call chains.
If claiming the bridge window after clipping fails, the bridge window
that was setup is left in place.
Rework the logic such that the bridge window is claimed before calling
the relevant bridge setup function. This make the behavior consistent
with resource fitting call chains that always assign the bridge window
before programming it.
If claiming the bridge window fails, the clipped bridge window is no
longer setup but pci_claim_bridge_resource() returns without writing
the bridge window at all.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
---
drivers/pci/setup-bus.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index c5fc4e2825be..b477f68b236c 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -857,9 +857,16 @@ int pci_claim_bridge_resource(struct pci_dev *bridge, int i)
if ((bridge->class >> 8) != PCI_CLASS_BRIDGE_PCI)
return 0;
+ if (i > PCI_BRIDGE_PREF_MEM_WINDOW)
+ return -EINVAL;
+
+ /* Try to clip the resource and claim the smaller window */
if (!pci_bus_clip_resource(bridge, i))
return -EINVAL; /* Clipping didn't change anything */
+ if (!pci_claim_resource(bridge, i))
+ return -EINVAL;
+
switch (i) {
case PCI_BRIDGE_IO_WINDOW:
pci_setup_bridge_io(bridge);
@@ -874,10 +881,7 @@ int pci_claim_bridge_resource(struct pci_dev *bridge, int i)
return -EINVAL;
}
- if (pci_claim_resource(bridge, i) == 0)
- return 0; /* Claimed a smaller window */
-
- return -EINVAL;
+ return 0;
}
/*
--
2.39.5
Powered by blists - more mailing lists