209 lines
8.4 KiB
Diff
209 lines
8.4 KiB
Diff
From 021c239865727a9e633d04f3fc490426b51012ad Mon Sep 17 00:00:00 2001
|
|
From: Chen Jun <chenjun102@huawei.com>
|
|
Date: Tue, 23 May 2023 14:44:24 +0800
|
|
Subject: [PATCH 46/55] perf: hisi: Extract hisi_pmu_init
|
|
|
|
mainline inclusion
|
|
from mainline-v6.0-rc1
|
|
commit e500405dd15d956790859fa532c64d8186445372
|
|
category: cleanup
|
|
bugzilla: https://gitee.com/openeuler/kernel/issues/I77IH6
|
|
CVE: NA
|
|
|
|
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e500405dd15d956790859fa532c64d8186445372
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
Extract the initialization code of hisi_pmu->pmu into a function
|
|
|
|
Signed-off-by: Chen Jun <chenjun102@huawei.com>
|
|
Link: https://lore.kernel.org/r/20220516131601.48383-1-chenjun102@huawei.com
|
|
Signed-off-by: Will Deacon <will@kernel.org>
|
|
Signed-off-by: Junhao He <hejunhao3@huawei.com>
|
|
Signed-off-by: hongrongxuan <hongrongxuan@huawei.com>
|
|
---
|
|
drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c | 16 +---------------
|
|
drivers/perf/hisilicon/hisi_uncore_hha_pmu.c | 16 +---------------
|
|
drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c | 16 +---------------
|
|
drivers/perf/hisilicon/hisi_uncore_pa_pmu.c | 16 +---------------
|
|
drivers/perf/hisilicon/hisi_uncore_pmu.c | 18 ++++++++++++++++++
|
|
drivers/perf/hisilicon/hisi_uncore_pmu.h | 2 ++
|
|
drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c | 15 +--------------
|
|
7 files changed, 25 insertions(+), 74 deletions(-)
|
|
|
|
diff --git a/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c b/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
|
|
index 457ac6a1ad64..69d2b08847e2 100644
|
|
--- a/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
|
|
+++ b/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
|
|
@@ -519,21 +519,7 @@ static int hisi_ddrc_pmu_probe(struct platform_device *pdev)
|
|
"hisi_sccl%u_ddrc%u", ddrc_pmu->sccl_id,
|
|
ddrc_pmu->index_id);
|
|
|
|
- ddrc_pmu->pmu = (struct pmu) {
|
|
- .name = name,
|
|
- .module = THIS_MODULE,
|
|
- .task_ctx_nr = perf_invalid_context,
|
|
- .event_init = hisi_uncore_pmu_event_init,
|
|
- .pmu_enable = hisi_uncore_pmu_enable,
|
|
- .pmu_disable = hisi_uncore_pmu_disable,
|
|
- .add = hisi_uncore_pmu_add,
|
|
- .del = hisi_uncore_pmu_del,
|
|
- .start = hisi_uncore_pmu_start,
|
|
- .stop = hisi_uncore_pmu_stop,
|
|
- .read = hisi_uncore_pmu_read,
|
|
- .attr_groups = ddrc_pmu->pmu_events.attr_groups,
|
|
- .capabilities = PERF_PMU_CAP_NO_EXCLUDE,
|
|
- };
|
|
+ hisi_pmu_init(&ddrc_pmu->pmu, name, ddrc_pmu->pmu_events.attr_groups, THIS_MODULE);
|
|
|
|
ret = perf_pmu_register(&ddrc_pmu->pmu, name, -1);
|
|
if (ret) {
|
|
diff --git a/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c b/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
|
|
index 3b120fc55e01..c5f752f4ff22 100644
|
|
--- a/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
|
|
+++ b/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
|
|
@@ -522,21 +522,7 @@ static int hisi_hha_pmu_probe(struct platform_device *pdev)
|
|
|
|
name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "hisi_sccl%u_hha%u",
|
|
hha_pmu->sccl_id, hha_pmu->index_id);
|
|
- hha_pmu->pmu = (struct pmu) {
|
|
- .name = name,
|
|
- .module = THIS_MODULE,
|
|
- .task_ctx_nr = perf_invalid_context,
|
|
- .event_init = hisi_uncore_pmu_event_init,
|
|
- .pmu_enable = hisi_uncore_pmu_enable,
|
|
- .pmu_disable = hisi_uncore_pmu_disable,
|
|
- .add = hisi_uncore_pmu_add,
|
|
- .del = hisi_uncore_pmu_del,
|
|
- .start = hisi_uncore_pmu_start,
|
|
- .stop = hisi_uncore_pmu_stop,
|
|
- .read = hisi_uncore_pmu_read,
|
|
- .attr_groups = hha_pmu->pmu_events.attr_groups,
|
|
- .capabilities = PERF_PMU_CAP_NO_EXCLUDE,
|
|
- };
|
|
+ hisi_pmu_init(&hha_pmu->pmu, name, hha_pmu->pmu_events.attr_groups, THIS_MODULE);
|
|
|
|
ret = perf_pmu_register(&hha_pmu->pmu, name, -1);
|
|
if (ret) {
|
|
diff --git a/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c b/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
|
|
index d70a01587d72..d723e008a0f9 100644
|
|
--- a/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
|
|
+++ b/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
|
|
@@ -560,21 +560,7 @@ static int hisi_l3c_pmu_probe(struct platform_device *pdev)
|
|
*/
|
|
name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "hisi_sccl%u_l3c%u",
|
|
l3c_pmu->sccl_id, l3c_pmu->ccl_id);
|
|
- l3c_pmu->pmu = (struct pmu) {
|
|
- .name = name,
|
|
- .module = THIS_MODULE,
|
|
- .task_ctx_nr = perf_invalid_context,
|
|
- .event_init = hisi_uncore_pmu_event_init,
|
|
- .pmu_enable = hisi_uncore_pmu_enable,
|
|
- .pmu_disable = hisi_uncore_pmu_disable,
|
|
- .add = hisi_uncore_pmu_add,
|
|
- .del = hisi_uncore_pmu_del,
|
|
- .start = hisi_uncore_pmu_start,
|
|
- .stop = hisi_uncore_pmu_stop,
|
|
- .read = hisi_uncore_pmu_read,
|
|
- .attr_groups = l3c_pmu->pmu_events.attr_groups,
|
|
- .capabilities = PERF_PMU_CAP_NO_EXCLUDE,
|
|
- };
|
|
+ hisi_pmu_init(&l3c_pmu->pmu, name, l3c_pmu->pmu_events.attr_groups, THIS_MODULE);
|
|
|
|
ret = perf_pmu_register(&l3c_pmu->pmu, name, -1);
|
|
if (ret) {
|
|
diff --git a/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c b/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c
|
|
index 8bab65d50316..99786ef708a6 100644
|
|
--- a/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c
|
|
+++ b/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c
|
|
@@ -414,21 +414,7 @@ static int hisi_pa_pmu_probe(struct platform_device *pdev)
|
|
return ret;
|
|
}
|
|
|
|
- pa_pmu->pmu = (struct pmu) {
|
|
- .module = THIS_MODULE,
|
|
- .task_ctx_nr = perf_invalid_context,
|
|
- .event_init = hisi_uncore_pmu_event_init,
|
|
- .pmu_enable = hisi_uncore_pmu_enable,
|
|
- .pmu_disable = hisi_uncore_pmu_disable,
|
|
- .add = hisi_uncore_pmu_add,
|
|
- .del = hisi_uncore_pmu_del,
|
|
- .start = hisi_uncore_pmu_start,
|
|
- .stop = hisi_uncore_pmu_stop,
|
|
- .read = hisi_uncore_pmu_read,
|
|
- .attr_groups = pa_pmu->pmu_events.attr_groups,
|
|
- .capabilities = PERF_PMU_CAP_NO_EXCLUDE,
|
|
- };
|
|
-
|
|
+ hisi_pmu_init(&pa_pmu->pmu, name, pa_pmu->pmu_events.attr_groups, THIS_MODULE);
|
|
ret = perf_pmu_register(&pa_pmu->pmu, name, -1);
|
|
if (ret) {
|
|
dev_err(pa_pmu->dev, "PMU register failed, ret = %d\n", ret);
|
|
diff --git a/drivers/perf/hisilicon/hisi_uncore_pmu.c b/drivers/perf/hisilicon/hisi_uncore_pmu.c
|
|
index 91d2da895924..41640de74072 100644
|
|
--- a/drivers/perf/hisilicon/hisi_uncore_pmu.c
|
|
+++ b/drivers/perf/hisilicon/hisi_uncore_pmu.c
|
|
@@ -540,4 +540,22 @@ int hisi_uncore_pmu_offline_cpu(unsigned int cpu, struct hlist_node *node)
|
|
}
|
|
EXPORT_SYMBOL_GPL(hisi_uncore_pmu_offline_cpu);
|
|
|
|
+void hisi_pmu_init(struct pmu *pmu, const char *name,
|
|
+ const struct attribute_group **attr_groups, struct module *module)
|
|
+{
|
|
+ pmu->name = name;
|
|
+ pmu->module = module;
|
|
+ pmu->task_ctx_nr = perf_invalid_context;
|
|
+ pmu->event_init = hisi_uncore_pmu_event_init;
|
|
+ pmu->pmu_enable = hisi_uncore_pmu_enable;
|
|
+ pmu->pmu_disable = hisi_uncore_pmu_disable;
|
|
+ pmu->add = hisi_uncore_pmu_add;
|
|
+ pmu->del = hisi_uncore_pmu_del;
|
|
+ pmu->start = hisi_uncore_pmu_start;
|
|
+ pmu->stop = hisi_uncore_pmu_stop;
|
|
+ pmu->read = hisi_uncore_pmu_read;
|
|
+ pmu->attr_groups = attr_groups;
|
|
+}
|
|
+EXPORT_SYMBOL_GPL(hisi_pmu_init);
|
|
+
|
|
MODULE_LICENSE("GPL v2");
|
|
diff --git a/drivers/perf/hisilicon/hisi_uncore_pmu.h b/drivers/perf/hisilicon/hisi_uncore_pmu.h
|
|
index 6a78c13176c2..9818e20d36f8 100644
|
|
--- a/drivers/perf/hisilicon/hisi_uncore_pmu.h
|
|
+++ b/drivers/perf/hisilicon/hisi_uncore_pmu.h
|
|
@@ -135,4 +135,6 @@ ssize_t hisi_uncore_pmu_identifier_attr_show(struct device *dev,
|
|
int hisi_uncore_pmu_init_irq(struct hisi_pmu *hisi_pmu,
|
|
struct platform_device *pdev);
|
|
|
|
+void hisi_pmu_init(struct pmu *pmu, const char *name,
|
|
+ const struct attribute_group **attr_groups, struct module *module);
|
|
#endif /* __HISI_UNCORE_PMU_H__ */
|
|
diff --git a/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c b/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c
|
|
index 71b199ec447a..b71de6597016 100644
|
|
--- a/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c
|
|
+++ b/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c
|
|
@@ -447,20 +447,7 @@ static int hisi_sllc_pmu_probe(struct platform_device *pdev)
|
|
return ret;
|
|
}
|
|
|
|
- sllc_pmu->pmu = (struct pmu) {
|
|
- .module = THIS_MODULE,
|
|
- .task_ctx_nr = perf_invalid_context,
|
|
- .event_init = hisi_uncore_pmu_event_init,
|
|
- .pmu_enable = hisi_uncore_pmu_enable,
|
|
- .pmu_disable = hisi_uncore_pmu_disable,
|
|
- .add = hisi_uncore_pmu_add,
|
|
- .del = hisi_uncore_pmu_del,
|
|
- .start = hisi_uncore_pmu_start,
|
|
- .stop = hisi_uncore_pmu_stop,
|
|
- .read = hisi_uncore_pmu_read,
|
|
- .attr_groups = sllc_pmu->pmu_events.attr_groups,
|
|
- .capabilities = PERF_PMU_CAP_NO_EXCLUDE,
|
|
- };
|
|
+ hisi_pmu_init(&sllc_pmu->pmu, name, sllc_pmu->pmu_events.attr_groups, THIS_MODULE);
|
|
|
|
ret = perf_pmu_register(&sllc_pmu->pmu, name, -1);
|
|
if (ret) {
|
|
--
|
|
2.27.0
|
|
|