diff options
-rw-r--r-- | arch/x86/kernel/cpu/perf_event_intel_uncore.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c index 2b0fa02268b7..42d00e53175d 100644 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c | |||
@@ -793,6 +793,7 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id | |||
793 | struct intel_uncore_box *box; | 793 | struct intel_uncore_box *box; |
794 | struct intel_uncore_type *type; | 794 | struct intel_uncore_type *type; |
795 | int phys_id; | 795 | int phys_id; |
796 | bool first_box = false; | ||
796 | 797 | ||
797 | phys_id = uncore_pcibus_to_physid[pdev->bus->number]; | 798 | phys_id = uncore_pcibus_to_physid[pdev->bus->number]; |
798 | if (phys_id < 0) | 799 | if (phys_id < 0) |
@@ -827,9 +828,13 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id | |||
827 | pci_set_drvdata(pdev, box); | 828 | pci_set_drvdata(pdev, box); |
828 | 829 | ||
829 | raw_spin_lock(&uncore_box_lock); | 830 | raw_spin_lock(&uncore_box_lock); |
831 | if (list_empty(&pmu->box_list)) | ||
832 | first_box = true; | ||
830 | list_add_tail(&box->list, &pmu->box_list); | 833 | list_add_tail(&box->list, &pmu->box_list); |
831 | raw_spin_unlock(&uncore_box_lock); | 834 | raw_spin_unlock(&uncore_box_lock); |
832 | 835 | ||
836 | if (first_box) | ||
837 | uncore_pmu_register(pmu); | ||
833 | return 0; | 838 | return 0; |
834 | } | 839 | } |
835 | 840 | ||
@@ -838,6 +843,7 @@ static void uncore_pci_remove(struct pci_dev *pdev) | |||
838 | struct intel_uncore_box *box = pci_get_drvdata(pdev); | 843 | struct intel_uncore_box *box = pci_get_drvdata(pdev); |
839 | struct intel_uncore_pmu *pmu; | 844 | struct intel_uncore_pmu *pmu; |
840 | int i, cpu, phys_id = uncore_pcibus_to_physid[pdev->bus->number]; | 845 | int i, cpu, phys_id = uncore_pcibus_to_physid[pdev->bus->number]; |
846 | bool last_box = false; | ||
841 | 847 | ||
842 | box = pci_get_drvdata(pdev); | 848 | box = pci_get_drvdata(pdev); |
843 | if (!box) { | 849 | if (!box) { |
@@ -859,6 +865,8 @@ static void uncore_pci_remove(struct pci_dev *pdev) | |||
859 | 865 | ||
860 | raw_spin_lock(&uncore_box_lock); | 866 | raw_spin_lock(&uncore_box_lock); |
861 | list_del(&box->list); | 867 | list_del(&box->list); |
868 | if (list_empty(&pmu->box_list)) | ||
869 | last_box = true; | ||
862 | raw_spin_unlock(&uncore_box_lock); | 870 | raw_spin_unlock(&uncore_box_lock); |
863 | 871 | ||
864 | for_each_possible_cpu(cpu) { | 872 | for_each_possible_cpu(cpu) { |
@@ -870,6 +878,9 @@ static void uncore_pci_remove(struct pci_dev *pdev) | |||
870 | 878 | ||
871 | WARN_ON_ONCE(atomic_read(&box->refcnt) != 1); | 879 | WARN_ON_ONCE(atomic_read(&box->refcnt) != 1); |
872 | kfree(box); | 880 | kfree(box); |
881 | |||
882 | if (last_box) | ||
883 | perf_pmu_unregister(&pmu->pmu); | ||
873 | } | 884 | } |
874 | 885 | ||
875 | static int __init uncore_pci_init(void) | 886 | static int __init uncore_pci_init(void) |
@@ -1221,14 +1232,6 @@ static int __init uncore_pmus_register(void) | |||
1221 | } | 1232 | } |
1222 | } | 1233 | } |
1223 | 1234 | ||
1224 | for (i = 0; uncore_pci_uncores[i]; i++) { | ||
1225 | type = uncore_pci_uncores[i]; | ||
1226 | for (j = 0; j < type->num_boxes; j++) { | ||
1227 | pmu = &type->pmus[j]; | ||
1228 | uncore_pmu_register(pmu); | ||
1229 | } | ||
1230 | } | ||
1231 | |||
1232 | return 0; | 1235 | return 0; |
1233 | } | 1236 | } |
1234 | 1237 | ||