.. | .. |
---|
2828 | 2828 | return false; |
---|
2829 | 2829 | |
---|
2830 | 2830 | pci_read_config_dword(dev, HSWEP_PCU_CAPID4_OFFET, &capid4); |
---|
| 2831 | + pci_dev_put(dev); |
---|
2831 | 2832 | if (!hswep_get_chop(capid4)) |
---|
2832 | 2833 | return true; |
---|
2833 | 2834 | |
---|
.. | .. |
---|
3642 | 3643 | } |
---|
3643 | 3644 | |
---|
3644 | 3645 | 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) |
---|
3646 | 3648 | { |
---|
3647 | 3649 | struct intel_uncore_pmu *pmu = dev_to_uncore_pmu(kobj_to_dev(kobj)); |
---|
3648 | 3650 | |
---|
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); |
---|
3651 | 3659 | } |
---|
3652 | 3660 | |
---|
3653 | 3661 | static ssize_t skx_iio_mapping_show(struct device *dev, |
---|
.. | .. |
---|
3739 | 3747 | NULL, |
---|
3740 | 3748 | }; |
---|
3741 | 3749 | |
---|
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) |
---|
3743 | 3767 | { |
---|
3744 | 3768 | char buf[64]; |
---|
3745 | 3769 | int ret; |
---|
.. | .. |
---|
3747 | 3771 | struct attribute **attrs = NULL; |
---|
3748 | 3772 | struct dev_ext_attribute *eas = NULL; |
---|
3749 | 3773 | |
---|
3750 | | - ret = skx_iio_get_topology(type); |
---|
3751 | | - if (ret) |
---|
| 3774 | + ret = type->get_topology(type); |
---|
| 3775 | + if (ret < 0) |
---|
3752 | 3776 | goto clear_attr_update; |
---|
3753 | 3777 | |
---|
3754 | 3778 | ret = -ENOMEM; |
---|
.. | .. |
---|
3774 | 3798 | eas[die].var = (void *)die; |
---|
3775 | 3799 | attrs[die] = &eas[die].attr.attr; |
---|
3776 | 3800 | } |
---|
3777 | | - skx_iio_mapping_group.attrs = attrs; |
---|
| 3801 | + ag->attrs = attrs; |
---|
3778 | 3802 | |
---|
3779 | 3803 | return 0; |
---|
3780 | 3804 | err: |
---|
.. | .. |
---|
3786 | 3810 | clear_topology: |
---|
3787 | 3811 | kfree(type->topology); |
---|
3788 | 3812 | clear_attr_update: |
---|
3789 | | - type->attr_update = NULL; |
---|
| 3813 | + pmu_clear_mapping_attr(type->attr_update, ag); |
---|
3790 | 3814 | 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); |
---|
3791 | 3820 | } |
---|
3792 | 3821 | |
---|
3793 | 3822 | static void skx_iio_cleanup_mapping(struct intel_uncore_type *type) |
---|
.. | .. |
---|
3820 | 3849 | .ops = &skx_uncore_iio_ops, |
---|
3821 | 3850 | .format_group = &skx_uncore_iio_format_group, |
---|
3822 | 3851 | .attr_update = skx_iio_attr_update, |
---|
| 3852 | + .get_topology = skx_iio_get_topology, |
---|
3823 | 3853 | .set_mapping = skx_iio_set_mapping, |
---|
3824 | 3854 | .cleanup_mapping = skx_iio_cleanup_mapping, |
---|
3825 | 3855 | }; |
---|
.. | .. |
---|
4680 | 4710 | |
---|
4681 | 4711 | addr += box_ctl; |
---|
4682 | 4712 | |
---|
| 4713 | + pci_dev_put(pdev); |
---|
| 4714 | + |
---|
4683 | 4715 | box->io_addr = ioremap(addr, type->mmio_map_size); |
---|
4684 | 4716 | if (!box->io_addr) { |
---|
4685 | 4717 | pr_warn("perf uncore: Failed to ioremap for %s.\n", type->name); |
---|