Skip to contentSkip to conversation

minimal alignment for p2p bars

PATCH RESEND Superseded Gavin Shan 2 participants 12 messages Jul 25, 2012 – Aug 17, 2012

Subsystems (2)

v7 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Gavin Shan

author
#0 lore raw

v7 cover minimal alignment for p2p bars

v1 -> v2:
* Shorten the varaible names so that they looks more short.
* Changelog adjustment so that they looks more meaningful.

v2 -> v3:
* Rebase to 3.5.RC4

v3 -> v4:
* Merge Yinghai's patches.

v3 -> v4:
* Split patch for easy review.
* Add function to retrieve the minimal alignment of p2p bridge.

v4 -> v5:
* Rebase to 3.5.RC7
* Introduce weak function pcibios_window_alignment() to retrieve I/O and memory alignment for P2P bridges.
* Introduce pcibios_window_alignment() for ppc to override the PCI function.
* Add ppc_md.pcibios_window_alignment() for specific platform like powernv can override ppc's pcibios_window_alignment().

v5 -> v6:
* Refactor pcibios_window_alignment() so the platform-specific implementation needn't return the default alignment according to Bjorn's suggestion.
* Simplify pbus_size_mem() according to Bjorn's suggestion: Just check the platform required alignment at very end and adjust the "min_align" if necessary.

v6 -> v7:
* Change "type" to "b_res->flags & mask" while retrieving the minimal alignment for memory window according to Ram's suggestion.
* Refactor pbus_size_mem() according to Ram's suggestion.
* ppc_md.pcibios_window_alignment returns 1 for those PCI bridges behind PCI bridges so that PCI core will use default alignment values.

Lu Yinghai(3):
pci: change variable name for find_pci_host_bridge
pci: argument pci_bus for find_pci_host_bridge
pci: fiddle with conversion of pci and CPU address

Gavin Shan(5)
pci: weak function returns alignment
pci: resource assignment based on p2p alignment
pci: refactor function pbus_size_mem ppc/pci: override pcibios_window_alignment ppc/pnv: I/O and memory alignment for p2p bridges

-----

arch/powerpc/include/asm/machdep.h        |    3 +
arch/powerpc/kernel/pci-common.c          |   20 ++++++++
arch/powerpc/platforms/powernv/pci-ioda.c |   38 ++++++++++++++++
drivers/pci/host-bridge.c                 |   35 ++++++++++-----
drivers/pci/setup-bus.c                   |   68 ++++++++++++++++++++++-------
include/linux/pci.h                       |    7 +++-
6 files changed, 142 insertions(+), 29 deletions(-)

Thanks,
Gavin

author
#1 lore raw

PATCH v7 1/8 pci: change variable name for find_pci_host_bridge

The patch changes the variable name for function find_pci_host_bridge() so that it looks more meaningful. More specificly, the "bus" has been replaced with "root_bus".

---
 drivers/pci/host-bridge.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/pci/host-bridge.c +2 -2
index a68dc61..c19776a 100644
@@ -22,9 +22,9 @@ static struct pci_bus *find_pci_root_bus(struct pci_dev *dev)
 
 static struct pci_host_bridge *find_pci_host_bridge(struct pci_dev *dev)
 {
-	struct pci_bus *bus = find_pci_root_bus(dev);
+	struct pci_bus *root_bus = find_pci_root_bus(dev);
 
-	return to_pci_host_bridge(bus->bridge);
+	return to_pci_host_bridge(root_bus->bridge);
 }
 
 void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
Signature · 1 line
1.7.5.4
author
#7 lore raw

PATCH v7 5/8 pci: resource assignment based on p2p alignment

In reply to Gavin Shan

The patch changes function pbus_size_io() and pbus_size_mem() to do resource (I/O, memory and prefetchable memory) reassignment based on the minimal alignments for the p2p bridge, which was retrieved by function window_alignment().

---
 drivers/pci/setup-bus.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
drivers/pci/setup-bus.c +9 -4
index c0fb9da..ca885ff 100644
@@ -731,6 +731,7 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size,
 	struct resource *b_res = find_free_bus_resource(bus, IORESOURCE_IO);
 	unsigned long size = 0, size0 = 0, size1 = 0;
 	resource_size_t children_add_size = 0;
