Commit 513d793e authored by Yan, Zheng's avatar Yan, Zheng Committed by Ingo Molnar

perf/x86/intel/uncore: Register the PMU only if the uncore pci device exists

Current code registers PMUs for all possible uncore pci devices.
This is not good because, on some machines, one or more uncore pci
devices can be missing. The missing pci device make corresponding
PMU unusable. Register the PMU only if the uncore device exists.
Signed-off-by: default avatarYan, Zheng <zheng.z.yan@intel.com>
Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: eranian@google.com
Link: http://lkml.kernel.org/r/1409872109-31645-3-git-send-email-andi@firstfloor.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent e735b9db
...@@ -793,6 +793,7 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id ...@@ -793,6 +793,7 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id
struct intel_uncore_box *box; struct intel_uncore_box *box;
struct intel_uncore_type *type; struct intel_uncore_type *type;
int phys_id; int phys_id;
bool first_box = false;
phys_id = uncore_pcibus_to_physid[pdev->bus->number]; phys_id = uncore_pcibus_to_physid[pdev->bus->number];
if (phys_id < 0) if (phys_id < 0)
...@@ -827,9 +828,13 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id ...@@ -827,9 +828,13 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id
pci_set_drvdata(pdev, box); pci_set_drvdata(pdev, box);
raw_spin_lock(&uncore_box_lock); raw_spin_lock(&uncore_box_lock);
if (list_empty(&pmu->box_list))
first_box = true;
list_add_tail(&box->list, &pmu->box_list); list_add_tail(&box->list, &pmu->box_list);
raw_spin_unlock(&uncore_box_lock); raw_spin_unlock(&uncore_box_lock);
if (first_box)
uncore_pmu_register(pmu);
return 0; return 0;
} }
...@@ -838,6 +843,7 @@ static void uncore_pci_remove(struct pci_dev *pdev) ...@@ -838,6 +843,7 @@ static void uncore_pci_remove(struct pci_dev *pdev)
struct intel_uncore_box *box = pci_get_drvdata(pdev); struct intel_uncore_box *box = pci_get_drvdata(pdev);
struct intel_uncore_pmu *pmu; struct intel_uncore_pmu *pmu;
int i, cpu, phys_id = uncore_pcibus_to_physid[pdev->bus->number]; int i, cpu, phys_id = uncore_pcibus_to_physid[pdev->bus->number];
bool last_box = false;
box = pci_get_drvdata(pdev); box = pci_get_drvdata(pdev);
if (!box) { if (!box) {
...@@ -859,6 +865,8 @@ static void uncore_pci_remove(struct pci_dev *pdev) ...@@ -859,6 +865,8 @@ static void uncore_pci_remove(struct pci_dev *pdev)
raw_spin_lock(&uncore_box_lock); raw_spin_lock(&uncore_box_lock);
list_del(&box->list); list_del(&box->list);
if (list_empty(&pmu->box_list))
last_box = true;
raw_spin_unlock(&uncore_box_lock); raw_spin_unlock(&uncore_box_lock);
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {
...@@ -870,6 +878,9 @@ static void uncore_pci_remove(struct pci_dev *pdev) ...@@ -870,6 +878,9 @@ static void uncore_pci_remove(struct pci_dev *pdev)
WARN_ON_ONCE(atomic_read(&box->refcnt) != 1); WARN_ON_ONCE(atomic_read(&box->refcnt) != 1);
kfree(box); kfree(box);
if (last_box)
perf_pmu_unregister(&pmu->pmu);
} }
static int __init uncore_pci_init(void) static int __init uncore_pci_init(void)
...@@ -1221,14 +1232,6 @@ static int __init uncore_pmus_register(void) ...@@ -1221,14 +1232,6 @@ static int __init uncore_pmus_register(void)
} }
} }
for (i = 0; uncore_pci_uncores[i]; i++) {
type = uncore_pci_uncores[i];
for (j = 0; j < type->num_boxes; j++) {
pmu = &type->pmus[j];
uncore_pmu_register(pmu);
}
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment