Skip to contentSkip to conversation

ACPI based PCI host driver with generic ECAM

PATCH In review Jayachandran C 6 participants 16 messages Apr 11, 2016 – Apr 14, 2016

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

v2 cover ACPI based PCI host driver with generic ECAM

Here is v2 of the patchset for the ACPI PCI controller driver based on the earlier discussion[1].

This patchset unifies the pci-host-generic ECAM code and the ACPI PCI ECAM code much further so that both the implementations can use the same structure (struct pci_config_window) as ->sysdata.

The patchset should also make it easier to share platform quirks between DT and ACPI PCI controller drivers using struct pci_generic_ecam_ops.

Short description of the patches in the patchset:
- fixup arm64 PCI code so that it can use the generic ACPI PCI driver.
- implement pci/drivers/ecam.[ch] which will replace drivers/pci/host/pci-host-common.h API for ECAM access and will be shared by ACPI and DT.
- Update users of the pci-host-common API to the ecam API
- implement a simple PCI ACPI host. I have not used the pci_mmcfg_list or the region definitions from x86, but have used a much simpler approach here.

This should apply cleanly on top of the current 4.6 tree or the pci next tree, and can be reviewed as a patchset. The full set of changes for arm64 includes other fixes, that series is available at
https://github.com/jchandra-brcm/linux branch arm64-acpi-pci-v2

This has been tested on qemu with OVMF for the ACPI part and with device tree for pci-host-generic code. Further testing and reviews are welcome.

Thanks,
JC.

[1] https://lkml.org/lkml/2016/3/3/921

Jayachandran C (4):
arm64: Prepare to use generic ACPI PCI implementation
PCI: Provide common functions for ECAM mapping
PCI: generic, thunder: update to use generic ECAM API
ACPI: PCI: Add generic PCI host controller

 arch/arm64/Kconfig                  |   3 +
 arch/arm64/kernel/pci.c             |   7 +-
 drivers/acpi/Kconfig                |   9 ++
 drivers/acpi/Makefile               |   1 +
 drivers/acpi/pci_gen_host.c         | 258 ++++++++++++++++++++++++++++++++++++
 drivers/pci/Kconfig                 |   3 +
 drivers/pci/Makefile                |   2 +
 drivers/pci/ecam.c                  | 130 ++++++++++++++++++
 drivers/pci/ecam.h                  |  63 +++++++++
 drivers/pci/host/Kconfig            |   1 +
 drivers/pci/host/pci-host-common.c  | 121 ++++++++---------
 drivers/pci/host/pci-host-common.h  |  47 -------
 drivers/pci/host/pci-host-generic.c |  50 ++-----
 drivers/pci/host/pci-thunder-ecam.c |  37 +-----
 drivers/pci/host/pci-thunder-pem.c  |  53 +++-----
 15 files changed, 560 insertions(+), 225 deletions(-)
 create mode 100644 drivers/acpi/pci_gen_host.c
 create mode 100644 drivers/pci/ecam.c
 create mode 100644 drivers/pci/ecam.h
 delete mode 100644 drivers/pci/host/pci-host-common.h
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/4 arm64: Prepare to use generic ACPI PCI implementation

Define PCI_MMCONFIG config option for arm64.

Weaken implementations of raw_pci_read/write and pci_acpi_scan_root, the generic ACPI PCI driver will implement these.

---
 arch/arm64/Kconfig      | 3 +++
 arch/arm64/kernel/pci.c | 7 +++----
 2 files changed, 6 insertions(+), 4 deletions(-)
arch/arm64/Kconfig +3 -0
index 4f43622..6c6658a 100644
@@ -236,6 +236,9 @@ config PCI_DOMAINS_GENERIC
 config PCI_SYSCALL
 	def_bool PCI
 
+config PCI_MMCONFIG
+	bool
+
 source "drivers/pci/Kconfig"
 
 endmenu
arch/arm64/kernel/pci.c +3 -4
index 15109c11..098028c 100644
@@ -67,13 +67,13 @@ int pcibios_alloc_irq(struct pci_dev *dev)
 /*
  * raw_pci_read/write - Platform-specific PCI config space access.
  */