+	resource_size_t io_align;
 
 	if (!b_res)
  		return;
@@ -756,13 +757,15 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size,
 				children_add_size += get_res_add_size(realloc_head, r);
 		}
 	}
+
+	io_align = window_alignment(bus, IORESOURCE_IO);
 	size0 = calculate_iosize(size, min_size, size1,
-			resource_size(b_res), 4096);
+			resource_size(b_res), io_align);
 	if (children_add_size > add_size)
 		add_size = children_add_size;
 	size1 = (!realloc_head || (realloc_head && !add_size)) ? size0 :
 		calculate_iosize(size, min_size, add_size + size1,
-			resource_size(b_res), 4096);
+			resource_size(b_res), io_align);
 	if (!size0 && !size1) {
 		if (b_res->start || b_res->end)
 			dev_info(&bus->self->dev, "disabling bridge window "
@@ -772,11 +775,11 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size,
 		return;
 	}
 	/* Alignment of the IO window is always 4K */
-	b_res->start = 4096;
+	b_res->start = io_align;
 	b_res->end = b_res->start + size0 - 1;
 	b_res->flags |= IORESOURCE_STARTALIGN;
 	if (size1 > size0 && realloc_head) {
-		add_to_list(realloc_head, bus->self, b_res, size1-size0, 4096);
+		add_to_list(realloc_head, bus->self, b_res, size1-size0, io_align);
 		dev_printk(KERN_DEBUG, &bus->self->dev, "bridge window "
 				 "%pR to [bus %02x-%02x] add_size %lx\n", b_res,
 				 bus->secondary, bus->subordinate, size1-size0);
@@ -875,6 +878,8 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
 			min_align = align1 >> 1;
 		align += aligns[order];
 	}
+
+	min_align = max(min_align, window_alignment(bus, b_res->flags & mask));
 	size0 = calculate_memsize(size, min_size, 0, resource_size(b_res), min_align);
 	if (children_add_size > add_size)
 		add_size = children_add_size;
Signature · 1 line
1.7.5.4
author
#10 lore raw

PATCH v7 8/8 ppc/pnv: I/O and memory alignment for p2p bridges

In reply to Gavin Shan

The patch implements ppc_md.pcibios_window_alignment for powernv platform so that the resource reassignment in PCI core will be done according to the I/O and memory alignment returned from powernv platform. The alignments returned from powernv platform is closely depending on the scheme for PE segmenting. Besides, the patch isn't useful for now, but the subsequent patches will be working based on it.

---
 arch/powerpc/platforms/powernv/pci-ioda.c |   38 +++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)
arch/powerpc/platforms/powernv/pci-ioda.c +38 -0
index fbdd74d..159bce5 100644
@@ -1139,6 +1139,43 @@ static void __devinit pnv_pci_ioda_fixup_phb(struct pci_controller *hose)
 	}
 }
 
+/*
+ * Returns the alignment for I/O or memory windows for p2p
+ * bridges. That actually depends on how PEs are segmented.
+ * For now, we return I/O or M32 segment size for PE sensitive
+ * p2p bridges. Otherwise, the default values (4KiB for I/O,
+ * 1MiB for memory) will be returned.
+ */
+static resource_size_t pnv_pci_window_alignment(struct pci_bus *bus,
+						unsigned long type)
+{
+	struct pci_dev *dev = bus->self;
+	struct pci_controller *hose = pci_bus_to_host(bus);
+	struct pnv_phb *phb = hose->private_data;
+
+	/* PCI root bus will be assigned with segment size */
+	if (!dev)
+		goto out;
+
+	/*
+	 * If the parent bridge is PCI bridge, we will return
+	 * the default values
+	 */
+	dev = dev->bus->self;
+	if (!dev)
+		goto out;
+	if (dev->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE) {
+		return 1;
+	}
+
+out:
+	/* We need support prefetchable memory window later */
+	if (type & IORESOURCE_MEM)
+		return phb->ioda.m32_segsize;
+
+	return phb->ioda.io_segsize;
+}
+
 /* Prevent enabling devices for which we couldn't properly
  * assign a PE
  */
