linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yinghai Lu <yinghai@kernel.org>
To: Jesse Barnes <jbarnes@virtuousgeek.org>
Cc: Ram Pai <linuxram@us.ibm.com>,
	Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>,
	linux-pci@vger.kernel.org, Yinghai Lu <yinghai@kernel.org>
Subject: [PATCH 4/5] PCI: Make rescan bus could increase bridge resource size if needed
Date: Wed,  7 Dec 2011 00:53:03 -0800	[thread overview]
Message-ID: <1323247984-15281-5-git-send-email-yinghai@kernel.org> (raw)
In-Reply-To: <1323247984-15281-1-git-send-email-yinghai@kernel.org>

Current rescan will not touch bridge MMIO and IO.

Try to reuse pci_assign_unassigned_bridge_resources(bridge) to update bridge
resource, if child devices need more resource.

only do that for bridges that all children get removed before. So do not
release resources that could already be used by drivers of child devices.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
 drivers/pci/pci-sysfs.c |    5 ++++-
 drivers/pci/probe.c     |   24 ++++++++++++++++++++++++
 include/linux/pci.h     |    1 +
 3 files changed, 29 insertions(+), 1 deletion(-)

Index: linux-2.6/drivers/pci/pci-sysfs.c
===================================================================
--- linux-2.6.orig/drivers/pci/pci-sysfs.c
+++ linux-2.6/drivers/pci/pci-sysfs.c
@@ -366,7 +366,10 @@ dev_bus_rescan_store(struct device *dev,
 
 	if (val) {
 		mutex_lock(&pci_remove_rescan_mutex);
-		pci_rescan_bus(bus);
+		if (!pci_is_root_bus(bus) && list_empty(&bus->devices))
+			pci_rescan_bus_bridge_resize(bus->self);
+		else
+			pci_rescan_bus(bus);
 		mutex_unlock(&pci_remove_rescan_mutex);
 	}
 	return count;
Index: linux-2.6/drivers/pci/probe.c
===================================================================
--- linux-2.6.orig/drivers/pci/probe.c
+++ linux-2.6/drivers/pci/probe.c
@@ -1661,6 +1661,30 @@ struct pci_bus * __devinit pci_scan_bus(
 
 #ifdef CONFIG_HOTPLUG
 /**
+ * pci_rescan_bus_bridge_resize - scan a PCI bus for devices.
+ * @bridge: PCI bridge for the bus to scan
+ *
+ * Scan a PCI bus and child buses for new devices, adds them,
+ * and enables them, it will resize bridge mmio/io resource if it is possible
+ * for safe, caller should make sure that children get removed already.
+ *
+ * Returns the max number of subordinate bus discovered.
+ */
+unsigned int __ref pci_rescan_bus_bridge_resize(struct pci_dev *bridge)
+{
+	unsigned int max;
+	struct pci_bus *bus = bridge->subordinate;
+
+	max = pci_scan_child_bus(bus);
+
+	pci_assign_unassigned_bridge_resources(bridge);
+
+	pci_bus_add_devices(bus);
+
+	return max;
+}
+
+/**
  * pci_rescan_bus - scan a PCI bus for devices.
  * @bus: PCI bus to scan
  *
Index: linux-2.6/include/linux/pci.h
===================================================================
--- linux-2.6.orig/include/linux/pci.h
+++ linux-2.6/include/linux/pci.h
@@ -882,6 +882,7 @@ void set_pcie_hotplug_bridge(struct pci_
 /* Functions for PCI Hotplug drivers to use */
 int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap);
 #ifdef CONFIG_HOTPLUG
+unsigned int pci_rescan_bus_bridge_resize(struct pci_dev *bridge);
 unsigned int pci_rescan_bus(struct pci_bus *bus);
 #endif
 

  parent reply	other threads:[~2011-12-07  8:53 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-07  8:52 [PATCH 0/5] PCI: make pci hotplug/rescan path to handle add_size list Yinghai Lu
2011-12-07  8:53 ` [PATCH 1/5] PCI : Calculate right add_size Yinghai Lu
2012-01-06 21:14   ` Jesse Barnes
2012-01-07  1:21     ` Yinghai Lu
2011-12-07  8:53 ` [PATCH 2/5] PCI: Try to assign required+option size at first Yinghai Lu
2012-01-06 21:49   ` Jesse Barnes
2012-01-07  3:46     ` Yinghai Lu
2012-01-07  5:51       ` Yinghai Lu
2012-01-07  5:53         ` Yinghai Lu
2012-01-07  6:12           ` Yinghai Lu
2012-01-07  4:49     ` Linus Torvalds
2012-01-09  6:01       ` Yinghai Lu
2012-01-11  6:20         ` Linus Torvalds
2012-01-11 18:01           ` Yinghai Lu
2012-01-13 16:39   ` Ram Pai
2012-01-13 23:28     ` Yinghai Lu
2012-01-15 16:05       ` Ram Pai
2012-01-16  1:14         ` Yinghai Lu
2012-01-16  3:26           ` Ram Pai
2012-01-16  4:54             ` Yinghai Lu
2012-01-16 10:29               ` Ram Pai
2012-01-16 17:13                 ` Yinghai Lu
2012-01-16 21:30                   ` Yinghai Lu
2012-01-16 19:59           ` Peter Henriksson
2012-01-16 21:41             ` Yinghai Lu
2011-12-07  8:53 ` [PATCH 3/5] PCI: Using add_list in pcie hotplug path Yinghai Lu
2012-01-06 21:58   ` Jesse Barnes
2012-01-07  1:30     ` Yinghai Lu
2011-12-07  8:53 ` Yinghai Lu [this message]
2011-12-07  8:53 ` [PATCH 5/5] PCI: Make pci_rescan_bus handle add_list Yinghai Lu

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=1323247984-15281-5-git-send-email-yinghai@kernel.org \
    --to=yinghai@kernel.org \
    --cc=jbarnes@virtuousgeek.org \
    --cc=kaneshige.kenji@jp.fujitsu.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=linuxram@us.ibm.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).