From d2e08a5dc3f137d0f4925ed6561d2d82365db0c7 Mon Sep 17 00:00:00 2001
From: Junhao He <hejunhao3@huawei.com>
Date: Wed, 30 Nov 2022 19:01:35 +0800
Subject: [PATCH 186/201] perf test: Add pmu-events test for aliases of hip09
 ddrc pmu

driver inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I63VF5

--------------------------------------------------------------------------

Add a test for aliases of hip09 ddrc pmu to ensure that
the pmu-events tables are as expects.

Signed-off-by: Qi Liu <liuqi115@huawei.com>
Signed-off-by: Junhao He <hejunhao3@huawei.com>
Signed-off-by: hongrongxuan <hongrongxuan@huawei.com>
---
 .../arch/test/test_soc/sys/uncore.json        |  8 ++++++
 tools/perf/tests/pmu-events.c                 | 26 +++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/tools/perf/pmu-events/arch/test/test_soc/sys/uncore.json b/tools/perf/pmu-events/arch/test/test_soc/sys/uncore.json
index 0f681a6e10ea..bfe4ea8b46fc 100644
--- a/tools/perf/pmu-events/arch/test/test_soc/sys/uncore.json
+++ b/tools/perf/pmu-events/arch/test/test_soc/sys/uncore.json
@@ -6,4 +6,12 @@
            "Unit": "sys_ddr_pmu",
            "Compat": "v8"
    },
+   {
+            "EventCode": "0x84",
+            "EventName": "sys_hisi_ddrc.flux_rd",
+            "BriefDescription": "DDRC read commands",
+            "PublicDescription": "DDRC read commands",
+            "Unit": "sys_hisi_ddrc",
+            "Compat": "hip09"
+    }
 ]
diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c
index c9a89c8f4ab1..eac481cd8fbb 100644
--- a/tools/perf/tests/pmu-events.c
+++ b/tools/perf/tests/pmu-events.c
@@ -208,8 +208,24 @@ static const struct perf_pmu_test_event sys_ddr_pmu_write_cycles = {
 	.matching_pmu = "uncore_sys_ddr_pmu",
 };
 
+static const struct perf_pmu_test_event sys_hisi_ddrc_flux_rd = {
+	.event = {
+		.name = "sys_hisi_ddrc.flux_rd",
+		.event = "event=0x84",
+		.desc = "DDRC read commands. Unit: uncore_sys_hisi_ddrc ",
+		.topic = "uncore",
+		.long_desc = "DDRC read commands",
+		.pmu = "uncore_sys_hisi_ddrc",
+		.compat = "hip09",
+	},
+	.alias_str = "event=0x84",
+	.alias_long_desc = "DDRC read commands",
+	.matching_pmu = "uncore_sys_hisi_ddrc_0",
+};
+
 static const struct perf_pmu_test_event *sys_events[] = {
 	&sys_ddr_pmu_write_cycles,
+	&sys_hisi_ddrc_flux_rd,
 	NULL
 };
 
@@ -677,6 +693,16 @@ static struct perf_pmu_test_pmu test_pmus[] = {
 			&sys_ddr_pmu_write_cycles,
 		},
 	},
+	{
+		.pmu = {
+			.name = (char *)"uncore_sys_hisi_ddrc_0",
+			.is_uncore = 1,
+			.id = (char *)"hip09",
+		},
+		.aliases = {
+			&sys_hisi_ddrc_flux_rd,
+		},
+	},
 };
 
 /* Test that aliases generated are as expected */
-- 
2.27.0

