All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] PCI: PCI_BUS_FLAGS_NO_IO flag for PCI bus
@ 2013-05-06 13:44 ` Gavin Shan
  0 siblings, 0 replies; 12+ messages in thread
From: Gavin Shan @ 2013-05-06 13:44 UTC (permalink / raw)
  To: linuxppc-dev, linux-pci; +Cc: benh, yinghai, bhelgaas, Gavin Shan

There has some PCI hosts (e.g. PHB3) that don't support IO. So the
patch intends to introduce the flag to indicate the special case.
In turn, we won't do IO resource assignment and enable that.

Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
---
 drivers/pci/pci.c       |    3 +++
 drivers/pci/setup-bus.c |   25 ++++++++++++++++---------
 include/linux/pci.h     |    1 +
 3 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index a899d8b..2548bad 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1218,6 +1218,9 @@ int pci_enable_device_mem(struct pci_dev *dev)
  */
 int pci_enable_device(struct pci_dev *dev)
 {
+	if (dev->bus->bus_flags & PCI_BUS_FLAGS_NO_IO)
+		return pci_enable_device_flags(dev, IORESOURCE_MEM);
+
 	return pci_enable_device_flags(dev, IORESOURCE_MEM | IORESOURCE_IO);
 }
 
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 16abaaa..c8293e90 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -133,6 +133,10 @@ static void pdev_sort_resources(struct pci_dev *dev, struct list_head *head)
 
 		r = &dev->resource[i];
 
+		if ((dev->bus->bus_flags & PCI_BUS_FLAGS_NO_IO) &&
+		    (r->flags & IORESOURCE_IO))
+			continue;
+
 		if (r->flags & IORESOURCE_PCI_FIXED)
 			continue;
 
@@ -1083,17 +1087,20 @@ static void __ref __pci_bus_size_bridges(struct pci_bus *bus,
 			additional_io_size  = pci_hotplug_io_size;
 			additional_mem_size = pci_hotplug_mem_size;
 		}
+
+		/* Follow thru */
+	default:
+		if (!(bus->bus_flags & PCI_BUS_FLAGS_NO_IO))
+			pbus_size_io(bus,
+				     realloc_head ? 0 : additional_io_size,
+				     additional_io_size, realloc_head);
 		/*
-		 * Follow thru
+		 * If the bridge supports prefetchable range, size it
+		 * separately. If it doesn't, or its prefetchable window
+		 * has already been allocated by arch code, try
+		 * non-prefetchable range for both types of PCI memory
+		 * resources.
 		 */
-	default:
-		pbus_size_io(bus, realloc_head ? 0 : additional_io_size,
-			     additional_io_size, realloc_head);
-		/* If the bridge supports prefetchable range, size it
-		   separately. If it doesn't, or its prefetchable window
-		   has already been allocated by arch code, try
-		   non-prefetchable range for both types of PCI memory
-		   resources. */
 		mask = IORESOURCE_MEM;
 		prefmask = IORESOURCE_MEM | IORESOURCE_PREFETCH;
 		if (pbus_size_mem(bus, prefmask, prefmask,
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 3a24e4f..53b595a 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -181,6 +181,7 @@ typedef unsigned short __bitwise pci_bus_flags_t;
 enum pci_bus_flags {
 	PCI_BUS_FLAGS_NO_MSI   = (__force pci_bus_flags_t) 1,
 	PCI_BUS_FLAGS_NO_MMRBC = (__force pci_bus_flags_t) 2,
+	PCI_BUS_FLAGS_NO_IO    = (__force pci_bus_flags_t) 4
 };
 
 /* Based on the PCI Hotplug Spec, but some values are made up by us */
-- 
1.7.5.4


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

* [PATCH 1/3] PCI: PCI_BUS_FLAGS_NO_IO flag for PCI bus
@ 2013-05-06 13:44 ` Gavin Shan
  0 siblings, 0 replies; 12+ messages in thread
From: Gavin Shan @ 2013-05-06 13:44 UTC (permalink / raw)
  To: linuxppc-dev, linux-pci; +Cc: bhelgaas, yinghai, Gavin Shan

