From nobody Fri Dec 19 20:34:55 2025 Received: from mail-m19731116.qiye.163.com (mail-m19731116.qiye.163.com [220.197.31.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B38B27AC31 for ; Fri, 7 Nov 2025 13:19:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762521586; cv=none; b=AedL9GckReyrpfM1Nb7QeYLZFS+aZparUwgAPtHcwD/YjtNRczHVZ6O4Flr+CgkAXMlLe1GHdJR+hSKcm54uqVqI69J+3KLHQjnkQafeZ49frqY7hNyYD2HO73n31hiG7NzvACCqPVt2njF/NYXrXJyRo1v4EPK+r6Su4+0Q3ZE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762521586; c=relaxed/simple; bh=GFrhyFs7hYtqLxbw2uhN+QJfUrdtqrVfhsgCP3ZvLN8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EdYezqXUL/8bZ53DnW7y/sP2hWRHCwR++CuHzt9qJ2Ich4l9uA6Y384plnOs1AXq0noZPgSqUs1bGnDI7oA36VCERyf3roVZbTsjt50Ed1qypFY1jW4A3QYYIL0kej1Tz+Ip5Op0Ivcdy53Wh6U+UNPLRpVtjSqo2rSS5MWTvKg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hj-micro.com; spf=pass smtp.mailfrom=hj-micro.com; arc=none smtp.client-ip=220.197.31.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hj-micro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hj-micro.com Received: from localhost.localdomain (unknown [122.224.147.158]) by smtp.qiye.163.com (Hmail) with ESMTP id 28c500960; Fri, 7 Nov 2025 16:43:33 +0800 (GMT+08:00) From: Shouping Wang To: will@kernel.org, robin.murphy@arm.com Cc: mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, allen.wang@hj-micro.com, andy.xu@hj-micro.com, peter.du@hj-micro.com Subject: [PATCH 1/2] perf/arm-ni: rename PMU device name Date: Fri, 7 Nov 2025 16:43:18 +0800 Message-ID: <20251107084320.555979-2-allen.wang@hj-micro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251107084320.555979-1-allen.wang@hj-micro.com> References: <20251107084320.555979-1-allen.wang@hj-micro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-HM-Tid: 0a9a5d7c37ed09d9kunm533ae5d212b2dd2 X-HM-MType: 1 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVlCHx8dVkIeHxpOQhpPTEJLSFYVFAkWGhdVEwETFh oSFyQUDg9ZV1kYEgtZQVlKSUlVSUlPVUpPTFVKTkNZV1kWGg8SFR0UWUFZT0tIVUpLSU9PT0hVSk tLVUpCS0tZBg++ Content-Type: text/plain; charset="utf-8" The PMU device names are arm_ni_1_*,arm_ni_2_*, etc.=20 The device names change based on the order of registration=20 for multiple NI instances. By naming the PMU device using=20 its address, the device name can be made independent of=20 the registration order. Signed-off-by: Shouping Wang --- drivers/perf/arm-ni.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/perf/arm-ni.c b/drivers/perf/arm-ni.c index 1615a0564031..32eabdbe877a 100644 --- a/drivers/perf/arm-ni.c +++ b/drivers/perf/arm-ni.c @@ -53,6 +53,7 @@ =20 #define NI_NUM_COUNTERS 8 #define NI_CCNT_IDX 31 +#define NI_PMU_PA_SHIFT 12 =20 /* Event attributes */ #define NI_CONFIG_TYPE GENMASK_ULL(15, 0) @@ -115,7 +116,6 @@ struct arm_ni { struct device *dev; void __iomem *base; enum ni_part part; - int id; int cpu; int num_cds; struct hlist_node cpuhp_node; @@ -560,7 +560,7 @@ static int arm_ni_init_cd(struct arm_ni *ni, struct arm= _ni_node *node, u64 res_s .read =3D arm_ni_event_read, }; =20 - name =3D devm_kasprintf(ni->dev, GFP_KERNEL, "arm_ni_%d_cd_%d", ni->id, c= d->id); + name =3D devm_kasprintf(ni->dev, GFP_KERNEL, "arm_ni_%llx", res_start >> = NI_PMU_PA_SHIFT); if (!name) return -ENOMEM; =20 @@ -623,7 +623,6 @@ static int arm_ni_probe(struct platform_device *pdev) struct arm_ni *ni; struct resource *res; void __iomem *base; - static atomic_t id; int ret, num_cds; u32 reg, part; =20 @@ -674,7 +673,6 @@ static int arm_ni_probe(struct platform_device *pdev) ni->base =3D base; ni->num_cds =3D num_cds; ni->part =3D part; - ni->id =3D atomic_fetch_inc(&id); ni->cpu =3D cpumask_local_spread(0, dev_to_node(ni->dev)); platform_set_drvdata(pdev, ni); =20 --=20 2.43.0 From nobody Fri Dec 19 20:34:55 2025 Received: from mail-m49219.qiye.163.com (mail-m49219.qiye.163.com [45.254.49.219]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69DB92AD04 for ; Fri, 7 Nov 2025 09:19:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.254.49.219 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762507167; cv=none; b=DOsQ7SIM0JfzGPaGWpfEBM9MVfIyy1MgJf7PP+Wq6UkmWnds4rxSrjHAtlExtX2+nUGBPfKjnmYooRcldI0yzTtQly3wlbE4Xc8Fd236x5MMTolLKv4MCxhOSaUgKy6XlxM0uVykm0JsQaKvT4CKb5eqvmv+5E73ka0GWGqabGI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762507167; c=relaxed/simple; bh=/RmS55EMHk9CoPzX2y/JRQSYZBorkiKegha7LSqfbxY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sgY6oehK/Q/6PAUzfAZYCrZk7CCIHMHmoYi3wz1hRixTNEwYnEZP2pdVgGC+vsim7Wda025DqKwnsS1gcQM32UTDTiNkZuNXuka/mJv4UahD1r3ca/f8reWwDAjpQ9/eWYDxb8CORnjTVWHxNehtqYm6Lzzypw3q9HMsUVeVT3Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hj-micro.com; spf=pass smtp.mailfrom=hj-micro.com; arc=none smtp.client-ip=45.254.49.219 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hj-micro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hj-micro.com Received: from localhost.localdomain (unknown [122.224.147.158]) by smtp.qiye.163.com (Hmail) with ESMTP id 28c500970; Fri, 7 Nov 2025 16:43:35 +0800 (GMT+08:00) From: Shouping Wang To: will@kernel.org, robin.murphy@arm.com Cc: mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, allen.wang@hj-micro.com, andy.xu@hj-micro.com, peter.du@hj-micro.com Subject: [PATCH 2/2] perf: arm-ni: add topology debug info for the clock domain Date: Fri, 7 Nov 2025 16:43:19 +0800 Message-ID: <20251107084320.555979-3-allen.wang@hj-micro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251107084320.555979-1-allen.wang@hj-micro.com> References: <20251107084320.555979-1-allen.wang@hj-micro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-HM-Tid: 0a9a5d7c3fe709d9kunm533ae5d212b2e0c X-HM-MType: 1 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVkaSUhKVk1MGUkZGk9DSh9MQ1YVFAkWGhdVEwETFh oSFyQUDg9ZV1kYEgtZQVlKSUlVSUlPVUpPTFVKTkNZV1kWGg8SFR0UWUFZT0tIVUpLSU9PT0hVSk tLVUpCS0tZBg++ Content-Type: text/plain; charset="utf-8" When capturing PMU info with perf, it is necessary to know the nodeid of=20 the interface. Here, we add topology debug info for the clock domain to=20 display the nodeid of the interfaces. $ cat /sys/kernel/debug/arm-ni/map_1f3c06 as shown below: | HSNI #5 || PMNI #6 || PMU #14 | Signed-off-by: Shouping Wang --- drivers/perf/arm-ni.c | 63 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/drivers/perf/arm-ni.c b/drivers/perf/arm-ni.c index 32eabdbe877a..e0f0e18d0120 100644 --- a/drivers/perf/arm-ni.c +++ b/drivers/perf/arm-ni.c @@ -13,6 +13,7 @@ #include #include #include +#include =20 /* Common registers */ #define NI_NODE_TYPE 0x000 @@ -110,6 +111,7 @@ struct arm_ni_cd { struct arm_ni_unit *units; struct perf_event *evcnt[NI_NUM_COUNTERS]; struct perf_event *ccnt; + struct dentry *debug; }; =20 struct arm_ni { @@ -476,6 +478,59 @@ static irqreturn_t arm_ni_handle_irq(int irq, void *de= v_id) } } =20 +static struct dentry *arm_ni_cd_debugfs; + +#ifdef CONFIG_DEBUG_FS +static const char *arm_ni_node_type(enum ni_node_type type) +{ + switch (type) { + case NI_ASNI: + return "| ASNI "; + case NI_AMNI: + return "| AMNI "; + case NI_PMU: + return "| PMU "; + case NI_HSNI: + return "| HSNI "; + case NI_HMNI: + return "| HMNI "; + case NI_PMNI: + return "| PMNI "; + default: + return "| ???? "; + } +} + +static int arm_ni_cd_map_show(struct seq_file *s, void *data) +{ + struct arm_ni_cd *cd =3D s->private; + + cd_for_each_unit(cd, unit) { + seq_printf(s, "%s#%-2d |", arm_ni_node_type(unit->type), unit->id); + } + seq_puts(s, "\n"); + + return 0; +} + +DEFINE_SHOW_ATTRIBUTE(arm_ni_cd_map); + +static void arm_ni_cd_debugfs_init(struct arm_ni_cd *cd, u64 res_start) +{ + const char *name =3D "map"; + + if (res_start > 0) + name =3D devm_kasprintf(cd_to_ni(cd)->dev, GFP_KERNEL, "map_%llx", + res_start >> NI_PMU_PA_SHIFT); + if (!name) + return; + + cd->debug =3D debugfs_create_file(name, 0444, arm_ni_cd_debugfs, cd, &arm= _ni_cd_map_fops); +} +#else +static void arm_ni_cd_debugfs_init(struct arm_ni_cd *cd, u64 res_start) {} +#endif + static int arm_ni_init_cd(struct arm_ni *ni, struct arm_ni_node *node, u64= res_start) { struct arm_ni_cd *cd =3D ni->cds + node->id; @@ -563,6 +618,7 @@ static int arm_ni_init_cd(struct arm_ni *ni, struct arm= _ni_node *node, u64 res_s name =3D devm_kasprintf(ni->dev, GFP_KERNEL, "arm_ni_%llx", res_start >> = NI_PMU_PA_SHIFT); if (!name) return -ENOMEM; + arm_ni_cd_debugfs_init(cd, res_start); =20 return perf_pmu_register(&cd->pmu, name, -1); } @@ -575,6 +631,7 @@ static void arm_ni_remove(struct platform_device *pdev) writel_relaxed(0, cd->pmu_base + NI_PMCR); writel_relaxed(U32_MAX, cd->pmu_base + NI_PMINTENCLR); perf_pmu_unregister(&cd->pmu); + debugfs_remove(cd->debug); } cpuhp_state_remove_instance_nocalls(arm_ni_hp_state, &ni->cpuhp_node); } @@ -787,9 +844,12 @@ static int __init arm_ni_init(void) =20 arm_ni_hp_state =3D ret; =20 + arm_ni_cd_debugfs =3D debugfs_create_dir("arm-ni", NULL); ret =3D platform_driver_register(&arm_ni_driver); - if (ret) + if (ret) { cpuhp_remove_multi_state(arm_ni_hp_state); + debugfs_remove(arm_ni_cd_debugfs); + } return ret; } =20 @@ -797,6 +857,7 @@ static void __exit arm_ni_exit(void) { platform_driver_unregister(&arm_ni_driver); cpuhp_remove_multi_state(arm_ni_hp_state); + debugfs_remove(arm_ni_cd_debugfs); } =20 module_init(arm_ni_init); --=20 2.43.0