linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
To: mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org
Cc: ak@linux.intel.com, srivatsa@mit.edu,
	linux-kernel@vger.kernel.org, eranian@google.com,
	linuxppc-dev@ozlabs.org,
	Madhavan Srinivasan <maddy@linux.vnet.ibm.com>,
	linuxppc-dev@lists.ozlabs.org
Subject: [RFC PATCH 2/7] powerpc/powernv: uncore foundation code
Date: Wed, 11 Mar 2015 18:37:08 +0530	[thread overview]
Message-ID: <1426079233-16720-3-git-send-email-maddy@linux.vnet.ibm.com> (raw)
In-Reply-To: <1426079233-16720-1-git-send-email-maddy@linux.vnet.ibm.com>

Patch adds the foundation code enable nest pmu. It defines
various init routines and these are based on Intel's uncore
framework. But it does differ since "box" structure abstraction
is not implemented here.

Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
---
 arch/powerpc/perf/uncore_pmu.c | 104 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 104 insertions(+)
 create mode 100644 arch/powerpc/perf/uncore_pmu.c

diff --git a/arch/powerpc/perf/uncore_pmu.c b/arch/powerpc/perf/uncore_pmu.c
new file mode 100644
index 0000000..cc544d3
--- /dev/null
+++ b/arch/powerpc/perf/uncore_pmu.c
@@ -0,0 +1,104 @@
+/*
+ * Uncore Performance Monitor counter support.
+ *
+ * Derived from Intel's uncore framework
+ *   written by: Liang,Kan
+ *               Zheng, Yan
+ *               Andi Keen
+ *
+ *   Copyright Intel Corporation.
+ *
+ * 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; under version
+ * 2 of the License.
+ */
+
+#include "uncore_pmu.h"
+
+struct ppc64_uncore_type *empty_uncore[] = { NULL, };
+struct ppc64_uncore_type **ppc64_uncore = empty_uncore;
+
+struct ppc64_uncore_pmu *uncore_event_to_pmu(struct perf_event *event)
+{
+	return container_of(event->pmu, struct ppc64_uncore_pmu, pmu);
+}
+
+int __init uncore_type_init(struct ppc64_uncore_type *type)
+{
+	struct ppc64_uncore_pmu *pmus;
+	int i;
+
+	pmus = kzalloc(sizeof(*pmus) * type->num_boxes, GFP_KERNEL);
+	if (!pmus)
+		return -ENOMEM;
+
+	type->pmus = pmus;
+
+	for (i = 0; i < type->num_boxes; i++) {
+		pmus[i].pmu_idx = i;
+		pmus[i].type = type;
+		pmus[i].pmu = *type->pmu;
+		sprintf((char *)pmus[i].name, "uncore_%s_%d",
+				type->name, (int)i);
+	}
+
+	return 0;
+}
+
+int __init uncore_types_init(struct ppc64_uncore_type **types)
+{
+	int i, ret;
+
+	for (i = 0; types[i]; i++) {
+		ret = uncore_type_init(types[i]);
+		if (ret)
+			goto fail;
+	}
+	return 0;
+fail:
+	while (--i >= 0)
+		kfree(types[i]);
+	return ret;
+}
+
+static int __init uncore_pmus_register(void)
+{
+	struct ppc64_uncore_pmu *pmus;
+	struct pmu *pmu;
+	struct ppc64_uncore_type *type;
+	int i, j, ret;
+
+	for (i = 0; ppc64_uncore[i]; i++) {
+		type = ppc64_uncore[i];
+		for (j = 0; j < type->num_boxes; j++) {
+			pmus = &type->pmus[j];
+			pmu = &pmus->pmu;
+			pmu->attr_groups = pmus->type->attr_groups;
+			ret = perf_pmu_register(pmu, pmus->name, -1);
+		}
+	}
+
+	return 0;
+}
+
+static int __init uncore_init(void)
+{
+	int ret = 0;
+
+	if (!cur_cpu_spec->oprofile_cpu_type ||
+	    strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power8") ||
+	    !cpu_has_feature(CPU_FTR_HVMODE))
+		return ret;
+
+	ret = uncore_types_init(ppc64_uncore);
+	if (ret)
+		return ret;
+
+	uncore_pmus_register();
+
+	return ret;
+}
+
+device_initcall(uncore_init);
+
-- 
1.9.1

  parent reply	other threads:[~2015-03-11 13:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-11 13:07 [RFC PATCH 0/7] powerpc/powernv: Nest Instrumentation support Madhavan Srinivasan
2015-03-11 13:07 ` [RFC PATCH 1/7] powerpc/powernv: Data structure and macros definition Madhavan Srinivasan
2015-03-11 13:07 ` Madhavan Srinivasan [this message]
2015-03-11 13:07 ` [RFC PATCH 3/7] powerpc/powernv: uncore cpumask and CPU hotplug Madhavan Srinivasan
2015-03-11 13:07 ` [RFC PATCH 4/7]powerpc/powernv: Add OPAL support for Nest pmu Madhavan Srinivasan
2015-03-11 22:57   ` Stewart Smith
2015-03-12  8:47     ` maddy
2015-03-11 13:07 ` [RFC PATCH 5/7]powerpc/powernv: Add POWER8 specific nest pmu support Madhavan Srinivasan
2015-03-11 13:07 ` [RFC PATCH 6/7]powerpc/powernv: add support to parse dt for nest pmu Madhavan Srinivasan
2015-03-11 13:07 ` [RFC PATCH 7/7]powerpc/powernv: enable nest pmu related file in Makefile Madhavan Srinivasan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1426079233-16720-3-git-send-email-maddy@linux.vnet.ibm.com \
    --to=maddy@linux.vnet.ibm.com \
    --cc=ak@linux.intel.com \
    --cc=benh@kernel.crashing.org \
    --cc=eranian@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.org \
    --cc=srivatsa@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).