lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1456199198-11056-4-git-send-email-maddy@linux.vnet.ibm.com>
Date:	Tue, 23 Feb 2016 09:16:34 +0530
From:	Madhavan Srinivasan <maddy@...ux.vnet.ibm.com>
To:	linux-kernel@...r.kernel.org
Cc:	Madhavan Srinivasan <maddy@...ux.vnet.ibm.com>,
	Michael Ellerman <mpe@...erman.id.au>,
	Benjamin Herrenschmidt <benh@...nel.crashing.org>,
	Paul Mackerras <paulus@...ba.org>,
	Anton Blanchard <anton@...ba.org>,
	Daniel Axtens <dja@...ens.net>,
	Stephane Eranian <eranian@...gle.com>,
	Sukadev Bhattiprolu <sukadev@...ux.vnet.ibm.com>
Subject: [PATCH v8 3/7] powerpc/powernv: autoload nest unit driver module

Device tree parsing of nest units and events are
separated from pmu code and are placed in powernv/
as "opal-nest.c". Makefile is updated to up pick
the file.

Code added to "opal.c" to create a platform device
for the nest unit. Nest device module code with a
probe function to get the nest counter memory address
information for each chip is added in this patch.

"ibm,opal-in-memory-counters" compatible string is
used for autoload device_id match.

Cc: Michael Ellerman <mpe@...erman.id.au>
Cc: Benjamin Herrenschmidt <benh@...nel.crashing.org>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Anton Blanchard <anton@...ba.org>
Cc: Daniel Axtens <dja@...ens.net>
Cc: Stephane Eranian <eranian@...gle.com>
Cc: Sukadev Bhattiprolu <sukadev@...ux.vnet.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@...ux.vnet.ibm.com>
---
 arch/powerpc/platforms/powernv/Makefile    |  2 +-
 arch/powerpc/platforms/powernv/opal-nest.c | 97 ++++++++++++++++++++++++++++++
 arch/powerpc/platforms/powernv/opal.c      | 12 ++++
 3 files changed, 110 insertions(+), 1 deletion(-)
 create mode 100644 arch/powerpc/platforms/powernv/opal-nest.c

diff --git a/arch/powerpc/platforms/powernv/Makefile b/arch/powerpc/platforms/powernv/Makefile
index f1516b5ecec9..ffc54cd49656 100644
--- a/arch/powerpc/platforms/powernv/Makefile
+++ b/arch/powerpc/platforms/powernv/Makefile
@@ -2,7 +2,7 @@ obj-y			+= setup.o opal-wrappers.o opal.o opal-async.o idle.o
 obj-y			+= opal-rtc.o opal-nvram.o opal-lpc.o opal-flash.o
 obj-y			+= rng.o opal-elog.o opal-dump.o opal-sysparam.o opal-sensor.o
 obj-y			+= opal-msglog.o opal-hmi.o opal-power.o opal-irqchip.o
-obj-y			+= opal-kmsg.o
+obj-y			+= opal-kmsg.o opal-nest.o
 
 obj-$(CONFIG_SMP)	+= smp.o subcore.o subcore-asm.o
 obj-$(CONFIG_PCI)	+= pci.o pci-p5ioc2.o pci-ioda.o npu-dma.o
diff --git a/arch/powerpc/platforms/powernv/opal-nest.c b/arch/powerpc/platforms/powernv/opal-nest.c
new file mode 100644
index 000000000000..2ca879fdf159
--- /dev/null
+++ b/arch/powerpc/platforms/powernv/opal-nest.c
@@ -0,0 +1,97 @@
+/*
+ * OPAL Nest detection interface driver
+ * Supported on POWERNV platform
+ *
+ * Copyright IBM Corporation 2016
+ *
+ * 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 distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/miscdevice.h>
+#include <linux/fs.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_platform.h>
+#include <linux/poll.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include <asm/opal.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <asm/nest-pmu.h>
+
+extern struct perchip_nest_info nest_perchip_info[NEST_MAX_CHIPS];
+
+static int opal_nest_counters_probe(struct platform_device *pdev)
+{
+	struct device_node *child, *parent;
+	struct perchip_nest_info *pcni;
+	u32 idx, range[4], pages;
+	int rc=0, i=0;
+
+	if (!pdev || !pdev->dev.of_node)
+		return -ENODEV;
+
+	/*
+	 * "nest-counters" folder contains two things,
+	 * a) per-chip reserved memory region for Nest PMU Counter data
+	 * b) Support Nest PMU units and their event files
+	 */
+	parent = pdev->dev.of_node;
+	for_each_child_of_node(parent, child) {
+		if (of_property_read_u32(child, "ibm,chip-id", &idx)) {
+			pr_err("opal-nest-counters: device %s missing property\n",
+							child->full_name);
+			return -ENODEV;
+		}
+
+		/*
+		 *"ranges" property will have four u32 cells.
+		 */
+		if (of_property_read_u32_array(child, "ranges", range, 4)) {
+			pr_err("opal-nest-counters: range property value wrong\n");
+			return -1;
+		}
+
+		pcni = &nest_perchip_info[idx];
+		pcni->pbase = range[1];
+		pcni->pbase = pcni->pbase << 32 | range[2];
+		pcni->size = range[3];
+
+		do
+		{
+			pages = PAGE_SIZE * i;
+			pcni->vbase[i++] = (u64)phys_to_virt(pcni->pbase + pages);
+		} while( i < (pcni->size/PAGE_SIZE));
+	}
+
+	return rc;
+}
+
+static const struct of_device_id opal_nest_match[] = {
+	{ .compatible = "ibm,opal-in-memory-counters" },
+	{ },
+};
+
+static struct platform_driver opal_nest_driver = {
+	.driver = {
+		.name           = "opal-nest-counters",
+		.of_match_table = opal_nest_match,
+	},
+	.probe  = opal_nest_counters_probe,
+};
+
+MODULE_DEVICE_TABLE(of, opal_nest_match);
+module_platform_driver(opal_nest_driver);
+MODULE_DESCRIPTION("PowerNV OPAL Nest Counters driver");
+MODULE_LICENSE("GPL");
diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
index 4e0da5af94a1..60b576d1fc94 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -651,6 +651,15 @@ static void opal_i2c_create_devs(void)
 		of_platform_device_create(np, NULL, NULL);
 }
 
+static void opal_nest_create_dev(void)
+{
+	struct device_node *np;
+
+	np = of_find_compatible_node(NULL, NULL, "ibm,opal-in-memory-counters");
+	if (np)
+		of_platform_device_create(np, NULL, NULL);
+}
+
 static int kopald(void *unused)
 {
 	__be64 events;
@@ -717,6 +726,9 @@ static int __init opal_init(void)
 	/* Setup a heatbeat thread if requested by OPAL */
 	opal_init_heartbeat();
 
+	/* Create nest platform devices */
+	opal_nest_create_dev();
+
 	/* Create leds platform devices */
 	leds = of_find_node_by_path("/ibm,opal/leds");
 	if (leds) {
-- 
1.9.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