@@ -1306,6 +1343,7 @@ void __init pnv_pci_init_ioda1_phb(struct device_node *np)
 	 */
 	ppc_md.pcibios_fixup_phb = pnv_pci_ioda_fixup_phb;
 	ppc_md.pcibios_enable_device_hook = pnv_pci_enable_device_hook;
+	ppc_md.pcibios_window_alignment = pnv_pci_window_alignment;
 	pci_add_flags(PCI_PROBE_ONLY | PCI_REASSIGN_ALL_RSRC);
 
 	/* Reset IODA tables to a clean state */
Signature · 1 line
1.7.5.4
author
#2 lore raw

PATCH v7 2/8 pci: argument pci_bus for find_pci_host_bridge

In reply to Gavin Shan

The patch changes the argument of find_pci_host_bridge() to pci_bus.

---
 drivers/pci/host-bridge.c |   13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)
drivers/pci/host-bridge.c +5 -8
index c19776a..fc16357 100644
@@ -9,20 +9,17 @@
 
 #include "pci.h"
 
-static struct pci_bus *find_pci_root_bus(struct pci_dev *dev)
+static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)
 {
-	struct pci_bus *bus;
-
-	bus = dev->bus;
 	while (bus->parent)
 		bus = bus->parent;
 
 	return bus;
 }
 
-static struct pci_host_bridge *find_pci_host_bridge(struct pci_dev *dev)
+static struct pci_host_bridge *find_pci_host_bridge(struct pci_bus *bus)
 {
-	struct pci_bus *root_bus = find_pci_root_bus(dev);
+	struct pci_bus *root_bus = find_pci_root_bus(bus);
 
 	return to_pci_host_bridge(root_bus->bridge);
 }
@@ -43,7 +40,7 @@ static bool resource_contains(struct resource *res1, struct resource *res2)
 void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
 			     struct resource *res)
 {
-	struct pci_host_bridge *bridge = find_pci_host_bridge(dev);
+	struct pci_host_bridge *bridge = find_pci_host_bridge(dev->bus);
 	struct pci_host_bridge_window *window;
 	resource_size_t offset = 0;
 
@@ -71,7 +68,7 @@ static bool region_contains(struct pci_bus_region *region1,
 void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
 			     struct pci_bus_region *region)
 {
-	struct pci_host_bridge *bridge = find_pci_host_bridge(dev);
+	struct pci_host_bridge *bridge = find_pci_host_bridge(dev->bus);
 	struct pci_host_bridge_window *window;
 	resource_size_t offset = 0;
 
Signature · 1 line
1.7.5.4
author
#3 lore raw

PATCH v7 3/8 fiddle with conversion of pci and CPU address

In reply to Gavin Shan

The patch fiddles with the those functions used to do conversion between PCI and CPU address. More specificly, 2 functions are
involved: pcibios_bus_to_resource() and pcibios_resource_to_bus()

---
 drivers/pci/host-bridge.c |   24 +++++++++++++++++++-----
 include/linux/pci.h       |    5 ++++-
 2 files changed, 23 insertions(+), 6 deletions(-)
drivers/pci/host-bridge.c +19 -5
index fc16357..abcf053 100644
@@ -37,10 +37,10 @@ static bool resource_contains(struct resource *res1, struct resource *res2)
 	return res1->start <= res2->start && res1->end >= res2->end;
 }
 
-void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
-			     struct resource *res)
+void __pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
+			       struct resource *res)
 {
-	struct pci_host_bridge *bridge = find_pci_host_bridge(dev->bus);
+	struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
 	struct pci_host_bridge_window *window;
 	resource_size_t offset = 0;
 
@@ -57,6 +57,13 @@ void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
 	region->start = res->start - offset;
 	region->end = res->end - offset;
 }
