Skip to contentSkip to conversation

ACPI PCI support for arm64

RFC PATCH New Jayachandran C 2 participants 7 messages Dec 2, 2015 – Dec 4, 2015 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover ACPI PCI support for arm64

This is a very simple and generic implementation of a PCI host controller based on ACPI. This approach does not pull in the MMCONFIG and ECAM code from x86.

It is important for us to have a working ACPI based PCI host controller implementation for arm64, so I thought I would post this as a simple and less disruptive alternative.

This is tested with arm64 QEMU and OVMF. Comments are very welcome.

Thanks,
JC.

Jayachandran C (3):
arm64: pci: Add ACPI support
pci: Handle NULL parent in pci_bus_assign_domain_nr pci/host : Add a generic ACPI based host controller

 arch/arm64/kernel/pci.c          |  47 ++++++++-
 drivers/pci/host/Kconfig         |   7 ++
 drivers/pci/host/Makefile        |   1 +
 drivers/pci/host/pci-host-acpi.c | 211 +++++++++++++++++++++++++++++++++++++++
 drivers/pci/pci.c                |   7 +-
 5 files changed, 270 insertions(+), 3 deletions(-)
 create mode 100644 drivers/pci/host/pci-host-acpi.c
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/3 arm64: pci: Add ACPI support

Add functions needed for ACPI support.

pci_acpi_scan_root(struct acpi_pci_root *root) is marked as weak so that it can be implemented by the generic acpi pci driver. pcibios_root_bridge_prepare assumes that the sysdata is struct acpi_pci_root_info and sets up the domain and ACPI companion

The functions pcibios_enable_device and pcibios_disable_device have been update to handle ACPI irq enable and disable. And pcibios_add_bus and pcibios_remove_bus have been added call the corresponding ACPI functions.

---
 arch/arm64/kernel/pci.c | 47 +++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 45 insertions(+), 2 deletions(-)
arch/arm64/kernel/pci.c +45 -2
index b3d098b..8597624 100644
@@ -17,6 +17,7 @@
 #include <linux/mm.h>
 #include <linux/of_pci.h>
 #include <linux/of_platform.h>
+#include <linux/pci-acpi.h>
 #include <linux/slab.h>
 
 #include <asm/pci-bridge.h>
@@ -48,9 +49,22 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
 	if (pci_has_flag(PCI_PROBE_ONLY))
 		return 0;
 
+#ifdef CONFIG_ACPI
+	if (acpi_find_root_bridge_handle(dev))
+		acpi_pci_irq_enable(dev);
+#endif
+
 	return pci_enable_resources(dev, mask);
 }
 
+void pcibios_disable_device(struct pci_dev *dev)
+{
+#ifdef CONFIG_ACPI
+	if (acpi_find_root_bridge_handle(dev))
+		acpi_pci_irq_disable(dev);
+#endif
+}
+
 /*
  * Try to assign the IRQ number from DT when adding a new device
  */
