Skip to content

Commit 949b113

Browse files
Kan LiangPeter Zijlstra
authored andcommitted
perf/x86/intel/uncore: Add Sapphire Rapids server CHA support
CHA merges the caching agent and Home Agent (HA) responsibilities of the chip into a single block. It's one of the Sapphire Rapids server uncore units. The layout of the control registers for a CHA uncore unit is a little bit different from the generic one. The CHA uncore unit also supports a filter register for TID. So a specific format and ops are required. Expose the common MSR ops which can be reused. Signed-off-by: Kan Liang <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Andi Kleen <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent c54c53d commit 949b113

File tree

3 files changed

+96
-4
lines changed

3 files changed

+96
-4
lines changed

arch/x86/events/intel/uncore_discovery.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,17 +337,17 @@ static const struct attribute_group generic_uncore_format_group = {
337337
.attrs = generic_uncore_formats_attr,
338338
};
339339

340-
static void intel_generic_uncore_msr_init_box(struct intel_uncore_box *box)
340+
void intel_generic_uncore_msr_init_box(struct intel_uncore_box *box)
341341
{
342342
wrmsrl(uncore_msr_box_ctl(box), GENERIC_PMON_BOX_CTL_INT);
343343
}
344344

345-
static void intel_generic_uncore_msr_disable_box(struct intel_uncore_box *box)
345+
void intel_generic_uncore_msr_disable_box(struct intel_uncore_box *box)
346346
{
347347
wrmsrl(uncore_msr_box_ctl(box), GENERIC_PMON_BOX_CTL_FRZ);
348348
}
349349

350-
static void intel_generic_uncore_msr_enable_box(struct intel_uncore_box *box)
350+
void intel_generic_uncore_msr_enable_box(struct intel_uncore_box *box)
351351
{
352352
wrmsrl(uncore_msr_box_ctl(box), 0);
353353
}

arch/x86/events/intel/uncore_discovery.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,5 +130,9 @@ void intel_uncore_generic_uncore_cpu_init(void);
130130
int intel_uncore_generic_uncore_pci_init(void);
131131
void intel_uncore_generic_uncore_mmio_init(void);
132132

133+
void intel_generic_uncore_msr_init_box(struct intel_uncore_box *box);
134+
void intel_generic_uncore_msr_disable_box(struct intel_uncore_box *box);
135+
void intel_generic_uncore_msr_enable_box(struct intel_uncore_box *box);
136+
133137
struct intel_uncore_type **
134138
intel_uncore_generic_init_uncores(enum uncore_access_type type_id);

arch/x86/events/intel/uncore_snbep.c

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,17 @@
455455
#define ICX_NUMBER_IMC_CHN 2
456456
#define ICX_IMC_MEM_STRIDE 0x4
457457

458+
/* SPR */
459+
#define SPR_RAW_EVENT_MASK_EXT 0xffffff
460+
461+
/* SPR CHA */
462+
#define SPR_CHA_PMON_CTL_TID_EN (1 << 16)
463+
#define SPR_CHA_PMON_EVENT_MASK (SNBEP_PMON_RAW_EVENT_MASK | \
464+
SPR_CHA_PMON_CTL_TID_EN)
465+
#define SPR_CHA_PMON_BOX_FILTER_TID 0x3ff
466+
467+
#define SPR_C0_MSR_PMON_BOX_FILTER0 0x200e
468+
458469
DEFINE_UNCORE_FORMAT_ATTR(event, event, "config:0-7");
459470
DEFINE_UNCORE_FORMAT_ATTR(event2, event, "config:0-6");
460471
DEFINE_UNCORE_FORMAT_ATTR(event_ext, event, "config:0-7,21");
@@ -467,6 +478,7 @@ DEFINE_UNCORE_FORMAT_ATTR(umask_ext4, umask, "config:8-15,32-55");
467478
DEFINE_UNCORE_FORMAT_ATTR(qor, qor, "config:16");
468479
DEFINE_UNCORE_FORMAT_ATTR(edge, edge, "config:18");
469480
DEFINE_UNCORE_FORMAT_ATTR(tid_en, tid_en, "config:19");
481+
DEFINE_UNCORE_FORMAT_ATTR(tid_en2, tid_en, "config:16");
470482
DEFINE_UNCORE_FORMAT_ATTR(inv, inv, "config:23");
471483
DEFINE_UNCORE_FORMAT_ATTR(thresh9, thresh, "config:24-35");
472484
DEFINE_UNCORE_FORMAT_ATTR(thresh8, thresh, "config:24-31");
@@ -5508,10 +5520,86 @@ void icx_uncore_mmio_init(void)
55085520