-int raw_pci_read(unsigned int domain, unsigned int bus,
+int __weak raw_pci_read(unsigned int domain, unsigned int bus,
 		  unsigned int devfn, int reg, int len, u32 *val)
 {
 	return -ENXIO;
 }
 
-int raw_pci_write(unsigned int domain, unsigned int bus,
+int __weak raw_pci_write(unsigned int domain, unsigned int bus,
 		unsigned int devfn, int reg, int len, u32 val)
 {
 	return -ENXIO;
@@ -81,9 +81,8 @@ 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;
 }
 #endif
Signature · 1 line
1.9.1
#2 lore raw

PATCH v2 2/4 PCI: Provide common functions for ECAM mapping

In reply to Jayachandran C

Add config option PCI_GENERIC_ECAM and file drivers/pci/ecam.c to provide generic functions for accessing memory mapped PCI config space.

The API is defined in drivers/pci/ecam.h and is written to replace the API in drivers/pci/host/pci-host-common.h. The file defines a new 'struct pci_config_window' to hold the information related to a PCI config area and its mapping. This structure is expected to be used as sysdata for controllers that have ECAM based mapping.

Helper functions are provided to setup the mapping, free the mapping and to implement the map_bus method in 'struct pci_ops'

---
 drivers/pci/Kconfig  |   3 ++
 drivers/pci/Makefile |   2 +
 drivers/pci/ecam.c   | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/pci/ecam.h   |  58 +++++++++++++++++++++++
 4 files changed, 193 insertions(+)
 create mode 100644 drivers/pci/ecam.c
 create mode 100644 drivers/pci/ecam.h
drivers/pci/Kconfig +3 -0
index 209292e..e930d62 100644
@@ -83,6 +83,9 @@ config HT_IRQ
 config PCI_ATS
 	bool
 
+config PCI_GENERIC_ECAM
+	bool
+
 config PCI_IOV
 	bool "PCI IOV support"
 	depends on PCI
drivers/pci/Makefile +2 -0
index 2154092..810aec8 100644
@@ -55,6 +55,8 @@ obj-$(CONFIG_PCI_SYSCALL) += syscall.o
 
 obj-$(CONFIG_PCI_STUB) += pci-stub.o
 
+obj-$(CONFIG_PCI_GENERIC_ECAM) += ecam.o
+
 obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += xen-pcifront.o
 
 obj-$(CONFIG_OF) += of.o
drivers/pci/ecam.c new file +130 -0

130 lines not on this page · raw message

drivers/pci/ecam.h new file +58 -0

58 lines not on this page · raw message

Signature · 1 line
1.9.1
#9 lore raw

PATCH v2 3/4 PCI: generic, thunder: update to use generic ECAM API

In reply to Jayachandran C

Use functions provided by drivers/pci/ecam.h for mapping the config space in drivers/pci/host/pci-host-common.c, and update its users to use 'struct pci_config_window' and 'struct pci_generic_ecam_ops'

The changes are mostly to use 'struct pci_config_window' in place of 'struct gen_pci'. Some of the fields of gen_pci were only used temporarily and can be eliminated by using local variables or function arguments, these are not carried over to struct pci_config_window.

pci-thunder-ecam.c and pci-thunder-pem.c are the only users of the pci_host_common_probe function and the gen_pci structure, these have been updated to use the new API as well.

The patch does not introduce any functional changes other than a very minor one: with the new code, on 64-bit platforms, we do just a single ioremap for the whole config space.

---
 drivers/pci/ecam.h                  |   5 ++
 drivers/pci/host/Kconfig            |   1 +
 drivers/pci/host/pci-host-common.c  | 121 ++++++++++++++++--------------------
 drivers/pci/host/pci-host-common.h  |  47 --------------
 drivers/pci/host/pci-host-generic.c |  50 +++------------
 drivers/pci/host/pci-thunder-ecam.c |  37 +++--------
 drivers/pci/host/pci-thunder-pem.c  |  53 +++++-----------
 7 files changed, 93 insertions(+), 221 deletions(-)
 delete mode 100644 drivers/pci/host/pci-host-common.h
drivers/pci/ecam.h +5 -0
index dda8c50..8a9ca51 100644
@@ -55,4 +55,9 @@ void __iomem *pci_generic_ecam_map_bus(struct pci_bus *bus, unsigned int devfn,
 /* default ECAM ops, bus shift 20, generic read and write */
 extern struct pci_generic_ecam_ops pci_generic_ecam_default_ops;
 
+#ifdef CONFIG_PCI_HOST_GENERIC
+/* for DT based pci controllers that support ECAM */
+int pci_host_common_probe(struct platform_device *pdev,
+			  struct pci_generic_ecam_ops *ops, void *priv);
+#endif
 #endif
drivers/pci/host/Kconfig +1 -0
index 7a0780d..31d6eb5 100644
@@ -82,6 +82,7 @@ config PCI_HOST_GENERIC
 	bool "Generic PCI host controller"
 	depends on (ARM || ARM64) && OF
 	select PCI_HOST_COMMON
+	select PCI_GENERIC_ECAM
 	help
 	  Say Y here if you want to support a simple generic PCI host
 	  controller, such as the one emulated by kvmtool.
drivers/pci/host/pci-host-common.c +54 -67

182 lines not on this page · raw message

drivers/pci/host/pci-host-common.h deleted +0 -47

47 lines not on this page · raw message

drivers/pci/host/pci-host-generic.c +9 -41

75 lines not on this page · raw message

drivers/pci/host/pci-thunder-ecam.c +7 -30
index d71935cb..6b8d4b4 100644
@@ -13,18 +13,7 @@
 #include <linux/of.h>
 #include <linux/platform_device.h>
 
-#include "pci-host-common.h"
-
-/* Mapping is standard ECAM */
-static void __iomem *thunder_ecam_map_bus(struct pci_bus *bus,
-					  unsigned int devfn,
-					  int where)
-{
-	struct gen_pci *pci = bus->sysdata;
-	resource_size_t idx = bus->number - pci->cfg.bus_range->start;
-
-	return pci->cfg.win[idx] + ((devfn << 12) | where);
-}
+#include "../ecam.h"
 
 static void set_val(u32 v, int where, int size, u32 *val)
 {
@@ -99,7 +88,7 @@ static int handle_ea_bar(u32 e0, int bar, struct pci_bus *bus,
 static int thunder_ecam_p2_config_read(struct pci_bus *bus, unsigned int devfn,
 				       int where, int size, u32 *val)
 {
-	struct gen_pci *pci = bus->sysdata;
+	struct pci_config_window *cfg = bus->sysdata;
 	int where_a = where & ~3;
 	void __iomem *addr;
 	u32 node_bits;
@@ -129,7 +118,7 @@ static int thunder_ecam_p2_config_read(struct pci_bus *bus, unsigned int devfn,
 	 * the config space access window.  Since we are working with
 	 * the high-order 32 bits, shift everything down by 32 bits.
 	 */
-	node_bits = (pci->cfg.res.start >> 32) & (1 << 12);
+	node_bits = (cfg->cfgaddr >> 32) & (1 << 12);
 
 	v |= node_bits;
 	set_val(v, where, size, val);
@@ -358,36 +347,24 @@ static int thunder_ecam_config_write(struct pci_bus *bus, unsigned int devfn,
 	return pci_generic_config_write(bus, devfn, where, size, val);
 }
 
-static struct gen_pci_cfg_bus_ops thunder_ecam_bus_ops = {
+static struct pci_generic_ecam_ops thunder_ecam_bus_ops = {
 	.bus_shift	= 20,
 	.ops		= {
-		.map_bus        = thunder_ecam_map_bus,
+		.map_bus        = pci_generic_ecam_map_bus,
 		.read           = thunder_ecam_config_read,
 		.write          = thunder_ecam_config_write,
 	}
 };
 
 static const struct of_device_id thunder_ecam_of_match[] = {
-	{ .compatible = "cavium,pci-host-thunder-ecam",
-	  .data = &thunder_ecam_bus_ops },
-
+	{ .compatible = "cavium,pci-host-thunder-ecam" },
 	{ },
 };
 MODULE_DEVICE_TABLE(of, thunder_ecam_of_match);
 
 static int thunder_ecam_probe(struct platform_device *pdev)
 {
-	struct device *dev = &pdev->dev;
-	const struct of_device_id *of_id;
-	struct gen_pci *pci = devm_kzalloc(dev, sizeof(*pci), GFP_KERNEL);
-
-	if (!pci)
-		return -ENOMEM;
-
-	of_id = of_match_node(thunder_ecam_of_match, dev->of_node);
-	pci->cfg.ops = (struct gen_pci_cfg_bus_ops *)of_id->data;
-
-	return pci_host_common_probe(pdev, pci);
+	return pci_host_common_probe(pdev, &thunder_ecam_bus_ops, NULL);
 }
 
 static struct platform_driver thunder_ecam_driver = {
drivers/pci/host/pci-thunder-pem.c +17 -36

138 lines not on this page · raw message

Signature · 1 line
1.9.1
#12 lore raw

PATCH v2 4/4 ACPI: PCI: Add generic PCI host controller

In reply to Jayachandran C

Add a generic ACPI based PCI host controller, and provide a config option ACPI_PCI_HOST_GENERIC to enable it.

The implementation selects PCI_GENERIC_ECAM and uses functions from drivers/pci/ecam.h to create and access ECAM mappings. It also selects PCI_MMCONFIG and implements the pci_mmcfg_late_init() function to parse and map entries in the MCFG table.

The implementation of pci_acpi_scan_root() looks up the saved mappings and sets up a new mapping if needed. Generic PCI functions are used for accessing config space.

---
 drivers/acpi/Kconfig        |   9 ++
 drivers/acpi/Makefile       |   1 +
 drivers/acpi/pci_gen_host.c | 258 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 268 insertions(+)
 create mode 100644 drivers/acpi/pci_gen_host.c
drivers/acpi/Kconfig +9 -0
index 82b96ee..f178f2e 100644
@@ -343,6 +343,15 @@ config ACPI_PCI_SLOT
 	  i.e., segment/bus/device/function tuples, with physical slots in
 	  the system.  If you are unsure, say N.
 
+config ACPI_PCI_HOST_GENERIC
+	bool "Generic ACPI based PCI controller"
+	depends on ARM64
+	select PCI_MMCONFIG
+	select PCI_GENERIC_ECAM
+	help
+	  Say Y if you want the generic ACPI based PCI controller
+	  implementation.
+
 config X86_PM_TIMER
 	bool "Power Management Timer Support" if EXPERT
 	depends on X86
drivers/acpi/Makefile +1 -0
index edeb2d1..eaf429c 100644
@@ -66,6 +66,7 @@ obj-$(CONFIG_ACPI_BUTTON)	+= button.o
 obj-$(CONFIG_ACPI_FAN)		+= fan.o
 obj-$(CONFIG_ACPI_VIDEO)	+= video.o
 obj-$(CONFIG_ACPI_PCI_SLOT)	+= pci_slot.o
+obj-$(CONFIG_ACPI_PCI_HOST_GENERIC)	+= pci_gen_host.o
 obj-$(CONFIG_ACPI_PROCESSOR)	+= processor.o
 obj-$(CONFIG_ACPI)		+= container.o
 obj-$(CONFIG_ACPI_THERMAL)	+= thermal.o
drivers/acpi/pci_gen_host.c new file +258 -0

258 lines not on this page · raw message

Signature · 1 line
1.9.1
Tested-by on v2 2/4
#3 lore raw

Re: [PATCH v2 2/4] PCI: Provide common functions for ECAM mapping

In reply to Jayachandran C
Quoted 9 lines · Jayachandran C

Add config option PCI_GENERIC_ECAM and file drivers/pci/ecam.c to provide generic functions for accessing memory mapped PCI config space.

The API is defined in drivers/pci/ecam.h and is written to replace the API in drivers/pci/host/pci-host-common.h. The file defines a new 'struct pci_config_window' to hold the information related to a PCI config area and its mapping. This structure is expected to be used as sysdata for controllers that have ECAM based mapping.

Quoted 4 lines

Helper functions are provided to setup the mapping, free the mapping and to implement the map_bus method in 'struct pci_ops'

Quoted 5 lines
---
  drivers/pci/Kconfig  |   3 ++
  drivers/pci/Makefile |   2 +
  drivers/pci/ecam.c   | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++
  drivers/pci/ecam.h   |  58 +++++++++++++++++++++++

I wonder if these files should go in drivers/pci/host ... I understand that you still have to use them from drivers/pci/acpi though.

I will let others opine on this, but could you put the contents of ecam.h into include/linux/pci.h along with the pci_generic_config_*() declarations?

If you did that, the contents of ecam.c could go into drivers/pci/access.c...

Quoted 4 lines
  4 files changed, 193 insertions(+)

create mode 100644 drivers/pci/ecam.c
create mode 100644 drivers/pci/ecam.h

[...]

Tested-by on v2 3/4
#10 lore raw

Re: [PATCH v2 3/4] PCI: generic, thunder: update to use generic ECAM API

In reply to Jayachandran C
Quoted 13 lines · Jayachandran C

Use functions provided by drivers/pci/ecam.h for mapping the config space in drivers/pci/host/pci-host-common.c, and update its users to use 'struct pci_config_window' and 'struct pci_generic_ecam_ops'

The changes are mostly to use 'struct pci_config_window' in place of 'struct gen_pci'. Some of the fields of gen_pci were only used temporarily and can be eliminated by using local variables or function arguments, these are not carried over to struct pci_config_window.

pci-thunder-ecam.c and pci-thunder-pem.c are the only users of the pci_host_common_probe function and the gen_pci structure, these have been updated to use the new API as well.

Quoted 5 lines

The patch does not introduce any functional changes other than a very minor one: with the new code, on 64-bit platforms, we do just a single ioremap for the whole config space.

However, ...

Quoted 8 lines
---
  drivers/pci/ecam.h                  |   5 ++
  drivers/pci/host/Kconfig            |   1 +
  drivers/pci/host/pci-host-common.c  | 121 ++++++++++++++++--------------------
  drivers/pci/host/pci-host-common.h  |  47 --------------
  drivers/pci/host/pci-host-generic.c |  50 +++------------
  drivers/pci/host/pci-thunder-ecam.c |  37 +++--------
  drivers/pci/host/pci-thunder-pem.c  |  53 +++++-----------

... The patch conflicts with a bug-fix patch I just sent to pci-thunder-pem.c, so there will be a race to see who gets in first.

Also, I don't know if it would make sense to split out the pci-thunder-* changes to a separate patch.

Quoted 3 lines
  7 files changed, 93 insertions(+), 221 deletions(-)

delete mode 100644 drivers/pci/host/pci-host-common.h

[...]

#13 lore raw

Re: [PATCH v2 4/4] ACPI: PCI: Add generic PCI host controller

In reply to Jayachandran C
reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…

Hi Jayachandran,

[auto build test ERROR on pci/next]
[also build test ERROR on v4.6-rc3 next-20160411]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Jayachandran-C/ACPI-based-PCI-host-driver-with-generic-ECAM/20160412-064853
base:   https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next
config: arm64-allyesconfig (attached as .config)

reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm64

All errors (new ones prefixed by >>):

>> drivers/xen/pci.c:31:25: fatal error: asm/pci_x86.h: No such file or directory
    #include <asm/pci_x86.h>
                            ^

compilation terminated.

vim +31 drivers/xen/pci.c

e28c31a9 Weidong Han           2010-10-27  15   * Place - Suite 330, Boston, MA 02111-1307 USA.
e28c31a9 Weidong Han           2010-10-27  16   *
e28c31a9 Weidong Han           2010-10-27  17   * Author: Weidong Han <[email protected]>
e28c31a9 Weidong Han           2010-10-27  18   */
e28c31a9 Weidong Han           2010-10-27  19  
e28c31a9 Weidong Han           2010-10-27  20  #include <linux/pci.h>
55e901fc Jan Beulich           2011-09-22  21  #include <linux/acpi.h>
0b97b03d Ross Lagerwall        2015-04-09  22  #include <linux/pci-acpi.h>
e28c31a9 Weidong Han           2010-10-27  23  #include <xen/xen.h>
e28c31a9 Weidong Han           2010-10-27  24  #include <xen/interface/physdev.h>
e28c31a9 Weidong Han           2010-10-27  25  #include <xen/interface/xen.h>
e28c31a9 Weidong Han           2010-10-27  26  
e28c31a9 Weidong Han           2010-10-27  27  #include <asm/xen/hypervisor.h>
e28c31a9 Weidong Han           2010-10-27  28  #include <asm/xen/hypercall.h>
e28c31a9 Weidong Han           2010-10-27  29  #include "../pci/pci.h"
b7ef4a6d Ben Hutchings         2013-12-31  30  #ifdef CONFIG_PCI_MMCONFIG
8deb3eb1 Konrad Rzeszutek Wilk 2013-10-25 @31  #include <asm/pci_x86.h>
b7ef4a6d Ben Hutchings         2013-12-31  32  #endif
e28c31a9 Weidong Han           2010-10-27  33  
55e901fc Jan Beulich           2011-09-22  34  static bool __read_mostly pci_seg_supported = true;
55e901fc Jan Beulich           2011-09-22  35  
e28c31a9 Weidong Han           2010-10-27  36  static int xen_add_device(struct device *dev)
e28c31a9 Weidong Han           2010-10-27  37  {
e28c31a9 Weidong Han           2010-10-27  38  	int r;
e28c31a9 Weidong Han           2010-10-27  39  	struct pci_dev *pci_dev = to_pci_dev(dev);

:::::: The code at line 31 was first introduced by commit
:::::: 8deb3eb1461e4cb136c88d03ec5a6729ccf2f933 xen/mcfg: Call PHYSDEVOP_pci_mmcfg_reserved for MCFG areas.

:::::: TO: Konrad Rzeszutek Wilk <[email protected]> :::::: CC: Konrad Rzeszutek Wilk <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#4 lore raw

Re: [PATCH v2 2/4] PCI: Provide common functions for ECAM mapping

In reply to David Daney

Hi David, JC,

Quoted 1 line · David Daney

On ThunderX (please let me know the silicon pass specifics off-list)? I'm planning to give this series a test run also on some other ARMv8 hardware and will prod a few of the other vendors to do so.

Quoted 6 lines
Quoted 2 lines
  drivers/pci/ecam.c   | 130
  drivers/pci/ecam.h   |  58 +++++++++++++++++++++++

I wonder if these files should go in drivers/pci/host ... I understand that you still have to use them from drivers/pci/acpi though.

Quoted 6 lines

I will let others opine on this, but could you put the contents of ecam.h into include/linux/pci.h along with the pci_generic_config_*() declarations?

If you did that, the contents of ecam.c could go into drivers/pci/access.c...

Quoting Bjorn's original reply to the previous series:

Quoted 4 lines

Some of the code that moved to drivers/acpi/pci_mcfg.c is not really ACPI-specific, and could potentially be used for non-ACPI bridges that support ECAM. I'd like to see that sort of code moved to a new file like drivers/pci/ecam.c.

So my guess is that this is the reasoning behind JC's file layout.

I'm curious what Lorenzo's take on things is currently. I assume this series is now to be the official coordinated version of this effort for upstream, following the advice of Bjorn previously, but I would like to know if everyone is behind this plan. I've (previously) requested a Linaro LEG meeting this week (part of our bootarch working group) to specifically discuss the status of PCI upstreaming in order to get the different vendors together to ensure every single one of them is tracking the correct latest effort and doing what is needed to test/aid, hence my ask. If this is now plan A, I'll make sure everyone is aligned behind it and start pinging people individually for testing.

Jon.

Signature · 1 line
Computer Architect
#5 lore raw

Re: [PATCH v2 2/4] PCI: Provide common functions for ECAM mapping

On Tue, Apr 12, 2016 at 12:26:25AM -0400, Jon Masters wrote:

[...]

Quoted 9 lines

Quoting Bjorn's original reply to the previous series:

Quoted 4 lines

Some of the code that moved to drivers/acpi/pci_mcfg.c is not really ACPI-specific, and could potentially be used for non-ACPI bridges that support ECAM. I'd like to see that sort of code moved to a new file like drivers/pci/ecam.c.

So my guess is that this is the reasoning behind JC's file layout.

Quoted 10 lines

I'm curious what Lorenzo's take on things is currently. I assume this series is now to be the official coordinated version of this effort for upstream, following the advice of Bjorn previously, but I would like to know if everyone is behind this plan. I've (previously) requested a Linaro LEG meeting this week (part of our bootarch working group) to specifically discuss the status of PCI upstreaming in order to get the different vendors together to ensure every single one of them is tracking the correct latest effort and doing what is needed to test/aid, hence my ask. If this is now plan A, I'll make sure everyone is aligned behind it and start pinging people individually for testing.

My take is that JC's aim is to get this four patch series reviewed and merged (which is *not* sufficient to get ACPI PCI to work fully on ARM64
- see cover letter - the remaining patches in his branch are not fixes, it is code that is required to get things to work, these 4 patches stand alone are not sufficient but I understand he wants to get them reviewed following feedback on the lists) so that we can make progress on ACPI PCI on ARM64.

I will comment on the patches as soon as I have time to review them, I certainly would like to understand what we have to do with the rest of the code though (provided this series is good to go) see above.

Lorenzo

#6 lore raw

Re: [PATCH v2 2/4] PCI: Provide common functions for ECAM mapping

Quoted 24 lines · Lorenzo Pieralisi

On Tue, Apr 12, 2016 at 12:26:25AM -0400, Jon Masters wrote:

[...]

Quoted 9 lines

Quoting Bjorn's original reply to the previous series:

Quoted 4 lines

Some of the code that moved to drivers/acpi/pci_mcfg.c is not really ACPI-specific, and could potentially be used for non-ACPI bridges that support ECAM. I'd like to see that sort of code moved to a new file like drivers/pci/ecam.c.

So my guess is that this is the reasoning behind JC's file layout.

Quoted 10 lines

I'm curious what Lorenzo's take on things is currently. I assume this series is now to be the official coordinated version of this effort for upstream, following the advice of Bjorn previously, but I would like to know if everyone is behind this plan. I've (previously) requested a Linaro LEG meeting this week (part of our bootarch working group) to specifically discuss the status of PCI upstreaming in order to get the different vendors together to ensure every single one of them is tracking the correct latest effort and doing what is needed to test/aid, hence my ask. If this is now plan A, I'll make sure everyone is aligned behind it and start pinging people individually for testing.

Quoted 2 lines

My take is that JC's aim is to get this four patch series reviewed and merged

Indeed, I see that's probably the goal, and why not :)

Quoted 6 lines

(which is *not* sufficient to get ACPI PCI to work fully on ARM64
- see cover letter - the remaining patches in his branch are not fixes, it is code that is required to get things to work, these 4 patches stand alone are not sufficient but I understand he wants to get them reviewed following feedback on the lists) so that we can make progress on ACPI PCI on ARM64.

Agreed. I went through the branch and the 11 patches there, reacquainted myself with what's what. So what we have now is 4 patches here plus a few others that in total replace v5 of your previous mmconfig patches in functionality. The question is what happens with the rest (of JC's branch let's say) - do they get sent out now too?

Quoted 3 lines

I will comment on the patches as soon as I have time to review them, I certainly would like to understand what we have to do with the rest of the code though (provided this series is good to go) see above.

Right. That's my reason for asking. I'd like to know who is driving (I believe that to be Lorenzo) and what the path forward is, and whether we need to get additional support from anyone else. There's a multi-vendor meeting in the morning where I'm going to summarize the current state of these patches and I would like to know (soon) what the plan is so that we can get everyone on deck to help out at least with testing (most have tested the previous set, but we need public acks happening).

Jon.

#7 lore raw

Re: [PATCH v2 2/4] PCI: Provide common functions for ECAM mapping

On Thu, Apr 14, 2016 at 01:55:32AM -0400, Jon Masters wrote:

[...]

Quoted 11 lines
Quoted 3 lines

I will comment on the patches as soon as I have time to review them, I certainly would like to understand what we have to do with the rest of the code though (provided this series is good to go) see above.

Right. That's my reason for asking. I'd like to know who is driving (I believe that to be Lorenzo) and what the path forward is, and whether we need to get additional support from anyone else. There's a multi-vendor meeting in the morning where I'm going to summarize the current state of these patches and I would like to know (soon) what the plan is so that we can get everyone on deck to help out at least with testing (most have tested the previous set, but we need public acks happening).

Testing always helps, this code needs reviewing from PCI and ACPI standpoints, what we can do is review this series and repost the whole thing when we agree the ECAM refactoring this series is implementing is the right way to go and it is a step in that direction, with no generic MCFG support in the kernel ACPI PCI on ARM64 can't be implemented so I would start from that.

Lorenzo

#11 lore raw

Re: [PATCH v2 3/4] PCI: generic, thunder: update to use generic ECAM API

In reply to David Daney

Hi David,

Quoted 15 lines · David Daney
Quoted 14 lines · Jayachandran C

Use functions provided by drivers/pci/ecam.h for mapping the config space in drivers/pci/host/pci-host-common.c, and update its users to use 'struct pci_config_window' and 'struct pci_generic_ecam_ops'

The changes are mostly to use 'struct pci_config_window' in place of 'struct gen_pci'. Some of the fields of gen_pci were only used temporarily and can be eliminated by using local variables or function arguments, these are not carried over to struct pci_config_window.

pci-thunder-ecam.c and pci-thunder-pem.c are the only users of the pci_host_common_probe function and the gen_pci structure, these have been updated to use the new API as well.

Quoted 8 lines
Quoted 5 lines

The patch does not introduce any functional changes other than a very minor one: with the new code, on 64-bit platforms, we do just a single ioremap for the whole config space.

Thanks.

Quoted 13 lines

However, ...

Quoted 9 lines
---
  drivers/pci/ecam.h                  |   5 ++
  drivers/pci/host/Kconfig            |   1 +
  drivers/pci/host/pci-host-common.c  | 121
++++++++++++++++--------------------
  drivers/pci/host/pci-host-common.h  |  47 --------------
  drivers/pci/host/pci-host-generic.c |  50 +++------------
  drivers/pci/host/pci-thunder-ecam.c |  37 +++--------
  drivers/pci/host/pci-thunder-pem.c  |  53 +++++-----------
Quoted 2 lines

... The patch conflicts with a bug-fix patch I just sent to pci-thunder-pem.c, so there will be a race to see who gets in first.

I would expect this patchset to take more time than the bugfix. I will update the patches when the fix is queued to -next.

Quoted 2 lines

Also, I don't know if it would make sense to split out the pci-thunder-* changes to a separate patch.

In this case, I think splitting the pci-thunder-* will make it more complex than just switching everything to ecam.h in one go.

If the patch needs to be split, I can move some of the simplification that was done to gen_pci structure and pci-host-common to a separate patch.

JC.

#8 lore raw

Re: [PATCH v2 2/4] PCI: Provide common functions for ECAM mapping

In reply to David Daney
Quoted 11 lines · David Daney
Quoted 10 lines · Jayachandran C

Add config option PCI_GENERIC_ECAM and file drivers/pci/ecam.c to provide generic functions for accessing memory mapped PCI config space.

The API is defined in drivers/pci/ecam.h and is written to replace the API in drivers/pci/host/pci-host-common.h. The file defines a new 'struct pci_config_window' to hold the information related to a PCI config area and its mapping. This structure is expected to be used as sysdata for controllers that have ECAM based mapping.

Quoted 6 lines
Quoted 4 lines

Helper functions are provided to setup the mapping, free the mapping and to implement the map_bus method in 'struct pci_ops'

I have updated the git tree (https://github.com/jchandra-brcm/linux/)
with a branch arm64-acpi-pci-v3 . The branch has a new patch to use thunder ECAM ops in case of Cavium ThunderX platform when doing generic ACPI PCI initialization.

I am hoping that the controllers that have "ECAM with quirks" can use this mechanism for sharing the quirks between OF and ACPI.

If you have some time to review the patch and see it works for you, then I can post it with the v3 of this patchset.

Quoted 11 lines
Quoted 6 lines
---
  drivers/pci/Kconfig  |   3 ++
  drivers/pci/Makefile |   2 +
  drivers/pci/ecam.c   | 130
+++++++++++++++++++++++++++++++++++++++++++++++++++
  drivers/pci/ecam.h   |  58 +++++++++++++++++++++++

I wonder if these files should go in drivers/pci/host ... I understand that you still have to use them from drivers/pci/acpi though.

Quoted 6 lines

I will let others opine on this, but could you put the contents of ecam.h into include/linux/pci.h along with the pci_generic_config_*() declarations?

If you did that, the contents of ecam.c could go into drivers/pci/access.c...

Earlier discussion seems to indicated that separate ecam.c/h was preferred. But I agree that it may be small enough to be merged.

Thanks,
JC.

#14 lore raw

Re: [PATCH v2 4/4] ACPI: PCI: Add generic PCI host controller

In reply to Jayachandran C

drivers/acpi/pci_gen_host.c line 59

Quoted 12 lines · Jayachandran C
drivers/acpi/pci_gen_host.c new file +12 -0
+/* find the entry in cfgarr which contains range bus_start..bus_end */
+static int mcfg_lookup(u16 seg, u8 bus_start, u8 bus_end)
+{
+	struct pci_config_window *cfg;
+	int i;
+
+	if (!cfgarr)
+		return -ENOENT;
+
+	for (i = 0; cfgarr[i]; i++) {
+		cfg = cfgarr[i];
+

I see that you are allocating an array of cfgarr to keep the MCFG table entries. The above way of checking the number of entries is not correct.

You should keep track of the number of entries you found out globally instead of relying an element being NULL or not.

If you exceed the array size, you may or may not be lucky to find another entry in memory.

Signature · 3 lines
Sinan Kaya
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
#15 lore raw

Re: [PATCH v2 4/4] ACPI: PCI: Add generic PCI host controller

Quoted 17 lines · Sinan Kaya

drivers/acpi/pci_gen_host.c line 59

Quoted 12 lines · Jayachandran C
drivers/acpi/pci_gen_host.c new file +12 -0
+/* find the entry in cfgarr which contains range bus_start..bus_end */
+static int mcfg_lookup(u16 seg, u8 bus_start, u8 bus_end)
+{
+	struct pci_config_window *cfg;
+	int i;
+
+	if (!cfgarr)
+		return -ENOENT;
+
+	for (i = 0; cfgarr[i]; i++) {
+		cfg = cfgarr[i];
+

I see that you are allocating an array of cfgarr to keep the MCFG table entries. The above way of checking the number of entries is not correct.

Quoted 6 lines

You should keep track of the number of entries you found out globally instead of relying an element being NULL or not.

If you exceed the array size, you may or may not be lucky to find another entry in memory.

I see now that you are allocating an extra element in memory. Still, looping to find out the number of elements didn't quite look good to me.

+ for (i = 0; cfgarr[i]; i++)
+ ;
+ pr_info(PREFIX " MCFG table at loaded, %d entries\n", i);

Signature · 3 lines
Sinan Kaya
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project