All of lore.kernel.org
 help / color / mirror / Atom feed
From: alexander.antonov@linux.intel.com
To: peterz@infradead.org, linux-kernel@vger.kernel.org
Cc: kan.liang@linux.intel.com, alexey.v.bayduraev@linux.intel.com,
	alexander.antonov@linux.intel.com
Subject: [PATCH 08/11] perf/x86/intel/uncore: Enable UPI topology discovery for Icelake Server
Date: Thu, 17 Nov 2022 12:28:30 +0000	[thread overview]
Message-ID: <20221117122833.3103580-9-alexander.antonov@linux.intel.com> (raw)
In-Reply-To: <20221117122833.3103580-1-alexander.antonov@linux.intel.com>

From: Alexander Antonov <alexander.antonov@linux.intel.com>

UPI topology discovery relies on data from KTILP0 (offset 0x94) and
KTIPCSTS (offset 0x120) as well as on SKX but on Icelake Server these
registers reside under UBOX (Device ID 0x3450) bus.

This patch enables /sys/devices/uncore_upi_*/die* attributes on Icelake
Server.

Signed-off-by: Alexander Antonov <alexander.antonov@linux.intel.com>
Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
---
 arch/x86/events/intel/uncore_snbep.c | 75 ++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)

diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c
index 6da5f692afea..d45f5843444d 100644
--- a/arch/x86/events/intel/uncore_snbep.c
+++ b/arch/x86/events/intel/uncore_snbep.c
@@ -445,6 +445,7 @@
 #define ICX_UPI_PCI_PMON_CTR0			0x320
 #define ICX_UPI_PCI_PMON_BOX_CTL		0x318
 #define ICX_UPI_CTL_UMASK_EXT			0xffffff
+#define ICX_UBOX_DID				0x3450
 
 /* ICX M3UPI*/
 #define ICX_M3UPI_PCI_PMON_CTL0			0xd8
@@ -5594,6 +5595,76 @@ static const struct attribute_group icx_upi_uncore_format_group = {
 	.attrs = icx_upi_uncore_formats_attr,
 };
 
