Patchwork PCI, x86: avoid redundant insert_resource() call in pci_mmcfg_insert_resources()

login
register
mail settings
Submitter Jiang Liu
Date May 2, 2012, 2:41 p.m.
Message ID <1335969706-13604-1-git-send-email-jiang.liu@huawei.com>
Download mbox | patch
Permalink /patch/156476/
State Superseded
Headers show

Comments

Jiang Liu - May 2, 2012, 2:41 p.m.
From: Jiang Liu <jiang.liu@huawei.com>

For hot-pluggable host bridges present at boot time, pci_mmconfig_insert() will
insert resources used by MMCFG items for those host bridges. So avoid redundant
call to insert_resource() when pci_mmcfg_insert_resources() is called later.

Reported-By: Taku Izumi <izumi.taku@jp.fujitsu.com>
Signed-off-by: Jiang Liu <liuj97@gmail.com>
---
 arch/x86/pci/mmconfig-shared.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Patch

diff --git a/arch/x86/pci/mmconfig-shared.c b/arch/x86/pci/mmconfig-shared.c
index f4d9ff9..7bba722 100644
--- a/arch/x86/pci/mmconfig-shared.c
+++ b/arch/x86/pci/mmconfig-shared.c
@@ -371,8 +371,13 @@  static void __init pci_mmcfg_insert_resources(void)
 {
 	struct pci_mmcfg_region *cfg;
 
+	/*
+	 * Insert resources for MMCFG items if the resource hasn't been
+	 * inserted by pci_mmconfig_insert() yet.
+	 */
 	list_for_each_entry(cfg, &pci_mmcfg_list, list)
-		insert_resource(&iomem_resource, &cfg->res);
+		if (!cfg->res.parent)
+			insert_resource(&iomem_resource, &cfg->res);
 
 	/* Mark that the resources have been inserted. */
 	pci_mmcfg_resources_inserted = 1;