55095521
/* SPR uncore support */
55105522

5523+
static void spr_uncore_msr_enable_event(struct intel_uncore_box *box,
5524+
struct perf_event *event)
5525+
{
5526+
struct hw_perf_event *hwc = &event->hw;
5527+
struct hw_perf_event_extra *reg1 = &hwc->extra_reg;
5528+
5529+
if (reg1->idx != EXTRA_REG_NONE)
5530+
wrmsrl(reg1->reg, reg1->config);
5531+
5532+
wrmsrl(hwc->config_base, hwc->config);
5533+
}
5534+
5535+
static void spr_uncore_msr_disable_event(struct intel_uncore_box *box,
5536+
struct perf_event *event)
5537+
{
5538+
struct hw_perf_event *hwc = &event->hw;
5539+
struct hw_perf_event_extra *reg1 = &hwc->extra_reg;
5540+
5541+
if (reg1->idx != EXTRA_REG_NONE)
5542+
wrmsrl(reg1->reg, 0);
5543+
5544+
wrmsrl(hwc->config_base, 0);
5545+
}
5546+
5547+
static int spr_cha_hw_config(struct intel_uncore_box *box, struct perf_event *event)
5548+
{
5549+
struct hw_perf_event_extra *reg1 = &event->hw.extra_reg;
5550+
bool tie_en = !!(event->hw.config & SPR_CHA_PMON_CTL_TID_EN);
5551+
struct intel_uncore_type *type = box->pmu->type;
5552+
5553+
if (tie_en) {
5554+
reg1->reg = SPR_C0_MSR_PMON_BOX_FILTER0 +
5555+
HSWEP_CBO_MSR_OFFSET * type->box_ids[box->pmu->pmu_idx];
5556+
reg1->config = event->attr.config1 & SPR_CHA_PMON_BOX_FILTER_TID;
5557+
reg1->idx = 0;
5558+
}
5559+
5560+
return 0;
5561+
}
5562+
5563+
static struct intel_uncore_ops spr_uncore_chabox_ops = {
5564+
.init_box = intel_generic_uncore_msr_init_box,
5565+
.disable_box = intel_generic_uncore_msr_disable_box,
5566+
.enable_box = intel_generic_uncore_msr_enable_box,
5567+
.disable_event = spr_uncore_msr_disable_event,
5568+
.enable_event = spr_uncore_msr_enable_event,
5569+
.read_counter = uncore_msr_read_counter,
5570+
.hw_config = spr_cha_hw_config,
5571+
.get_constraint = uncore_get_constraint,
5572+
.put_constraint = uncore_put_constraint,
5573+
};
5574+
5575+
static struct attribute *spr_uncore_cha_formats_attr[] = {
5576+
&format_attr_event.attr,
5577+
&format_attr_umask_ext4.attr,
5578+
&format_attr_tid_en2.attr,
5579+
&format_attr_edge.attr,
5580+
&format_attr_inv.attr,
5581+
&format_attr_thresh8.attr,
5582+
&format_attr_filter_tid5.attr,
5583+
NULL,
5584+
};
5585+
static const struct attribute_group spr_uncore_chabox_format_group = {
5586+
.name = "format",
5587+
.attrs = spr_uncore_cha_formats_attr,
5588+
};
5589+
5590+
static struct intel_uncore_type spr_uncore_chabox = {
5591+
.name = "cha",
5592+
.event_mask = SPR_CHA_PMON_EVENT_MASK,
5593+
.event_mask_ext = SPR_RAW_EVENT_MASK_EXT,
5594+
.num_shared_regs = 1,
5595+
.ops = &spr_uncore_chabox_ops,
5596+
.format_group = &spr_uncore_chabox_format_group,
5597+
};
5598+
55115599
#define UNCORE_SPR_NUM_UNCORE_TYPES 12
55125600

55135601
static struct intel_uncore_type *spr_uncores[UNCORE_SPR_NUM_UNCORE_TYPES] = {
5514-
NULL,
5602+
&spr_uncore_chabox,
55155603
NULL,
55165604
NULL,
55175605
NULL,

0 commit comments

Comments
 (0)