+
+void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
+			     struct resource *res)
+{
+	__pcibios_resource_to_bus(dev->bus, region, res);
+}
+
 EXPORT_SYMBOL(pcibios_resource_to_bus);
 
 static bool region_contains(struct pci_bus_region *region1,
@@ -65,10 +72,10 @@ static bool region_contains(struct pci_bus_region *region1,
 	return region1->start <= region2->start && region1->end >= region2->end;
 }
 
-void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
+void __pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
 			     struct pci_bus_region *region)
 {
-	struct pci_host_bridge *bridge = find_pci_host_bridge(dev->bus);
+	struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
 	struct pci_host_bridge_window *window;
 	resource_size_t offset = 0;
 
@@ -90,4 +97,11 @@ void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
 	res->start = region->start + offset;
 	res->end = region->end + offset;
 }
+
+void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
+			     struct pci_bus_region *region)
+{
+	__pcibios_bus_to_resource(dev->bus, res, region);
+}
+
 EXPORT_SYMBOL(pcibios_bus_to_resource);
include/linux/pci.h +4 -1
index d8c379d..9acea4b 100644
@@ -654,9 +654,12 @@ void pcibios_update_irq(struct pci_dev *, int irq);
 void pci_fixup_cardbus(struct pci_bus *);
 
 /* Generic PCI functions used internally */
-
+void __pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
+				struct resource *res);
 void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
 			     struct resource *res);
+void __pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
+			       struct pci_bus_region *region);
 void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
 			     struct pci_bus_region *region);
 void pcibios_scan_specific_bus(int busn);
Signature · 1 line
1.7.5.4
author
#5 lore raw

PATCH v7 4/8 pci: weak function returns alignment

In reply to Gavin Shan

The patch implements the weak function to return the default I/O or memory alignment for P2P bridge. Currently, I/O window has 4KiB alignment and memory window is 4MiB aligned by default. On the other hand, those platforms (e.g. powernv) that have special requirements on the alignment could override the function by themselves.

---
 drivers/pci/setup-bus.c |   21 +++++++++++++++++++++
 include/linux/pci.h     |    2 ++
 2 files changed, 23 insertions(+), 0 deletions(-)
drivers/pci/setup-bus.c +21 -0
index 8fa2d4b..c0fb9da 100644
@@ -690,6 +690,27 @@ static resource_size_t calculate_memsize(resource_size_t size,
 	return size;
 }
 
+resource_size_t __weak pcibios_window_alignment(struct pci_bus *bus,
+						unsigned long type)
+{
+	return 1;
+}
+
+static resource_size_t window_alignment(struct pci_bus *bus,
+					unsigned long type)
+{
+	resource_size_t align = 1, arch_align;
+
+	if (type & IORESOURCE_MEM)
+		align = 1024*1024;	/* 1MiB */
+	else if (type & IORESOURCE_IO)
+		align = 4*1024;		/* 4KiB */
+
+	arch_align = pcibios_window_alignment(bus, type);
+
+	return max(align, arch_align);
+}
+
 /**
  * pbus_size_io() - size the io window of a given bus
  *
include/linux/pci.h +2 -0
index 9acea4b..34ff2bb 100644
@@ -988,6 +988,8 @@ int pci_cfg_space_size_ext(struct pci_dev *dev);
 int pci_cfg_space_size(struct pci_dev *dev);
 unsigned char pci_bus_max_busnr(struct pci_bus *bus);
 void pci_setup_bridge(struct pci_bus *bus);
+resource_size_t pcibios_window_alignment(struct pci_bus *bus,
+					 unsigned long type);
 
 #define PCI_VGA_STATE_CHANGE_BRIDGE (1 << 0)
 #define PCI_VGA_STATE_CHANGE_DECODES (1 << 1)
Signature · 1 line
1.7.5.4
author
#9 lore raw

PATCH v7 7/8 ppc/pci: override pcibios_window_alignment

In reply to Gavin Shan

Function pcibios_window_alignment() has been implemented as "weak" in PCI core to return the default alignment of I/O and memory windows for the associated p2p bridge. The patch adds same function to override the weak one so that the default alignment could be changed for those platforms (e.g. powernv).

---
 arch/powerpc/include/asm/machdep.h |    3 +++
 arch/powerpc/kernel/pci-common.c   |   20 ++++++++++++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/machdep.h +3 -0
index 42ce570..f7706d7 100644
@@ -214,6 +214,9 @@ struct machdep_calls {
 	/* Called after scan and before resource survey */
 	void (*pcibios_fixup_phb)(struct pci_controller *hose);
 
