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 07/11] perf/x86/intel/uncore: Get UPI NodeID and GroupID
Date: Thu, 17 Nov 2022 12:28:29 +0000	[thread overview]
Message-ID: <20221117122833.3103580-8-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>

The GIDNIDMAP register of UBOX device is used to get the topology
information in the snbep_pci2phy_map_init(). The same approach will be
used to discover UPI topology for ICX and SPR platforms.

Move common code that will be reused in next patches.

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 | 33 +++++++++++++++++++++-------
 1 file changed, 25 insertions(+), 8 deletions(-)

diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c
index f682a9a0f562..6da5f692afea 100644
--- a/arch/x86/events/intel/uncore_snbep.c
+++ b/arch/x86/events/intel/uncore_snbep.c
@@ -1372,6 +1372,28 @@ static struct pci_driver snbep_uncore_pci_driver = {
 
 #define NODE_ID_MASK	0x7
 
+/* Each three bits from 0 to 23 of GIDNIDMAP register correspond Node ID. */
+#define GIDNIDMAP(config, id)	(((config) >> (3 * (id))) & 0x7)
+
+static int upi_nodeid_groupid(struct pci_dev *ubox_dev, int nodeid_loc, int idmap_loc,
+			      int *nodeid, int *groupid)
+{
+	int ret;
+
+	/* get the Node ID of the local register */
+	ret = pci_read_config_dword(ubox_dev, nodeid_loc, nodeid);
+	if (ret)
+		goto err;
+
+	*nodeid = *nodeid & NODE_ID_MASK;
+	/* get the Node ID mapping */
+	ret = pci_read_config_dword(ubox_dev, idmap_loc, groupid);
+	if (ret)
+		goto err;
+err:
+	return ret;
+}
+
 /*
  * build pci bus to socket mapping
  */
@@ -1397,13 +1419,8 @@ static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool
 		 * the topology.
 		 */
 		if (nr_node_ids <= 8) {
-			/* get the Node ID of the local register */
-			err = pci_read_config_dword(ubox_dev, nodeid_loc, &config);
-			if (err)
-				break;
-			nodeid = config & NODE_ID_MASK;
-			/* get the Node ID mapping */
-			err = pci_read_config_dword(ubox_dev, idmap_loc, &config);
+			err = upi_nodeid_groupid(ubox_dev, nodeid_loc, idmap_loc,
+						 &nodeid, &config);
 			if (err)
 				break;
 
@@ -1421,7 +1438,7 @@ static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool
 			 * to a particular node.
 			 */
 			for (i = 0; i < 8; i++) {
-				if (nodeid == ((config >> (3 * i)) & 0x7)) {
+				if (nodeid == GIDNIDMAP(config, i)) {
 					if (topology_max_die_per_package() > 1)
 						die_id = i;
 					else
-- 
2.25.1


  parent reply	other threads:[~2022-11-17 12:29 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 ` alexander.antonov [this message]
2022-11-24 12:02   ` [tip: perf/core] perf/x86/intel/uncore: Get UPI NodeID and GroupID tip-bot2 for Alexander Antonov
2022-11-17 12:28 ` [PATCH 08/11] perf/x86/intel/uncore: Enable UPI topology discovery for Icelake Server alexander.antonov
2022-11-24 12:02   ` [tip: perf/core] " 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-8-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.