Skip to content

Commit f57191e

Browse files
Kan LiangPeter Zijlstra
authored andcommitted
perf/x86/intel/uncore: Add Sapphire Rapids server M2M support
The M2M blocks manage the interface between the mesh (operating on both the mesh and the SMI3 protocol) and the memory controllers. The layout of the control registers for a M2M uncore unit is a little bit different from the generic one. So a specific format and ops are required. Expose the common PCI 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 85f2e30 commit f57191e

File tree

3 files changed

+44
-8
lines changed

3 files changed

+44
-8
lines changed

arch/x86/events/intel/uncore_discovery.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ static struct intel_uncore_ops generic_uncore_msr_ops = {
377377
.read_counter = uncore_msr_read_counter,
378378
};
379379

380-
static void intel_generic_uncore_pci_init_box(struct intel_uncore_box *box)
380+
void intel_generic_uncore_pci_init_box(struct intel_uncore_box *box)
381381
{
382382
struct pci_dev *pdev = box->pci_dev;
383383
int box_ctl = uncore_pci_box_ctl(box);
@@ -386,15 +386,15 @@ static void intel_generic_uncore_pci_init_box(struct intel_uncore_box *box)
386386
pci_write_config_dword(pdev, box_ctl, GENERIC_PMON_BOX_CTL_INT);
387387
}
388388

389-
static void intel_generic_uncore_pci_disable_box(struct intel_uncore_box *box)
389+
void intel_generic_uncore_pci_disable_box(struct intel_uncore_box *box)
390390
{
391391
struct pci_dev *pdev = box->pci_dev;
392392
int box_ctl = uncore_pci_box_ctl(box);
393393

394394
pci_write_config_dword(pdev, box_ctl, GENERIC_PMON_BOX_CTL_FRZ);
395395
}
396396

397-
static void intel_generic_uncore_pci_enable_box(struct intel_uncore_box *box)
397+
void intel_generic_uncore_pci_enable_box(struct intel_uncore_box *box)
398398
{
399399
struct pci_dev *pdev = box->pci_dev;
400400
int box_ctl = uncore_pci_box_ctl(box);
@@ -411,17 +411,17 @@ static void intel_generic_uncore_pci_enable_event(struct intel_uncore_box *box,
411411
pci_write_config_dword(pdev, hwc->config_base, hwc->config);
412412
}
413413

414-
static void intel_generic_uncore_pci_disable_event(struct intel_uncore_box *box,
415-
struct perf_event *event)
414+
void intel_generic_uncore_pci_disable_event(struct intel_uncore_box *box,
415+
struct perf_event *event)
416416
{
417417
struct pci_dev *pdev = box->pci_dev;
418418
struct hw_perf_event *hwc = &event->hw;
419419

420420
pci_write_config_dword(pdev, hwc->config_base, 0);
421421
}
422422

423-
static u64 intel_generic_uncore_pci_read_counter(struct intel_uncore_box *box,
424-
struct perf_event *event)
423+
u64 intel_generic_uncore_pci_read_counter(struct intel_uncore_box *box,
424+
struct perf_event *event)
425425
{
426426
struct pci_dev *pdev = box->pci_dev;
427427
struct hw_perf_event *hwc = &event->hw;

arch/x86/events/intel/uncore_discovery.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,13 @@ void intel_generic_uncore_mmio_enable_box(struct intel_uncore_box *box);
140140
void intel_generic_uncore_mmio_disable_event(struct intel_uncore_box *box,
141141
struct perf_event *event);
142142

143+
void intel_generic_uncore_pci_init_box(struct intel_uncore_box *box);
144+
void intel_generic_uncore_pci_disable_box(struct intel_uncore_box *box);
145+
void intel_generic_uncore_pci_enable_box(struct intel_uncore_box *box);
146+
void intel_generic_uncore_pci_disable_event(struct intel_uncore_box *box,
147+
struct perf_event *event);
148+
u64 intel_generic_uncore_pci_read_counter(struct intel_uncore_box *box,
149+
struct perf_event *event);
150+
143151
struct intel_uncore_type **
144152
intel_uncore_generic_init_uncores(enum uncore_access_type type_id);

arch/x86/events/intel/uncore_snbep.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5670,6 +5670,34 @@ static struct intel_uncore_type spr_uncore_imc = {
56705670
.ops = &spr_uncore_mmio_ops,
56715671
};
56725672

5673+
static void spr_uncore_pci_enable_event(struct intel_uncore_box *box,
5674+
struct perf_event *event)
5675+
{
5676+
struct pci_dev *pdev = box->pci_dev;
5677+
struct hw_perf_event *hwc = &event->hw;
5678+
5679+
pci_write_config_dword(pdev, hwc->config_base + 4, (u32)(hwc->config >> 32));
5680+
pci_write_config_dword(pdev, hwc->config_base, (u32)hwc->config);
5681+
}
5682+
5683+
static struct intel_uncore_ops spr_uncore_pci_ops = {
5684+
.init_box = intel_generic_uncore_pci_init_box,
5685+
.disable_box = intel_generic_uncore_pci_disable_box,
5686+
.enable_box = intel_generic_uncore_pci_enable_box,
5687+
.disable_event = intel_generic_uncore_pci_disable_event,
5688+
.enable_event = spr_uncore_pci_enable_event,
5689+
.read_counter = intel_generic_uncore_pci_read_counter,
5690+
};
5691+
5692+
#define SPR_UNCORE_PCI_COMMON_FORMAT() \
5693+
SPR_UNCORE_COMMON_FORMAT(), \
5694+
.ops = &spr_uncore_pci_ops
5695+
5696+
static struct intel_uncore_type spr_uncore_m2m = {
5697+
SPR_UNCORE_PCI_COMMON_FORMAT(),
5698+
.name = "m2m",
5699+
};
5700+
56735701
#define UNCORE_SPR_NUM_UNCORE_TYPES 12
56745702

56755703
static struct intel_uncore_type *spr_uncores[UNCORE_SPR_NUM_UNCORE_TYPES] = {
@@ -5680,7 +5708,7 @@ static struct intel_uncore_type *spr_uncores[UNCORE_SPR_NUM_UNCORE_TYPES] = {
56805708
&spr_uncore_pcu,
56815709
NULL,
56825710
&spr_uncore_imc,
5683-
NULL,
5711+
&spr_uncore_m2m,
56845712
NULL,
56855713
NULL,
56865714
NULL,

0 commit comments

Comments
 (0)