+	/* Called during PCI resource reassignment */
+	resource_size_t (*pcibios_window_alignment)(struct pci_bus *, unsigned long type);
+
 	/* Called to shutdown machine specific hardware not already controlled
 	 * by other drivers.
 	 */
arch/powerpc/kernel/pci-common.c +20 -0
index 8e78e93..776df07 100644
@@ -99,6 +99,26 @@ void pcibios_free_controller(struct pci_controller *phb)
 		kfree(phb);
 }
 
+/*
+ * The function is used to return the minimal alignment
+ * for memory or I/O windows of the associated P2P bridge.
+ * By default, 4KiB alignment for I/O windows and 1MiB for
+ * memory windows.
+ */
+resource_size_t pcibios_window_alignment(struct pci_bus *bus,
+					 unsigned long type)
+{
+	if (ppc_md.pcibios_window_alignment)
+		return ppc_md.pcibios_window_alignment(bus, type);
+
+	/*
+	 * PCI core will figure out the default
+	 * alignment: 4KiB for I/O and 1MiB for
+	 * memory window.
+	 */
+	return 1;
+}
+
 static resource_size_t pcibios_io_size(const struct pci_controller *hose)
 {
 #ifdef CONFIG_PPC64
Signature · 1 line
1.7.5.4
author
#8 lore raw

PATCH v7 6/8 pci: refactor function pbus_size_mem

In reply to Gavin Shan

The original idea comes from Ram Pai. The patch puts the chunk of code for calculating the minimal alignment of memory window into separate inline function.

---
 drivers/pci/setup-bus.c |   36 +++++++++++++++++++++++-------------
 1 files changed, 23 insertions(+), 13 deletions(-)
drivers/pci/setup-bus.c +23 -13
index ca885ff..bdb7bd5 100644
@@ -786,6 +786,28 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size,
 	}
 }
 
+static inline resource_size_t calculate_mem_align(resource_size_t *aligns,
+						  int max_order)
+{
+	resource_size_t align = 0;
+	resource_size_t min_align = 0;
+	int order;
+
+	for (order = 0; order <= max_order; order++) {
+		resource_size_t align1 = 1;
+
+		align1 <<= (order + 20);
+
+		if (!align)
+			min_align = align1;
+		else if (ALIGN(align + min_align, min_align) < align1)
+			min_align = align1 >> 1;
+		align += aligns[order];
+	}
+
+	return min_align;
+}
+
 /**
  * pbus_size_mem() - size the memory window of a given bus
  *
@@ -865,20 +887,8 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
 				children_add_size += get_res_add_size(realloc_head, r);
 		}
 	}
-	align = 0;
-	min_align = 0;
-	for (order = 0; order <= max_order; order++) {
-		resource_size_t align1 = 1;
-
-		align1 <<= (order + 20);
-
-		if (!align)
-			min_align = align1;
-		else if (ALIGN(align + min_align, min_align) < align1)
-			min_align = align1 >> 1;
-		align += aligns[order];
-	}
 
+	min_align = calculate_mem_align(aligns, max_order);
 	min_align = max(min_align, window_alignment(bus, b_res->flags & mask));
 	size0 = calculate_memsize(size, min_size, 0, resource_size(b_res), min_align);
 	if (children_add_size > add_size)
Signature · 1 line
1.7.5.4
#11 lore raw

Re: [PATCH 8/8] ppc/pnv: I/O and memory alignment for p2p bridges

In reply to Gavin Shan

2012/7/25 Gavin Shan <[email protected]>:

Quoted 29 lines

The patch implements ppc_md.pcibios_window_alignment for powernv platform so that the resource reassignment in PCI core will be done according to the I/O and memory alignment returned from powernv platform. The alignments returned from powernv platform is closely depending on the scheme for PE segmenting. Besides, the patch isn't useful for now, but the subsequent patches will be working based on it.

---
 arch/powerpc/platforms/powernv/pci-ioda.c |   38 +++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)
arch/powerpc/platforms/powernv/pci-ioda.c +8 -0
index fbdd74d..159bce5 100644
@@ -1139,6 +1139,43 @@ static void __devinit pnv_pci_ioda_fixup_phb(struct pci_controller *hose)
        }
 }
 
+/*
+ * Returns the alignment for I/O or memory windows for p2p
+ * bridges. That actually depends on how PEs are segmented.
+ * For now, we return I/O or M32 segment size for PE sensitive
+ * p2p bridges. Otherwise, the default values (4KiB for I/O,
+ * 1MiB for memory) will be returned.
+ */
+static resource_size_t pnv_pci_window_alignment(struct pci_bus *bus,

arch/powerpc/platforms/powernv/pci-ioda.c static void __devinit pnv_pci_ioda_fixup_phb(struct pci_controller *hose) · line 1159

Quoted 10 lines
arch/powerpc/platforms/powernv/pci-ioda.c +10 -0
+                                               unsigned long type)
+{
+       struct pci_dev *dev = bus->self;
+       struct pci_controller *hose = pci_bus_to_host(bus);
+       struct pnv_phb *phb = hose->private_data;
+
+       /* PCI root bus will be assigned with segment size */
+       if (!dev)
+               goto out;
+

there is a function, pci_is_root_bus() which is introduced in 79af72d7, to check whether
this bus is a root bus or not.

Quoted 37 lines
arch/powerpc/platforms/powernv/pci-ioda.c +20 -1
+       /*
+        * If the parent bridge is PCI bridge, we will return
+        * the default values
+        */
+       dev = dev->bus->self;
+       if (!dev)
+               goto out;
+       if (dev->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE) {
+               return 1;
+       }
+
+out:
+       /* We need support prefetchable memory window later */
+       if (type & IORESOURCE_MEM)
+               return phb->ioda.m32_segsize;
+
+       return phb->ioda.io_segsize;
+}
+
 /* Prevent enabling devices for which we couldn't properly
  * assign a PE
  */
