linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
       [not found] <20121030040237.GA10472@google.com>
@ 2012-11-04  4:39 ` Yinghai Lu
  2012-11-04  4:39   ` [PATCH 1/8] PCI, x86: Separate out pcibios_allocate_bridge_resources() Yinghai Lu
                     ` (8 more replies)
  0 siblings, 9 replies; 24+ messages in thread
From: Yinghai Lu @ 2012-11-04  4:39 UTC (permalink / raw)
  To: Bjorn Helgaas, Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu
  Cc: linux-pci, linux-kernel, linux-acpi, Yinghai Lu

For root bus hot add, fw could assign some resource for the devices for
that root bus before notifying os via acpi, we should check and use those
resources at first just like we do for booting path.

At first, we need to refactor x86 pci pcibios_allocate related functions
for booting path to take bus as parameter.

After that, we could use the survey function for hot add root bus.

based on pci/yinghai-for-pci-root-bus-hotplug

could get from
        git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git for-pci-survey-resources

Yinghai Lu (8):
  PCI, x86: Separate out pcibios_allocate_bridge_resources()
  PCI, x86: Separate out pcibios_allocate_dev_resources()
  PCI, x86: Let pcibios_allocate_bus_resources() take bus instead
  PCI, x86: Separate out rom resource claim
  PCI, x86: Add pcibios_fw_addr_done
  PCI, x86: Remove __init for hw/fw allocated functions
  PCI, x86: Claim FW allocated resources in hot add path.
  PCI, ACPI: reserve fw allocated resource for hot added root bus

 arch/x86/pci/i386.c     |  185 +++++++++++++++++++++++++++++++----------------
 drivers/acpi/pci_root.c |    4 +-
 drivers/pci/bus.c       |    2 +
 include/linux/pci.h     |    1 +
 4 files changed, 127 insertions(+), 65 deletions(-)

-- 
1.7.7


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH 1/8] PCI, x86: Separate out pcibios_allocate_bridge_resources()
  2012-11-04  4:39 ` [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus Yinghai Lu
@ 2012-11-04  4:39   ` Yinghai Lu
  2012-11-04  4:39   ` [PATCH 2/8] PCI, x86: Separate out pcibios_allocate_dev_resources() Yinghai Lu
                     ` (7 subsequent siblings)
  8 siblings, 0 replies; 24+ messages in thread
From: Yinghai Lu @ 2012-11-04  4:39 UTC (permalink / raw)
  To: Bjorn Helgaas, Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu
  Cc: linux-pci, linux-kernel, linux-acpi, Yinghai Lu, x86

Thus pcibios_allocate_bus_resources() could more simple and clean.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: x86@kernel.org
---
 arch/x86/pci/i386.c |   46 ++++++++++++++++++++++++----------------------
 1 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
index dd8ca6f..9800362 100644
--- a/arch/x86/pci/i386.c
+++ b/arch/x86/pci/i386.c
@@ -193,34 +193,36 @@ EXPORT_SYMBOL(pcibios_align_resource);
  *	    as well.
  */
 
-static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
+static void __init pcibios_allocate_bridge_resources(struct pci_dev *dev)
 {
-	struct pci_bus *bus;
-	struct pci_dev *dev;
 	int idx;
 	struct resource *r;
 
+	for (idx = PCI_BRIDGE_RESOURCES; idx < PCI_NUM_RESOURCES; idx++) {
+		r = &dev->resource[idx];
+		if (!r->flags)
+			continue;
+		if (!r->start || pci_claim_resource(dev, idx) < 0) {
+			/*
+			 * Something is wrong with the region.
+			 * Invalidate the resource to prevent
+			 * child resource allocations in this
+			 * range.
+			 */
+			r->start = r->end = 0;
+			r->flags = 0;
+		}
+	}
+}
+
+static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
+{
+	struct pci_bus *bus;
+
 	/* Depth-First Search on bus tree */
 	list_for_each_entry(bus, bus_list, node) {
-		if ((dev = bus->self)) {
-			for (idx = PCI_BRIDGE_RESOURCES;
-			    idx < PCI_NUM_RESOURCES; idx++) {
-				r = &dev->resource[idx];
-				if (!r->flags)
-					continue;
-				if (!r->start ||
-				    pci_claim_resource(dev, idx) < 0) {
-					/*
-					 * Something is wrong with the region.
-					 * Invalidate the resource to prevent
-					 * child resource allocations in this
-					 * range.
-					 */
-					r->start = r->end = 0;
-					r->flags = 0;
-				}
-			}
-		}
+		if (bus->self)
+			pcibios_allocate_bridge_resources(bus->self);
 		pcibios_allocate_bus_resources(&bus->children);
 	}
 }
-- 
1.7.7


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 2/8] PCI, x86: Separate out pcibios_allocate_dev_resources()
  2012-11-04  4:39 ` [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus Yinghai Lu
  2012-11-04  4:39   ` [PATCH 1/8] PCI, x86: Separate out pcibios_allocate_bridge_resources() Yinghai Lu
@ 2012-11-04  4:39   ` Yinghai Lu
  2012-11-04  4:39   ` [PATCH 3/8] PCI, x86: Let pcibios_allocate_bus_resources() take bus instead Yinghai Lu
                     ` (6 subsequent siblings)
  8 siblings, 0 replies; 24+ messages in thread
From: Yinghai Lu @ 2012-11-04  4:39 UTC (permalink / raw)
  To: Bjorn Helgaas, Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu
  Cc: linux-pci, linux-kernel, linux-acpi, Yinghai Lu, x86

Thus pcibios_allocate_resources() could more simple and clean.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: x86@kernel.org
---
 arch/x86/pci/i386.c |   42 +++++++++++++++++++++++-------------------
 1 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
index 9800362..5817cf2 100644
--- a/arch/x86/pci/i386.c
+++ b/arch/x86/pci/i386.c
@@ -232,9 +232,8 @@ struct pci_check_idx_range {
 	int end;
 };
 
-static void __init pcibios_allocate_resources(int pass)
+static void __init pcibios_allocate_dev_resources(struct pci_dev *dev, int pass)
 {
-	struct pci_dev *dev = NULL;
 	int idx, disabled, i;
 	u16 command;
 	struct resource *r;
@@ -246,14 +245,13 @@ static void __init pcibios_allocate_resources(int pass)
 #endif
 	};
 
-	for_each_pci_dev(dev) {
-		pci_read_config_word(dev, PCI_COMMAND, &command);
-		for (i = 0; i < ARRAY_SIZE(idx_range); i++)
+	pci_read_config_word(dev, PCI_COMMAND, &command);
+	for (i = 0; i < ARRAY_SIZE(idx_range); i++)
 		for (idx = idx_range[i].start; idx <= idx_range[i].end; idx++) {
 			r = &dev->resource[idx];
-			if (r->parent)		/* Already allocated */
+			if (r->parent)	/* Already allocated */
 				continue;
-			if (!r->start)		/* Address not assigned at all */
+			if (!r->start)	/* Address not assigned at all */
 				continue;
 			if (r->flags & IORESOURCE_IO)
 				disabled = !(command & PCI_COMMAND_IO);
@@ -272,23 +270,29 @@ static void __init pcibios_allocate_resources(int pass)
 				}
 			}
 		}
-		if (!pass) {
-			r = &dev->resource[PCI_ROM_RESOURCE];
-			if (r->flags & IORESOURCE_ROM_ENABLE) {
-				/* Turn the ROM off, leave the resource region,
-				 * but keep it unregistered. */
-				u32 reg;
-				dev_dbg(&dev->dev, "disabling ROM %pR\n", r);
-				r->flags &= ~IORESOURCE_ROM_ENABLE;
-				pci_read_config_dword(dev,
-						dev->rom_base_reg, &reg);
-				pci_write_config_dword(dev, dev->rom_base_reg,
+	if (!pass) {
+		r = &dev->resource[PCI_ROM_RESOURCE];
+		if (r->flags & IORESOURCE_ROM_ENABLE) {
+			/* Turn the ROM off, leave the resource region,
+			 * but keep it unregistered. */
+			u32 reg;
+			dev_dbg(&dev->dev, "disabling ROM %pR\n", r);
+			r->flags &= ~IORESOURCE_ROM_ENABLE;
+			pci_read_config_dword(dev, dev->rom_base_reg, &reg);
+			pci_write_config_dword(dev, dev->rom_base_reg,
 						reg & ~PCI_ROM_ADDRESS_ENABLE);
-			}
 		}
 	}
 }
 
+static void __init pcibios_allocate_resources(int pass)
+{
+	struct pci_dev *dev = NULL;
+
+	for_each_pci_dev(dev)
+		pcibios_allocate_dev_resources(dev, pass);
+}
+
 static int __init pcibios_assign_resources(void)
 {
 	struct pci_dev *dev = NULL;
-- 
1.7.7


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 3/8] PCI, x86: Let pcibios_allocate_bus_resources() take bus instead
  2012-11-04  4:39 ` [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus Yinghai Lu
  2012-11-04  4:39   ` [PATCH 1/8] PCI, x86: Separate out pcibios_allocate_bridge_resources() Yinghai Lu
  2012-11-04  4:39   ` [PATCH 2/8] PCI, x86: Separate out pcibios_allocate_dev_resources() Yinghai Lu
@ 2012-11-04  4:39   ` Yinghai Lu
  2012-11-04  4:39   ` [PATCH 4/8] PCI, x86: Separate out rom resource claim Yinghai Lu
                     ` (5 subsequent siblings)
  8 siblings, 0 replies; 24+ messages in thread
From: Yinghai Lu @ 2012-11-04  4:39 UTC (permalink / raw)
  To: Bjorn Helgaas, Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu
  Cc: linux-pci, linux-kernel, linux-acpi, Yinghai Lu, x86

Will need call the same code for one single root bus during hot add.
So make it take bus instead of bus list.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: x86@kernel.org
---
 arch/x86/pci/i386.c |   38 +++++++++++++++++++++++++-------------
 1 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
index 5817cf2..84696ed 100644
--- a/arch/x86/pci/i386.c
+++ b/arch/x86/pci/i386.c
@@ -215,16 +215,15 @@ static void __init pcibios_allocate_bridge_resources(struct pci_dev *dev)
 	}
 }
 
