Commit 72dd74d2 authored by Kan Liang's avatar Kan Liang Committed by Yunying Sun
Browse files

perf/x86/intel/uncore: Support HBM and CXL PMON counters

mainline inclusion
from mainline-v6.11-rc1
commit f8a86a9bb5f7e65d8c4405052de062639a8783bb
category: feature
bugzilla: https://gitee.com/openeuler/intel-kernel/issues/IAGJQ7
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f8a86a9bb5f7e65d8c4405052de062639a8783bb



-------------------------------------

Unknown uncore PMON types can be found in both SPR and EMR with HBM or
CXL.

 $ls /sys/devices/ | grep type
 uncore_type_12_16
 uncore_type_12_18
 uncore_type_12_2
 uncore_type_12_4
 uncore_type_12_6
 uncore_type_12_8
 uncore_type_13_17
 uncore_type_13_19
 uncore_type_13_3
 uncore_type_13_5
 uncore_type_13_7
 uncore_type_13_9

The unknown PMON types are HBM and CXL PMON. Except for the name, the
other information regarding the HBM and CXL PMON counters can be
retrieved via the discovery table. Add them into the uncores tables for
SPR and EMR.

The event config registers for all CXL related units are 8-byte apart.
Add SPR_UNCORE_MMIO_OFFS8_COMMON_FORMAT to specially handle it.

Intel-SIG: commit f8a86a9bb5f7 perf/x86/intel/uncore: Support HBM and CXL PMON counters
Backport SPR/EMR CXL and HBM perfmon support to kernel v5.10

Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: default avatarYunying Sun <yunying.sun@intel.com>
Link: https://lore.kernel.org/r/20240614134631.1092359-9-kan.liang@linux.intel.com


Signed-off-by: default avatarYunying Sun <yunying.sun@intel.com>
parent 52f6907d
Loading
Loading
Loading
Loading
+53 −2
Original line number Diff line number Diff line
@@ -5632,7 +5632,55 @@ static struct intel_uncore_type spr_uncore_mdf = {
	.name			= "mdf",
};

#define UNCORE_SPR_NUM_UNCORE_TYPES		12
static void spr_uncore_mmio_offs8_init_box(struct intel_uncore_box *box)
{
	__set_bit(UNCORE_BOX_FLAG_CTL_OFFS8, &box->flags);
	intel_generic_uncore_mmio_init_box(box);
}

static struct intel_uncore_ops spr_uncore_mmio_offs8_ops = {
	.init_box		= spr_uncore_mmio_offs8_init_box,
	.exit_box		= uncore_mmio_exit_box,
	.disable_box		= intel_generic_uncore_mmio_disable_box,
	.enable_box		= intel_generic_uncore_mmio_enable_box,
	.disable_event		= intel_generic_uncore_mmio_disable_event,
	.enable_event		= spr_uncore_mmio_enable_event,
	.read_counter		= uncore_mmio_read_counter,
};

#define SPR_UNCORE_MMIO_OFFS8_COMMON_FORMAT()			\
	SPR_UNCORE_COMMON_FORMAT(),				\
	.ops			= &spr_uncore_mmio_offs8_ops

static struct event_constraint spr_uncore_cxlcm_constraints[] = {
	UNCORE_EVENT_CONSTRAINT(0x02, 0x0f),
	UNCORE_EVENT_CONSTRAINT(0x05, 0x0f),
	UNCORE_EVENT_CONSTRAINT(0x40, 0xf0),
	UNCORE_EVENT_CONSTRAINT(0x41, 0xf0),
	UNCORE_EVENT_CONSTRAINT(0x42, 0xf0),
	UNCORE_EVENT_CONSTRAINT(0x43, 0xf0),
	UNCORE_EVENT_CONSTRAINT(0x4b, 0xf0),
	UNCORE_EVENT_CONSTRAINT(0x52, 0xf0),
	EVENT_CONSTRAINT_END
};

static struct intel_uncore_type spr_uncore_cxlcm = {
	SPR_UNCORE_MMIO_OFFS8_COMMON_FORMAT(),
	.name			= "cxlcm",
	.constraints		= spr_uncore_cxlcm_constraints,
};

static struct intel_uncore_type spr_uncore_cxldp = {
	SPR_UNCORE_MMIO_OFFS8_COMMON_FORMAT(),
	.name			= "cxldp",
};

static struct intel_uncore_type spr_uncore_hbm = {
	SPR_UNCORE_COMMON_FORMAT(),
	.name			= "hbm",
};

#define UNCORE_SPR_NUM_UNCORE_TYPES		15
#define UNCORE_SPR_CHA				0
#define UNCORE_SPR_IIO				1
#define UNCORE_SPR_IMC				6
@@ -5656,6 +5704,9 @@ static struct intel_uncore_type *spr_uncores[UNCORE_SPR_NUM_UNCORE_TYPES] = {
	NULL,
	NULL,
	&spr_uncore_mdf,
	&spr_uncore_cxlcm,
	&spr_uncore_cxldp,
	&spr_uncore_hbm,
};

/*
@@ -6112,7 +6163,7 @@ static struct intel_uncore_type gnr_uncore_b2cmi = {
};

static struct intel_uncore_type gnr_uncore_b2cxl = {
	SPR_UNCORE_MMIO_COMMON_FORMAT(),
	SPR_UNCORE_MMIO_OFFS8_COMMON_FORMAT(),
	.name			= "b2cxl",
};