@@ -101,40 +101,31 @@ struct mips_pmu {
101
101
102
102
static struct mips_pmu mipspmu ;
103
103
104
- #define M_PERFCTL_EXL (1 << 0)
105
- #define M_PERFCTL_KERNEL (1 << 1)
106
- #define M_PERFCTL_SUPERVISOR (1 << 2)
107
- #define M_PERFCTL_USER (1 << 3)
108
- #define M_PERFCTL_INTERRUPT_ENABLE (1 << 4)
109
- #define M_PERFCTL_EVENT (event ) (((event) & 0x3ff) << 5)
110
- #define M_PERFCTL_VPEID (vpe ) ((vpe) << 16)
104
+ #define M_PERFCTL_EVENT (event ) (((event) << MIPS_PERFCTRL_EVENT_S) & \
105
+ MIPS_PERFCTRL_EVENT)
106
+ #define M_PERFCTL_VPEID (vpe ) ((vpe) << MIPS_PERFCTRL_VPEID_S)
111
107
112
108
#ifdef CONFIG_CPU_BMIPS5000
113
109
#define M_PERFCTL_MT_EN (filter ) 0
114
110
#else /* !CONFIG_CPU_BMIPS5000 */
115
- #define M_PERFCTL_MT_EN (filter ) (( filter) << 20 )
111
+ #define M_PERFCTL_MT_EN (filter ) (filter)
116
112
#endif /* CONFIG_CPU_BMIPS5000 */
117
113
118
- #define M_TC_EN_ALL M_PERFCTL_MT_EN(0)
119
- #define M_TC_EN_VPE M_PERFCTL_MT_EN(1)
120
- #define M_TC_EN_TC M_PERFCTL_MT_EN(2)
121
- #define M_PERFCTL_TCID (tcid ) ((tcid) << 22)
122
- #define M_PERFCTL_WIDE (1 << 30)
123
- #define M_PERFCTL_MORE (1 << 31)
124
- #define M_PERFCTL_TC (1 << 30)
114
+ #define M_TC_EN_ALL M_PERFCTL_MT_EN(MIPS_PERFCTRL_MT_EN_ALL)
115
+ #define M_TC_EN_VPE M_PERFCTL_MT_EN(MIPS_PERFCTRL_MT_EN_VPE)
116
+ #define M_TC_EN_TC M_PERFCTL_MT_EN(MIPS_PERFCTRL_MT_EN_TC)
125
117
126
- #define M_PERFCTL_COUNT_EVENT_WHENEVER (M_PERFCTL_EXL | \
127
- M_PERFCTL_KERNEL | \
128
- M_PERFCTL_USER | \
129
- M_PERFCTL_SUPERVISOR | \
130
- M_PERFCTL_INTERRUPT_ENABLE )
118
+ #define M_PERFCTL_COUNT_EVENT_WHENEVER (MIPS_PERFCTRL_EXL | \
119
+ MIPS_PERFCTRL_K | \
120
+ MIPS_PERFCTRL_U | \
121
+ MIPS_PERFCTRL_S | \
122
+ MIPS_PERFCTRL_IE )
131
123
132
124
#ifdef CONFIG_MIPS_MT_SMP
133
125
#define M_PERFCTL_CONFIG_MASK 0x3fff801f
134
126
#else
135
127
#define M_PERFCTL_CONFIG_MASK 0x1f
136
128
#endif
137
- #define M_PERFCTL_EVENT_MASK 0xfe0
138
129
139
130
140
131
#ifdef CONFIG_MIPS_PERF_SHARED_TC_COUNTERS
@@ -345,11 +336,11 @@ static void mipsxx_pmu_enable_event(struct hw_perf_event *evt, int idx)
345
336
cpuc -> saved_ctrl [idx ] = M_PERFCTL_EVENT (evt -> event_base & 0xff ) |
346
337
(evt -> config_base & M_PERFCTL_CONFIG_MASK ) |
347
338
/* Make sure interrupt enabled. */
348
- M_PERFCTL_INTERRUPT_ENABLE ;
339
+ MIPS_PERFCTRL_IE ;
349
340
if (IS_ENABLED (CONFIG_CPU_BMIPS5000 ))
350
341
/* enable the counter for the calling thread */
351
342
cpuc -> saved_ctrl [idx ] |=
352
- (1 << (12 + vpe_id ())) | M_PERFCTL_TC ;
343
+ (1 << (12 + vpe_id ())) | BRCM_PERFCTRL_TC ;
353
344
354
345
/*
355
346
* We do not actually let the counter run. Leave it until start().
@@ -754,11 +745,11 @@ static int __n_counters(void)
754
745
{
755
746
if (!cpu_has_perf )
756
747
return 0 ;
757
- if (!(read_c0_perfctrl0 () & M_PERFCTL_MORE ))
748
+ if (!(read_c0_perfctrl0 () & MIPS_PERFCTRL_M ))
758
749
return 1 ;
759
- if (!(read_c0_perfctrl1 () & M_PERFCTL_MORE ))
750
+ if (!(read_c0_perfctrl1 () & MIPS_PERFCTRL_M ))
760
751
return 2 ;
761
- if (!(read_c0_perfctrl2 () & M_PERFCTL_MORE ))
752
+ if (!(read_c0_perfctrl2 () & MIPS_PERFCTRL_M ))
762
753
return 3 ;
763
754
764
755
return 4 ;
@@ -1339,7 +1330,7 @@ static int __hw_perf_event_init(struct perf_event *event)
1339
1330
* We allow max flexibility on how each individual counter shared
1340
1331
* by the single CPU operates (the mode exclusion and the range).
1341
1332
*/
1342
- hwc -> config_base = M_PERFCTL_INTERRUPT_ENABLE ;
1333
+ hwc -> config_base = MIPS_PERFCTRL_IE ;
1343
1334
1344
1335
/* Calculate range bits and validate it. */
1345
1336
if (num_possible_cpus () > 1 )
@@ -1350,14 +1341,14 @@ static int __hw_perf_event_init(struct perf_event *event)
1350
1341
mutex_unlock (& raw_event_mutex );
1351
1342
1352
1343
if (!attr -> exclude_user )
1353
- hwc -> config_base |= M_PERFCTL_USER ;
1344
+ hwc -> config_base |= MIPS_PERFCTRL_U ;
1354
1345
if (!attr -> exclude_kernel ) {
1355
- hwc -> config_base |= M_PERFCTL_KERNEL ;
1346
+ hwc -> config_base |= MIPS_PERFCTRL_K ;
1356
1347
/* MIPS kernel mode: KSU == 00b || EXL == 1 || ERL == 1 */
1357
- hwc -> config_base |= M_PERFCTL_EXL ;
1348
+ hwc -> config_base |= MIPS_PERFCTRL_EXL ;
1358
1349
}
1359
1350
if (!attr -> exclude_hv )
1360
- hwc -> config_base |= M_PERFCTL_SUPERVISOR ;
1351
+ hwc -> config_base |= MIPS_PERFCTRL_S ;
1361
1352
1362
1353
hwc -> config_base &= M_PERFCTL_CONFIG_MASK ;
1363
1354
/*
@@ -1830,7 +1821,7 @@ init_hw_perf_events(void)
1830
1821
mipspmu .num_counters = counters ;
1831
1822
mipspmu .irq = irq ;
1832
1823
1833
- if (read_c0_perfctrl0 () & M_PERFCTL_WIDE ) {
1824
+ if (read_c0_perfctrl0 () & MIPS_PERFCTRL_W ) {
1834
1825
mipspmu .max_period = (1ULL << 63 ) - 1 ;
1835
1826
mipspmu .valid_count = (1ULL << 63 ) - 1 ;
1836
1827
mipspmu .overflow = 1ULL << 63 ;
0 commit comments