[PATCH v2] perf/hx_arm_ni: Support uncore ARM NI-700 PMU

Yang Jialong 杨佳龙 jialong.yang at shingroup.cn
Wed Feb 28 18:26:32 PST 2024


 From d11d3c01978ef0fd8bfd125189c671c9bcc3c096 Mon Sep 17 00:00:00 2001
From: yjl00405 <jialong.yang at shingroup.cn>
Date: Thu, 29 Feb 2024 09:39:51 +0800
Subject: [PATCH] arm-ni:Some changes.

---
1. Some small mistakes.
2. Have not given 'NI_PMU unit->ns = true'. So no cycles event exists
    in arm_ni_0_cd_0/events.

Test(multiple cores server):
1. hotplug test pass.
    ~ # cat /sys/bus/event_source/devices/arm_ni_0_cd_0/cpumask
    0
    ~ # echo 0 > /sys/devices/system/cpu/cpu0/online
    ~ # cat /sys/bus/event_source/devices/arm_ni_0_cd_0/cpumask
    1
    ~ # # Test cycles event
    ~ # perf stat -e arm_ni_0_cd_0/type=6/ echo
    Performance counter stats for 'system wide':

                397282      arm_ni_0_cd_0/type=6/

          0.000228680 seconds time elapsed
2. Normal event test and overflow interrupt handler test pass.
    ~ # perf stat -e arm_ni_0_cd_0/type=4,nodeid=0,eventid=1/
    Performance counter stats for 'system wide':

                8192    arm_ni_0_cd_0/type=4,nodeid=0,eventid=1/

          0.123881102 seconds time elapsed

    There is no device after the interface. So I use devmem tool give a 
0x80001000
    first time. Then trigger the ovsr. See the counter value 0x80000000. 
Then
    I give 0x80001000 again and exit.

It's very hard to write such code without machine with NI component.
Could we merge our code and push it into community together?

  drivers/perf/arm-ni.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/perf/arm-ni.c b/drivers/perf/arm-ni.c
index 4a769a421c81..d14ebcbeb598 100644
--- a/drivers/perf/arm-ni.c
+++ b/drivers/perf/arm-ni.c
@@ -171,7 +171,7 @@ static umode_t arm_ni_event_attr_is_visible(struct 
kobject *kobj,
         eattr = container_of(attr, typeof(*eattr), attr.attr);

         cd_for_each_unit(cd, unit) {
-               if (unit->type == eattr->type && unit->ns)
+               if (unit->type == eattr->type && (unit->ns | unit->type 
== NI_PMU))
                         return attr->mode;
         }

@@ -592,7 +592,7 @@ static int arm_ni_probe(struct platform_device *pdev)
         for (int v = 0; v < cfg.num_components; v++) {
                 reg = readl_relaxed(cfg.base + NI_CHILD_PTR(v));
                 arm_ni_probe_domain(base + reg, &vd);
-               for (int p = 0; p < vd.num_components; v++) {
+               for (int p = 0; p < vd.num_components; p++) {
                         reg = readl_relaxed(vd.base + NI_CHILD_PTR(p));
                         arm_ni_probe_domain(base + reg, &pd);
                         num_cds += pd.num_components;
@@ -612,13 +612,13 @@ static int arm_ni_probe(struct platform_device *pdev)
         for (int v = 0; v < cfg.num_components; v++) {
                 reg = readl_relaxed(cfg.base + NI_CHILD_PTR(v));
                 arm_ni_probe_domain(base + reg, &vd);
-               for (int p = 0; p < pd.num_components; v++) {
+               for (int p = 0; p < pd.num_components; p++) {
                         reg = readl_relaxed(vd.base + NI_CHILD_PTR(p));
                         arm_ni_probe_domain(base + reg, &pd);
                         for (int c = 0; c < vd.num_components; c++) {
                                 int ret;

-                               reg = readl_relaxed(vd.base + 
NI_CHILD_PTR(c));
+                               reg = readl_relaxed(pd.base + 
NI_CHILD_PTR(c));
                                 arm_ni_probe_domain(base + reg, &cd);
                                 ret = arm_ni_init_cd(ni, &cd);
                                 if (ret)
--
2.27.0



More information about the linux-arm-kernel mailing list