@@ -1306,6 +1343,7 @@ void __init pnv_pci_init_ioda1_phb(struct device_node *np)
         */
        ppc_md.pcibios_fixup_phb = pnv_pci_ioda_fixup_phb;
        ppc_md.pcibios_enable_device_hook = pnv_pci_enable_device_hook;
+       ppc_md.pcibios_window_alignment = pnv_pci_window_alignment;
        pci_add_flags(PCI_PROBE_ONLY | PCI_REASSIGN_ALL_RSRC);
 
        /* Reset IODA tables to a clean state */
--

1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Richard Yang
Help You, Help Me
#6 lore raw

Re: [PATCH 4/8] pci: weak function returns alignment

In reply to Gavin Shan

2012/7/25 Gavin Shan <[email protected]>:

Quoted 26 lines

The patch implements the weak function to return the default I/O or memory alignment for P2P bridge. Currently, I/O window has 4KiB alignment and memory window is 4MiB aligned by default. On the other hand, those platforms (e.g. powernv) that have special requirements on the alignment could override the function by themselves.

---
 drivers/pci/setup-bus.c |   21 +++++++++++++++++++++
 include/linux/pci.h     |    2 ++
 2 files changed, 23 insertions(+), 0 deletions(-)
drivers/pci/setup-bus.c +6 -0
index 8fa2d4b..c0fb9da 100644
@@ -690,6 +690,27 @@ static resource_size_t calculate_memsize(resource_size_t size,
        return size;
 }
 
+resource_size_t __weak pcibios_window_alignment(struct pci_bus *bus,
+                                               unsigned long type)
+{
+       return 1;
+}
+

