]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
powerpc/perf: init pmu from core-book3s
authorMadhavan Srinivasan <maddy@linux.vnet.ibm.com>
Thu, 4 Apr 2019 11:54:49 +0000 (17:24 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 2 May 2019 16:54:58 +0000 (02:54 +1000)
Currenty pmu driver file for each ppc64 generation processor
has a __init call in itself. Refactor the code by moving the
__init call to core-books.c. This also clean's up compat mode
pmu driver registration.

Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
[mpe: Use SPDX tag for license]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/perf/core-book3s.c
arch/powerpc/perf/internal.h [new file with mode: 0644]
arch/powerpc/perf/power5+-pmu.c
arch/powerpc/perf/power5-pmu.c
arch/powerpc/perf/power6-pmu.c
arch/powerpc/perf/power7-pmu.c
arch/powerpc/perf/power8-pmu.c
arch/powerpc/perf/power9-pmu.c
arch/powerpc/perf/ppc970-pmu.c

index b0723002a3967f895d0799fa07a5f0a871c3889b..a96f9420139ca15088774f4e1e8af8d4f85a5d00 100644 (file)
 #include <asm/ptrace.h>
 #include <asm/code-patching.h>
 
+#ifdef CONFIG_PPC64
+#include "internal.h"
+#endif
+
 #define BHRB_MAX_ENTRIES       32
 #define BHRB_TARGET            0x0000000000000002
 #define BHRB_PREDICTION                0x0000000000000001
@@ -2294,3 +2298,27 @@ int register_power_pmu(struct power_pmu *pmu)
                          power_pmu_prepare_cpu, NULL);
        return 0;
 }
+
+#ifdef CONFIG_PPC64
+static int __init init_ppc64_pmu(void)
+{
+       /* run through all the pmu drivers one at a time */
+       if (!init_power5_pmu())
+               return 0;
+       else if (!init_power5p_pmu())
+               return 0;
+       else if (!init_power6_pmu())
+               return 0;
+       else if (!init_power7_pmu())
+               return 0;
+       else if (!init_power8_pmu())
+               return 0;
+       else if (!init_power9_pmu())
+               return 0;
+       else if (!init_ppc970_pmu())
+               return 0;
+       else
+               return -ENODEV;
+}
+early_initcall(init_ppc64_pmu);
+#endif
diff --git a/arch/powerpc/perf/internal.h b/arch/powerpc/perf/internal.h
new file mode 100644 (file)
index 0000000..683f481
--- /dev/null
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright 2019 Madhavan Srinivasan, IBM Corporation.
+
+extern int init_ppc970_pmu(void);
+extern int init_power5_pmu(void);
+extern int init_power5p_pmu(void);
+extern int init_power6_pmu(void);
+extern int init_power7_pmu(void);
+extern int init_power8_pmu(void);
+extern int init_power9_pmu(void);
index 0526dac66007fee536d5e831ba6bdc7ad079cdc4..9aa803504cb289cb50ee713081dfc2bd194699b9 100644 (file)
@@ -677,7 +677,7 @@ static struct power_pmu power5p_pmu = {
        .cache_events           = &power5p_cache_events,
 };
 
-static int __init init_power5p_pmu(void)
+int init_power5p_pmu(void)
 {
        if (!cur_cpu_spec->oprofile_cpu_type ||
            (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power5+")
@@ -686,5 +686,3 @@ static int __init init_power5p_pmu(void)
 
        return register_power_pmu(&power5p_pmu);
 }
-
-early_initcall(init_power5p_pmu);
index 4dc99f9f796258df3fe77419142ea9984d07f831..30cb13d081a9b1e55cebce1768cfe10c5731f971 100644 (file)
@@ -618,7 +618,7 @@ static struct power_pmu power5_pmu = {
        .flags                  = PPMU_HAS_SSLOT,
 };
 
-static int __init init_power5_pmu(void)
+int init_power5_pmu(void)
 {
        if (!cur_cpu_spec->oprofile_cpu_type ||
            strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power5"))
@@ -626,5 +626,3 @@ static int __init init_power5_pmu(void)
 
        return register_power_pmu(&power5_pmu);
 }
-
-early_initcall(init_power5_pmu);
index 9c9d646b68a1eb29da4e154a5118ddc8d8fc6ffb..80ec48632cfe03d68f946ff998315576820c7394 100644 (file)
@@ -540,7 +540,7 @@ static struct power_pmu power6_pmu = {
        .cache_events           = &power6_cache_events,
 };
 
-static int __init init_power6_pmu(void)
+int init_power6_pmu(void)
 {
        if (!cur_cpu_spec->oprofile_cpu_type ||
            strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power6"))
@@ -548,5 +548,3 @@ static int __init init_power6_pmu(void)
 
        return register_power_pmu(&power6_pmu);
 }
-
-early_initcall(init_power6_pmu);
index 6dbae9884ec439351146062256cf0bed6e239901..bb6efd5d253093ae6d21b3bd5a51b9ffd3d962e4 100644 (file)
@@ -445,7 +445,7 @@ static struct power_pmu power7_pmu = {
        .cache_events           = &power7_cache_events,
 };
 
-static int __init init_power7_pmu(void)
+int init_power7_pmu(void)
 {
        if (!cur_cpu_spec->oprofile_cpu_type ||
            strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power7"))
@@ -456,5 +456,3 @@ static int __init init_power7_pmu(void)
 
        return register_power_pmu(&power7_pmu);
 }
-
-early_initcall(init_power7_pmu);
index d12a2db2635353c38fd27510512dff89da80ea28..bcc3409a06de4b1b86ab568904a74fdc286c8b1b 100644 (file)
@@ -379,7 +379,7 @@ static struct power_pmu power8_pmu = {
        .bhrb_nr                = 32,
 };
 
-static int __init init_power8_pmu(void)
+int init_power8_pmu(void)
 {
        int rc;
 
@@ -399,4 +399,3 @@ static int __init init_power8_pmu(void)
 
        return 0;
 }
-early_initcall(init_power8_pmu);
index 030544e35959fe494536617df31d92a4dd0f79bc..3a31ac6f4805113a47cc39c67bd7e9c62eacd018 100644 (file)
@@ -437,7 +437,7 @@ static struct power_pmu power9_pmu = {
        .bhrb_nr                = 32,
 };
 
-static int __init init_power9_pmu(void)
+int init_power9_pmu(void)
 {
        int rc = 0;
        unsigned int pvr = mfspr(SPRN_PVR);
@@ -467,4 +467,3 @@ static int __init init_power9_pmu(void)
 
        return 0;
 }
-early_initcall(init_power9_pmu);
index 8b6a8a36fa3818cc67093ac60f968089b84944eb..1d33709140222b095ae8d153e117d13dd68e59d0 100644 (file)
@@ -490,7 +490,7 @@ static struct power_pmu ppc970_pmu = {
        .flags                  = PPMU_NO_SIPR | PPMU_NO_CONT_SAMPLING,
 };
 
-static int __init init_ppc970_pmu(void)
+int init_ppc970_pmu(void)
 {
        if (!cur_cpu_spec->oprofile_cpu_type ||
            (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/970")
@@ -499,5 +499,3 @@ static int __init init_ppc970_pmu(void)
 
        return register_power_pmu(&ppc970_pmu);
 }
-
-early_initcall(init_ppc970_pmu);