Skip to content

Commit 320b065

Browse files
Kan LiangIngo Molnar
authored andcommitted
perf/x86/intel/uncore: Fix multi-domain PCI CHA enumeration bug on Skylake servers
The number of CHAs is miscalculated on multi-domain PCI Skylake server systems, resulting in an uncore driver initialization error. Gary Kroening explains: "For systems with a single PCI segment, it is sufficient to look for the bus number to change in order to determine that all of the CHa's have been counted for a single socket. However, for multi PCI segment systems, each socket is given a new segment and the bus number does NOT change. So looking only for the bus number to change ends up counting all of the CHa's on all sockets in the system. This leads to writing CPU MSRs beyond a valid range and causes an error in ivbep_uncore_msr_init_box()." To fix this bug, query the number of CHAs from the CAPID6 register: it should read bits 27:0 in the CAPID6 register located at Device 30, Function 3, Offset 0x9C. These 28 bits form a bit vector of available LLC slices and the CHAs that manage those slices. Reported-by: Kroening, Gary <[email protected]> Tested-by: Kroening, Gary <[email protected]> Signed-off-by: Kan Liang <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Andy Shevchenko <[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]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Fixes: cd34cd9 ("perf/x86/intel/uncore: Add Skylake server uncore support") Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 174afc3 commit 320b065

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

arch/x86/events/intel/uncore_snbep.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3563,24 +3563,27 @@ static struct intel_uncore_type *skx_msr_uncores[] = {
35633563
NULL,
35643564
};
35653565

3566+
/*
3567+
* To determine the number of CHAs, it should read bits 27:0 in the CAPID6
3568+
* register which located at Device 30, Function 3, Offset 0x9C. PCI ID 0x2083.
3569+
*/
3570+
#define SKX_CAPID6 0x9c
3571+
#define SKX_CHA_BIT_MASK GENMASK(27, 0)
3572+
35663573
static int skx_count_chabox(void)
35673574
{
3568-
struct pci_dev *chabox_dev = NULL;
3569-
int bus, count = 0;
3575+
struct pci_dev *dev = NULL;
3576+
u32 val = 0;
35703577

3571-
while (1) {
3572-
chabox_dev = pci_get_device(PCI_VENDOR_ID_INTEL, 0x208d, chabox_dev);
3573-
if (!chabox_dev)
3574-
break;
3575-
if (count == 0)
3576-
bus = chabox_dev->bus->number;
3577-
if (bus != chabox_dev->bus->number)
3578-
break;
3579-
count++;
3580-
}
3578+
dev = pci_get_device(PCI_VENDOR_ID_INTEL, 0x2083, dev);
3579+
if (!dev)
3580+
goto out;
35813581

3582-
pci_dev_put(chabox_dev);
3583-
return count;
3582+
pci_read_config_dword(dev, SKX_CAPID6, &val);
3583+
val &= SKX_CHA_BIT_MASK;
3584+
out:
3585+
pci_dev_put(dev);
3586+
return hweight32(val);
35843587
}
35853588

35863589
void skx_uncore_cpu_init(void)

0 commit comments

Comments
 (0)