There has some PCI hosts (e.g. PHB3) that don't support IO. So the
patch intends to introduce the flag to indicate the special case.
In turn, we won't do IO resource assignment and enable that.

Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
---
 drivers/pci/pci.c       |    3 +++
 drivers/pci/setup-bus.c |   25 ++++++++++++++++---------
 include/linux/pci.h     |    1 +
 3 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index a899d8b..2548bad 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1218,6 +1218,9 @@ int pci_enable_device_mem(struct pci_dev *dev)
  */
 int pci_enable_device(struct pci_dev *dev)
 {
+	if (dev->bus->bus_flags & PCI_BUS_FLAGS_NO_IO)
+		return pci_enable_device_flags(dev, IORESOURCE_MEM);
+
 	return pci_enable_device_flags(dev, IORESOURCE_MEM | IORESOURCE_IO);
 }
 
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 16abaaa..c8293e90 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -133,6 +133,10 @@ static void pdev_sort_resources(struct pci_dev *dev, struct list_head *head)
 
 		r = &dev->resource[i];
 
+		if ((dev->bus->bus_flags & PCI_BUS_FLAGS_NO_IO) &&
+		    (r->flags & IORESOURCE_IO))
+			continue;
+
 		if (r->flags & IORESOURCE_PCI_FIXED)
 			continue;
 
@@ -1083,17 +1087,20 @@ static void __ref __pci_bus_size_bridges(struct pci_bus *bus,
 			additional_io_size  = pci_hotplug_io_size;
 			additional_mem_size = pci_hotplug_mem_size;
 		}
+
+		/* Follow thru */
+	default:
+		if (!(bus->bus_flags & PCI_BUS_FLAGS_NO_IO))
+			pbus_size_io(bus,
+				     realloc_head ? 0 : additional_io_size,
+				     additional_io_size, realloc_head);
 		/*
-		 * Follow thru
+		 * If the bridge supports prefetchable range, size it
+		 * separately. If it doesn't, or its prefetchable window
+		 * has already been allocated by arch code, try
+		 * non-prefetchable range for both types of PCI memory
+		 * resources.
 		 */
