Skip to content

Commit 68ce4a0

Browse files
kliang2Ingo Molnar
authored andcommitted
perf/x86/intel/uncore: Remove hard-coded implementation for Node ID mapping location
The method to build PCI bus to socket mapping is similar among platforms. However, the PCI location which stores Node ID mapping could vary between different platforms. For example, the Node ID mapping address on Skylake server is different from the previous platform. Also, to build the mapping for the PCI bus without UBOX, it has to start from bus 0 on Skylake server. This patch removes the current hardcoded implementation and adds three parameters for snbep_pci2phy_map_init(). This way the Node ID mapping address and bus searching direction can be configured according to different platforms. Signed-off-by: Kan Liang <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Nilay Vaish <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vince Weaver <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 2cc5384 commit 68ce4a0

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

arch/x86/events/intel/uncore_snbep.c

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
/* SandyBridge-EP/IvyTown uncore support */
22
#include "uncore.h"
33

4+
/* SNB-EP pci bus to socket mapping */
5+
#define SNBEP_CPUNODEID 0x40
6+
#define SNBEP_GIDNIDMAP 0x54
7+
48
/* SNB-EP Box level control */
59
#define SNBEP_PMON_BOX_CTL_RST_CTRL (1 << 0)
610
#define SNBEP_PMON_BOX_CTL_RST_CTRS (1 << 1)
@@ -1153,7 +1157,7 @@ static struct pci_driver snbep_uncore_pci_driver = {
11531157
/*
11541158
* build pci bus to socket mapping
11551159
*/
1156-
static int snbep_pci2phy_map_init(int devid)
1160+
static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool reverse)
11571161
{
11581162
struct pci_dev *ubox_dev = NULL;
11591163
int i, bus, nodeid, segment;
@@ -1168,12 +1172,12 @@ static int snbep_pci2phy_map_init(int devid)
11681172
break;
11691173
bus = ubox_dev->bus->number;
11701174
/* get the Node ID of the local register */
1171-
err = pci_read_config_dword(ubox_dev, 0x40, &config);
1175+
err = pci_read_config_dword(ubox_dev, nodeid_loc, &config);
11721176
if (err)
11731177
break;
11741178
nodeid = config;
11751179
/* get the Node ID mapping */
1176-
err = pci_read_config_dword(ubox_dev, 0x54, &config);
1180+
err = pci_read_config_dword(ubox_dev, idmap_loc, &config);
11771181
if (err)
11781182
break;
11791183

@@ -1207,11 +1211,20 @@ static int snbep_pci2phy_map_init(int devid)
12071211
raw_spin_lock(&pci2phy_map_lock);
12081212
list_for_each_entry(map, &pci2phy_map_head, list) {
12091213
i = -1;
1210-
for (bus = 255; bus >= 0; bus--) {
1211-
if (map->pbus_to_physid[bus] >= 0)
1212-
i = map->pbus_to_physid[bus];
1213-
else
1214-
map->pbus_to_physid[bus] = i;
1214+
if (reverse) {
1215+
for (bus = 255; bus >= 0; bus--) {
1216+
if (map->pbus_to_physid[bus] >= 0)
1217+
i = map->pbus_to_physid[bus];
1218+
else
1219+
map->pbus_to_physid[bus] = i;
1220+
}
1221+
} else {
1222+
for (bus = 0; bus <= 255; bus++) {
1223+
if (map->pbus_to_physid[bus] >= 0)
1224+
i = map->pbus_to_physid[bus];
1225+
else
1226+
map->pbus_to_physid[bus] = i;
1227+
}
12151228
}
12161229
}
12171230
raw_spin_unlock(&pci2phy_map_lock);
@@ -1224,7 +1237,7 @@ static int snbep_pci2phy_map_init(int devid)
12241237

12251238
int snbep_uncore_pci_init(void)
12261239
{
1227-
int ret = snbep_pci2phy_map_init(0x3ce0);
1240+
int ret = snbep_pci2phy_map_init(0x3ce0, SNBEP_CPUNODEID, SNBEP_GIDNIDMAP, true);
12281241
if (ret)
12291242
return ret;
12301243
uncore_pci_uncores = snbep_pci_uncores;
@@ -1788,7 +1801,7 @@ static struct pci_driver ivbep_uncore_pci_driver = {
17881801

17891802
int ivbep_uncore_pci_init(void)
17901803
{
1791-
int ret = snbep_pci2phy_map_init(0x0e1e);
1804+
int ret = snbep_pci2phy_map_init(0x0e1e, SNBEP_CPUNODEID, SNBEP_GIDNIDMAP, true);
17921805
if (ret)
17931806
return ret;
17941807
uncore_pci_uncores = ivbep_pci_uncores;
@@ -2897,7 +2910,7 @@ static struct pci_driver hswep_uncore_pci_driver = {
28972910

28982911
int hswep_uncore_pci_init(void)
28992912
{
2900-
int ret = snbep_pci2phy_map_init(0x2f1e);
2913+
int ret = snbep_pci2phy_map_init(0x2f1e, SNBEP_CPUNODEID, SNBEP_GIDNIDMAP, true);
29012914
if (ret)
29022915
return ret;
29032916
uncore_pci_uncores = hswep_pci_uncores;
@@ -3186,7 +3199,7 @@ static struct pci_driver bdx_uncore_pci_driver = {
31863199

31873200
int bdx_uncore_pci_init(void)
31883201
{
3189-
int ret = snbep_pci2phy_map_init(0x6f1e);
3202+
int ret = snbep_pci2phy_map_init(0x6f1e, SNBEP_CPUNODEID, SNBEP_GIDNIDMAP, true);
31903203

31913204
if (ret)
31923205
return ret;

0 commit comments

Comments
 (0)