Skip to content

Commit c4aebdb

Browse files
Alexander AntonovPeter Zijlstra
authored andcommitted
perf/x86/intel/uncore: Get UPI NodeID and GroupID
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> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Kan Liang <kan.liang@linux.intel.com> Link: https://lore.kernel.org/r/20221117122833.3103580-8-alexander.antonov@linux.intel.com
1 parent 4cfce57 commit c4aebdb

1 file changed

Lines changed: 25 additions & 8 deletions

File tree

arch/x86/events/intel/uncore_snbep.c

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,28 @@ static struct pci_driver snbep_uncore_pci_driver = {
13721372

13731373
#define NODE_ID_MASK 0x7
13741374

1375+
/* Each three bits from 0 to 23 of GIDNIDMAP register correspond Node ID. */
1376+
#define GIDNIDMAP(config, id) (((config) >> (3 * (id))) & 0x7)
1377+
1378+
static int upi_nodeid_groupid(struct pci_dev *ubox_dev, int nodeid_loc, int idmap_loc,
1379+
int *nodeid, int *groupid)
1380+
{
1381+
int ret;
1382+
1383+
/* get the Node ID of the local register */
1384+
ret = pci_read_config_dword(ubox_dev, nodeid_loc, nodeid);
1385+
if (ret)
1386+
goto err;
1387+
1388+
*nodeid = *nodeid & NODE_ID_MASK;
1389+
/* get the Node ID mapping */
1390+
ret = pci_read_config_dword(ubox_dev, idmap_loc, groupid);
1391+
if (ret)
1392+
goto err;
1393+
err:
1394+
return ret;
1395+
}
1396+
13751397
/*
13761398
* build pci bus to socket mapping
13771399
*/
@@ -1397,13 +1419,8 @@ static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool
13971419
* the topology.
13981420
*/
13991421
if (nr_node_ids <= 8) {
1400-
/* get the Node ID of the local register */
1401-
err = pci_read_config_dword(ubox_dev, nodeid_loc, &config);
1402-
if (err)
1403-
break;
1404-
nodeid = config & NODE_ID_MASK;
1405-
/* get the Node ID mapping */
1406-
err = pci_read_config_dword(ubox_dev, idmap_loc, &config);
1422+
err = upi_nodeid_groupid(ubox_dev, nodeid_loc, idmap_loc,
1423+
&nodeid, &config);
14071424
if (err)
14081425
break;
14091426

@@ -1421,7 +1438,7 @@ static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool
14211438
* to a particular node.
14221439
*/
14231440
for (i = 0; i < 8; i++) {
1424-
if (nodeid == ((config >> (3 * i)) & 0x7)) {
1441+
if (nodeid == GIDNIDMAP(config, i)) {
14251442
if (topology_max_die_per_package() > 1)
14261443
die_id = i;
14271444
else

0 commit comments

Comments
 (0)