-static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
+static void __init pcibios_allocate_bus_resources(struct pci_bus *bus)
 {
-	struct pci_bus *bus;
+	struct pci_bus *child;
 
 	/* Depth-First Search on bus tree */
-	list_for_each_entry(bus, bus_list, node) {
-		if (bus->self)
-			pcibios_allocate_bridge_resources(bus->self);
-		pcibios_allocate_bus_resources(&bus->children);
-	}
+	if (bus->self)
+		pcibios_allocate_bridge_resources(bus->self);
+	list_for_each_entry(child, &bus->children, node)
+		pcibios_allocate_bus_resources(child);
 }
 
 struct pci_check_idx_range {
@@ -285,12 +284,18 @@ static void __init pcibios_allocate_dev_resources(struct pci_dev *dev, int pass)
 	}
 }
 
-static void __init pcibios_allocate_resources(int pass)
+static void __init pcibios_allocate_resources(struct pci_bus *bus, int pass)
 {
-	struct pci_dev *dev = NULL;
+	struct pci_dev *dev;
+	struct pci_bus *child;
 
-	for_each_pci_dev(dev)
+	list_for_each_entry(dev, &bus->devices, bus_list) {
 		pcibios_allocate_dev_resources(dev, pass);
+
+		child = dev->subordinate;
+		if (child)
+			pcibios_allocate_resources(child, pass);
+	}
 }
 
 static int __init pcibios_assign_resources(void)
@@ -323,10 +328,17 @@ static int __init pcibios_assign_resources(void)
 
 void __init pcibios_resource_survey(void)
 {
+	struct pci_bus *bus;
+
 	DBG("PCI: Allocating resources\n");
-	pcibios_allocate_bus_resources(&pci_root_buses);
-	pcibios_allocate_resources(0);
-	pcibios_allocate_resources(1);
+
+	list_for_each_entry(bus, &pci_root_buses, node)
+		pcibios_allocate_bus_resources(bus);
+
+	list_for_each_entry(bus, &pci_root_buses, node)
+		pcibios_allocate_resources(bus, 0);
+	list_for_each_entry(bus, &pci_root_buses, node)
+		pcibios_allocate_resources(bus, 1);
 
 	e820_reserve_resources_late();
 	/*
-- 
1.7.7


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 4/8] PCI, x86: Separate out rom resource claim
  2012-11-04  4:39 ` [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus Yinghai Lu
                     ` (2 preceding siblings ...)
  2012-11-04  4:39   ` [PATCH 3/8] PCI, x86: Let pcibios_allocate_bus_resources() take bus instead Yinghai Lu
@ 2012-11-04  4:39   ` Yinghai Lu
  2012-11-04  4:39   ` [PATCH 5/8] PCI, x86: Add pcibios_fw_addr_done Yinghai Lu
                     ` (4 subsequent siblings)
  8 siblings, 0 replies; 24+ messages in thread
From: Yinghai Lu @ 2012-11-04  4:39 UTC (permalink / raw)
  To: Bjorn Helgaas, Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu
  Cc: linux-pci, linux-kernel, linux-acpi, Yinghai Lu, x86

So could use it with hot-added root bus later.

-v2: remove extra functions.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: x86@kernel.org
---
 arch/x86/pci/i386.c |   52 ++++++++++++++++++++++++++++++++++----------------
 1 files changed, 35 insertions(+), 17 deletions(-)

diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
index 84696ed..42dd755 100644
--- a/arch/x86/pci/i386.c
+++ b/arch/x86/pci/i386.c
@@ -298,27 +298,45 @@ static void __init pcibios_allocate_resources(struct pci_bus *bus, int pass)
 	}
 }
 
-static int __init pcibios_assign_resources(void)
+static void __init pcibios_allocate_dev_rom_resource(struct pci_dev *dev)
 {
-	struct pci_dev *dev = NULL;
 	struct resource *r;
 
-	if (!(pci_probe & PCI_ASSIGN_ROMS)) {
-		/*
-		 * Try to use BIOS settings for ROMs, otherwise let
-		 * pci_assign_unassigned_resources() allocate the new
-		 * addresses.
-		 */
-		for_each_pci_dev(dev) {
-			r = &dev->resource[PCI_ROM_RESOURCE];
-			if (!r->flags || !r->start)
-				continue;
-			if (pci_claim_resource(dev, PCI_ROM_RESOURCE) < 0) {
-				r->end -= r->start;
-				r->start = 0;
-			}
-		}
+	/*
+	 * Try to use BIOS settings for ROMs, otherwise let
+	 * pci_assign_unassigned_resources() allocate the new
+	 * addresses.
+	 */
+	r = &dev->resource[PCI_ROM_RESOURCE];
+	if (!r->flags || !r->start)
+		return;
+
+	if (pci_claim_resource(dev, PCI_ROM_RESOURCE) < 0) {
+		r->end -= r->start;
+		r->start = 0;
 	}
+}
+static void __init pcibios_allocate_rom_resources(struct pci_bus *bus)
+{
+	struct pci_dev *dev;
+	struct pci_bus *child;
+
+	list_for_each_entry(dev, &bus->devices, bus_list) {
+		pcibios_allocate_dev_rom_resource(dev);
+
+		child = dev->subordinate;
+		if (child)
+			pcibios_allocate_rom_resources(child);
+	}
+}
+
+static int __init pcibios_assign_resources(void)
+{
+	struct pci_bus *bus;
+
+	if (!(pci_probe & PCI_ASSIGN_ROMS))
+		list_for_each_entry(bus, &pci_root_buses, node)
+			pcibios_allocate_rom_resources(bus);
 
 	pci_assign_unassigned_resources();
 	pcibios_fw_addr_list_del();
-- 
1.7.7


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 5/8] PCI, x86: Add pcibios_fw_addr_done
  2012-11-04  4:39 ` [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus Yinghai Lu
                     ` (3 preceding siblings ...)
  2012-11-04  4:39   ` [PATCH 4/8] PCI, x86: Separate out rom resource claim Yinghai Lu
@ 2012-11-04  4:39   ` Yinghai Lu
  2012-11-04  4:39   ` [PATCH 6/8] PCI, x86: Remove __init for hw/fw allocated functions Yinghai Lu
                     ` (3 subsequent siblings)
  8 siblings, 0 replies; 24+ messages in thread
