23
23
#include <asm/barrier.h>
24
24
#include <asm/local64.h>
25
25
#include <asm/sysreg.h>
26
+ #include <soc/qcom/kryo-l2-accessors.h>
26
27
27
28
#define MAX_L2_CTRS 9
28
29
79
80
#define L2_COUNTER_RELOAD BIT_ULL(31)
80
81
#define L2_CYCLE_COUNTER_RELOAD BIT_ULL(63)
81
82
82
- #define L2CPUSRSELR_EL1 sys_reg(3, 3, 15, 0, 6)
83
- #define L2CPUSRDR_EL1 sys_reg(3, 3, 15, 0, 7)
84
83
85
84
#define reg_idx (reg , i ) (((i) * IA_L2_REG_OFFSET) + reg##_BASE)
86
85
99
98
#define L2_EVENT_STREX 0x421
100
99
#define L2_EVENT_CLREX 0x422
101
100
102
- static DEFINE_RAW_SPINLOCK (l2_access_lock );
103
101
104
- /**
105
- * set_l2_indirect_reg: write value to an L2 register
106
- * @reg: Address of L2 register.
107
- * @value: Value to be written to register.
108
- *
109
- * Use architecturally required barriers for ordering between system register
110
- * accesses
111
- */
112
- static void set_l2_indirect_reg (u64 reg , u64 val )
113
- {
114
- unsigned long flags ;
115
-
116
- raw_spin_lock_irqsave (& l2_access_lock , flags );
117
- write_sysreg_s (reg , L2CPUSRSELR_EL1 );
118
- isb ();
119
- write_sysreg_s (val , L2CPUSRDR_EL1 );
120
- isb ();
121
- raw_spin_unlock_irqrestore (& l2_access_lock , flags );
122
- }
123
-
124
- /**
125
- * get_l2_indirect_reg: read an L2 register value
126
- * @reg: Address of L2 register.
127
- *
128
- * Use architecturally required barriers for ordering between system register
129
- * accesses
130
- */
131
- static u64 get_l2_indirect_reg (u64 reg )
132
- {
133
- u64 val ;
134
- unsigned long flags ;
135
-
136
- raw_spin_lock_irqsave (& l2_access_lock , flags );
137
- write_sysreg_s (reg , L2CPUSRSELR_EL1 );
138
- isb ();
139
- val = read_sysreg_s (L2CPUSRDR_EL1 );
140
- raw_spin_unlock_irqrestore (& l2_access_lock , flags );
141
-
142
- return val ;
143
- }
144
102
145
103
struct cluster_pmu ;
146
104
@@ -211,75 +169,75 @@ static inline struct cluster_pmu *get_cluster_pmu(
211
169
static void cluster_pmu_reset (void )
212
170
{
213
171
/* Reset all counters */
214
- set_l2_indirect_reg (L2PMCR , L2PMCR_RESET_ALL );
215
- set_l2_indirect_reg (L2PMCNTENCLR , l2_counter_present_mask );
216
- set_l2_indirect_reg (L2PMINTENCLR , l2_counter_present_mask );
217
- set_l2_indirect_reg (L2PMOVSCLR , l2_counter_present_mask );
172
+ kryo_l2_set_indirect_reg (L2PMCR , L2PMCR_RESET_ALL );
173
+ kryo_l2_set_indirect_reg (L2PMCNTENCLR , l2_counter_present_mask );
174
+ kryo_l2_set_indirect_reg (L2PMINTENCLR , l2_counter_present_mask );
175
+ kryo_l2_set_indirect_reg (L2PMOVSCLR , l2_counter_present_mask );
218
176
}
219
177
220
178
static inline void cluster_pmu_enable (void )
221
179
{
222
- set_l2_indirect_reg (L2PMCR , L2PMCR_COUNTERS_ENABLE );
180
+ kryo_l2_set_indirect_reg (L2PMCR , L2PMCR_COUNTERS_ENABLE );
223
181
}
224
182
225
183
static inline void cluster_pmu_disable (void )
226
184
{
227
- set_l2_indirect_reg (L2PMCR , L2PMCR_COUNTERS_DISABLE );
185
+ kryo_l2_set_indirect_reg (L2PMCR , L2PMCR_COUNTERS_DISABLE );
228
186
}
229
187
230
188
static inline void cluster_pmu_counter_set_value (u32 idx , u64 value )
231
189
{
232
190
if (idx == l2_cycle_ctr_idx )
233
- set_l2_indirect_reg (L2PMCCNTR , value );
191
+ kryo_l2_set_indirect_reg (L2PMCCNTR , value );
234
192
else
235
- set_l2_indirect_reg (reg_idx (IA_L2PMXEVCNTR , idx ), value );
193
+ kryo_l2_set_indirect_reg (reg_idx (IA_L2PMXEVCNTR , idx ), value );
236
194
}
237
195
238
196
static inline u64 cluster_pmu_counter_get_value (u32 idx )
239
197
{
240
198
u64 value ;
241
199
242
200
if (idx == l2_cycle_ctr_idx )
243
- value = get_l2_indirect_reg (L2PMCCNTR );
201
+ value = kryo_l2_get_indirect_reg (L2PMCCNTR );
244
202
else
245
- value = get_l2_indirect_reg (reg_idx (IA_L2PMXEVCNTR , idx ));
203
+ value = kryo_l2_get_indirect_reg (reg_idx (IA_L2PMXEVCNTR , idx ));
246
204
247
205
return value ;
248
206
}
249
207
250
208
static inline void cluster_pmu_counter_enable (u32 idx )
251
209
{
252
- set_l2_indirect_reg (L2PMCNTENSET , idx_to_reg_bit (idx ));
210
+ kryo_l2_set_indirect_reg (L2PMCNTENSET , idx_to_reg_bit (idx ));
253
211
}
254
212
255
213
static inline void cluster_pmu_counter_disable (u32 idx )
256
214
{
257
- set_l2_indirect_reg (L2PMCNTENCLR , idx_to_reg_bit (idx ));
215
+ kryo_l2_set_indirect_reg (L2PMCNTENCLR , idx_to_reg_bit (idx ));
258
216
}
259
217
260
218
static inline void cluster_pmu_counter_enable_interrupt (u32 idx )
261
219
{
262
- set_l2_indirect_reg (L2PMINTENSET , idx_to_reg_bit (idx ));
220
+ kryo_l2_set_indirect_reg (L2PMINTENSET , idx_to_reg_bit (idx ));
263
221
}
264
222
265
223
static inline void cluster_pmu_counter_disable_interrupt (u32 idx )
266
224
{
267
- set_l2_indirect_reg (L2PMINTENCLR , idx_to_reg_bit (idx ));
225
+ kryo_l2_set_indirect_reg (L2PMINTENCLR , idx_to_reg_bit (idx ));
268
226
}
269
227
270
228
static inline void cluster_pmu_set_evccntcr (u32 val )
271
229
{
272
- set_l2_indirect_reg (L2PMCCNTCR , val );
230
+ kryo_l2_set_indirect_reg (L2PMCCNTCR , val );
273
231
}
274
232
275
233
static inline void cluster_pmu_set_evcntcr (u32 ctr , u32 val )
276
234
{
277
- set_l2_indirect_reg (reg_idx (IA_L2PMXEVCNTCR , ctr ), val );
235
+ kryo_l2_set_indirect_reg (reg_idx (IA_L2PMXEVCNTCR , ctr ), val );
278
236
}
279
237
280
238
static inline void cluster_pmu_set_evtyper (u32 ctr , u32 val )
281
239
{
282
- set_l2_indirect_reg (reg_idx (IA_L2PMXEVTYPER , ctr ), val );
240
+ kryo_l2_set_indirect_reg (reg_idx (IA_L2PMXEVTYPER , ctr ), val );
283
241
}
284
242
285
243
static void cluster_pmu_set_resr (struct cluster_pmu * cluster ,
@@ -295,11 +253,11 @@ static void cluster_pmu_set_resr(struct cluster_pmu *cluster,
295
253
296
254
spin_lock_irqsave (& cluster -> pmu_lock , flags );
297
255
298
- resr_val = get_l2_indirect_reg (L2PMRESR );
256
+ resr_val = kryo_l2_get_indirect_reg (L2PMRESR );
299
257
resr_val &= ~(L2PMRESR_GROUP_MASK << shift );
300
258
resr_val |= field ;
301
259
resr_val |= L2PMRESR_EN ;
302
- set_l2_indirect_reg (L2PMRESR , resr_val );
260
+ kryo_l2_set_indirect_reg (L2PMRESR , resr_val );
303
261
304
262
spin_unlock_irqrestore (& cluster -> pmu_lock , flags );
305
263
}
@@ -315,14 +273,14 @@ static inline void cluster_pmu_set_evfilter_sys_mode(u32 ctr)
315
273
L2PMXEVFILTER_ORGFILTER_IDINDEP |
316
274
L2PMXEVFILTER_ORGFILTER_ALL ;
317
275
318
- set_l2_indirect_reg (reg_idx (IA_L2PMXEVFILTER , ctr ), val );
276
+ kryo_l2_set_indirect_reg (reg_idx (IA_L2PMXEVFILTER , ctr ), val );
319
277
}
320
278
321
279
static inline u32 cluster_pmu_getreset_ovsr (void )
322
280
{
323
- u32 result = get_l2_indirect_reg (L2PMOVSSET );
281
+ u32 result = kryo_l2_get_indirect_reg (L2PMOVSSET );
324
282
325
- set_l2_indirect_reg (L2PMOVSCLR , result );
283
+ kryo_l2_set_indirect_reg (L2PMOVSCLR , result );
326
284
return result ;
327
285
}
328
286
@@ -767,7 +725,7 @@ static int get_num_counters(void)
767
725
{
768
726
int val ;
769
727
770
- val = get_l2_indirect_reg (L2PMCR );
728
+ val = kryo_l2_get_indirect_reg (L2PMCR );
771
729
772
730
/*
773
731
* Read number of counters from L2PMCR and add 1
0 commit comments