aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/powerpc/perf/isa207-common.c43
-rw-r--r--arch/powerpc/perf/isa207-common.h1
2 files changed, 37 insertions, 7 deletions
diff --git a/arch/powerpc/perf/isa207-common.c b/arch/powerpc/perf/isa207-common.c
index e79fb5fb817d..cd951fd231c4 100644
--- a/arch/powerpc/perf/isa207-common.c
+++ b/arch/powerpc/perf/isa207-common.c
@@ -65,12 +65,41 @@ static bool is_event_valid(u64 event)
65 return !(event & ~valid_mask); 65 return !(event & ~valid_mask);
66} 66}
67 67
68static u64 mmcra_sdar_mode(u64 event) 68static 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)) 70 if (event & EVENT_IS_MARKED)
71 return p9_SDAR_MODE(event) << MMCRA_SDAR_MODE_SHIFT; 71 return true;
72
73 return false;
74}
72 75
73 return MMCRA_SDAR_MODE_TLB; 76static 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
76static u64 thresh_cmp_val(u64 value) 105static u64 thresh_cmp_val(u64 value)
@@ -180,7 +209,7 @@ int isa207_get_constraint(u64 event, unsigned long *maskp, unsigned long *valp)
180 value |= CNST_L1_QUAL_VAL(cache); 209 value |= CNST_L1_QUAL_VAL(cache);
181 } 210 }
182 211
183 if (event & EVENT_IS_MARKED) { 212 if (is_event_marked(event)) {
184 mask |= CNST_SAMPLE_MASK; 213 mask |= CNST_SAMPLE_MASK;
185 value |= CNST_SAMPLE_VAL(event >> EVENT_SAMPLE_SHIFT); 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 /* In continuous sampling mode, update SDAR on TLB miss */ 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 if (event[i] & EVENT_IS_L1) { 310 if (event[i] & EVENT_IS_L1) {
282 cache = event[i] >> EVENT_CACHE_SEL_SHIFT; 311 cache = event[i] >> EVENT_CACHE_SEL_SHIFT;
@@ -285,7 +314,7 @@ int isa207_compute_mmcr(u64 event[], int n_ev,
285 mmcr1 |= (cache & 1) << MMCR1_DC_QUAL_SHIFT; 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 mmcra |= MMCRA_SAMPLE_ENABLE; 318 mmcra |= MMCRA_SAMPLE_ENABLE;
290 319
291 val = (event[i] >> EVENT_SAMPLE_SHIFT) & EVENT_SAMPLE_MASK; 320 val = (event[i] >> EVENT_SAMPLE_SHIFT) & EVENT_SAMPLE_MASK;
diff --git a/arch/powerpc/perf/isa207-common.h b/arch/powerpc/perf/isa207-common.h
index cf9bd8990159..899210f14ee4 100644
--- a/arch/powerpc/perf/isa207-common.h
+++ b/arch/powerpc/perf/isa207-common.h
@@ -246,6 +246,7 @@
246#define MMCRA_THR_CMP_SHIFT 32 246#define MMCRA_THR_CMP_SHIFT 32
247#define MMCRA_SDAR_MODE_SHIFT 42 247#define MMCRA_SDAR_MODE_SHIFT 42
248#define MMCRA_SDAR_MODE_TLB (1ull << MMCRA_SDAR_MODE_SHIFT) 248#define MMCRA_SDAR_MODE_TLB (1ull << MMCRA_SDAR_MODE_SHIFT)
249#define MMCRA_SDAR_MODE_NO_UPDATES ~(0x3ull << MMCRA_SDAR_MODE_SHIFT)
249#define MMCRA_IFM_SHIFT 30 250#define MMCRA_IFM_SHIFT 30
250 251
251/* MMCR1 Threshold Compare bit constant for power9 */ 252/* MMCR1 Threshold Compare bit constant for power9 */