[RFC PATCH 5/7] arm64/perf: Cavium ThunderX OCX LNE uncore support

2016-02-12 Thread Jan Glauber
Support counters for the CCPI Interface controller (OCX) lanes.

Signed-off-by: Jan Glauber 
---
 arch/arm64/kernel/uncore/Makefile|   3 +-
 arch/arm64/kernel/uncore/uncore_cavium.c |   3 +
 arch/arm64/kernel/uncore/uncore_cavium.h |   4 +
 arch/arm64/kernel/uncore/uncore_cavium_ocx_lne.c | 270 +++
 4 files changed, 279 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm64/kernel/uncore/uncore_cavium_ocx_lne.c

diff --git a/arch/arm64/kernel/uncore/Makefile 
b/arch/arm64/kernel/uncore/Makefile
index 81479e8..da39f452 100644
--- a/arch/arm64/kernel/uncore/Makefile
+++ b/arch/arm64/kernel/uncore/Makefile
@@ -1,4 +1,5 @@
 obj-$(CONFIG_ARCH_THUNDER) += uncore_cavium.o  \
  uncore_cavium_l2c_tad.o   \
  uncore_cavium_l2c_cbc.o   \
- uncore_cavium_lmc.o
+ uncore_cavium_lmc.o   \
+ uncore_cavium_ocx_lne.o
diff --git a/arch/arm64/kernel/uncore/uncore_cavium.c 
b/arch/arm64/kernel/uncore/uncore_cavium.c
index a972418..f2fbdea 100644
--- a/arch/arm64/kernel/uncore/uncore_cavium.c
+++ b/arch/arm64/kernel/uncore/uncore_cavium.c
@@ -28,6 +28,8 @@ struct thunder_uncore *event_to_thunder_uncore(struct 
perf_event *event)
return thunder_uncore_l2c_cbc;
else if (event->pmu->type == thunder_lmc_pmu.type)
return thunder_uncore_lmc;
+   else if (event->pmu->type == thunder_ocx_lne_pmu.type)
+   return thunder_uncore_ocx_lne;
else
return NULL;
 }
@@ -215,6 +217,7 @@ static int __init thunder_uncore_init(void)
thunder_uncore_l2c_tad_setup();
thunder_uncore_l2c_cbc_setup();
thunder_uncore_lmc_setup();
+   thunder_uncore_ocx_lne_setup();
return 0;
 }
 late_initcall(thunder_uncore_init);
diff --git a/arch/arm64/kernel/uncore/uncore_cavium.h 
b/arch/arm64/kernel/uncore/uncore_cavium.h
index 6e3beba..b9bcb42 100644
--- a/arch/arm64/kernel/uncore/uncore_cavium.h
+++ b/arch/arm64/kernel/uncore/uncore_cavium.h
@@ -16,6 +16,7 @@ enum uncore_type {
L2C_TAD_TYPE,
L2C_CBC_TYPE,
LMC_TYPE,
+   OCX_LNE_TYPE,
 };
 
 extern int thunder_uncore_version;
@@ -64,9 +65,11 @@ extern struct attribute_group thunder_uncore_attr_group;
 extern struct thunder_uncore *thunder_uncore_l2c_tad;
 extern struct thunder_uncore *thunder_uncore_l2c_cbc;
 extern struct thunder_uncore *thunder_uncore_lmc;
+extern struct thunder_uncore *thunder_uncore_ocx_lne;
 extern struct pmu thunder_l2c_tad_pmu;
 extern struct pmu thunder_l2c_cbc_pmu;
 extern struct pmu thunder_lmc_pmu;
+extern struct pmu thunder_ocx_lne_pmu;
 
 /* Prototypes */
 struct thunder_uncore *event_to_thunder_uncore(struct perf_event *event);