From: Yinghai Lu @ 2012-11-04  4:39 UTC (permalink / raw)
  To: Bjorn Helgaas, Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu
  Cc: linux-pci, linux-kernel, linux-acpi, Yinghai Lu, x86

Use it to skip not needed function after pcibios_fw_addr_list_del is called.

for pci root bus hot add, we will need to use pcibios_allocate_dev_resources(),
and don't want to mess up with fw_addr, for hot-add removing path.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: x86@kernel.org
---
 arch/x86/pci/i386.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
index 42dd755..edfc376 100644
--- a/arch/x86/pci/i386.c
+++ b/arch/x86/pci/i386.c
@@ -51,6 +51,7 @@ struct pcibios_fwaddrmap {
 
 static LIST_HEAD(pcibios_fwaddrmappings);
 static DEFINE_SPINLOCK(pcibios_fwaddrmap_lock);
+static bool pcibios_fw_addr_done;
 
 /* Must be called with 'pcibios_fwaddrmap_lock' lock held. */
 static struct pcibios_fwaddrmap *pcibios_fwaddrmap_lookup(struct pci_dev *dev)
@@ -72,6 +73,9 @@ pcibios_save_fw_addr(struct pci_dev *dev, int idx, resource_size_t fw_addr)
 	unsigned long flags;
 	struct pcibios_fwaddrmap *map;
 
+	if (pcibios_fw_addr_done)
+		return;
+
 	spin_lock_irqsave(&pcibios_fwaddrmap_lock, flags);
 	map = pcibios_fwaddrmap_lookup(dev);
 	if (!map) {
@@ -97,6 +101,9 @@ resource_size_t pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx)
 	struct pcibios_fwaddrmap *map;
 	resource_size_t fw_addr = 0;
 
+	if (pcibios_fw_addr_done)
+		return fw_addr;
+
 	spin_lock_irqsave(&pcibios_fwaddrmap_lock, flags);
 	map = pcibios_fwaddrmap_lookup(dev);
 	if (map)
@@ -106,7 +113,7 @@ resource_size_t pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx)
 	return fw_addr;
 }
 
-static void pcibios_fw_addr_list_del(void)
+static void __init pcibios_fw_addr_list_del(void)
 {
 	unsigned long flags;
 	struct pcibios_fwaddrmap *entry, *next;
@@ -118,6 +125,7 @@ static void pcibios_fw_addr_list_del(void)
 		kfree(entry);
 	}
 	spin_unlock_irqrestore(&pcibios_fwaddrmap_lock, flags);
+	pcibios_fw_addr_done = true;
 }
 
 static int
-- 
1.7.7


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 6/8] PCI, x86: Remove __init for hw/fw allocated functions
  2012-11-04  4:39 ` [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus Yinghai Lu
                     ` (4 preceding siblings ...)
  2012-11-04  4:39   ` [PATCH 5/8] PCI, x86: Add pcibios_fw_addr_done Yinghai Lu
@ 2012-11-04  4:39   ` Yinghai Lu
  2012-11-04  4:39   ` [PATCH 7/8] PCI, x86: Claim FW allocated resources in hot add path Yinghai Lu
                     ` (2 subsequent siblings)
  8 siblings, 0 replies; 24+ messages in thread
From: Yinghai Lu @ 2012-11-04  4:39 UTC (permalink / raw)
  To: Bjorn Helgaas, Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu
  Cc: linux-pci, linux-kernel, linux-acpi, Yinghai Lu, x86

will need it for hot add path.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: x86@kernel.org
---
 arch/x86/pci/i386.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
index edfc376..1806e91 100644
--- a/arch/x86/pci/i386.c
+++ b/arch/x86/pci/i386.c
@@ -201,7 +201,7 @@ EXPORT_SYMBOL(pcibios_align_resource);
  *	    as well.
  */
 
-static void __init pcibios_allocate_bridge_resources(struct pci_dev *dev)
+static void pcibios_allocate_bridge_resources(struct pci_dev *dev)
 {
 	int idx;
 	struct resource *r;
@@ -223,7 +223,7 @@ static void __init pcibios_allocate_bridge_resources(struct pci_dev *dev)
 	}
 }
 
-static void __init pcibios_allocate_bus_resources(struct pci_bus *bus)
+static void pcibios_allocate_bus_resources(struct pci_bus *bus)
 {
 	struct pci_bus *child;
 
@@ -239,7 +239,7 @@ struct pci_check_idx_range {
 	int end;
 };
 
-static void __init pcibios_allocate_dev_resources(struct pci_dev *dev, int pass)
+static void pcibios_allocate_dev_resources(struct pci_dev *dev, int pass)
 {
 	int idx, disabled, i;
 	u16 command;
@@ -292,7 +292,7 @@ static void __init pcibios_allocate_dev_resources(struct pci_dev *dev, int pass)
 	}
 }
 
-static void __init pcibios_allocate_resources(struct pci_bus *bus, int pass)
+static void pcibios_allocate_resources(struct pci_bus *bus, int pass)
 {
 	struct pci_dev *dev;
 	struct pci_bus *child;
@@ -306,7 +306,7 @@ static void __init pcibios_allocate_resources(struct pci_bus *bus, int pass)
 	}
 }
 
-static void __init pcibios_allocate_dev_rom_resource(struct pci_dev *dev)
+static void pcibios_allocate_dev_rom_resource(struct pci_dev *dev)
 {
 	struct resource *r;
 
@@ -324,7 +324,7 @@ static void __init pcibios_allocate_dev_rom_resource(struct pci_dev *dev)
 		r->start = 0;
 	}
 }