drivers/pci/setup-bus.c static resource_size_t calculate_memsize(resource_size_t size, · line 708

Quoted 10 lines
drivers/pci/setup-bus.c +10 -0
+static resource_size_t window_alignment(struct pci_bus *bus,
+                                       unsigned long type)
+{
+       resource_size_t align = 1, arch_align;
+
+       if (type & IORESOURCE_MEM)
+               align = 1024*1024;      /* 1MiB */
+       else if (type & IORESOURCE_IO)
+               align = 4*1024;         /* 4KiB */
+

If this is a constant, could we use define a macro? So we don't use to calculate the value every time. Maybe some compile will be smart enough to optimize this, still think it is better to give a result.

Quoted 28 lines
drivers/pci/setup-bus.c +5 -0
+       arch_align = pcibios_window_alignment(bus, type);
+
+       return max(align, arch_align);
+}
+
 /**
  * pbus_size_io() - size the io window of a given bus
  *
include/linux/pci.h +2 -1
index 9acea4b..34ff2bb 100644
@@ -988,6 +988,8 @@ int pci_cfg_space_size_ext(struct pci_dev *dev);
 int pci_cfg_space_size(struct pci_dev *dev);
 unsigned char pci_bus_max_busnr(struct pci_bus *bus);
 void pci_setup_bridge(struct pci_bus *bus);
+resource_size_t pcibios_window_alignment(struct pci_bus *bus,
+                                        unsigned long type);
 
 #define PCI_VGA_STATE_CHANGE_BRIDGE (1 << 0)
 #define PCI_VGA_STATE_CHANGE_DECODES (1 << 1)
--

1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Richard Yang
Help You, Help Me
#4 lore raw

Re: [PATCH 3/8] fiddle with conversion of pci and CPU address

In reply to Gavin Shan

I am not sure why you want to rename those functions.

BTW, i think you change the parameter of find_pci_host_bridge() in patch 2/8.

So if I just apply 2/8, it will fail the compilation, i think.

2012/7/25 Gavin Shan <[email protected]>:

Quoted 93 lines

The patch fiddles with the those functions used to do conversion between PCI and CPU address. More specificly, 2 functions are
involved: pcibios_bus_to_resource() and pcibios_resource_to_bus()

---
 drivers/pci/host-bridge.c |   24 +++++++++++++++++++-----
 include/linux/pci.h       |    5 ++++-
 2 files changed, 23 insertions(+), 6 deletions(-)
drivers/pci/host-bridge.c +19 -5
index fc16357..abcf053 100644
@@ -37,10 +37,10 @@ static bool resource_contains(struct resource *res1, struct resource *res2)
        return res1->start <= res2->start && res1->end >= res2->end;
 }
 
-void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
-                            struct resource *res)
+void __pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
+                              struct resource *res)
 {
-       struct pci_host_bridge *bridge = find_pci_host_bridge(dev->bus);
+       struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
        struct pci_host_bridge_window *window;
        resource_size_t offset = 0;
 
@@ -57,6 +57,13 @@ void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
        region->start = res->start - offset;
        region->end = res->end - offset;
 }
+
+void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
+                            struct resource *res)
+{
+       __pcibios_resource_to_bus(dev->bus, region, res);
+}
+
 EXPORT_SYMBOL(pcibios_resource_to_bus);
 
 static bool region_contains(struct pci_bus_region *region1,
@@ -65,10 +72,10 @@ static bool region_contains(struct pci_bus_region *region1,
        return region1->start <= region2->start && region1->end >= region2->end;
 }
 
-void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
+void __pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
                             struct pci_bus_region *region)
 {
-       struct pci_host_bridge *bridge = find_pci_host_bridge(dev->bus);
+       struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
        struct pci_host_bridge_window *window;
        resource_size_t offset = 0;
 
@@ -90,4 +97,11 @@ void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
        res->start = region->start + offset;
        res->end = region->end + offset;
 }
+
+void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
+                            struct pci_bus_region *region)
+{
+       __pcibios_bus_to_resource(dev->bus, res, region);
+}
+
 EXPORT_SYMBOL(pcibios_bus_to_resource);
include/linux/pci.h +4 -2
index d8c379d..9acea4b 100644
@@ -654,9 +654,12 @@ void pcibios_update_irq(struct pci_dev *, int irq);
 void pci_fixup_cardbus(struct pci_bus *);
 
 /* Generic PCI functions used internally */
-
+void __pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
+                               struct resource *res);
 void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
                             struct resource *res);
+void __pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
+                              struct pci_bus_region *region);
 void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
                             struct pci_bus_region *region);
 void pcibios_scan_specific_bus(int busn);
--

1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Richard Yang
Help You, Help Me