Skip to content

Commit 1897336

Browse files
ZideChen0Peter Zijlstra
authored andcommitted
perf/x86/intel/uncore: Remove has_generic_discovery_table()
In the !x86_match_cpu() fallback path, has_generic_discovery_table() is removed because it does not handle multiple PCI devices. Instead, use PCI_ANY_ID in generic_uncore_init[] to probe all PCI devices. For MSR portals, only probe MSR 0x201e to keep the fallback simple, as this path is best-effort only. Signed-off-by: Zide Chen <zide.chen@intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com> Link: https://patch.msgid.link/20251231224233.113839-4-zide.chen@intel.com
1 parent e75462f commit 1897336

2 files changed

Lines changed: 12 additions & 33 deletions

File tree

arch/x86/events/intel/uncore.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1835,6 +1835,9 @@ static const struct uncore_plat_init generic_uncore_init __initconst = {
18351835
.cpu_init = intel_uncore_generic_uncore_cpu_init,
18361836
.pci_init = intel_uncore_generic_uncore_pci_init,
18371837
.mmio_init = intel_uncore_generic_uncore_mmio_init,
1838+
.domain[0].base_is_pci = true,
1839+
.domain[0].discovery_base = PCI_ANY_ID,
1840+
.domain[1].discovery_base = UNCORE_DISCOVERY_MSR,
18381841
};
18391842

18401843
static const struct x86_cpu_id intel_uncore_match[] __initconst = {

arch/x86/events/intel/uncore_discovery.c

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,6 @@
1212
static struct rb_root discovery_tables = RB_ROOT;
1313
static int num_discovered_types[UNCORE_ACCESS_MAX];
1414

15-
static bool has_generic_discovery_table(void)
16-
{
17-
struct pci_dev *dev;
18-
int dvsec;
19-
20-
dev = pci_get_device(PCI_VENDOR_ID_INTEL, UNCORE_DISCOVERY_TABLE_DEVICE, NULL);
21-
if (!dev)
22-
return false;
23-
24-
/* A discovery table device has the unique capability ID. */
25-
dvsec = pci_find_next_ext_capability(dev, 0, UNCORE_EXT_CAP_ID_DISCOVERY);
26-
pci_dev_put(dev);
27-
if (dvsec)
28-
return true;
29-
30-
return false;
31-
}
32-
3315
static int logical_die_id;
3416

3517
static int get_device_die_id(struct pci_dev *dev)
@@ -358,12 +340,7 @@ static bool uncore_discovery_pci(struct uncore_discovery_domain *domain)
358340
struct pci_dev *dev = NULL;
359341
bool parsed = false;
360342

361-
if (domain->discovery_base)
362-
device = domain->discovery_base;
363-
else if (has_generic_discovery_table())
364-
device = UNCORE_DISCOVERY_TABLE_DEVICE;
365-
else
366-
device = PCI_ANY_ID;
343+
device = domain->discovery_base;
367344

368345
/*
369346
* Start a new search and iterates through the list of
@@ -406,24 +383,21 @@ static bool uncore_discovery_msr(struct uncore_discovery_domain *domain)
406383
{
407384
unsigned long *die_mask;
408385
bool parsed = false;
409-
int cpu, die, msr;
386+
int cpu, die;
410387
u64 base;
411388

412389
die_mask = kcalloc(BITS_TO_LONGS(uncore_max_dies()),
413390
sizeof(unsigned long), GFP_KERNEL);
414391
if (!die_mask)
415392
return false;
416393

417-
msr = domain->discovery_base ?
418-
domain->discovery_base : UNCORE_DISCOVERY_MSR;
419-
420394
cpus_read_lock();
421395
for_each_online_cpu(cpu) {
422396
die = topology_logical_die_id(cpu);
423397
if (__test_and_set_bit(die, die_mask))
424398
continue;
425399

426-
if (rdmsrq_safe_on_cpu(cpu, msr, &base))
400+
if (rdmsrq_safe_on_cpu(cpu, domain->discovery_base, &base))
427401
continue;
428402

429403
if (!base)
@@ -446,10 +420,12 @@ bool uncore_discovery(struct uncore_plat_init *init)
446420

447421
for (i = 0; i < UNCORE_DISCOVERY_DOMAINS; i++) {
448422
domain = &init->domain[i];
449-
if (!domain->base_is_pci)
450-
ret |= uncore_discovery_msr(domain);
451-
else
452-
ret |= uncore_discovery_pci(domain);
423+
if (domain->discovery_base) {
424+
if (!domain->base_is_pci)
425+
ret |= uncore_discovery_msr(domain);
426+
else
427+
ret |= uncore_discovery_pci(domain);
428+
}
453429
}
454430

455431
return ret;

0 commit comments

Comments
 (0)