-static void __init pcibios_allocate_rom_resources(struct pci_bus *bus)
+static void pcibios_allocate_rom_resources(struct pci_bus *bus)
 {
 	struct pci_dev *dev;
 	struct pci_bus *child;
-- 
1.7.7


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 7/8] PCI, x86: Claim FW allocated resources in hot add path.
  2012-11-04  4:39 ` [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus Yinghai Lu
                     ` (5 preceding siblings ...)
  2012-11-04  4:39   ` [PATCH 6/8] PCI, x86: Remove __init for hw/fw allocated functions Yinghai Lu
@ 2012-11-04  4:39   ` Yinghai Lu
  2012-11-04  4:39   ` [PATCH 8/8] PCI, ACPI: reserve fw allocated resource for hot added root bus Yinghai Lu
  2012-12-07  7:15   ` [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add " Yinghai Lu
  8 siblings, 0 replies; 24+ messages in thread
From: Yinghai Lu @ 2012-11-04  4:39 UTC (permalink / raw)
  To: Bjorn Helgaas, Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu
  Cc: linux-pci, linux-kernel, linux-acpi, Yinghai Lu, x86

During testing remove/rescan root bus 00, found
[  338.142574] bus: 'pci': really_probe: probing driver ata_piix with device 0000:00:01.1
[  338.146788] ata_piix 0000:00:01.1: device not available (can't reserve [io  0x01f0-0x01f7])
[  338.150565] ata_piix: probe of 0000:00:01.1 failed with error -22

because that fixed resource is not claimed.
For bootint path it is claimed in  from
        arch/x86/pci/i386.c::pcibios_allocate_resources()

Claim those resources, so on the remove/rescan will still use old
resources.

It is some kind honoring FW setting in the registers during hot add.
esp root-bus hot add is through acpi, BIOS has chance to set some registers
before handing over.

-v2: add rom resource claiming.
-v3: separate __init removing to another patch, also
   put pci_probe checking with caller from rom resource allocating

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: x86@kernel.org
---
 arch/x86/pci/i386.c |   13 +++++++++++++
 drivers/pci/bus.c   |    2 ++
 include/linux/pci.h |    1 +
 3 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
index 1806e91..e0b7f30 100644
--- a/arch/x86/pci/i386.c
+++ b/arch/x86/pci/i386.c
@@ -352,6 +352,19 @@ static int __init pcibios_assign_resources(void)
 	return 0;
 }
 
+void pcibios_resource_survey_bus(struct pci_bus *bus)
+{
+	dev_printk(KERN_DEBUG, &bus->dev, "Allocating resources\n");
+
+	pcibios_allocate_bus_resources(bus);
+
+	pcibios_allocate_resources(bus, 0);
+	pcibios_allocate_resources(bus, 1);
+
+	if (!(pci_probe & PCI_ASSIGN_ROMS))
+		pcibios_allocate_rom_resources(bus);
+}
+
 void __init pcibios_resource_survey(void)
 {
 	struct pci_bus *bus;
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 6241fd0..a85247d 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -158,6 +158,8 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
 	return ret;
 }
 
+void __weak pcibios_resource_survey_bus(struct pci_bus *bus) { }
+
 /**
  * pci_bus_add_device - add a single device
  * @dev: device to add
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 7860942..f30af2f 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -654,6 +654,7 @@ extern struct list_head pci_root_buses;	/* list of all known PCI buses */
 /* Some device drivers need know if pci is initiated */
 extern int no_pci_devices(void);
 
+void pcibios_resource_survey_bus(struct pci_bus *bus);
 void pcibios_fixup_bus(struct pci_bus *);
 int __must_check pcibios_enable_device(struct pci_dev *, int mask);
 /* Architecture specific versions may override this (weak) */
-- 
1.7.7


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 8/8] PCI, ACPI: reserve fw allocated resource for hot added root bus
  2012-11-04  4:39 ` [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus Yinghai Lu
                     ` (6 preceding siblings ...)
  2012-11-04  4:39   ` [PATCH 7/8] PCI, x86: Claim FW allocated resources in hot add path Yinghai Lu
@ 2012-11-04  4:39   ` Yinghai Lu
  2012-12-07  7:15   ` [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add " Yinghai Lu
  8 siblings, 0 replies; 24+ messages in thread
From: Yinghai Lu @ 2012-11-04  4:39 UTC (permalink / raw)
  To: Bjorn Helgaas, Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu
  Cc: linux-pci, linux-kernel, linux-acpi, Yinghai Lu

FW could already allocate resource in pci bar registers, and we need to
reserve it before try to allocate another one.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 drivers/acpi/pci_root.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 012f40d..bc09567 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -644,8 +644,10 @@ static int acpi_pci_root_start(struct acpi_device *device)
 	struct acpi_pci_root *root = acpi_driver_data(device);
 	struct acpi_pci_driver *driver;
 
-	if (system_state != SYSTEM_BOOTING)
+	if (system_state != SYSTEM_BOOTING) {
+		pcibios_resource_survey_bus(root->bus);
 		pci_assign_unassigned_bus_resources(root->bus);
+	}
 
 	mutex_lock(&acpi_pci_root_lock);
 	list_for_each_entry(driver, &acpi_pci_drivers, node)
-- 
1.7.7


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
  2012-11-04  4:39 ` [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus Yinghai Lu
                     ` (7 preceding siblings ...)
  2012-11-04  4:39   ` [PATCH 8/8] PCI, ACPI: reserve fw allocated resource for hot added root bus Yinghai Lu
@ 2012-12-07  7:15   ` Yinghai Lu
  2013-01-07 23:49     ` Bjorn Helgaas
  8 siblings, 1 reply; 24+ messages in thread
From: Yinghai Lu @ 2012-12-07  7:15 UTC (permalink / raw)
  To: Bjorn Helgaas, Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu
  Cc: linux-pci, linux-kernel, linux-acpi, Yinghai Lu

On Sat, Nov 3, 2012 at 9:39 PM, Yinghai Lu <yinghai@kernel.org> wrote:
> For root bus hot add, fw could assign some resource for the devices for
> that root bus before notifying os via acpi, we should check and use those
> resources at first just like we do for booting path.
>
> At first, we need to refactor x86 pci pcibios_allocate related functions
> for booting path to take bus as parameter.
>
> After that, we could use the survey function for hot add root bus.
>
> based on pci/yinghai-for-pci-root-bus-hotplug
>
> could get from
>         git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git for-pci-survey-resources
>
> Yinghai Lu (8):
>   PCI, x86: Separate out pcibios_allocate_bridge_resources()
>   PCI, x86: Separate out pcibios_allocate_dev_resources()
>   PCI, x86: Let pcibios_allocate_bus_resources() take bus instead
>   PCI, x86: Separate out rom resource claim
>   PCI, x86: Add pcibios_fw_addr_done
>   PCI, x86: Remove __init for hw/fw allocated functions
>   PCI, x86: Claim FW allocated resources in hot add path.
>   PCI, ACPI: reserve fw allocated resource for hot added root bus
>
>  arch/x86/pci/i386.c     |  185 +++++++++++++++++++++++++++++++----------------
>  drivers/acpi/pci_root.c |    4 +-
>  drivers/pci/bus.c       |    2 +
>  include/linux/pci.h     |    1 +
>  4 files changed, 127 insertions(+), 65 deletions(-)
>

Bjorn,

Can you queue those 8 patches for v3.9 in pci tree?

So I  could resend out other pci root hotplug patches.

Thanks

Yinghai

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
  2012-12-07  7:15   ` [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add " Yinghai Lu
@ 2013-01-07 23:49     ` Bjorn Helgaas
  2013-01-08 17:57       ` Bjorn Helgaas
  0 siblings, 1 reply; 24+ messages in thread
From: Bjorn Helgaas @ 2013-01-07 23:49 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu, linux-pci,
	linux-kernel, linux-acpi, David Howells, Michal Simek,
	Koichi Yasutake, Benjamin Herrenschmidt, Paul Mackerras

[+cc David, Michal, Koichi, Ben, Paul]

On Fri, Dec 7, 2012 at 12:15 AM, Yinghai Lu <yinghai@kernel.org> wrote:
> On Sat, Nov 3, 2012 at 9:39 PM, Yinghai Lu <yinghai@kernel.org> wrote:
>> For root bus hot add, fw could assign some resource for the devices for
>> that root bus before notifying os via acpi, we should check and use those
>> resources at first just like we do for booting path.
>>
>> At first, we need to refactor x86 pci pcibios_allocate related functions
>> for booting path to take bus as parameter.
>>
>> After that, we could use the survey function for hot add root bus.
>>
>> based on pci/yinghai-for-pci-root-bus-hotplug
>>
>> could get from
>>         git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git for-pci-survey-resources
>>
>> Yinghai Lu (8):
>>   PCI, x86: Separate out pcibios_allocate_bridge_resources()
>>   PCI, x86: Separate out pcibios_allocate_dev_resources()
>>   PCI, x86: Let pcibios_allocate_bus_resources() take bus instead
>>   PCI, x86: Separate out rom resource claim
>>   PCI, x86: Add pcibios_fw_addr_done
>>   PCI, x86: Remove __init for hw/fw allocated functions
>>   PCI, x86: Claim FW allocated resources in hot add path.
>>   PCI, ACPI: reserve fw allocated resource for hot added root bus
>>
>>  arch/x86/pci/i386.c     |  185 +++++++++++++++++++++++++++++++----------------
>>  drivers/acpi/pci_root.c |    4 +-
>>  drivers/pci/bus.c       |    2 +
>>  include/linux/pci.h     |    1 +
>>  4 files changed, 127 insertions(+), 65 deletions(-)
>>
>
> Bjorn,
>
> Can you queue those 8 patches for v3.9 in pci tree?
>
> So I  could resend out other pci root hotplug patches.

I'm really sorry that it's taken me so long to get to these.

I applied these to my pci/yinghai-survey-resources branch.  I
re-ordered the last two and reworked some of the changelogs.

In general these look good.  My main concern is that they only touch
x86, without touching the similar code in frv, microblaze, mn10300,
and powerpc.

This code (pcibios_resource_survey(), pcibios_assign_resources(),
pcibios_allocate_resources(), pcibios_allocate_bus_resources()) was
obviously copied from x86 originally, and I'd like to preserve the
similarity between them.  It would be even better to refactor it so
it's actually *shared*, but I don't think that's a requirement right
now.

If we allow it to diverge now, it will make it harder to refactor and
harder to notice when bug fixes should be applied to all of them.  For
example, looking at pcibios_allocate_resources(), commit 575939cf5
added some SR-IOV support to x86.  Should similar code be added for
frv, microblaze, mn10300, and powerpc?

Anybody else have thoughts on this?

Bjorn

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
  2013-01-07 23:49     ` Bjorn Helgaas
@ 2013-01-08 17:57       ` Bjorn Helgaas
  2013-01-08 18:27         ` Yinghai Lu
  0 siblings, 1 reply; 24+ messages in thread
From: Bjorn Helgaas @ 2013-01-08 17:57 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu, linux-pci,
	linux-kernel, linux-acpi, David Howells, Michal Simek,
	Koichi Yasutake, Benjamin Herrenschmidt, Paul Mackerras

On Mon, Jan 7, 2013 at 4:49 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> [+cc David, Michal, Koichi, Ben, Paul]
>
> On Fri, Dec 7, 2012 at 12:15 AM, Yinghai Lu <yinghai@kernel.org> wrote:
>> On Sat, Nov 3, 2012 at 9:39 PM, Yinghai Lu <yinghai@kernel.org> wrote:
>>> For root bus hot add, fw could assign some resource for the devices for
>>> that root bus before notifying os via acpi, we should check and use those
>>> resources at first just like we do for booting path.
>>>
>>> At first, we need to refactor x86 pci pcibios_allocate related functions
>>> for booting path to take bus as parameter.
>>>
>>> After that, we could use the survey function for hot add root bus.
>>>
>>> based on pci/yinghai-for-pci-root-bus-hotplug
>>>
>>> could get from
>>>         git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git for-pci-survey-resources
>>>
>>> Yinghai Lu (8):
>>>   PCI, x86: Separate out pcibios_allocate_bridge_resources()
>>>   PCI, x86: Separate out pcibios_allocate_dev_resources()
>>>   PCI, x86: Let pcibios_allocate_bus_resources() take bus instead
>>>   PCI, x86: Separate out rom resource claim
>>>   PCI, x86: Add pcibios_fw_addr_done
>>>   PCI, x86: Remove __init for hw/fw allocated functions
>>>   PCI, x86: Claim FW allocated resources in hot add path.
>>>   PCI, ACPI: reserve fw allocated resource for hot added root bus
>>>
>>>  arch/x86/pci/i386.c     |  185 +++++++++++++++++++++++++++++++----------------
>>>  drivers/acpi/pci_root.c |    4 +-
>>>  drivers/pci/bus.c       |    2 +
>>>  include/linux/pci.h     |    1 +
>>>  4 files changed, 127 insertions(+), 65 deletions(-)
>>>
>>
>> Bjorn,
>>
>> Can you queue those 8 patches for v3.9 in pci tree?
>>
>> So I  could resend out other pci root hotplug patches.
>
> I'm really sorry that it's taken me so long to get to these.
>
> I applied these to my pci/yinghai-survey-resources branch.  I
> re-ordered the last two and reworked some of the changelogs.

To be clear about this, the pci/yinghai-survey-resources branch I
mentioned is a staging branch that just gets build test coverage.  I
don't plan to actually merge this or put it into -next until the
questions below are resolved.

My inclination, until I'm persuaded otherwise, is to wait for patches
that preserve the similarities among these architectures.

> In general these look good.  My main concern is that they only touch
> x86, without touching the similar code in frv, microblaze, mn10300,
> and powerpc.
>
> This code (pcibios_resource_survey(), pcibios_assign_resources(),
> pcibios_allocate_resources(), pcibios_allocate_bus_resources()) was
> obviously copied from x86 originally, and I'd like to preserve the
> similarity between them.  It would be even better to refactor it so
> it's actually *shared*, but I don't think that's a requirement right
> now.
>
> If we allow it to diverge now, it will make it harder to refactor and
> harder to notice when bug fixes should be applied to all of them.  For
> example, looking at pcibios_allocate_resources(), commit 575939cf5
> added some SR-IOV support to x86.  Should similar code be added for
> frv, microblaze, mn10300, and powerpc?
>
> Anybody else have thoughts on this?
>
> Bjorn

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
  2013-01-08 17:57       ` Bjorn Helgaas
@ 2013-01-08 18:27         ` Yinghai Lu
  2013-01-09 17:35           ` Bjorn Helgaas
  0 siblings, 1 reply; 24+ messages in thread
From: Yinghai Lu @ 2013-01-08 18:27 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu, linux-pci,
	linux-kernel, linux-acpi, David Howells, Michal Simek,
	Koichi Yasutake, Benjamin Herrenschmidt, Paul Mackerras

On Tue, Jan 8, 2013 at 9:57 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>> I'm really sorry that it's taken me so long to get to these.
>>
>> I applied these to my pci/yinghai-survey-resources branch.  I
>> re-ordered the last two and reworked some of the changelogs.
>
> To be clear about this, the pci/yinghai-survey-resources branch I
> mentioned is a staging branch that just gets build test coverage.  I
> don't plan to actually merge this or put it into -next until the
> questions below are resolved.
>
> My inclination, until I'm persuaded otherwise, is to wait for patches
> that preserve the similarities among these architectures.

I don't know, that could be separated patcheset after we conclude
pci root bus hotplug support.

>
>> In general these look good.  My main concern is that they only touch
>> x86, without touching the similar code in frv, microblaze, mn10300,
>> and powerpc.
>>
>> This code (pcibios_resource_survey(), pcibios_assign_resources(),
>> pcibios_allocate_resources(), pcibios_allocate_bus_resources()) was
>> obviously copied from x86 originally, and I'd like to preserve the
>> similarity between them.  It would be even better to refactor it so
>> it's actually *shared*, but I don't think that's a requirement right
>> now.

yes, should be moved to drivers/pci

>>
>> If we allow it to diverge now, it will make it harder to refactor and
>> harder to notice when bug fixes should be applied to all of them.  For
>> example, looking at pcibios_allocate_resources(), commit 575939cf5
>> added some SR-IOV support to x86.  Should similar code be added for
>> frv, microblaze, mn10300, and powerpc?

should be treated the same.

>>
>> Anybody else have thoughts on this?
>>
>> Bjorn

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
  2013-01-08 18:27         ` Yinghai Lu
@ 2013-01-09 17:35           ` Bjorn Helgaas
  2013-01-09 17:53             ` Yinghai Lu
  0 siblings, 1 reply; 24+ messages in thread
From: Bjorn Helgaas @ 2013-01-09 17:35 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu, linux-pci,
	linux-kernel, linux-acpi, David Howells, Michal Simek,
	Koichi Yasutake, Benjamin Herrenschmidt, Paul Mackerras

On Tue, Jan 8, 2013 at 11:27 AM, Yinghai Lu <yinghai@kernel.org> wrote:
> On Tue, Jan 8, 2013 at 9:57 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>>> I'm really sorry that it's taken me so long to get to these.
>>>
>>> I applied these to my pci/yinghai-survey-resources branch.  I
>>> re-ordered the last two and reworked some of the changelogs.
>>
>> To be clear about this, the pci/yinghai-survey-resources branch I
>> mentioned is a staging branch that just gets build test coverage.  I
>> don't plan to actually merge this or put it into -next until the
>> questions below are resolved.
>>
>> My inclination, until I'm persuaded otherwise, is to wait for patches
>> that preserve the similarities among these architectures.
>
> I don't know, that could be separated patcheset after we conclude
> pci root bus hotplug support.

The main reason I review patches before merging them is to identify
issues that we can fix before they affect everybody.  It makes my life
a lot easier if I don't have to keep track of pending unaddressed
review comments.  Is there an advantage to waiting and doing this work
later?

>>> In general these look good.  My main concern is that they only touch
>>> x86, without touching the similar code in frv, microblaze, mn10300,
>>> and powerpc.
>>>
>>> This code (pcibios_resource_survey(), pcibios_assign_resources(),
>>> pcibios_allocate_resources(), pcibios_allocate_bus_resources()) was
>>> obviously copied from x86 originally, and I'd like to preserve the
>>> similarity between them.  It would be even better to refactor it so
>>> it's actually *shared*, but I don't think that's a requirement right
>>> now.
>
> yes, should be moved to drivers/pci
>
>>>
>>> If we allow it to diverge now, it will make it harder to refactor and
>>> harder to notice when bug fixes should be applied to all of them.  For
>>> example, looking at pcibios_allocate_resources(), commit 575939cf5
>>> added some SR-IOV support to x86.  Should similar code be added for
>>> frv, microblaze, mn10300, and powerpc?
>
> should be treated the same.
>
>>>
>>> Anybody else have thoughts on this?
>>>
>>> Bjorn

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
  2013-01-09 17:35           ` Bjorn Helgaas
@ 2013-01-09 17:53             ` Yinghai Lu
  2013-01-09 18:39               ` Bjorn Helgaas
  0 siblings, 1 reply; 24+ messages in thread
From: Yinghai Lu @ 2013-01-09 17:53 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu, linux-pci,
	linux-kernel, linux-acpi, David Howells, Michal Simek,
	Koichi Yasutake, Benjamin Herrenschmidt, Paul Mackerras

On Wed, Jan 9, 2013 at 9:35 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>> I don't know, that could be separated patcheset after we conclude
>> pci root bus hotplug support.
>
> The main reason I review patches before merging them is to identify
> issues that we can fix before they affect everybody.  It makes my life
> a lot easier if I don't have to keep track of pending unaddressed
> review comments.  Is there an advantage to waiting and doing this work
> later?
>
>>>> In general these look good.  My main concern is that they only touch
>>>> x86, without touching the similar code in frv, microblaze, mn10300,
>>>> and powerpc.

the reason why we need to change those codes for x86, we want to make it support
pci root bus hotplug. So it would be reasonable for us to align other
platform to x86
changes after pci root bus hotplug change is completely done.
Also I have for_dev_each_res patches rely on this patchset.
After those done, we can move the code from x86 to drivers/pci and delete
other arches code one by one.

Yinghai

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
  2013-01-09 17:53             ` Yinghai Lu
@ 2013-01-09 18:39               ` Bjorn Helgaas
  2013-01-09 19:01                 ` Yinghai Lu
                                   ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: Bjorn Helgaas @ 2013-01-09 18:39 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu, linux-pci,
	linux-kernel, linux-acpi, David Howells, Michal Simek,
	Koichi Yasutake, Benjamin Herrenschmidt, Paul Mackerras

On Wed, Jan 9, 2013 at 10:53 AM, Yinghai Lu <yinghai@kernel.org> wrote:
> On Wed, Jan 9, 2013 at 9:35 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>>> I don't know, that could be separated patcheset after we conclude
>>> pci root bus hotplug support.
>>
>> The main reason I review patches before merging them is to identify
>> issues that we can fix before they affect everybody.  It makes my life
>> a lot easier if I don't have to keep track of pending unaddressed
>> review comments.  Is there an advantage to waiting and doing this work
>> later?
>>
>>>>> In general these look good.  My main concern is that they only touch
>>>>> x86, without touching the similar code in frv, microblaze, mn10300,
>>>>> and powerpc.
>
> the reason why we need to change those codes for x86, we want to make it support
> pci root bus hotplug. So it would be reasonable for us to align other
> platform to x86
> changes after pci root bus hotplug change is completely done.

OK, I opened https://bugzilla.kernel.org/show_bug.cgi?id=52531 as a
way to keep track of this consistency issue and merged
pci/yinghai-survey-resources to my -next branch.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
  2013-01-09 18:39               ` Bjorn Helgaas
@ 2013-01-09 19:01                 ` Yinghai Lu
  2013-01-09 20:10                   ` Rafael J. Wysocki
  2013-01-09 20:59                 ` Benjamin Herrenschmidt
  2013-07-02 21:31                 ` Bjorn Helgaas
  2 siblings, 1 reply; 24+ messages in thread
From: Yinghai Lu @ 2013-01-09 19:01 UTC (permalink / raw)
  To: Bjorn Helgaas, Rafael J. Wysocki
  Cc: Len Brown, Taku Izumi, Jiang Liu, linux-pci, linux-kernel,
	linux-acpi, David Howells, Michal Simek, Koichi Yasutake,
	Benjamin Herrenschmidt, Paul Mackerras

On Wed, Jan 9, 2013 at 10:39 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>> the reason why we need to change those codes for x86, we want to make it support
>> pci root bus hotplug. So it would be reasonable for us to align other
>> platform to x86
>> changes after pci root bus hotplug change is completely done.
>
> OK, I opened https://bugzilla.kernel.org/show_bug.cgi?id=52531 as a
> way to keep track of this consistency issue and merged
> pci/yinghai-survey-resources to my -next branch.

Thanks a lot. will send other pci root bus hotplug out.

question: now Rafael's tree has acpi-scan branch and it touches pci-root.c.

so is it ok for me to base patches on your pci/next and his pm/acpi-scan?
how?
can you two have some arrangement like you pulling Rafael's branch?

Thanks

Yinghai

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
  2013-01-09 19:01                 ` Yinghai Lu
@ 2013-01-09 20:10                   ` Rafael J. Wysocki
  2013-01-10  0:34                     ` Bjorn Helgaas
  0 siblings, 1 reply; 24+ messages in thread
From: Rafael J. Wysocki @ 2013-01-09 20:10 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Bjorn Helgaas, Len Brown, Taku Izumi, Jiang Liu, linux-pci,
	linux-kernel, linux-acpi, David Howells, Michal Simek,
	Koichi Yasutake, Benjamin Herrenschmidt, Paul Mackerras

On Wednesday, January 09, 2013 11:01:39 AM Yinghai Lu wrote:
> On Wed, Jan 9, 2013 at 10:39 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> >> the reason why we need to change those codes for x86, we want to make it support
> >> pci root bus hotplug. So it would be reasonable for us to align other
> >> platform to x86
> >> changes after pci root bus hotplug change is completely done.
> >
> > OK, I opened https://bugzilla.kernel.org/show_bug.cgi?id=52531 as a
> > way to keep track of this consistency issue and merged
> > pci/yinghai-survey-resources to my -next branch.
> 
> Thanks a lot. will send other pci root bus hotplug out.
> 
> question: now Rafael's tree has acpi-scan branch and it touches pci-root.c.
> 
> so is it ok for me to base patches on your pci/next and his pm/acpi-scan?
> how?
> can you two have some arrangement like you pulling Rafael's branch?

My acpi-scan branch is not going to be rebased going forward, so it can be
pulled from safely if that helps.

Thanks,
Rafael


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
  2013-01-09 18:39               ` Bjorn Helgaas
  2013-01-09 19:01                 ` Yinghai Lu
@ 2013-01-09 20:59                 ` Benjamin Herrenschmidt
  2013-07-02 21:31                 ` Bjorn Helgaas
  2 siblings, 0 replies; 24+ messages in thread
From: Benjamin Herrenschmidt @ 2013-01-09 20:59 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Yinghai Lu, Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu,
	linux-pci, linux-kernel, linux-acpi, David Howells, Michal Simek,
	Koichi Yasutake, Paul Mackerras

On Wed, 2013-01-09 at 11:39 -0700, Bjorn Helgaas wrote:
> 
> > the reason why we need to change those codes for x86, we want to
> make it support
> > pci root bus hotplug. So it would be reasonable for us to align
> other
> > platform to x86
> > changes after pci root bus hotplug change is completely done.
> 
> OK, I opened https://bugzilla.kernel.org/show_bug.cgi?id=52531 as a
> way to keep track of this consistency issue and merged
> pci/yinghai-survey-resources to my -next branch.

Hrm... that's going to be tricky. For example the SR-IOV stuff will not
work for us, we are working on a different implementation, due to some
of "interesting" bridge constraints etc...

It would be nice to get more of the resource survey in common, our
original code was actually completely different and I reconciled it a
lot with x86 in the past few years, but I'm sure we can do better.
However there are still going to be corner cases....

Ben.



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
  2013-01-09 20:10                   ` Rafael J. Wysocki
@ 2013-01-10  0:34                     ` Bjorn Helgaas
  2013-01-10 13:07                       ` Rafael J. Wysocki
  0 siblings, 1 reply; 24+ messages in thread
From: Bjorn Helgaas @ 2013-01-10  0:34 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Yinghai Lu, Len Brown, Taku Izumi, Jiang Liu, linux-pci,
	linux-kernel, linux-acpi, David Howells, Michal Simek,
	Koichi Yasutake, Benjamin Herrenschmidt, Paul Mackerras

On Wed, Jan 9, 2013 at 1:10 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> On Wednesday, January 09, 2013 11:01:39 AM Yinghai Lu wrote:
>> On Wed, Jan 9, 2013 at 10:39 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>> >> the reason why we need to change those codes for x86, we want to make it support
>> >> pci root bus hotplug. So it would be reasonable for us to align other
>> >> platform to x86
>> >> changes after pci root bus hotplug change is completely done.
>> >
>> > OK, I opened https://bugzilla.kernel.org/show_bug.cgi?id=52531 as a
>> > way to keep track of this consistency issue and merged
>> > pci/yinghai-survey-resources to my -next branch.
>>
>> Thanks a lot. will send other pci root bus hotplug out.
>>
>> question: now Rafael's tree has acpi-scan branch and it touches pci-root.c.
>>
>> so is it ok for me to base patches on your pci/next and his pm/acpi-scan?
>> how?
>> can you two have some arrangement like you pulling Rafael's branch?
>
> My acpi-scan branch is not going to be rebased going forward, so it can be
> pulled from safely if that helps.

I'm happy to do that, but it is outside the scope of my limited git
experience.  My guess is that I should do this (doing the pull into a
branch which I later merge into my -next branch):

  $ git checkout -b pci/yinghai-survey-resources+acpi-scan
pci/yinghai-survey-resources
  $ git pull --no-ff --log
git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git
acpi-scan
  $ vi drivers/acpi/pci_root.c    # resolve conflicts
  $ git add drivers/acpi/pci_root.c
  $ git commit

  $ git checkout next
  $ git merge --no-ff --log pci/yinghai-survey-resources+acpi-scan

Is that reasonable?  This won't cause issues when both Rafael and I
ask Linus to pull from our trees later?

Bjorn

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
  2013-01-10  0:34                     ` Bjorn Helgaas
@ 2013-01-10 13:07                       ` Rafael J. Wysocki
  2013-01-10 14:49                         ` Bjorn Helgaas
  0 siblings, 1 reply; 24+ messages in thread
From: Rafael J. Wysocki @ 2013-01-10 13:07 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Yinghai Lu, Len Brown, Taku Izumi, Jiang Liu, linux-pci,
	linux-kernel, linux-acpi, David Howells, Michal Simek,
	Koichi Yasutake, Benjamin Herrenschmidt, Paul Mackerras

On Wednesday, January 09, 2013 05:34:32 PM Bjorn Helgaas wrote:
> On Wed, Jan 9, 2013 at 1:10 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> > On Wednesday, January 09, 2013 11:01:39 AM Yinghai Lu wrote:
> >> On Wed, Jan 9, 2013 at 10:39 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> >> >> the reason why we need to change those codes for x86, we want to make it support
> >> >> pci root bus hotplug. So it would be reasonable for us to align other
> >> >> platform to x86
> >> >> changes after pci root bus hotplug change is completely done.
> >> >
> >> > OK, I opened https://bugzilla.kernel.org/show_bug.cgi?id=52531 as a
> >> > way to keep track of this consistency issue and merged
> >> > pci/yinghai-survey-resources to my -next branch.
> >>
> >> Thanks a lot. will send other pci root bus hotplug out.
> >>
> >> question: now Rafael's tree has acpi-scan branch and it touches pci-root.c.
> >>
> >> so is it ok for me to base patches on your pci/next and his pm/acpi-scan?
> >> how?
> >> can you two have some arrangement like you pulling Rafael's branch?
> >
> > My acpi-scan branch is not going to be rebased going forward, so it can be
> > pulled from safely if that helps.
> 
> I'm happy to do that, but it is outside the scope of my limited git
> experience.  My guess is that I should do this (doing the pull into a
> branch which I later merge into my -next branch):
> 
>   $ git checkout -b pci/yinghai-survey-resources+acpi-scan
> pci/yinghai-survey-resources
>   $ git pull --no-ff --log
> git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git
> acpi-scan
>   $ vi drivers/acpi/pci_root.c    # resolve conflicts
>   $ git add drivers/acpi/pci_root.c
>   $ git commit
> 
>   $ git checkout next
>   $ git merge --no-ff --log pci/yinghai-survey-resources+acpi-scan
> 
> Is that reasonable?

Yes, it looks reasonable.

> This won't cause issues when both Rafael and I ask Linus to pull from our
> trees later?

No, it won't, as long as I don't rebase the original acpi-scan branch (which
I'm not going to do) and you don't rebase your
pci/yinghai-survey-resources+acpi-scan branch going forward.

The pull makes your tree contain the same commits (i.e. commit IDs along with
the data) that are in my acpi-scan branch, so when Linus merges them together,
git will notice that the commits are the same.

Thanks,
Rafael


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
  2013-01-10 13:07                       ` Rafael J. Wysocki
@ 2013-01-10 14:49                         ` Bjorn Helgaas
  0 siblings, 0 replies; 24+ messages in thread
From: Bjorn Helgaas @ 2013-01-10 14:49 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Yinghai Lu, Len Brown, Taku Izumi, Jiang Liu, linux-pci,
	linux-kernel, linux-acpi, David Howells, Michal Simek,
	Koichi Yasutake, Benjamin Herrenschmidt, Paul Mackerras

On Thu, Jan 10, 2013 at 6:07 AM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> On Wednesday, January 09, 2013 05:34:32 PM Bjorn Helgaas wrote:
>> On Wed, Jan 9, 2013 at 1:10 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
>> > On Wednesday, January 09, 2013 11:01:39 AM Yinghai Lu wrote:
>> >> On Wed, Jan 9, 2013 at 10:39 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>> >> >> the reason why we need to change those codes for x86, we want to make it support
>> >> >> pci root bus hotplug. So it would be reasonable for us to align other
>> >> >> platform to x86
>> >> >> changes after pci root bus hotplug change is completely done.
>> >> >
>> >> > OK, I opened https://bugzilla.kernel.org/show_bug.cgi?id=52531 as a
>> >> > way to keep track of this consistency issue and merged
>> >> > pci/yinghai-survey-resources to my -next branch.
>> >>
>> >> Thanks a lot. will send other pci root bus hotplug out.
>> >>
>> >> question: now Rafael's tree has acpi-scan branch and it touches pci-root.c.
>> >>
>> >> so is it ok for me to base patches on your pci/next and his pm/acpi-scan?
>> >> how?
>> >> can you two have some arrangement like you pulling Rafael's branch?
>> >
>> > My acpi-scan branch is not going to be rebased going forward, so it can be
>> > pulled from safely if that helps.
>>
>> I'm happy to do that, but it is outside the scope of my limited git
>> experience.  My guess is that I should do this (doing the pull into a
>> branch which I later merge into my -next branch):
>>
>>   $ git checkout -b pci/yinghai-survey-resources+acpi-scan
>> pci/yinghai-survey-resources
>>   $ git pull --no-ff --log
>> git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git
>> acpi-scan
>>   $ vi drivers/acpi/pci_root.c    # resolve conflicts
>>   $ git add drivers/acpi/pci_root.c
>>   $ git commit
>>
>>   $ git checkout next
>>   $ git merge --no-ff --log pci/yinghai-survey-resources+acpi-scan
>>
>> Is that reasonable?
>
> Yes, it looks reasonable.
>
>> This won't cause issues when both Rafael and I ask Linus to pull from our
>> trees later?
>
> No, it won't, as long as I don't rebase the original acpi-scan branch (which
> I'm not going to do) and you don't rebase your
> pci/yinghai-survey-resources+acpi-scan branch going forward.
>
> The pull makes your tree contain the same commits (i.e. commit IDs along with
> the data) that are in my acpi-scan branch, so when Linus merges them together,
> git will notice that the commits are the same.

OK, I did the above, merged it into my -next branch, and pushed it.
Let me know if you see any issues.

Bjorn

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
  2013-01-09 18:39               ` Bjorn Helgaas
  2013-01-09 19:01                 ` Yinghai Lu
  2013-01-09 20:59                 ` Benjamin Herrenschmidt
@ 2013-07-02 21:31                 ` Bjorn Helgaas
  2013-07-02 22:55                   ` Yinghai Lu
  2 siblings, 1 reply; 24+ messages in thread
From: Bjorn Helgaas @ 2013-07-02 21:31 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu, linux-pci,
	linux-kernel, linux-acpi

On Wed, Jan 9, 2013 at 11:39 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> On Wed, Jan 9, 2013 at 10:53 AM, Yinghai Lu <yinghai@kernel.org> wrote:

>> the reason why we need to change those codes for x86, we want to make it support
>> pci root bus hotplug. So it would be reasonable for us to align other
>> platform to x86
>> changes after pci root bus hotplug change is completely done.
>
> OK, I opened https://bugzilla.kernel.org/show_bug.cgi?id=52531 as a
> way to keep track of this consistency issue ...

What's your plan for this?  We desperately need more cross-arch
consistency in how we manage resources, and I'd like to make some
progress in this cycle.

Bjorn

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
  2013-07-02 21:31                 ` Bjorn Helgaas
@ 2013-07-02 22:55                   ` Yinghai Lu
  0 siblings, 0 replies; 24+ messages in thread
From: Yinghai Lu @ 2013-07-02 22:55 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu, linux-pci,
	linux-kernel, linux-acpi

[-- Attachment #1: Type: text/plain, Size: 955 bytes --]

On Tue, Jul 2, 2013 at 2:31 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> On Wed, Jan 9, 2013 at 11:39 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>> On Wed, Jan 9, 2013 at 10:53 AM, Yinghai Lu <yinghai@kernel.org> wrote:
>
>>> the reason why we need to change those codes for x86, we want to make it support
>>> pci root bus hotplug. So it would be reasonable for us to align other
>>> platform to x86
>>> changes after pci root bus hotplug change is completely done.
>>
>> OK, I opened https://bugzilla.kernel.org/show_bug.cgi?id=52531 as a
>> way to keep track of this consistency issue ...
>
> What's your plan for this?  We desperately need more cross-arch
> consistency in how we manage resources, and I'd like to make some
> progress in this cycle.

Ok, will work on that.

but will on top of

[PATCH v5 0/7] PCI: Change assign unassigned resources per root bus bassis
and attached.

will resend them after v3.11-rc1 is out.

Thanks

Yinghai

[-- Attachment #2: root_bus_ioport_skip_2_a.patch --]
[-- Type: application/octet-stream, Size: 1298 bytes --]

Subject: [PATCH] PCI: check pci bus address for unassigned res

We should compare res->start with root bus window offset.
Otherwise will have problem with arch that support hostbridge
resource offset.

BenH pointed out that during reviewing patchset that separate
assign unassigned to per root buses.

According to Bjorn, have it in separated patch.

Use pcibios_resource_to_bus to get region at first, and check
region.start instead.

Suggested-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
 drivers/pci/setup-bus.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Index: linux-2.6/drivers/pci/setup-bus.c
===================================================================
--- linux-2.6.orig/drivers/pci/setup-bus.c
+++ linux-2.6/drivers/pci/setup-bus.c
@@ -1420,9 +1420,14 @@ static int check_unassigned_resources(st
 
 	for (i = PCI_IOV_RESOURCES; i <= PCI_IOV_RESOURCE_END; i++) {
 		struct resource *r = &dev->resource[i];
+		struct pci_bus_region region;
 
 		/* Not assigned, or rejected by kernel ? */
-		if (r->flags && !r->start) {
+		if (!r->flags)
+			continue;
+
+		pcibios_resource_to_bus(dev, &region, r);
+		if (!region.start) {
 			(*unassigned)++;
 			return 1; /* return early from pci_walk_bus */
 		}

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2013-07-02 22:55 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20121030040237.GA10472@google.com>
2012-11-04  4:39 ` [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus Yinghai Lu
2012-11-04  4:39   ` [PATCH 1/8] PCI, x86: Separate out pcibios_allocate_bridge_resources() Yinghai Lu
2012-11-04  4:39   ` [PATCH 2/8] PCI, x86: Separate out pcibios_allocate_dev_resources() Yinghai Lu
2012-11-04  4:39   ` [PATCH 3/8] PCI, x86: Let pcibios_allocate_bus_resources() take bus instead Yinghai Lu
2012-11-04  4:39   ` [PATCH 4/8] PCI, x86: Separate out rom resource claim Yinghai Lu
2012-11-04  4:39   ` [PATCH 5/8] PCI, x86: Add pcibios_fw_addr_done Yinghai Lu
2012-11-04  4:39   ` [PATCH 6/8] PCI, x86: Remove __init for hw/fw allocated functions Yinghai Lu
2012-11-04  4:39   ` [PATCH 7/8] PCI, x86: Claim FW allocated resources in hot add path Yinghai Lu
2012-11-04  4:39   ` [PATCH 8/8] PCI, ACPI: reserve fw allocated resource for hot added root bus Yinghai Lu
2012-12-07  7:15   ` [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add " Yinghai Lu
2013-01-07 23:49     ` Bjorn Helgaas
2013-01-08 17:57       ` Bjorn Helgaas
2013-01-08 18:27         ` Yinghai Lu
2013-01-09 17:35           ` Bjorn Helgaas
2013-01-09 17:53             ` Yinghai Lu
2013-01-09 18:39               ` Bjorn Helgaas
2013-01-09 19:01                 ` Yinghai Lu
2013-01-09 20:10                   ` Rafael J. Wysocki
2013-01-10  0:34                     ` Bjorn Helgaas
2013-01-10 13:07                       ` Rafael J. Wysocki
2013-01-10 14:49                         ` Bjorn Helgaas
2013-01-09 20:59                 ` Benjamin Herrenschmidt
2013-07-02 21:31                 ` Bjorn Helgaas
2013-07-02 22:55                   ` Yinghai Lu

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).