Skip to content

Commit d1c93d5

Browse files
Yicong Yangwilldeacon
authored andcommitted
drivers/perf: hisi_pcie: Export supported Root Ports [bdf_min, bdf_max]
Currently users can get the Root Ports supported by the PCIe PMU by "bus" sysfs attributes which indicates the PCIe bus number where Root Ports are located. This maybe insufficient since Root Ports supported by different PCIe PMUs may be located on the same PCIe bus. So export the BDF range the Root Ports additionally. Signed-off-by: Yicong Yang <yangyicong@hisilicon.com> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Link: https://lore.kernel.org/r/20240829090332.28756-4-yangyicong@huawei.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent 17bf68a commit d1c93d5

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

Documentation/admin-guide/perf/hisi-pcie-pmu.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ The "identifier" sysfs file allows users to identify the version of the
2828
PMU hardware device.
2929

3030
The "bus" sysfs file allows users to get the bus number of Root Ports
31-
monitored by PMU.
31+
monitored by PMU. Furthermore users can get the Root Ports range in
32+
[bdf_min, bdf_max] from "bdf_min" and "bdf_max" sysfs attributes
33+
respectively.
3234

3335
Example usage of perf::
3436

drivers/perf/hisilicon/hisi_pcie_pmu.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,22 @@ static ssize_t bus_show(struct device *dev, struct device_attribute *attr, char
141141
}
142142
static DEVICE_ATTR_RO(bus);
143143

144+
static ssize_t bdf_min_show(struct device *dev, struct device_attribute *attr, char *buf)
145+
{
146+
struct hisi_pcie_pmu *pcie_pmu = to_pcie_pmu(dev_get_drvdata(dev));
147+
148+
return sysfs_emit(buf, "%#04x\n", pcie_pmu->bdf_min);
149+
}
150+
static DEVICE_ATTR_RO(bdf_min);
151+
152+
static ssize_t bdf_max_show(struct device *dev, struct device_attribute *attr, char *buf)
153+
{
154+
struct hisi_pcie_pmu *pcie_pmu = to_pcie_pmu(dev_get_drvdata(dev));
155+
156+
return sysfs_emit(buf, "%#04x\n", pcie_pmu->bdf_max);
157+
}
158+
static DEVICE_ATTR_RO(bdf_max);
159+
144160
static struct hisi_pcie_reg_pair
145161
hisi_pcie_parse_reg_value(struct hisi_pcie_pmu *pcie_pmu, u32 reg_off)
146162
{
@@ -763,6 +779,8 @@ static const struct attribute_group hisi_pcie_pmu_format_group = {
763779

764780
static struct attribute *hisi_pcie_pmu_bus_attrs[] = {
765781
&dev_attr_bus.attr,
782+
&dev_attr_bdf_max.attr,
783+
&dev_attr_bdf_min.attr,
766784
NULL
767785
};
768786

0 commit comments

Comments
 (0)