hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/arch/x86/events/intel/uncore_snbep.c
....@@ -2828,6 +2828,7 @@
28282828 return false;
28292829
28302830 pci_read_config_dword(dev, HSWEP_PCU_CAPID4_OFFET, &capid4);
2831
+ pci_dev_put(dev);
28312832 if (!hswep_get_chop(capid4))
28322833 return true;
28332834
....@@ -3642,12 +3643,19 @@
36423643 }
36433644
36443645 static umode_t
3645
-skx_iio_mapping_visible(struct kobject *kobj, struct attribute *attr, int die)
3646
+pmu_iio_mapping_visible(struct kobject *kobj, struct attribute *attr,
3647
+ int die, int zero_bus_pmu)
36463648 {
36473649 struct intel_uncore_pmu *pmu = dev_to_uncore_pmu(kobj_to_dev(kobj));
36483650
3649
- /* Root bus 0x00 is valid only for die 0 AND pmu_idx = 0. */
3650
- return (!skx_iio_stack(pmu, die) && pmu->pmu_idx) ? 0 : attr->mode;
3651
+ return (!skx_iio_stack(pmu, die) && pmu->pmu_idx != zero_bus_pmu) ? 0 : attr->mode;
3652
+}
3653
+
3654
+static umode_t
3655
+skx_iio_mapping_visible(struct kobject *kobj, struct attribute *attr, int die)
3656
+{
3657
+ /* Root bus 0x00 is valid only for pmu_idx = 0. */
3658
+ return pmu_iio_mapping_visible(kobj, attr, die, 0);
36513659 }
36523660
36533661 static ssize_t skx_iio_mapping_show(struct device *dev,
....@@ -3739,7 +3747,23 @@
37393747 NULL,
37403748 };
37413749
3742
-static int skx_iio_set_mapping(struct intel_uncore_type *type)
3750
+static void pmu_clear_mapping_attr(const struct attribute_group **groups,
3751
+ struct attribute_group *ag)
3752
+{
3753
+ int i;
3754
+
3755
+ for (i = 0; groups[i]; i++) {
3756
+ if (groups[i] == ag) {
3757
+ for (i++; groups[i]; i++)
3758
+ groups[i - 1] = groups[i];
3759
+ groups[i - 1] = NULL;
3760
+ break;
3761
+ }
3762
+ }
3763
+}
3764
+
3765
+static int
3766
+pmu_iio_set_mapping(struct intel_uncore_type *type, struct attribute_group *ag)
37433767 {
37443768 char buf[64];
37453769 int ret;
....@@ -3747,8 +3771,8 @@
37473771 struct attribute **attrs = NULL;
37483772 struct dev_ext_attribute *eas = NULL;
37493773
3750
- ret = skx_iio_get_topology(type);
3751
- if (ret)
3774
+ ret = type->get_topology(type);
3775
+ if (ret < 0)
37523776 goto clear_attr_update;
37533777
37543778 ret = -ENOMEM;
....@@ -3774,7 +3798,7 @@
37743798 eas[die].var = (void *)die;
37753799 attrs[die] = &eas[die].attr.attr;
37763800 }
3777
- skx_iio_mapping_group.attrs = attrs;
3801
+ ag->attrs = attrs;
37783802
37793803 return 0;
37803804 err:
....@@ -3786,8 +3810,13 @@
37863810 clear_topology:
37873811 kfree(type->topology);
37883812 clear_attr_update:
3789
- type->attr_update = NULL;
3813
+ pmu_clear_mapping_attr(type->attr_update, ag);
37903814 return ret;
3815
+}
3816
+
3817
+static int skx_iio_set_mapping(struct intel_uncore_type *type)
3818
+{
3819
+ return pmu_iio_set_mapping(type, &skx_iio_mapping_group);
37913820 }
37923821
37933822 static void skx_iio_cleanup_mapping(struct intel_uncore_type *type)
....@@ -3820,6 +3849,7 @@
38203849 .ops = &skx_uncore_iio_ops,
38213850 .format_group = &skx_uncore_iio_format_group,
38223851 .attr_update = skx_iio_attr_update,
3852
+ .get_topology = skx_iio_get_topology,
38233853 .set_mapping = skx_iio_set_mapping,
38243854 .cleanup_mapping = skx_iio_cleanup_mapping,
38253855 };
....@@ -4680,6 +4710,8 @@
46804710
46814711 addr += box_ctl;
46824712
4713
+ pci_dev_put(pdev);
4714
+
46834715 box->io_addr = ioremap(addr, type->mmio_map_size);
46844716 if (!box->io_addr) {
46854717 pr_warn("perf uncore: Failed to ioremap for %s.\n", type->name);