Skip to content

Commit 85f2e30

Browse files
Kan LiangPeter Zijlstra
authored andcommitted
perf/x86/intel/uncore: Add Sapphire Rapids server IMC support
The Sapphire Rapids IMC provides the interface to the DRAM and communicates to the rest of the uncore through the M2M block. The layout of the control registers for a IMC uncore unit is a little bit different from the generic one. There is a fixed counter for IMC. So a specific format and ops are required. Expose the common MMIO 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 0654dfd commit 85f2e30

File tree

3 files changed

+45
-6
lines changed

3 files changed

+45
-6
lines changed

arch/x86/events/intel/uncore_discovery.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ static unsigned int generic_uncore_mmio_box_ctl(struct intel_uncore_box *box)
454454
return type->box_ctls[box->dieid] + type->mmio_offsets[box->pmu->pmu_idx];
455455
}
456456

457-
static void intel_generic_uncore_mmio_init_box(struct intel_uncore_box *box)
457+
void intel_generic_uncore_mmio_init_box(struct intel_uncore_box *box)
458458
{
459459
unsigned int box_ctl = generic_uncore_mmio_box_ctl(box);
460460
struct intel_uncore_type *type = box->pmu->type;
@@ -478,15 +478,15 @@ static void intel_generic_uncore_mmio_init_box(struct intel_uncore_box *box)
478478
writel(GENERIC_PMON_BOX_CTL_INT, box->io_addr);
479479
}
480480

481-
static void intel_generic_uncore_mmio_disable_box(struct intel_uncore_box *box)
481+
void intel_generic_uncore_mmio_disable_box(struct intel_uncore_box *box)
482482
{
483483
if (!box->io_addr)
484484
return;
485485

486486
writel(GENERIC_PMON_BOX_CTL_FRZ, box->io_addr);
487487
}
488488

489-
static void intel_generic_uncore_mmio_enable_box(struct intel_uncore_box *box)
489+
void intel_generic_uncore_mmio_enable_box(struct intel_uncore_box *box)
490490
{
491491
if (!box->io_addr)
492492
return;
@@ -505,8 +505,8 @@ static void intel_generic_uncore_mmio_enable_event(struct intel_uncore_box *box,
505505
writel(hwc->config, box->io_addr + hwc->config_base);
506506
}
507507

508-
static void intel_generic_uncore_mmio_disable_event(struct intel_uncore_box *box,
509-
struct perf_event *event)
508+
void intel_generic_uncore_mmio_disable_event(struct intel_uncore_box *box,
509+
struct perf_event *event)
510510
{
511511
struct hw_perf_event *hwc = &event->hw;
512512

arch/x86/events/intel/uncore_discovery.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,11 @@ void intel_generic_uncore_msr_init_box(struct intel_uncore_box *box);
134134
void intel_generic_uncore_msr_disable_box(struct intel_uncore_box *box);
135135
void intel_generic_uncore_msr_enable_box(struct intel_uncore_box *box);
136136

137+
void intel_generic_uncore_mmio_init_box(struct intel_uncore_box *box);
138+
void intel_generic_uncore_mmio_disable_box(struct intel_uncore_box *box);
139+
void intel_generic_uncore_mmio_enable_box(struct intel_uncore_box *box);
140+
void intel_generic_uncore_mmio_disable_event(struct intel_uncore_box *box,
141+
struct perf_event *event);
142+
137143
struct intel_uncore_type **
138144
intel_uncore_generic_init_uncores(enum uncore_access_type type_id);

arch/x86/events/intel/uncore_snbep.c

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5637,6 +5637,39 @@ static struct intel_uncore_type spr_uncore_pcu = {
56375637
.name = "pcu",
56385638
};
56395639

5640+
static void spr_uncore_mmio_enable_event(struct intel_uncore_box *box,
5641+
struct perf_event *event)
5642+
{
5643+
struct hw_perf_event *hwc = &event->hw;
5644+
5645+
if (!box->io_addr)
5646+
return;
5647+
5648+
if (uncore_pmc_fixed(hwc->idx))
5649+
writel(SNBEP_PMON_CTL_EN, box->io_addr + hwc->config_base);
5650+
else
5651+
writel(hwc->config, box->io_addr + hwc->config_base);
5652+
}
5653+
5654+
static struct intel_uncore_ops spr_uncore_mmio_ops = {
5655+
.init_box = intel_generic_uncore_mmio_init_box,
5656+
.exit_box = uncore_mmio_exit_box,
5657+
.disable_box = intel_generic_uncore_mmio_disable_box,
5658+
.enable_box = intel_generic_uncore_mmio_enable_box,
5659+
.disable_event = intel_generic_uncore_mmio_disable_event,
5660+
.enable_event = spr_uncore_mmio_enable_event,
5661+
.read_counter = uncore_mmio_read_counter,
5662+
};
5663+
5664+
static struct intel_uncore_type spr_uncore_imc = {
5665+
SPR_UNCORE_COMMON_FORMAT(),
5666+
.name = "imc",
5667+
.fixed_ctr_bits = 48,
5668+
.fixed_ctr = SNR_IMC_MMIO_PMON_FIXED_CTR,
5669+
.fixed_ctl = SNR_IMC_MMIO_PMON_FIXED_CTL,
5670+
.ops = &spr_uncore_mmio_ops,
5671+
};
5672+
56405673
#define UNCORE_SPR_NUM_UNCORE_TYPES 12
56415674

56425675
static struct intel_uncore_type *spr_uncores[UNCORE_SPR_NUM_UNCORE_TYPES] = {
@@ -5646,7 +5679,7 @@ static struct intel_uncore_type *spr_uncores[UNCORE_SPR_NUM_UNCORE_TYPES] = {
56465679
&spr_uncore_m2pcie,
56475680
&spr_uncore_pcu,
56485681
NULL,
5649-
NULL,
5682+
&spr_uncore_imc,
56505683
NULL,
56515684
NULL,
56525685
NULL,

0 commit comments

Comments
 (0)