linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jon Derrick <jonathan.derrick@intel.com>
To: <linux-pci@vger.kernel.org>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Bjorn Helgaas <helgaas@kernel.org>,
	Andrzej Jakowski <andrzej.jakowski@linux.intel.com>,
	Dave Fugate <david.fugate@intel.com>,
	Jon Derrick <jonathan.derrick@intel.com>
Subject: [PATCH 1/3] PCI: Create helper to release/restore bridge resources
Date: Sun, 27 Sep 2020 21:06:07 -0400	[thread overview]
Message-ID: <20200928010609.5375-2-jonathan.derrick@intel.com> (raw)
In-Reply-To: <20200928010609.5375-1-jonathan.derrick@intel.com>

Moves bridge release and restore code into a common helper. No
functional changes.

Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
---
 drivers/pci/setup-bus.c | 49 +++++++++++++++++++++++------------------
 1 file changed, 28 insertions(+), 21 deletions(-)

diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 3951e02b7ded..f22502e8e6e6 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -2047,6 +2047,33 @@ static void pci_bridge_distribute_available_resources(struct pci_dev *bridge,
 					       available_mmio_pref);
 }
 
+static void release_and_restore_resources(struct list_head *head)
+{
+	struct pci_dev_resource *dev_res;
+
+	list_for_each_entry(dev_res, head, list)
+		pci_bus_release_bridge_resources(dev_res->dev->bus,
+						 dev_res->flags & PCI_RES_TYPE_MASK,
+						 whole_subtree);
+
+	/* Restore size and flags */
+	list_for_each_entry(dev_res, head, list) {
+		struct resource *res = dev_res->res;
+		int idx;
+
+		res->start = dev_res->start;
+		res->end = dev_res->end;
+		res->flags = dev_res->flags;
+
+		if (pci_is_bridge(dev_res->dev)) {
+			idx = res - &dev_res->dev->resource[0];
+			if (idx >= PCI_BRIDGE_RESOURCES &&
+			    idx <= PCI_BRIDGE_RESOURCE_END)
+				res->flags = 0;
+		}
+	}
+}
+
 void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge)
 {
 	struct pci_bus *parent = bridge->subordinate;
@@ -2088,27 +2115,7 @@ void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge)
 	 * Try to release leaf bridge's resources that aren't big enough
 	 * to contain child device resources.
 	 */
-	list_for_each_entry(fail_res, &fail_head, list)
-		pci_bus_release_bridge_resources(fail_res->dev->bus,
-						 fail_res->flags & PCI_RES_TYPE_MASK,
-						 whole_subtree);
-
-	/* Restore size and flags */
-	list_for_each_entry(fail_res, &fail_head, list) {
-		struct resource *res = fail_res->res;
-		int idx;
-
-		res->start = fail_res->start;
-		res->end = fail_res->end;
-		res->flags = fail_res->flags;
-
-		if (pci_is_bridge(fail_res->dev)) {
-			idx = res - &fail_res->dev->resource[0];
-			if (idx >= PCI_BRIDGE_RESOURCES &&
-			    idx <= PCI_BRIDGE_RESOURCE_END)
-				res->flags = 0;
-		}
-	}
+	release_and_restore_resources(&fail_head);
 	free_list(&fail_head);
 
 	goto again;
-- 
2.18.1


  reply	other threads:[~2020-09-28  1:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-28  1:06 [PATCH 0/3] PCI: Minimizing resource assignment algorithm Jon Derrick
2020-09-28  1:06 ` Jon Derrick [this message]
2020-09-28  1:06 ` [PATCH 2/3] PCI: Introduce a minimizing " Jon Derrick
2020-09-28  7:17   ` Christoph Hellwig
2020-09-28 13:34     ` Derrick, Jonathan
2020-09-29 17:48       ` hch
2020-09-28  1:06 ` [PATCH 3/3] PCI: vmd: Wire up VMD for fallback resource assignment Jon Derrick
2020-09-28  7:16 ` [PATCH 0/3] PCI: Minimizing resource assignment algorithm Christoph Hellwig

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=20200928010609.5375-2-jonathan.derrick@intel.com \
    --to=jonathan.derrick@intel.com \
    --cc=andrzej.jakowski@linux.intel.com \
    --cc=david.fugate@intel.com \
    --cc=helgaas@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    /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;
as well as URLs for NNTP newsgroup(s).