perf/x86/intel/uncore: Support CoffeeLake 8th CBOX

Coffee Lake has 8 core products which has 8 Cboxes. The 8th CBOX is
mapped into different MSR space.

Increase the num_boxes to 8 to handle the new products. It will not
impact the previous platforms, SkyLake, KabyLake and earlier CoffeeLake.
Because the num_boxes will be recalculated in uncore_cpu_init and
doesn't exceed the x86_max_cores.

Introduce a new box flag bit to indicate the 8th CBOX.

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Link: http://lkml.kernel.org/r/20181019170419.378-2-kan.liang@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by Kan Liang and committed by Ingo Molnar 4d47d640 c10a8de0

Changed files
+30 -9
arch
x86
events
+25 -8
arch/x86/events/intel/uncore.h
··· 129 129 struct intel_uncore_extra_reg shared_regs[0]; 130 130 }; 131 131 132 - #define UNCORE_BOX_FLAG_INITIATED 0 133 - #define UNCORE_BOX_FLAG_CTL_OFFS8 1 /* event config registers are 8-byte apart */ 132 + /* CFL uncore 8th cbox MSRs */ 133 + #define CFL_UNC_CBO_7_PERFEVTSEL0 0xf70 134 + #define CFL_UNC_CBO_7_PER_CTR0 0xf76 135 + 136 + #define UNCORE_BOX_FLAG_INITIATED 0 137 + /* event config registers are 8-byte apart */ 138 + #define UNCORE_BOX_FLAG_CTL_OFFS8 1 139 + /* CFL 8th CBOX has different MSR space */ 140 + #define UNCORE_BOX_FLAG_CFL8_CBOX_MSR_OFFS 2 134 141 135 142 struct uncore_event_desc { 136 143 struct kobj_attribute attr; ··· 304 297 static inline 305 298 unsigned uncore_msr_event_ctl(struct intel_uncore_box *box, int idx) 306 299 { 307 - return box->pmu->type->event_ctl + 308 - (box->pmu->type->pair_ctr_ctl ? 2 * idx : idx) + 309 - uncore_msr_box_offset(box); 300 + if (test_bit(UNCORE_BOX_FLAG_CFL8_CBOX_MSR_OFFS, &box->flags)) { 301 + return CFL_UNC_CBO_7_PERFEVTSEL0 + 302 + (box->pmu->type->pair_ctr_ctl ? 2 * idx : idx); 303 + } else { 304 + return box->pmu->type->event_ctl + 305 + (box->pmu->type->pair_ctr_ctl ? 2 * idx : idx) + 306 + uncore_msr_box_offset(box); 307 + } 310 308 } 311 309 312 310 static inline 313 311 unsigned uncore_msr_perf_ctr(struct intel_uncore_box *box, int idx) 314 312 { 315 - return box->pmu->type->perf_ctr + 316 - (box->pmu->type->pair_ctr_ctl ? 2 * idx : idx) + 317 - uncore_msr_box_offset(box); 313 + if (test_bit(UNCORE_BOX_FLAG_CFL8_CBOX_MSR_OFFS, &box->flags)) { 314 + return CFL_UNC_CBO_7_PER_CTR0 + 315 + (box->pmu->type->pair_ctr_ctl ? 2 * idx : idx); 316 + } else { 317 + return box->pmu->type->perf_ctr + 318 + (box->pmu->type->pair_ctr_ctl ? 2 * idx : idx) + 319 + uncore_msr_box_offset(box); 320 + } 318 321 } 319 322 320 323 static inline
+5 -1
arch/x86/events/intel/uncore_snb.c
··· 221 221 wrmsrl(SKL_UNC_PERF_GLOBAL_CTL, 222 222 SNB_UNC_GLOBAL_CTL_EN | SKL_UNC_GLOBAL_CTL_CORE_ALL); 223 223 } 224 + 225 + /* The 8th CBOX has different MSR space */ 226 + if (box->pmu->pmu_idx == 7) 227 + __set_bit(UNCORE_BOX_FLAG_CFL8_CBOX_MSR_OFFS, &box->flags); 224 228 } 225 229 226 230 static void skl_uncore_msr_enable_box(struct intel_uncore_box *box) ··· 251 247 static struct intel_uncore_type skl_uncore_cbox = { 252 248 .name = "cbox", 253 249 .num_counters = 4, 254 - .num_boxes = 5, 250 + .num_boxes = 8, 255 251 .perf_ctr_bits = 44, 256 252 .fixed_ctr_bits = 48, 257 253 .perf_ctr = SNB_UNC_CBO_0_PER_CTR0,