+#define ICX_UPI_REGS_ADDR_DEVICE_LINK0	0x02
+#define ICX_UPI_REGS_ADDR_FUNCTION	0x01
+
+static int discover_upi_topology(struct intel_uncore_type *type, int ubox_did, int dev_link0)
+{
+	struct pci_dev *ubox = NULL;
+	struct pci_dev *dev = NULL;
+	u32 nid, gid;
+	int i, idx, ret = -EPERM;
+	struct intel_uncore_topology *upi;
+	unsigned int devfn;
+
+	/* GIDNIDMAP method supports machines which have less than 8 sockets. */
+	if (uncore_max_dies() > 8)
+		goto err;
+
+	while ((ubox = pci_get_device(PCI_VENDOR_ID_INTEL, ubox_did, ubox))) {
+		ret = upi_nodeid_groupid(ubox, SKX_CPUNODEID, SKX_GIDNIDMAP, &nid, &gid);
+		if (ret) {
+			ret = pcibios_err_to_errno(ret);
+			break;
+		}
+
+		for (i = 0; i < 8; i++) {
+			if (nid != GIDNIDMAP(gid, i))
+				continue;
+			for (idx = 0; idx < type->num_boxes; idx++) {
+				upi = &type->topology[nid][idx];
+				devfn = PCI_DEVFN(dev_link0 + idx, ICX_UPI_REGS_ADDR_FUNCTION);
+				dev = pci_get_domain_bus_and_slot(pci_domain_nr(ubox->bus),
+								  ubox->bus->number,
+								  devfn);
+				if (dev) {
+					ret = upi_fill_topology(dev, upi, idx);
+					if (ret)
+						goto err;
+				}
+			}
+		}
+	}
+err:
+	pci_dev_put(ubox);
+	pci_dev_put(dev);
+	return ret;
+}
+
+static int icx_upi_get_topology(struct intel_uncore_type *type)
+{
+	return discover_upi_topology(type, ICX_UBOX_DID, ICX_UPI_REGS_ADDR_DEVICE_LINK0);
+}
+
+static struct attribute_group icx_upi_mapping_group = {
+	.is_visible	= skx_upi_mapping_visible,
+};
+
+static const struct attribute_group *icx_upi_attr_update[] = {
+	&icx_upi_mapping_group,
+	NULL
+};
+
+static int icx_upi_set_mapping(struct intel_uncore_type *type)
+{
+	return pmu_upi_set_mapping(type, &icx_upi_mapping_group);
+}
+
+static void icx_upi_cleanup_mapping(struct intel_uncore_type *type)
+{
+	pmu_cleanup_mapping(type, &icx_upi_mapping_group);
+}
+
 static struct intel_uncore_type icx_uncore_upi = {
 	.name		= "upi",
 	.num_counters   = 4,
@@ -5606,6 +5677,10 @@ static struct intel_uncore_type icx_uncore_upi = {
 	.box_ctl	= ICX_UPI_PCI_PMON_BOX_CTL,
 	.ops		= &skx_upi_uncore_pci_ops,
 	.format_group	= &icx_upi_uncore_format_group,
+	.attr_update	= icx_upi_attr_update,
+	.get_topology	= icx_upi_get_topology,
+	.set_mapping	= icx_upi_set_mapping,
+	.cleanup_mapping = icx_upi_cleanup_mapping,
 };
 
 static struct event_constraint icx_uncore_m3upi_constraints[] = {
-- 
2.25.1


  parent reply	other threads:[~2022-11-17 12:30 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-17 12:28 [PATCH 00/11] UPI topology discovery for SKX/ICX/SPR alexander.antonov
2022-11-17 12:28 ` [PATCH 01/11] perf/x86/intel/uncore: Generalize IIO topology support alexander.antonov
2022-11-24 12:03   ` [tip: perf/core] " tip-bot2 for Alexander Antonov
2022-11-17 12:28 ` [PATCH 02/11] perf/x86/intel/uncore: Introduce UPI topology type alexander.antonov
2022-11-24 12:03   ` [tip: perf/core] " tip-bot2 for Alexander Antonov
2022-11-17 12:28 ` [PATCH 03/11] perf/x86/intel/uncore: Clear attr_update properly alexander.antonov
2022-11-24 12:02   ` [tip: perf/core] " tip-bot2 for Alexander Antonov
2022-11-17 12:28 ` [PATCH 04/11] perf/x86/intel/uncore: Disable I/O stacks to PMU mapping on ICX-D alexander.antonov
2022-11-24 12:02   ` [tip: perf/core] " tip-bot2 for Alexander Antonov
2022-11-17 12:28 ` [PATCH 05/11] perf/x86/intel/uncore: Generalize get_topology() for SKX PMUs alexander.antonov
2022-11-24 12:02   ` [tip: perf/core] " tip-bot2 for Alexander Antonov
2022-11-17 12:28 ` [PATCH 06/11] perf/x86/intel/uncore: Enable UPI topology discovery for Skylake Server alexander.antonov
2022-11-24 12:02   ` [tip: perf/core] " tip-bot2 for Alexander Antonov
2022-11-17 12:28 ` [PATCH 07/11] perf/x86/intel/uncore: Get UPI NodeID and GroupID alexander.antonov
2022-11-24 12:02   ` [tip: perf/core] " tip-bot2 for Alexander Antonov
2022-11-17 12:28 ` alexander.antonov [this message]
2022-11-24 12:02   ` [tip: perf/core] perf/x86/intel/uncore: Enable UPI topology discovery for Icelake Server tip-bot2 for Alexander Antonov
2022-11-17 12:28 ` [PATCH 09/11] perf/x86/intel/uncore: Enable UPI topology discovery for Sapphire Rapids alexander.antonov
2022-11-24 12:02   ` [tip: perf/core] " tip-bot2 for Alexander Antonov
2022-11-17 12:28 ` [PATCH 10/11] perf/x86/intel/uncore: Update sysfs-devices-mapping file alexander.antonov
2022-11-24 12:02   ` [tip: perf/core] " tip-bot2 for Alexander Antonov
2022-11-17 12:28 ` [PATCH 11/11] perf/x86/intel/uncore: Make set_mapping() procedure void alexander.antonov
2022-11-24 12:02   ` [tip: perf/core] " tip-bot2 for Alexander Antonov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221117122833.3103580-9-alexander.antonov@linux.intel.com \
    --to=alexander.antonov@linux.intel.com \
    --cc=alexey.v.bayduraev@linux.intel.com \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.