]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - arch/x86/events/amd/uncore.c
perf/amd/uncore: Clean up per-family setup
[mirror_ubuntu-bionic-kernel.git] / arch / x86 / events / amd / uncore.c
index 4d1f7f2d9aff6f3383ab09de7119d3812d8ed3fe..975f24f6e238e701be9d7858a71669de69b59dee 100644 (file)
@@ -509,51 +509,34 @@ static int __init amd_uncore_init(void)
        int ret = -ENODEV;
 
        if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
-               goto fail_nodev;
-
-       switch(boot_cpu_data.x86) {
-               case 23:
-                       /* Family 17h: */
-                       num_counters_nb = NUM_COUNTERS_NB;
-                       num_counters_llc = NUM_COUNTERS_L3;
-                       /*
-                        * For Family17h, the NorthBridge counters are
-                        * re-purposed as Data Fabric counters. Also, support is
-                        * added for L3 counters. The pmus are exported based on
-                        * family as either L2 or L3 and NB or DF.
-                        */
-                       amd_nb_pmu.name = "amd_df";
-                       amd_llc_pmu.name = "amd_l3";
-                       format_attr_event_df.show = &event_show_df;
-                       format_attr_event_l3.show = &event_show_l3;
-                       break;
-               case 22:
-                       /* Family 16h - may change: */
-                       num_counters_nb = NUM_COUNTERS_NB;
-                       num_counters_llc = NUM_COUNTERS_L2;
-                       amd_nb_pmu.name = "amd_nb";
-                       amd_llc_pmu.name = "amd_l2";
-                       format_attr_event_df = format_attr_event;
-                       format_attr_event_l3 = format_attr_event;
-                       break;
-               default:
-                       /*
-                        * All prior families have the same number of
-                        * NorthBridge and Last Level Cache counters
-                        */
-                       num_counters_nb = NUM_COUNTERS_NB;
-                       num_counters_llc = NUM_COUNTERS_L2;
-                       amd_nb_pmu.name = "amd_nb";
-                       amd_llc_pmu.name = "amd_l2";
-                       format_attr_event_df = format_attr_event;
-                       format_attr_event_l3 = format_attr_event;
-                       break;
-       }
-       amd_nb_pmu.attr_groups = amd_uncore_attr_groups_df;
-       amd_llc_pmu.attr_groups = amd_uncore_attr_groups_l3;
+               return -ENODEV;
 
        if (!boot_cpu_has(X86_FEATURE_TOPOEXT))
-               goto fail_nodev;
+               return -ENODEV;
+
+       if (boot_cpu_data.x86 == 0x17) {
+               /*
+                * For F17h, the Northbridge counters are repurposed as Data
+                * Fabric counters. Also, L3 counters are supported too. The PMUs
+                * are exported based on  family as either L2 or L3 and NB or DF.
+                */
+               num_counters_nb           = NUM_COUNTERS_NB;
+               num_counters_llc          = NUM_COUNTERS_L3;
+               amd_nb_pmu.name           = "amd_df";
+               amd_llc_pmu.name          = "amd_l3";
+               format_attr_event_df.show = &event_show_df;
+               format_attr_event_l3.show = &event_show_l3;
+       } else {
+               num_counters_nb           = NUM_COUNTERS_NB;
+               num_counters_llc          = NUM_COUNTERS_L2;
+               amd_nb_pmu.name           = "amd_nb";
+               amd_llc_pmu.name          = "amd_l2";
+               format_attr_event_df      = format_attr_event;
+               format_attr_event_l3      = format_attr_event;
+       }
+
+       amd_nb_pmu.attr_groups  = amd_uncore_attr_groups_df;
+       amd_llc_pmu.attr_groups = amd_uncore_attr_groups_l3;
 
        if (boot_cpu_has(X86_FEATURE_PERFCTR_NB)) {
                amd_uncore_nb = alloc_percpu(struct amd_uncore *);
@@ -615,7 +598,6 @@ fail_nb:
        if (amd_uncore_nb)
                free_percpu(amd_uncore_nb);
 
-fail_nodev:
        return ret;
 }
 device_initcall(amd_uncore_init);