@@ -65,12 +65,41 @@ static bool is_event_valid(u64 event)
65
65
return !(event & ~valid_mask );
66
66
}
67
67
68
- static u64 mmcra_sdar_mode (u64 event )
68
+ static inline bool is_event_marked (u64 event )
69
69
{
70
- if (cpu_has_feature (CPU_FTR_ARCH_300 ) && !cpu_has_feature (CPU_FTR_POWER9_DD1 ))
71
- return p9_SDAR_MODE (event ) << MMCRA_SDAR_MODE_SHIFT ;
70
+ if (event & EVENT_IS_MARKED )
71
+ return true;
72
+
73
+ return false;
74
+ }
72
75
73
- return MMCRA_SDAR_MODE_TLB ;
76
+ static void mmcra_sdar_mode (u64 event , unsigned long * mmcra )
77
+ {
78
+ /*
79
+ * MMCRA[SDAR_MODE] specifices how the SDAR should be updated in
80
+ * continous sampling mode.
81
+ *
82
+ * Incase of Power8:
83
+ * MMCRA[SDAR_MODE] will be programmed as "0b01" for continous sampling
84
+ * mode and will be un-changed when setting MMCRA[63] (Marked events).
85
+ *
86
+ * Incase of Power9:
87
+ * Marked event: MMCRA[SDAR_MODE] will be set to 0b00 ('No Updates'),
88
+ * or if group already have any marked events.
89
+ * Non-Marked events (for DD1):
90
+ * MMCRA[SDAR_MODE] will be set to 0b01
91
+ * For rest
92
+ * MMCRA[SDAR_MODE] will be set from event code.
93
+ */
94
+ if (cpu_has_feature (CPU_FTR_ARCH_300 )) {
95
+ if (is_event_marked (event ) || (* mmcra & MMCRA_SAMPLE_ENABLE ))
96
+ * mmcra &= MMCRA_SDAR_MODE_NO_UPDATES ;
97
+ else if (!cpu_has_feature (CPU_FTR_POWER9_DD1 ))
98
+ * mmcra |= p9_SDAR_MODE (event ) << MMCRA_SDAR_MODE_SHIFT ;
99
+ else if (cpu_has_feature (CPU_FTR_POWER9_DD1 ))
100
+ * mmcra |= MMCRA_SDAR_MODE_TLB ;
101
+ } else
102
+ * mmcra |= MMCRA_SDAR_MODE_TLB ;
74
103
}
75
104
76
105
static u64 thresh_cmp_val (u64 value )
@@ -180,7 +209,7 @@ int isa207_get_constraint(u64 event, unsigned long *maskp, unsigned long *valp)
180
209
value |= CNST_L1_QUAL_VAL (cache );
181
210
}
182
211
183
- if (event & EVENT_IS_MARKED ) {
212
+ if (is_event_marked ( event ) ) {
184
213
mask |= CNST_SAMPLE_MASK ;
185
214
value |= CNST_SAMPLE_VAL (event >> EVENT_SAMPLE_SHIFT );
186
215
}
@@ -276,7 +305,7 @@ int isa207_compute_mmcr(u64 event[], int n_ev,
276
305
}
277
306
278
307
/* In continuous sampling mode, update SDAR on TLB miss */
279
- mmcra |= mmcra_sdar_mode (event [i ]);
308
+ mmcra_sdar_mode (event [i ], & mmcra );
280
309
281
310
if (event [i ] & EVENT_IS_L1 ) {
282
311
cache = event [i ] >> EVENT_CACHE_SEL_SHIFT ;
@@ -285,7 +314,7 @@ int isa207_compute_mmcr(u64 event[], int n_ev,
285
314
mmcr1 |= (cache & 1 ) << MMCR1_DC_QUAL_SHIFT ;
286
315
}
287
316
288
- if (event [i ] & EVENT_IS_MARKED ) {
317
+ if (is_event_marked ( event [i ]) ) {
289
318
mmcra |= MMCRA_SAMPLE_ENABLE ;
290
319
291
320
val = (event [i ] >> EVENT_SAMPLE_SHIFT ) & EVENT_SAMPLE_MASK ;
0 commit comments