@@ -83,3 +86,4 @@ ssize_t thunder_events_sysfs_show(struct device *dev,
 int thunder_uncore_l2c_tad_setup(void);
 int thunder_uncore_l2c_cbc_setup(void);
 int thunder_uncore_lmc_setup(void);
+int thunder_uncore_ocx_lne_setup(void);
diff --git a/arch/arm64/kernel/uncore/uncore_cavium_ocx_lne.c 
b/arch/arm64/kernel/uncore/uncore_cavium_ocx_lne.c
new file mode 100644
index 000..c2981b9
--- /dev/null
+++ b/arch/arm64/kernel/uncore/uncore_cavium_ocx_lne.c
@@ -0,0 +1,270 @@
+/*
+ * Cavium Thunder uncore PMU support, OCX LNE counters.
+ *
+ * Copyright 2016 Cavium Inc.
+ * Author: Jan Glauber 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "uncore_cavium.h"
+
+#ifndef PCI_DEVICE_ID_THUNDER_OCX
+#define PCI_DEVICE_ID_THUNDER_OCX  0xa013
+#endif
+
+#define OCX_LNE_NR_COUNTERS15
+#define OCX_LNE_NR_UNITS   24
+#define OCX_LNE_UNIT_OFFSET0x100
+#define OCX_LNE_CONTROL_OFFSET 0x8000
+#define OCX_LNE_COUNTER_OFFSET 0x40
+
+#define OCX_LNE_STAT_DISABLE   0
+#define OCX_LNE_STAT_ENABLE1
+
+/* OCX LNE event list */
+#define OCX_LNE_EVENT_STAT00   0x00
+#define OCX_LNE_EVENT_STAT01   0x01
+#define OCX_LNE_EVENT_STAT02   0x02
+#define OCX_LNE_EVENT_STAT03   0x03
+#define OCX_LNE_EVENT_STAT04   0x04
+#define OCX_LNE_EVENT_STAT05   0x05
+#define OCX_LNE_EVENT_STAT06   0x06
+#define OCX_LNE_EVENT_STAT07   0x07
+#define OCX_LNE_EVENT_STAT08   0x08
+#define OCX_LNE_EVENT_STAT09   0x09
+#define OCX_LNE_EVENT_STAT10   0x0a
+#define OCX_LNE_EVENT_STAT11   0x0b
+#define OCX_LNE_EVENT_STAT12   0x0c
+#define OCX_LNE_EVENT_STAT13   0x0d
+#define OCX_LNE_EVENT_STAT14   0x0e
+
+struct thunder_uncore *thunder_uncore_ocx_lne;
+
+static inline void __iomem *map_offset_ocx_lne(unsigned long addr,
+   

[RFC PATCH 5/7] arm64/perf: Cavium ThunderX OCX LNE uncore support

2016-02-12 Thread Jan Glauber
Support counters for the CCPI Interface controller (OCX) lanes.

Signed-off-by: Jan Glauber 
---
 arch/arm64/kernel/uncore/Makefile|   3 +-
 arch/arm64/kernel/uncore/uncore_cavium.c |   3 +
 arch/arm64/kernel/uncore/uncore_cavium.h |   4 +
 arch/arm64/kernel/uncore/uncore_cavium_ocx_lne.c | 270 +++
 4 files changed, 279 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm64/kernel/uncore/uncore_cavium_ocx_lne.c

diff --git a/arch/arm64/kernel/uncore/Makefile 
b/arch/arm64/kernel/uncore/Makefile
index 81479e8..da39f452 100644
--- a/arch/arm64/kernel/uncore/Makefile
+++ b/arch/arm64/kernel/uncore/Makefile
@@ -1,4 +1,5 @@
 obj-$(CONFIG_ARCH_THUNDER) += uncore_cavium.o  \
  uncore_cavium_l2c_tad.o   \
  uncore_cavium_l2c_cbc.o   \
- uncore_cavium_lmc.o
+ uncore_cavium_lmc.o   \
+ uncore_cavium_ocx_lne.o
diff --git a/arch/arm64/kernel/uncore/uncore_cavium.c 
b/arch/arm64/kernel/uncore/uncore_cavium.c
index a972418..f2fbdea 100644
--- a/arch/arm64/kernel/uncore/uncore_cavium.c
+++ b/arch/arm64/kernel/uncore/uncore_cavium.c
@@ -28,6 +28,8 @@ struct thunder_uncore *event_to_thunder_uncore(struct 
perf_event *event)
return thunder_uncore_l2c_cbc;
else if (event->pmu->type == thunder_lmc_pmu.type)
return thunder_uncore_lmc;
+   else if (event->pmu->type == thunder_ocx_lne_pmu.type)
+   return thunder_uncore_ocx_lne;
else
return NULL;
 }
@@ -215,6 +217,7 @@ static int __init thunder_uncore_init(void)
thunder_uncore_l2c_tad_setup();
thunder_uncore_l2c_cbc_setup();
thunder_uncore_lmc_setup();
+   thunder_uncore_ocx_lne_setup();
return 0;
 }
 late_initcall(thunder_uncore_init);
