From: Jonas Svennebring <jonas.svennebr...@gmail.com>

AXXIA uncore perf support, added dts support in driver
as well as perf delta read support to smon block.

Signed-off-by: Jonas Svennebring <jonas.svennebr...@gmail.com>
---
 arch/arm/mach-axxia/perf_event_platform.c | 13 +++++++++----
 arch/arm/mach-axxia/smon.c                | 31 +++++++++++++++++++++++++++----
 arch/arm/mach-axxia/smon.h                |  1 +
 3 files changed, 37 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-axxia/perf_event_platform.c 
b/arch/arm/mach-axxia/perf_event_platform.c
index 903dbe6..538fd1a 100644
--- a/arch/arm/mach-axxia/perf_event_platform.c
+++ b/arch/arm/mach-axxia/perf_event_platform.c
@@ -242,17 +242,22 @@ static int axmperf_probe(struct platform_device *dev)
        return ret;
 }
 
+static const struct of_device_id lsi_platformperf_match[] = {
+       { .compatible = "lsi,axm-platformperf", },
+       {},
+};
+
 static struct platform_driver axmperf_driver = {
        .driver = {
-                  .name = "AXM55xxPlatformPerf",
-                  .owner = THIS_MODULE,
-                  },
+               .name = "AXM55xxPlatformPerf",
+               .of_match_table = lsi_platformperf_match,
+               .owner = THIS_MODULE,
+               },
        .probe = axmperf_probe,
 };
 
 static int __init axmperf_init(void)
 {
-       platform_device_register(&axmperf_device);
        platform_driver_register(&axmperf_driver);
 
        return 0;
diff --git a/arch/arm/mach-axxia/smon.c b/arch/arm/mach-axxia/smon.c
index b2f0a56..313a3ce 100644
--- a/arch/arm/mach-axxia/smon.c
+++ b/arch/arm/mach-axxia/smon.c
@@ -116,6 +116,8 @@ uint32_t smon_event_active(struct smon_s *smon, uint8_t 
event)
 
 uint32_t smon_read(struct smon_s *smon, uint8_t event)
 {
+       uint32_t deltacount;
+
        if (smon->type == NCP_SMON)
                ncr_read(NCP_REGION_ID(smon->node, smon->target), smon->offset,
                         8 * REG_SZ, &smon->regs);
@@ -123,10 +125,29 @@ uint32_t smon_read(struct smon_s *smon, uint8_t event)
                memcpy32_fromio((uint32_t *)&smon->regs,
                        (uint32_t *)smon->addr + smon->offset, 8);
 
-       if ((smon->assigned[0] == ASSIGNED) && (smon->events[0] == event))
-               return smon->regs.count0;
-       else if ((smon->assigned[1] == ASSIGNED) && (smon->events[1] == event))
-               return smon->regs.count1;
+       if ((smon->assigned[0] == ASSIGNED) &&
+                       (smon->events[0] == event)) {
+               if (smon->regs.count0 >= smon->lastread[0])
+                       deltacount = smon->regs.count0 - smon->lastread[0];
+               else
+                       deltacount = 0xffffffff - smon->lastread[0]
+                                       + smon->regs.count0;
+
+               smon->lastread[0] = smon->regs.count0;
+
+               return deltacount;
+       } else if ((smon->assigned[1] == ASSIGNED) &&
+                       (smon->events[1] == event)) {
+               if (smon->regs.count1 >= smon->lastread[1])
+                       deltacount = smon->regs.count1 - smon->lastread[1];
+               else
+                       deltacount = 0xffffffff - smon->lastread[1]
+                                       + smon->regs.count1;
+
+               smon->lastread[1] = smon->regs.count1;
+
+               return deltacount;
+       }
 
        return -ENOEVENT;
 }
@@ -146,6 +167,7 @@ uint32_t smon_start(struct smon_s *smon, uint8_t event)
        if ((smon->assigned[0] == ASSIGNED) && (smon->events[0] == event)) {
                smon->regs.event0 = event;
                smon->regs.count0 = 0;
+               smon->lastread[0] = 0;
 
                if (smon->type == NCP_SMON) {
                        /* write configuration, but do not change count reg */
@@ -171,6 +193,7 @@ uint32_t smon_start(struct smon_s *smon, uint8_t event)
                && (smon->events[1] == event)) {
                smon->regs.event1 = event;
                smon->regs.count1 = 0;
+               smon->lastread[1] = 0;
 
                if (smon->type == NCP_SMON) {
                        /* write configuration, but do not change count reg */
diff --git a/arch/arm/mach-axxia/smon.h b/arch/arm/mach-axxia/smon.h
index bcdf39f..d3573cd 100644
--- a/arch/arm/mach-axxia/smon.h
+++ b/arch/arm/mach-axxia/smon.h
@@ -43,6 +43,7 @@ struct smon_s {
        uint32_t node; /* NCP_SMON */
        uint32_t target; /* " */
        uint32_t offset;
+       uint32_t lastread[2];
        uint8_t assigned[2];
        uint8_t events[2];
 };
-- 
1.8.1.4

-- 
_______________________________________________
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto

Reply via email to