Skip to content

Commit 78b4416

Browse files
Madhavan Srinivasanmpe
authored andcommitted
powerpc/perf: Handle sdar_mode for marked event in power9
MMCRA[SDAR_MODE] specifices how the SDAR should be updated in continous sampling mode. On P9 it must be set to 0b00 when MMCRA[63] is set. Fixes: c7c3f56 ('powerpc/perf: macros for power9 format encoding') Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent f04d108 commit 78b4416

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

arch/powerpc/perf/isa207-common.c

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,41 @@ static bool is_event_valid(u64 event)
6565
return !(event & ~valid_mask);
6666
}
6767

68-
static u64 mmcra_sdar_mode(u64 event)
68+
static inline bool is_event_marked(u64 event)
6969
{
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+
}
7275

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;
74103
}
75104

76105
static u64 thresh_cmp_val(u64 value)
@@ -180,7 +209,7 @@ int isa207_get_constraint(u64 event, unsigned long *maskp, unsigned long *valp)
180209
value |= CNST_L1_QUAL_VAL(cache);
181210
}
182211

183-
if (event & EVENT_IS_MARKED) {
212+
if (is_event_marked(event)) {
184213
mask |= CNST_SAMPLE_MASK;
185214
value |= CNST_SAMPLE_VAL(event >> EVENT_SAMPLE_SHIFT);
186215
}
@@ -276,7 +305,7 @@ int isa207_compute_mmcr(u64 event[], int n_ev,
276305
}
277306

278307
/* In continuous sampling mode, update SDAR on TLB miss */
279-
mmcra |= mmcra_sdar_mode(event[i]);
308+
mmcra_sdar_mode(event[i], &mmcra);
280309

281310
if (event[i] & EVENT_IS_L1) {
282311
cache = event[i] >> EVENT_CACHE_SEL_SHIFT;
@@ -285,7 +314,7 @@ int isa207_compute_mmcr(u64 event[], int n_ev,
285314
mmcr1 |= (cache & 1) << MMCR1_DC_QUAL_SHIFT;
286315
}
287316

288-
if (event[i] & EVENT_IS_MARKED) {
317+
if (is_event_marked(event[i])) {
289318
mmcra |= MMCRA_SAMPLE_ENABLE;
290319

291320
val = (event[i] >> EVENT_SAMPLE_SHIFT) & EVENT_SAMPLE_MASK;

arch/powerpc/perf/isa207-common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@
246246
#define MMCRA_THR_CMP_SHIFT 32
247247
#define MMCRA_SDAR_MODE_SHIFT 42
248248
#define MMCRA_SDAR_MODE_TLB (1ull << MMCRA_SDAR_MODE_SHIFT)
249+
#define MMCRA_SDAR_MODE_NO_UPDATES ~(0x3ull << MMCRA_SDAR_MODE_SHIFT)
249250
#define MMCRA_IFM_SHIFT 30
250251

251252
/* MMCR1 Threshold Compare bit constant for power9 */

0 commit comments

Comments
 (0)