@@ -78,9 +92,38 @@ int raw_pci_write(unsigned int domain, unsigned int bus,
 
 #ifdef CONFIG_ACPI
 /* Root bridge scanning */
-struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
+struct pci_bus *__weak pci_acpi_scan_root(struct acpi_pci_root *root)
 {
-	/* TODO: Should be revisited when implementing PCI on ACPI */
 	return NULL;
 }
+
+void pcibios_add_bus(struct pci_bus *bus)
+{
+	acpi_pci_add_bus(bus);
+}
+
+void pcibios_remove_bus(struct pci_bus *bus)
+{
+	acpi_pci_remove_bus(bus);
+}
+
+int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
+{
+	if (!acpi_disabled) {
+		struct pci_bus *b = bridge->bus;
+		struct acpi_pci_root_info *ci = b->sysdata;
+
+		ACPI_COMPANION_SET(&bridge->dev, ci->bridge);
+		b->domain_nr = ci->root->segment;
+	}
+	return 0;
+}
+
+static int __init pcibios_assign_resources(void)
+{
+	pci_assign_unassigned_resources();
+	return 0;
+}
+
+fs_initcall(pcibios_assign_resources);
 #endif
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/3 pci: Handle NULL parent in pci_bus_assign_domain_nr

In reply to Jayachandran C

pci_create_root_bus is called with NULL parent from ACPI. On arm64, this ends up calling pci_bus_assign_domain_nr, which crashes when dereferencing parent.

To fix this, we update pci_bus_assign_domain_nr to return if parent is NULL. Setting up the domain number will be handled from pcibios_root_bridge_prepare on arm64 when booted with ACPI.

---
 drivers/pci/pci.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/pci/pci.c +6 -1
index 314db8c..a96c356 100644
@@ -4772,8 +4772,13 @@ int pci_get_new_domain_nr(void)
 void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
 {
 	static int use_dt_domains = -1;
-	int domain = of_get_pci_domain_nr(parent->of_node);
+	int domain;
 
+	/* in case of ACPI, parent is NULL */
+	if (parent == NULL)
+		return;
+
+	domain = of_get_pci_domain_nr(parent->of_node);
 	/*
 	 * Check DT domain and use_dt_domains values.
 	 *
Signature · 1 line
1.9.1
#3 lore raw

PATCH 3/3 pci/host : Add a generic ACPI based host controller

In reply to Jayachandran C

Add a simple ACPI based PCI host controller. This is done by providing a simple implementation of pci_acpi_scan_root(). The MCFG table is parsed early and saved so that it can be mapped when ACPI calls pci_acpi_scan_root.

This is enabled only for ARM64 now.

---
 drivers/pci/host/Kconfig         |   7 ++
 drivers/pci/host/Makefile        |   1 +
 drivers/pci/host/pci-host-acpi.c | 211 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 219 insertions(+)
 create mode 100644 drivers/pci/host/pci-host-acpi.c
drivers/pci/host/Kconfig +7 -0
index f131ba9..8321efc 100644
@@ -53,6 +53,13 @@ config PCI_RCAR_GEN2_PCIE
 	help
 	  Say Y here if you want PCIe controller support on R-Car Gen2 SoCs.
 
+config PCI_HOST_GENERIC_ACPI
+	bool "Generic ACPI PCI host controller"
+	depends on ARM64 && ACPI
+	help
+	  Say Y here if you want to support a simple generic ACPI PCI host
+	  controller.
+
 config PCI_HOST_GENERIC
 	bool "Generic PCI host controller"
 	depends on (ARM || ARM64) && OF
drivers/pci/host/Makefile +1 -0
index 9d4d3c6..bc31852 100644
@@ -6,6 +6,7 @@ obj-$(CONFIG_PCI_MVEBU) += pci-mvebu.o
 obj-$(CONFIG_PCI_TEGRA) += pci-tegra.o
 obj-$(CONFIG_PCI_RCAR_GEN2) += pci-rcar-gen2.o
 obj-$(CONFIG_PCI_RCAR_GEN2_PCIE) += pcie-rcar.o
+obj-$(CONFIG_PCI_HOST_GENERIC_ACPI) += pci-host-acpi.o
 obj-$(CONFIG_PCI_HOST_GENERIC) += pci-host-generic.o
 obj-$(CONFIG_PCIE_SPEAR13XX) += pcie-spear13xx.o
 obj-$(CONFIG_PCI_KEYSTONE) += pci-keystone-dw.o pci-keystone.o
drivers/pci/host/pci-host-acpi.c new file +211 -0

211 lines not on this page · raw message

Signature · 1 line
1.9.1

A message that is not in the archive (sent off-list or not yet received): 20151203105628.GD2110@red-moon

#5 lore raw

cover ACPI PCI support for arm64

[Resend, LAKML copied-in]

Quoted 55 lines · Lorenzo Pieralisi

[CC'ing Tomasz]

Quoted 3 lines · Jayachandran C

This is a very simple and generic implementation of a PCI host controller based on ACPI. This approach does not pull in the MMCONFIG and ECAM code from x86.

Why ? Tomasz's patchset does not move MMCONFIG and ECAM code to the generic PCI layer for fun, it is generic code and should be shared by all architectures and most importantly we should not add more churn on top of it which would complicate consolidation even further.

Quoted 3 lines

It is important for us to have a working ACPI based PCI host controller implementation for arm64, so I thought I would post this as a simple and less disruptive alternative.

It is important for everyone but that's not a reason granting shortcuts.

Quoted 1 line

This is tested with arm64 QEMU and OVMF. Comments are very welcome.

Tomasz's patch went through several review cycles, please help review it and test it, that's my comment.

A new version should be posted soon, previous version here:

https://lkml.org/lkml/2015/10/27/504

Thanks,
Lorenzo

Quoted 25 lines

Thanks,
JC.

Jayachandran C (3):
arm64: pci: Add ACPI support
pci: Handle NULL parent in pci_bus_assign_domain_nr pci/host : Add a generic ACPI based host controller

 arch/arm64/kernel/pci.c          |  47 ++++++++-
 drivers/pci/host/Kconfig         |   7 ++
 drivers/pci/host/Makefile        |   1 +
 drivers/pci/host/pci-host-acpi.c | 211 +++++++++++++++++++++++++++++++++++++++
 drivers/pci/pci.c                |   7 +-
 5 files changed, 270 insertions(+), 3 deletions(-)
 create mode 100644 drivers/pci/host/pci-host-acpi.c
Signature · 6 lines
1.9.1

--
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
#6 lore raw

cover ACPI PCI support for arm64

In reply to a message not in the archive
Quoted 9 lines · Lorenzo Pieralisi

[CC'ing Tomasz]

Quoted 3 lines · Jayachandran C

This is a very simple and generic implementation of a PCI host controller based on ACPI. This approach does not pull in the MMCONFIG and ECAM code from x86.

Why ? Tomasz's patchset does not move MMCONFIG and ECAM code to the generic PCI layer for fun,

Honestly, Lorenzo, I can see that it was not fun :)

Quoted 3 lines

it is generic code and should be shared by all architectures and most importantly we should not add more churn on top of it which would complicate consolidation even further.

There is no need for such a common/generic infrastructure to walk thru a simple table. In my opinion, trying to do this added a lot of complexity into what should be a very simple patchset.

The x86 code has to deal with a lot more fw/hw issues and I fail to see why that mess should be brought into the a new architecture.

Quoted 5 lines
Quoted 3 lines

It is important for us to have a working ACPI based PCI host controller implementation for arm64, so I thought I would post this as a simple and less disruptive alternative.

It is important for everyone but that's not a reason granting shortcuts.

I am suggesting a simpler (and maybe better) implementation, which is much easier to review and merge - not a shortcut.

Quoted 8 lines
Quoted 1 line

This is tested with arm64 QEMU and OVMF. Comments are very welcome.

Tomasz's patch went through several review cycles, please help review it and test it, that's my comment.

A new version should be posted soon, previous version here:

https://lkml.org/lkml/2015/10/27/504

It seems to be v1, I did not see any ACKs from maintainers either - sorry if I am missing something here.

JC.

#7 lore raw

cover ACPI PCI support for arm64

Quoted 4 lines · Jayachandran C.
Quoted 3 lines · Lorenzo Pieralisi

[CC'ing Tomasz]

On Thu, Dec 03, 2015 at 03:54:43AM +0530, Jayachandran C wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

This is a very simple and generic implementation of a PCI host controller based on ACPI. This approach does not pull in the MMCONFIG and ECAM code from x86.

Why ? Tomasz's patchset does not move MMCONFIG and ECAM code to the generic PCI layer for fun,

Honestly, Lorenzo, I can see that it was not fun :)

Ok, maybe you have not noticed it was done on Bjorn's request to consolidate ECAM (ie pulling that code out of x86) instead of reinventing the wheel for arm64.

Quoted 10 lines
Quoted 3 lines

it is generic code and should be shared by all architectures and most importantly we should not add more churn on top of it which would complicate consolidation even further.

There is no need for such a common/generic infrastructure to walk thru a simple table. In my opinion, trying to do this added a lot of complexity into what should be a very simple patchset.

The x86 code has to deal with a lot more fw/hw issues and I fail to see why that mess should be brought into the a new architecture.

See above. We can't keep adding code that does the same thing as code already in the mainline.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

It is important for us to have a working ACPI based PCI host controller implementation for arm64, so I thought I would post this as a simple and less disruptive alternative.

It is important for everyone but that's not a reason granting shortcuts.

I am suggesting a simpler (and maybe better) implementation, which is much easier to review and merge - not a shortcut.

You are suggesting adding code to parse the MCFG table, it exists today and should be consolidated instead of adding on top of it.

Quoted 11 lines
Quoted 8 lines
Quoted 1 line

This is tested with arm64 QEMU and OVMF. Comments are very welcome.

Tomasz's patch went through several review cycles, please help review it and test it, that's my comment.

A new version should be posted soon, previous version here:

https://lkml.org/lkml/2015/10/27/504

It seems to be v1, I did not see any ACKs from maintainers either - sorry if I am missing something here.

That patchset went through several reviews already, they just reset the version. I agree with you it is time we got this done, with Tomasz's code, your code or any combination thereof, please help us get this through, thanks.

Lorenzo