diff --git a/arch/arm64/kernel/uncore/uncore_cavium.h 
b/arch/arm64/kernel/uncore/uncore_cavium.h
index 6e3beba..b9bcb42 100644
--- a/arch/arm64/kernel/uncore/uncore_cavium.h
+++ b/arch/arm64/kernel/uncore/uncore_cavium.h
@@ -16,6 +16,7 @@ enum uncore_type {
L2C_TAD_TYPE,
L2C_CBC_TYPE,
LMC_TYPE,
+   OCX_LNE_TYPE,
 };
 
 extern int thunder_uncore_version;
@@ -64,9 +65,11 @@ extern struct attribute_group thunder_uncore_attr_group;
 extern struct thunder_uncore *thunder_uncore_l2c_tad;
 extern struct thunder_uncore *thunder_uncore_l2c_cbc;
 extern struct thunder_uncore *thunder_uncore_lmc;
+extern struct thunder_uncore *thunder_uncore_ocx_lne;
 extern struct pmu thunder_l2c_tad_pmu;
 extern struct pmu thunder_l2c_cbc_pmu;
 extern struct pmu thunder_lmc_pmu;
+extern struct pmu thunder_ocx_lne_pmu;
 
 /* Prototypes */
 struct thunder_uncore *event_to_thunder_uncore(struct perf_event *event);
@@ -83,3 +86,4 @@ ssize_t thunder_events_sysfs_show(struct device *dev,
 int thunder_uncore_l2c_tad_setup(void);
 int thunder_uncore_l2c_cbc_setup(void);
 int thunder_uncore_lmc_setup(void);
+int thunder_uncore_ocx_lne_setup(void);
diff --git a/arch/arm64/kernel/uncore/uncore_cavium_ocx_lne.c 
b/arch/arm64/kernel/uncore/uncore_cavium_ocx_lne.c
new file mode 100644
index 000..c2981b9
--- /dev/null
+++ b/arch/arm64/kernel/uncore/uncore_cavium_ocx_lne.c
@@ -0,0 +1,270 @@
+/*
+ * Cavium Thunder uncore PMU support, OCX LNE counters.
+ *
+ * Copyright 2016 Cavium Inc.
+ * Author: Jan Glauber 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "uncore_cavium.h"
+
+#ifndef PCI_DEVICE_ID_THUNDER_OCX
+#define PCI_DEVICE_ID_THUNDER_OCX  0xa013
+#endif
+
+#define OCX_LNE_NR_COUNTERS15
+#define OCX_LNE_NR_UNITS   24
+#define OCX_LNE_UNIT_OFFSET0x100
+#define OCX_LNE_CONTROL_OFFSET 0x8000
+#define OCX_LNE_COUNTER_OFFSET 0x40
+
+#define OCX_LNE_STAT_DISABLE   0
+#define OCX_LNE_STAT_ENABLE1
+
+/* OCX LNE event list */
+#define OCX_LNE_EVENT_STAT00   0x00
+#define OCX_LNE_EVENT_STAT01   0x01
+#define OCX_LNE_EVENT_STAT02   0x02
+#define OCX_LNE_EVENT_STAT03   0x03
+#define OCX_LNE_EVENT_STAT04   0x04
+#define OCX_LNE_EVENT_STAT05   0x05
+#define OCX_LNE_EVENT_STAT06   0x06
+#define OCX_LNE_EVENT_STAT07   0x07
+#define OCX_LNE_EVENT_STAT08   0x08
+#define OCX_LNE_EVENT_STAT09   0x09
+#define OCX_LNE_EVENT_STAT10   0x0a
+#define OCX_LNE_EVENT_STAT11   0x0b
+#define OCX_LNE_EVENT_STAT12   0x0c
+#define OCX_LNE_EVENT_STAT13   0x0d
+#define OCX_LNE_EVENT_STAT14   0x0e
+
+struct thunder_uncore *thunder_uncore_ocx_lne;
+
+static inline void __iomem