-	default:
-		pbus_size_io(bus, realloc_head ? 0 : additional_io_size,
-			     additional_io_size, realloc_head);
-		/* If the bridge supports prefetchable range, size it
-		   separately. If it doesn't, or its prefetchable window
-		   has already been allocated by arch code, try
-		   non-prefetchable range for both types of PCI memory
-		   resources. */
 		mask = IORESOURCE_MEM;
 		prefmask = IORESOURCE_MEM | IORESOURCE_PREFETCH;
 		if (pbus_size_mem(bus, prefmask, prefmask,
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 3a24e4f..53b595a 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -181,6 +181,7 @@ typedef unsigned short __bitwise pci_bus_flags_t;
 enum pci_bus_flags {
 	PCI_BUS_FLAGS_NO_MSI   = (__force pci_bus_flags_t) 1,
 	PCI_BUS_FLAGS_NO_MMRBC = (__force pci_bus_flags_t) 2,
+	PCI_BUS_FLAGS_NO_IO    = (__force pci_bus_flags_t) 4
 };
 
 /* Based on the PCI Hotplug Spec, but some values are made up by us */
-- 
1.7.5.4

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

* [PATCH 2/3] powerpc/powernv: Disable IO space for PCI buses
  2013-05-06 13:44 ` Gavin Shan
@ 2013-05-06 13:44   ` Gavin Shan
  -1 siblings, 0 replies; 12+ messages in thread
From: Gavin Shan @ 2013-05-06 13:44 UTC (permalink / raw)
  To: linuxppc-dev, linux-pci; +Cc: benh, yinghai, bhelgaas, Gavin Shan

The patch intends to set the special flag (PCI_BUS_FLAGS_NO_IO) for
root buses so PCI core will skip assignment for IO stuff. Besides,
we also clear the IO resources on all PCI devices for PHB3.

Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/machdep.h        |    3 ++
 arch/powerpc/kernel/pci-common.c          |    7 +++++
 arch/powerpc/platforms/powernv/pci-ioda.c |   38 +++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index 3f3f691..ebc2ffd 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -220,6 +220,9 @@ struct machdep_calls {
 	/* Called during PCI resource reassignment */
 	resource_size_t (*pcibios_window_alignment)(struct pci_bus *, unsigned long type);
 
+	/* Called when adding PCI bus */
+	void (*pcibios_add_bus)(struct pci_bus *);
+
 	/* Called to shutdown machine specific hardware not already controlled
 	 * by other drivers.
 	 */
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index f325dc9..7b8a6f1 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -120,6 +120,13 @@ resource_size_t pcibios_window_alignment(struct pci_bus *bus,
 	return 1;
 }
 
+/* The function will be called while adding PCI bus to system */
+void pcibios_add_bus(struct pci_bus *bus)
+{
+	if (ppc_md.pcibios_add_bus)
+		ppc_md.pcibios_add_bus(bus);
+}
+
 static resource_size_t pcibios_io_size(const struct pci_controller *hose)
 {
 #ifdef CONFIG_PPC64
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 8c6c9cf..0c3fa29 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -1015,6 +1015,40 @@ static resource_size_t pnv_pci_window_alignment(struct pci_bus *bus,
 	return phb->ioda.io_segsize;
 }
 
+/*
+ * The function will be called while adding PCI bus to the
+ * system. In turn, we should set flag to indicate that the
+ * root bus doesn't have IO resources.
+ */
+static void pnv_pci_add_bus(struct pci_bus *bus)
+{
+	struct pci_controller *hose = pci_bus_to_host(bus);
+	struct pnv_phb *phb = hose->private_data;
+
+	/*
+	 * We only need set the flag for root bus since the
+	 * bus flags are copied over from parent to children
+	 */
+	if (pci_is_root_bus(bus) &&
+	    phb->model == PNV_PHB_MODEL_PHB3)
+		bus->bus_flags |= PCI_BUS_FLAGS_NO_IO;
+}
+
+static void pnv_pci_fixup_resources(struct pci_dev *dev)
+{
+	int i;
+	struct resource *res;
+
+	if (!(dev->bus->bus_flags & PCI_BUS_FLAGS_NO_IO))
+		return;
+
+	for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
+		res = dev->resource + i;
+		if (res->flags & IORESOURCE_IO)
+			res->flags = 0;
+	}
+}
+
 /* Prevent enabling devices for which we couldn't properly
  * assign a PE
  */
@@ -1189,6 +1223,10 @@ void __init pnv_pci_init_ioda_phb(struct device_node *np, int ioda_type)
 	ppc_md.pcibios_fixup = pnv_pci_ioda_fixup;
 	ppc_md.pcibios_enable_device_hook = pnv_pci_enable_device_hook;
 	ppc_md.pcibios_window_alignment = pnv_pci_window_alignment;
+	if (ioda_type == PNV_PHB_IODA2) {
+		ppc_md.pcibios_add_bus = pnv_pci_add_bus;
+		ppc_md.pcibios_fixup_resources = pnv_pci_fixup_resources;
+	}
 	pci_add_flags(PCI_REASSIGN_ALL_RSRC);
 
 	/* Reset IODA tables to a clean state */
-- 
1.7.5.4


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

* [PATCH 2/3] powerpc/powernv: Disable IO space for PCI buses
@ 2013-05-06 13:44   ` Gavin Shan
  0 siblings, 0 replies; 12+ messages in thread
From: Gavin Shan @ 2013-05-06 13:44 UTC (permalink / raw)
  To: linuxppc-dev, linux-pci; +Cc: bhelgaas, yinghai, Gavin Shan

The patch intends to set the special flag (PCI_BUS_FLAGS_NO_IO) for
root buses so PCI core will skip assignment for IO stuff. Besides,
we also clear the IO resources on all PCI devices for PHB3.

Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/machdep.h        |    3 ++
 arch/powerpc/kernel/pci-common.c          |    7 +++++
 arch/powerpc/platforms/powernv/pci-ioda.c |   38 +++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index 3f3f691..ebc2ffd 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -220,6 +220,9 @@ struct machdep_calls {
 	/* Called during PCI resource reassignment */
 	resource_size_t (*pcibios_window_alignment)(struct pci_bus *, unsigned long type);
 
+	/* Called when adding PCI bus */
+	void (*pcibios_add_bus)(struct pci_bus *);
+
 	/* Called to shutdown machine specific hardware not already controlled
 	 * by other drivers.
 	 */
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index f325dc9..7b8a6f1 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -120,6 +120,13 @@ resource_size_t pcibios_window_alignment(struct pci_bus *bus,
 	return 1;
 }
 
+/* The function will be called while adding PCI bus to system */
+void pcibios_add_bus(struct pci_bus *bus)
+{
+	if (ppc_md.pcibios_add_bus)
+		ppc_md.pcibios_add_bus(bus);
+}
+
 static resource_size_t pcibios_io_size(const struct pci_controller *hose)
 {
 #ifdef CONFIG_PPC64
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 8c6c9cf..0c3fa29 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -1015,6 +1015,40 @@ static resource_size_t pnv_pci_window_alignment(struct pci_bus *bus,
 	return phb->ioda.io_segsize;
 }
 
+/*
+ * The function will be called while adding PCI bus to the
+ * system. In turn, we should set flag to indicate that the
+ * root bus doesn't have IO resources.
+ */
+static void pnv_pci_add_bus(struct pci_bus *bus)
+{
+	struct pci_controller *hose = pci_bus_to_host(bus);
+	struct pnv_phb *phb = hose->private_data;
+
+	/*
+	 * We only need set the flag for root bus since the
+	 * bus flags are copied over from parent to children
+	 */
+	if (pci_is_root_bus(bus) &&
+	    phb->model == PNV_PHB_MODEL_PHB3)
+		bus->bus_flags |= PCI_BUS_FLAGS_NO_IO;
+}
+
+static void pnv_pci_fixup_resources(struct pci_dev *dev)
+{
+	int i;
+	struct resource *res;
+
+	if (!(dev->bus->bus_flags & PCI_BUS_FLAGS_NO_IO))
+		return;
+
+	for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
+		res = dev->resource + i;
+		if (res->flags & IORESOURCE_IO)
+			res->flags = 0;
+	}
+}
+
 /* Prevent enabling devices for which we couldn't properly
  * assign a PE
  */
@@ -1189,6 +1223,10 @@ void __init pnv_pci_init_ioda_phb(struct device_node *np, int ioda_type)
 	ppc_md.pcibios_fixup = pnv_pci_ioda_fixup;
 	ppc_md.pcibios_enable_device_hook = pnv_pci_enable_device_hook;
 	ppc_md.pcibios_window_alignment = pnv_pci_window_alignment;
+	if (ioda_type == PNV_PHB_IODA2) {
+		ppc_md.pcibios_add_bus = pnv_pci_add_bus;
+		ppc_md.pcibios_fixup_resources = pnv_pci_fixup_resources;
+	}
 	pci_add_flags(PCI_REASSIGN_ALL_RSRC);
 
 	/* Reset IODA tables to a clean state */
-- 
1.7.5.4

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

* [PATCH 3/3] powerpc/powernv: Don't configure IO window on PHB3
  2013-05-06 13:44 ` Gavin Shan
@ 2013-05-06 13:44   ` Gavin Shan
  -1 siblings, 0 replies; 12+ messages in thread
From: Gavin Shan @ 2013-05-06 13:44 UTC (permalink / raw)
  To: linuxppc-dev, linux-pci; +Cc: benh, yinghai, bhelgaas, Gavin Shan

We needn't configure IO windows for the corresponding PEs on PHB3
since that doesn't support IO.

Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
---
 arch/powerpc/platforms/powernv/pci-ioda.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 0c3fa29..b4f3edb 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -894,7 +894,9 @@ static void pnv_ioda_setup_pe_seg(struct pci_controller *hose,
 		    res->start > res->end)
 			continue;
 
-		if (res->flags & IORESOURCE_IO) {
+		/* We needn't setup IO windows for PHB3 */
+		if (!(pe->pbus->bus_flags & PCI_BUS_FLAGS_NO_IO) &&
+		    res->flags & IORESOURCE_IO) {
 			region.start = res->start - phb->ioda.io_pci_base;
 			region.end   = res->end - phb->ioda.io_pci_base;
 			index = region.start / phb->ioda.io_segsize;
-- 
1.7.5.4


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

* [PATCH 3/3] powerpc/powernv: Don't configure IO window on PHB3
@ 2013-05-06 13:44   ` Gavin Shan
  0 siblings, 0 replies; 12+ messages in thread
From: Gavin Shan @ 2013-05-06 13:44 UTC (permalink / raw)
  To: linuxppc-dev, linux-pci; +Cc: bhelgaas, yinghai, Gavin Shan

We needn't configure IO windows for the corresponding PEs on PHB3
since that doesn't support IO.

Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
---
 arch/powerpc/platforms/powernv/pci-ioda.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 0c3fa29..b4f3edb 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -894,7 +894,9 @@ static void pnv_ioda_setup_pe_seg(struct pci_controller *hose,
 		    res->start > res->end)
 			continue;
 
-		if (res->flags & IORESOURCE_IO) {
+		/* We needn't setup IO windows for PHB3 */
+		if (!(pe->pbus->bus_flags & PCI_BUS_FLAGS_NO_IO) &&
+		    res->flags & IORESOURCE_IO) {
 			region.start = res->start - phb->ioda.io_pci_base;
 			region.end   = res->end - phb->ioda.io_pci_base;
 			index = region.start / phb->ioda.io_segsize;
-- 
1.7.5.4

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

* Re: [PATCH 2/3] powerpc/powernv: Disable IO space for PCI buses
  2013-05-06 13:44   ` Gavin Shan
@ 2013-05-06 21:33     ` Benjamin Herrenschmidt
  -1 siblings, 0 replies; 12+ messages in thread
From: Benjamin Herrenschmidt @ 2013-05-06 21:33 UTC (permalink / raw)
  To: Gavin Shan; +Cc: linuxppc-dev, linux-pci, yinghai, bhelgaas

On Mon, 2013-05-06 at 21:44 +0800, Gavin Shan wrote:
> The patch intends to set the special flag (PCI_BUS_FLAGS_NO_IO) for
> root buses so PCI core will skip assignment for IO stuff. Besides,
> we also clear the IO resources on all PCI devices for PHB3.

Why the new hook ? Can't this be detected simply because there is
no aperture in the pci_host_bridge with IORESOURCE_IO set in the flags ?

Ben.

> Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
> ---
>  arch/powerpc/include/asm/machdep.h        |    3 ++
>  arch/powerpc/kernel/pci-common.c          |    7 +++++
>  arch/powerpc/platforms/powernv/pci-ioda.c |   38 +++++++++++++++++++++++++++++
>  3 files changed, 48 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
> index 3f3f691..ebc2ffd 100644
> --- a/arch/powerpc/include/asm/machdep.h
> +++ b/arch/powerpc/include/asm/machdep.h
> @@ -220,6 +220,9 @@ struct machdep_calls {
>  	/* Called during PCI resource reassignment */
>  	resource_size_t (*pcibios_window_alignment)(struct pci_bus *, unsigned long type);
>  
> +	/* Called when adding PCI bus */
> +	void (*pcibios_add_bus)(struct pci_bus *);
> +
>  	/* Called to shutdown machine specific hardware not already controlled
>  	 * by other drivers.
>  	 */
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index f325dc9..7b8a6f1 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -120,6 +120,13 @@ resource_size_t pcibios_window_alignment(struct pci_bus *bus,
>  	return 1;
>  }
>  
> +/* The function will be called while adding PCI bus to system */
> +void pcibios_add_bus(struct pci_bus *bus)
> +{
> +	if (ppc_md.pcibios_add_bus)
> +		ppc_md.pcibios_add_bus(bus);
> +}
> +
>  static resource_size_t pcibios_io_size(const struct pci_controller *hose)
>  {
>  #ifdef CONFIG_PPC64
> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
> index 8c6c9cf..0c3fa29 100644
> --- a/arch/powerpc/platforms/powernv/pci-ioda.c
> +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
> @@ -1015,6 +1015,40 @@ static resource_size_t pnv_pci_window_alignment(struct pci_bus *bus,
>  	return phb->ioda.io_segsize;
>  }
>  
> +/*
> + * The function will be called while adding PCI bus to the
> + * system. In turn, we should set flag to indicate that the
> + * root bus doesn't have IO resources.
> + */
> +static void pnv_pci_add_bus(struct pci_bus *bus)
> +{
> +	struct pci_controller *hose = pci_bus_to_host(bus);
> +	struct pnv_phb *phb = hose->private_data;
> +
> +	/*
> +	 * We only need set the flag for root bus since the
> +	 * bus flags are copied over from parent to children
> +	 */
> +	if (pci_is_root_bus(bus) &&
> +	    phb->model == PNV_PHB_MODEL_PHB3)
> +		bus->bus_flags |= PCI_BUS_FLAGS_NO_IO;
> +}
> +
> +static void pnv_pci_fixup_resources(struct pci_dev *dev)
> +{
> +	int i;
> +	struct resource *res;
> +
> +	if (!(dev->bus->bus_flags & PCI_BUS_FLAGS_NO_IO))
> +		return;
> +
> +	for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
> +		res = dev->resource + i;
> +		if (res->flags & IORESOURCE_IO)
> +			res->flags = 0;
> +	}
> +}
> +
>  /* Prevent enabling devices for which we couldn't properly
>   * assign a PE
>   */
> @@ -1189,6 +1223,10 @@ void __init pnv_pci_init_ioda_phb(struct device_node *np, int ioda_type)
>  	ppc_md.pcibios_fixup = pnv_pci_ioda_fixup;
>  	ppc_md.pcibios_enable_device_hook = pnv_pci_enable_device_hook;
>  	ppc_md.pcibios_window_alignment = pnv_pci_window_alignment;
> +	if (ioda_type == PNV_PHB_IODA2) {
> +		ppc_md.pcibios_add_bus = pnv_pci_add_bus;
> +		ppc_md.pcibios_fixup_resources = pnv_pci_fixup_resources;
> +	}
>  	pci_add_flags(PCI_REASSIGN_ALL_RSRC);
>  
>  	/* Reset IODA tables to a clean state */



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

* Re: [PATCH 2/3] powerpc/powernv: Disable IO space for PCI buses
@ 2013-05-06 21:33     ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 12+ messages in thread
From: Benjamin Herrenschmidt @ 2013-05-06 21:33 UTC (permalink / raw)
  To: Gavin Shan; +Cc: yinghai, linux-pci, bhelgaas, linuxppc-dev

On Mon, 2013-05-06 at 21:44 +0800, Gavin Shan wrote:
> The patch intends to set the special flag (PCI_BUS_FLAGS_NO_IO) for
> root buses so PCI core will skip assignment for IO stuff. Besides,
> we also clear the IO resources on all PCI devices for PHB3.

Why the new hook ? Can't this be detected simply because there is
no aperture in the pci_host_bridge with IORESOURCE_IO set in the flags ?

Ben.

> Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
> ---
>  arch/powerpc/include/asm/machdep.h        |    3 ++
>  arch/powerpc/kernel/pci-common.c          |    7 +++++
>  arch/powerpc/platforms/powernv/pci-ioda.c |   38 +++++++++++++++++++++++++++++
>  3 files changed, 48 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
> index 3f3f691..ebc2ffd 100644
> --- a/arch/powerpc/include/asm/machdep.h
> +++ b/arch/powerpc/include/asm/machdep.h
> @@ -220,6 +220,9 @@ struct machdep_calls {
>  	/* Called during PCI resource reassignment */
>  	resource_size_t (*pcibios_window_alignment)(struct pci_bus *, unsigned long type);
>  
> +	/* Called when adding PCI bus */
> +	void (*pcibios_add_bus)(struct pci_bus *);
> +
>  	/* Called to shutdown machine specific hardware not already controlled
>  	 * by other drivers.
>  	 */
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index f325dc9..7b8a6f1 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -120,6 +120,13 @@ resource_size_t pcibios_window_alignment(struct pci_bus *bus,
>  	return 1;
>  }
>  
> +/* The function will be called while adding PCI bus to system */
> +void pcibios_add_bus(struct pci_bus *bus)
> +{
> +	if (ppc_md.pcibios_add_bus)
> +		ppc_md.pcibios_add_bus(bus);
> +}
> +
>  static resource_size_t pcibios_io_size(const struct pci_controller *hose)
>  {
>  #ifdef CONFIG_PPC64
> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
> index 8c6c9cf..0c3fa29 100644
> --- a/arch/powerpc/platforms/powernv/pci-ioda.c
> +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
> @@ -1015,6 +1015,40 @@ static resource_size_t pnv_pci_window_alignment(struct pci_bus *bus,
>  	return phb->ioda.io_segsize;
>  }
>  
> +/*
> + * The function will be called while adding PCI bus to the
> + * system. In turn, we should set flag to indicate that the
> + * root bus doesn't have IO resources.
> + */
> +static void pnv_pci_add_bus(struct pci_bus *bus)
> +{
> +	struct pci_controller *hose = pci_bus_to_host(bus);
> +	struct pnv_phb *phb = hose->private_data;
> +
> +	/*
> +	 * We only need set the flag for root bus since the
> +	 * bus flags are copied over from parent to children
> +	 */
> +	if (pci_is_root_bus(bus) &&
> +	    phb->model == PNV_PHB_MODEL_PHB3)
> +		bus->bus_flags |= PCI_BUS_FLAGS_NO_IO;
> +}
> +
> +static void pnv_pci_fixup_resources(struct pci_dev *dev)
> +{
> +	int i;
> +	struct resource *res;
> +
> +	if (!(dev->bus->bus_flags & PCI_BUS_FLAGS_NO_IO))
> +		return;
> +
> +	for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
> +		res = dev->resource + i;
> +		if (res->flags & IORESOURCE_IO)
> +			res->flags = 0;
> +	}
> +}
> +
>  /* Prevent enabling devices for which we couldn't properly
>   * assign a PE
>   */
> @@ -1189,6 +1223,10 @@ void __init pnv_pci_init_ioda_phb(struct device_node *np, int ioda_type)
>  	ppc_md.pcibios_fixup = pnv_pci_ioda_fixup;
>  	ppc_md.pcibios_enable_device_hook = pnv_pci_enable_device_hook;
>  	ppc_md.pcibios_window_alignment = pnv_pci_window_alignment;
> +	if (ioda_type == PNV_PHB_IODA2) {
> +		ppc_md.pcibios_add_bus = pnv_pci_add_bus;
> +		ppc_md.pcibios_fixup_resources = pnv_pci_fixup_resources;
> +	}
>  	pci_add_flags(PCI_REASSIGN_ALL_RSRC);
>  
>  	/* Reset IODA tables to a clean state */

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

* Re: [PATCH 3/3] powerpc/powernv: Don't configure IO window on PHB3
  2013-05-06 13:44   ` Gavin Shan
@ 2013-05-06 21:34     ` Benjamin Herrenschmidt
  -1 siblings, 0 replies; 12+ messages in thread
From: Benjamin Herrenschmidt @ 2013-05-06 21:34 UTC (permalink / raw)
  To: Gavin Shan; +Cc: linuxppc-dev, linux-pci, yinghai, bhelgaas

On Mon, 2013-05-06 at 21:44 +0800, Gavin Shan wrote:
> We needn't configure IO windows for the corresponding PEs on PHB3
> since that doesn't support IO.

Here too, no need for such a flag, just check that
pci_controller->io_resource.flags is 0.

BTW. Please work on top of the patch I sent already that avoids adding
bogus resources to pci_host_bridge when their flags are 0. I'll send
it to Linus today.

Cheers,
Ben.

> Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
> ---
>  arch/powerpc/platforms/powernv/pci-ioda.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
> index 0c3fa29..b4f3edb 100644
> --- a/arch/powerpc/platforms/powernv/pci-ioda.c
> +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
> @@ -894,7 +894,9 @@ static void pnv_ioda_setup_pe_seg(struct pci_controller *hose,
>  		    res->start > res->end)
>  			continue;
>  
> -		if (res->flags & IORESOURCE_IO) {
> +		/* We needn't setup IO windows for PHB3 */
> +		if (!(pe->pbus->bus_flags & PCI_BUS_FLAGS_NO_IO) &&
> +		    res->flags & IORESOURCE_IO) {
>  			region.start = res->start - phb->ioda.io_pci_base;
>  			region.end   = res->end - phb->ioda.io_pci_base;
>  			index = region.start / phb->ioda.io_segsize;



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

* Re: [PATCH 3/3] powerpc/powernv: Don't configure IO window on PHB3
@ 2013-05-06 21:34     ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 12+ messages in thread
From: Benjamin Herrenschmidt @ 2013-05-06 21:34 UTC (permalink / raw)
  To: Gavin Shan; +Cc: yinghai, linux-pci, bhelgaas, linuxppc-dev

On Mon, 2013-05-06 at 21:44 +0800, Gavin Shan wrote:
> We needn't configure IO windows for the corresponding PEs on PHB3
> since that doesn't support IO.

Here too, no need for such a flag, just check that
pci_controller->io_resource.flags is 0.

BTW. Please work on top of the patch I sent already that avoids adding
bogus resources to pci_host_bridge when their flags are 0. I'll send
it to Linus today.

Cheers,
Ben.

> Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
> ---
>  arch/powerpc/platforms/powernv/pci-ioda.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
> index 0c3fa29..b4f3edb 100644
> --- a/arch/powerpc/platforms/powernv/pci-ioda.c
> +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
> @@ -894,7 +894,9 @@ static void pnv_ioda_setup_pe_seg(struct pci_controller *hose,
>  		    res->start > res->end)
>  			continue;
>  
> -		if (res->flags & IORESOURCE_IO) {
> +		/* We needn't setup IO windows for PHB3 */
> +		if (!(pe->pbus->bus_flags & PCI_BUS_FLAGS_NO_IO) &&
> +		    res->flags & IORESOURCE_IO) {
>  			region.start = res->start - phb->ioda.io_pci_base;
>  			region.end   = res->end - phb->ioda.io_pci_base;
>  			index = region.start / phb->ioda.io_segsize;

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

* Re: [PATCH 2/3] powerpc/powernv: Disable IO space for PCI buses
  2013-05-06 21:33     ` Benjamin Herrenschmidt
  (?)
@ 2013-05-07  5:11     ` Gavin Shan
  -1 siblings, 0 replies; 12+ messages in thread
From: Gavin Shan @ 2013-05-07  5:11 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: bhelgaas, linux-pci, linuxppc-dev, yinghai, Gavin Shan

On Tue, May 07, 2013 at 07:33:02AM +1000, Benjamin Herrenschmidt wrote:
>On Mon, 2013-05-06 at 21:44 +0800, Gavin Shan wrote:
>> The patch intends to set the special flag (PCI_BUS_FLAGS_NO_IO) for
>> root buses so PCI core will skip assignment for IO stuff. Besides,
>> we also clear the IO resources on all PCI devices for PHB3.
>
>Why the new hook ? Can't this be detected simply because there is
>no aperture in the pci_host_bridge with IORESOURCE_IO set in the flags ?
>

Yeah, Ben. I've changed it accordingly in v2 and the problem is that we
need the proposed patches from Yinghai or mine :-)

Thanks,
Gavin 

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

* Re: [PATCH 3/3] powerpc/powernv: Don't configure IO window on PHB3
  2013-05-06 21:34     ` Benjamin Herrenschmidt
  (?)
@ 2013-05-07  5:12     ` Gavin Shan
  -1 siblings, 0 replies; 12+ messages in thread
From: Gavin Shan @ 2013-05-07  5:12 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: yinghai, linux-pci, bhelgaas, linuxppc-dev, Gavin Shan

On Tue, May 07, 2013 at 07:34:30AM +1000, Benjamin Herrenschmidt wrote:
>On Mon, 2013-05-06 at 21:44 +0800, Gavin Shan wrote:
>> We needn't configure IO windows for the corresponding PEs on PHB3
>> since that doesn't support IO.
>
>Here too, no need for such a flag, just check that
>pci_controller->io_resource.flags is 0.
>
>BTW. Please work on top of the patch I sent already that avoids adding
>bogus resources to pci_host_bridge when their flags are 0. I'll send
>it to Linus today.
>

I've changed it accordingly on top of your patches in v2 :-)

Thanks,
Gavin

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

end of thread, other threads:[~2013-05-07  5:12 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-06 13:44 [PATCH 1/3] PCI: PCI_BUS_FLAGS_NO_IO flag for PCI bus Gavin Shan
2013-05-06 13:44 ` Gavin Shan
2013-05-06 13:44 ` [PATCH 2/3] powerpc/powernv: Disable IO space for PCI buses Gavin Shan
2013-05-06 13:44   ` Gavin Shan
2013-05-06 21:33   ` Benjamin Herrenschmidt
2013-05-06 21:33     ` Benjamin Herrenschmidt
2013-05-07  5:11     ` Gavin Shan
2013-05-06 13:44 ` [PATCH 3/3] powerpc/powernv: Don't configure IO window on PHB3 Gavin Shan
2013-05-06 13:44   ` Gavin Shan
2013-05-06 21:34   ` Benjamin Herrenschmidt
2013-05-06 21:34     ` Benjamin Herrenschmidt
2013-05-07  5:12     ` Gavin Shan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.