--- v8
+++ v9
@@ -1,33 +1,26 @@
-This patch does three things :
- - Enables "opal.c" to create a platform device for the IMC interface
- according to the appropriate compatibility string.
- - Find the reserved-memory region details from the system device tree
- and get the base address of HOMER (Reserved memory) region address for each chip.
- - We also get the Nest PMU counter data offsets (in the HOMER region)
- and their sizes. The offsets for the counters' data are fixed and
- won't change from chip to chip.
+Code to create platform device for the IMC counters.
+Paltform devices are created based on the IMC compatibility
+string.
-The device tree parsing logic is separated from the PMU creation
-functions (which is done in subsequent patches).
-
-Patch also adds a CONFIG_HV_PERF_IMC_CTRS for the IMC driver.
+New Config flag "CONFIG_HV_PERF_IMC_CTRS" add to contain the
+IMC counter changes.
Signed-off-by: Anju T Sudhakar <anju@linux.vnet.ibm.com>
Signed-off-by: Hemant Kumar <hemant@linux.vnet.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
---
- arch/powerpc/platforms/powernv/Kconfig | 10 +++
- arch/powerpc/platforms/powernv/Makefile | 1 +
- arch/powerpc/platforms/powernv/opal-imc.c | 140 ++++++++++++++++++++++++++++++
- arch/powerpc/platforms/powernv/opal.c | 18 ++++
- 4 files changed, 169 insertions(+)
+ arch/powerpc/platforms/powernv/Kconfig | 10 +++++
+ arch/powerpc/platforms/powernv/Makefile | 1 +
+ arch/powerpc/platforms/powernv/opal-imc.c | 73 +++++++++++++++++++++++++++++++
+ arch/powerpc/platforms/powernv/opal.c | 18 ++++++++
+ 4 files changed, 102 insertions(+)
create mode 100644 arch/powerpc/platforms/powernv/opal-imc.c
diff --git a/arch/powerpc/platforms/powernv/Kconfig b/arch/powerpc/platforms/powernv/Kconfig
-index 3a07e4d..1b90a98 100644
+index 6a6f4ef..543c6cd 100644
--- a/arch/powerpc/platforms/powernv/Kconfig
+++ b/arch/powerpc/platforms/powernv/Kconfig
-@@ -27,3 +27,13 @@ config OPAL_PRD
+@@ -30,3 +30,13 @@ config OPAL_PRD
help
This enables the opal-prd driver, a facility to run processor
recovery diagnostics on OpenPower machines
@@ -52,10 +45,10 @@
+obj-$(CONFIG_HV_PERF_IMC_CTRS) += opal-imc.o
diff --git a/arch/powerpc/platforms/powernv/opal-imc.c b/arch/powerpc/platforms/powernv/opal-imc.c
new file mode 100644
-index 0000000..3a87000
+index 0000000..5b1045c
--- /dev/null
+++ b/arch/powerpc/platforms/powernv/opal-imc.c
-@@ -0,0 +1,140 @@
+@@ -0,0 +1,73 @@
+/*
+ * OPAL IMC interface detection driver
+ * Supported on POWERNV platform
@@ -64,9 +57,10 @@
+ * (C) 2017 Anju T Sudhakar, IBM Corporation.
+ * (C) 2017 Hemant K Shaw, IBM Corporation.
+ *
-+ * This program is free software; you can redistribute it and/or modify
-+ * it under the terms of the GNU General Public License version 2 as
-+ * published by the Free Software Foundation.
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version
++ * 2 of the License, or later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -91,25 +85,9 @@
+#include <asm/cputable.h>
+#include <asm/imc-pmu.h>
+
-+struct perchip_nest_info nest_perchip_info[IMC_MAX_CHIPS];
-+
-+/*
-+ * imc_pmu_setup : Setup the IMC PMUs (children of "parent").
-+ */
-+static void __init imc_pmu_setup(struct device_node *parent)
-+{
-+ if (!parent)
-+ return;
-+}
-+
+static int opal_imc_counters_probe(struct platform_device *pdev)
+{
-+ struct device_node *imc_dev, *dn, *rm_node = NULL;
-+ struct perchip_nest_info *pcni;
-+ u32 pages, nest_offset, nest_size, chip_id;
-+ int i = 0;
-+ const __be32 *addrp;
-+ u64 reg_addr, reg_size;
++ struct device_node *imc_dev = NULL;
+
+ if (!pdev || !pdev->dev.of_node)
+ return -ENODEV;
@@ -121,62 +99,10 @@
+ return -ENODEV;
+
+ imc_dev = pdev->dev.of_node;
-+
-+ /*
-+ * Nest counter data are saved in a reserved memory called HOMER.
-+ * "imc-nest-offset" identifies the counter data location within HOMER.
-+ * size : size of the entire nest-counters region
-+ */
-+ if (of_property_read_u32(imc_dev, "imc-nest-offset", &nest_offset))
-+ goto err;
-+
-+ if (of_property_read_u32(imc_dev, "imc-nest-size", &nest_size))
-+ goto err;
-+
-+ /* Sanity check */
-+ if ((nest_size/PAGE_SIZE) > IMC_NEST_MAX_PAGES)
-+ goto err;
-+
-+ /* Find the "HOMER region" for each chip */
-+ rm_node = of_find_node_by_path("/reserved-memory");
-+ if (!rm_node)
-+ goto err;
-+
-+ /*
-+ * We need to look for the "ibm,homer-image" node in the
-+ * "/reserved-memory" node.
-+ */
-+ for (dn = of_find_node_by_name(rm_node, "ibm,homer-image"); dn;
-+ dn = of_find_node_by_name(dn, "ibm,homer-image")) {
-+
-+ /* Get the chip id to which the above homer region belongs to */
-+ if (of_property_read_u32(dn, "ibm,chip-id", &chip_id))
-+ goto err;
-+
-+ pcni = &nest_perchip_info[chip_id];
-+ addrp = of_get_address(dn, 0, ®_size, NULL);
-+ if (!addrp)
-+ goto err;
-+
-+ /* Fetch the homer region base address */
-+ reg_addr = of_read_number(addrp, 2);
-+ pcni->pbase = reg_addr;
-+ /* Add the nest IMC Base offset */
-+ pcni->pbase = pcni->pbase + nest_offset;
-+ /* Fetch the size of the homer region */
-+ pcni->size = nest_size;
-+
-+ for (i = 0; i < (pcni->size / PAGE_SIZE); i++) {
-+ pages = PAGE_SIZE * i;
-+ pcni->vbase[i] = (u64)phys_to_virt(pcni->pbase + pages);
-+ }
-+ }
-+
-+ imc_pmu_setup(imc_dev);
++ if (!imc_dev)
++ return -ENODEV;
+
+ return 0;
-+err:
-+ return -ENODEV;
+}
+
+static const struct of_device_id opal_imc_match[] = {
@@ -197,7 +123,7 @@
+MODULE_DESCRIPTION("PowerNV OPAL IMC driver");
+MODULE_LICENSE("GPL");
diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
-index e0f856b..b06f896 100644
+index 59684b4..fbdca25 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -14,6 +14,7 @@
@@ -216,7 +142,7 @@
#include "powernv.h"
-@@ -631,6 +633,17 @@ static void opal_pdev_init(const char *compatible)
+@@ -705,6 +707,17 @@ static void opal_pdev_init(const char *compatible)
of_platform_device_create(np, NULL, NULL);
}
@@ -234,7 +160,7 @@
static int kopald(void *unused)
{
unsigned long timeout = msecs_to_jiffies(opal_heartbeat) + 1;
-@@ -704,6 +717,11 @@ static int __init opal_init(void)
+@@ -778,6 +791,11 @@ static int __init opal_init(void)
/* Setup a heatbeat thread if requested by OPAL */
opal_init_heartbeat();