Unverified Commit 17c4a028 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!4202 Intel: Backport GNR/SRF pmu uncore support back to kernel 5.10

Merge Pull Request from: @yunyingsun 
 
Title: Backport GNR/SRF pmu uncore support back to kernel 5.10

Content:
To support perf reading uncore PMU performance events on Granite Rapids(GNR) and Sierra Forest(SRF), below upstream commits from v6.8-rc1 should be included in kernel OLK-5.10:
cb4a6ccf3583 perf/x86/intel/uncore: Support Sierra Forest and Grand Ridge
388d76175bd9 perf/x86/intel/uncore: Support IIO free-running counters on GNR
632c4bf6d007 perf/x86/intel/uncore: Support Granite Rapids
b560e0cd882b perf/x86/uncore: Use u64 to replace unsigned for the uncore offsets array
cf35791476fc perf/x86/intel/uncore: Generic uncore_get_uncores and MMIO format of SPR

The backported patches are identical with the upstream version, and has been verified on Intel internal GNR/SRF platforms.

Intel-kernel issue:
https://gitee.com/openeuler/intel-kernel/issues/I8YW2E

Test:
Before backport: on GNR/SRF with OLK-5.10 kernel, uncore devices under "/sys/devices/" are all using generic names with numbers like "uncore_type_x_y", no meaningful uncore names.

After backport: uncore devices under "/sys/devices/" are using meaningful names like "uncore_imc_0", and uncore events can be read successfully with command like "perf stat -e uncore_imc_0/event=0x1/ -- sleep 1".

Known issue:
N/A

Default config change:
N/A 
 
Link:https://gitee.com/openeuler/kernel/pulls/4202

 

Reviewed-by: default avatarAichun Shi <aichun.shi@intel.com>
Reviewed-by: default avatarJason Zeng <jason.zeng@intel.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parents 0e7e6fc7 68487d22
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -1796,6 +1796,14 @@ static const struct intel_uncore_init_fun spr_uncore_init __initconst = {
	.uncore_units_ignore = spr_uncore_units_ignore,
};

static const struct intel_uncore_init_fun gnr_uncore_init __initconst = {
	.cpu_init = gnr_uncore_cpu_init,
	.pci_init = gnr_uncore_pci_init,
	.mmio_init = gnr_uncore_mmio_init,
	.use_discovery = true,
	.uncore_units_ignore = gnr_uncore_units_ignore,
};

static const struct intel_uncore_init_fun generic_uncore_init __initconst = {
	.cpu_init = intel_uncore_generic_uncore_cpu_init,
	.pci_init = intel_uncore_generic_uncore_pci_init,
@@ -1843,8 +1851,12 @@ static const struct x86_cpu_id intel_uncore_match[] __initconst = {
	X86_MATCH_INTEL_FAM6_MODEL(RAPTORLAKE_P,	&adl_uncore_init),
	X86_MATCH_INTEL_FAM6_MODEL(SAPPHIRERAPIDS_X,	&spr_uncore_init),
	X86_MATCH_INTEL_FAM6_MODEL(EMERALDRAPIDS_X,	&spr_uncore_init),
	X86_MATCH_INTEL_FAM6_MODEL(GRANITERAPIDS_X,	&gnr_uncore_init),
	X86_MATCH_INTEL_FAM6_MODEL(GRANITERAPIDS_D,	&gnr_uncore_init),
	X86_MATCH_INTEL_FAM6_MODEL(ATOM_TREMONT_D,	&snr_uncore_init),
	X86_MATCH_INTEL_FAM6_MODEL(ATOM_GRACEMONT,	&adl_uncore_init),
	X86_MATCH_INTEL_FAM6_MODEL(ATOM_CRESTMONT_X,	&gnr_uncore_init),
	X86_MATCH_INTEL_FAM6_MODEL(ATOM_CRESTMONT,	&gnr_uncore_init),
	{},
};
MODULE_DEVICE_TABLE(x86cpu, intel_uncore_match);
+7 −3
Original line number Diff line number Diff line
@@ -70,9 +70,9 @@ struct intel_uncore_type {
	unsigned single_fixed:1;
	unsigned pair_ctr_ctl:1;
	union {
		unsigned *msr_offsets;
		unsigned *pci_offsets;
		unsigned *mmio_offsets;
		u64 *msr_offsets;
		u64 *pci_offsets;
		u64 *mmio_offsets;
	};
	unsigned *box_ids;
	struct event_constraint unconstrainted;
@@ -570,6 +570,7 @@ extern struct list_head pci2phy_map_head;
extern struct pci_extra_dev *uncore_extra_pci_dev;
extern struct event_constraint uncore_constraint_empty;
extern int spr_uncore_units_ignore[];
extern int gnr_uncore_units_ignore[];

/* uncore_snb.c */
int snb_uncore_pci_init(void);
@@ -610,6 +611,9 @@ void icx_uncore_mmio_init(void);
int spr_uncore_pci_init(void);
void spr_uncore_cpu_init(void);
void spr_uncore_mmio_init(void);
int gnr_uncore_pci_init(void);
void gnr_uncore_cpu_init(void);
void gnr_uncore_mmio_init(void);

/* uncore_nhmex.c */
void nhmex_uncore_cpu_init(void);
+3 −2
Original line number Diff line number Diff line
@@ -125,7 +125,8 @@ uncore_insert_box_info(struct uncore_unit_discovery *unit,
		       int die, bool parsed)
{
	struct intel_uncore_discovery_type *type;
	unsigned int *box_offset, *ids;
	unsigned int *ids;
	u64 *box_offset;
	int i;

	if (!unit->ctl || !unit->ctl_offset || !unit->ctr_offset) {
@@ -153,7 +154,7 @@ uncore_insert_box_info(struct uncore_unit_discovery *unit,
	if (!type)
		return;

	box_offset = kcalloc(type->num_boxes + 1, sizeof(unsigned int), GFP_KERNEL);
	box_offset = kcalloc(type->num_boxes + 1, sizeof(u64), GFP_KERNEL);
	if (!box_offset)
		return;

+1 −1
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ struct intel_uncore_discovery_type {
	u8		ctr_offset;	/* Counter 0 offset */
	u16		num_boxes;	/* number of boxes for the uncore block */
	unsigned int	*ids;		/* Box IDs */
	unsigned int	*box_offset;	/* Box offset */
	u64		*box_offset;	/* Box offset */
};

bool intel_uncore_has_discovery_tables(int *ignore);
+1 −1
Original line number Diff line number Diff line
@@ -306,7 +306,7 @@ static const struct attribute_group nhmex_uncore_cbox_format_group = {
};

/* msr offset for each instance of cbox */
static unsigned nhmex_cbox_msr_offsets[] = {
static u64 nhmex_cbox_msr_offsets[] = {
	0x0, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x240, 0x2c0,
};

Loading