perf/arm_cspmu: nvidia: handle empty resource list in PCIE-TGT init
PATCH 2/3 perf/arm_cspmu: nvidia: handle empty resource list in PCIE-TGT init
When acpi_dev_get_memory_resources() returns success but the resource list is empty (rentry is NULL), addr_filter_reg remains NULL from devm_kzalloc. Since IS_ERR(NULL) is false, the function proceeds without error and later dereferences the NULL pointer in pcie_tgt_pmu_config_addr_filter().
Set addr_filter_reg to ERR_PTR(-ENODEV) when the resource list is empty so the existing IS_ERR check catches it.
--- drivers/perf/arm_cspmu/nvidia_cspmu.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/perf/arm_cspmu/nvidia_cspmu.c +5 -3
@@ -555,14 +555,16 @@ static int pcie_tgt_init_data(struct arm_cspmu *cspmu) rentry =list_first_entry_or_null ( &resource_list, struct resource_entry, node); -if (rentry) { +if (rentry) data->addr_filter_reg =devm_ioremap_resource (dev, rentry->res); - ret =0 ; - } +else + data->addr_filter_reg =ERR_PTR (-ENODEV );if (IS_ERR (data->addr_filter_reg)) {dev_err (dev,"failed to get address filter resource\n" ); ret =PTR_ERR (data->addr_filter_reg); + }else { + ret =0 ; }acpi_dev_free_resource_list (&resource_list);
Signature · 1 line
2.47.3
PATCH 3/3 perf/arm_cspmu: nvidia: fix BDF calculation examples in PCIE PMU docs
The BDF hex values in the documentation examples are inconsistent with the stated formula (bus << 8) + (device << 3) + (function):
- BDF 27:01.1: documented as 0x2781, correct value is 0x2709
(0x27 << 8) + (0x01 << 3) + 0x1 = 0x2709
- BDF 01:01.0: documented as 0x0180, correct value is 0x0108
(0x01 << 8) + (0x01 << 3) + 0x0 = 0x0108It appears (device << 7) was used instead of (device << 3) when computing the example values.
--- Documentation/admin-guide/perf/nvidia-tegra410-pmu.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/admin-guide/perf/nvidia-tegra410-pmu.rst +2 -2
@@ -170,7 +170,7 @@ The list of event filters: devices in root port 0 to 3. * src_bdf: the BDF that will be monitored. This is a 16-bit value that follows formula: (bus << 8) + (device << 3) + (function). For example, the - value of BDF 27:01.1 is 0x2781. + value of BDF 27:01.1 is 0x2709. * src_bdf_en: enable the BDF filter. If this is set, the BDF filter value in "src_bdf" is used to filter the traffic.
@@ -215,7 +215,7 @@ Example usage: * Count event id 0x4 from BDF 01:01.0 of PCIE RC-4 on socket 0 targeting all destinations:: - perf stat -a -e nvidia_pcie_pmu_0_rc_4/event=0x4,src_bdf=0x0180,src_bdf_en=0x1/ + perf stat -a -e nvidia_pcie_pmu_0_rc_4/event=0x4,src_bdf=0x0108,src_bdf_en=0x1/ .. _NVIDIA_T410_PCIE_PMU_RC_Mapping_Section:
Signature · 1 line
2.47.3
RE: [PATCH 3/3] perf/arm_cspmu: nvidia: fix BDF calculation examples in PCIE PMU docs
Quoted 26 lines
-----Original Message-----
From: Saurav Sachidanand <[email protected]>
Sent: Monday, May 11, 2026 4:09 PM
To: Will Deacon <[email protected]>
Cc: Mark Rutland <[email protected]>; Besar Wicaksono <[email protected]>; Ilkka Koskinen <[email protected]>; Jon Hunter <[email protected]>; [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; Saurav Sachidanand <[email protected]>
Subject: [PATCH 3/3] perf/arm_cspmu: nvidia: fix BDF calculation examples in PCIE PMU docsExternal email: Use caution opening links or attachments
The BDF hex values in the documentation examples are inconsistent with the stated formula (bus << 8) + (device << 3) + (function):
- BDF 27:01.1: documented as
0x2781, correct value is0x2709(0x27 << 8) + (0x01 << 3) + 0x1 = 0x2709 - BDF 01:01.0: documented as 0x0180, correct value is 0x0108 (0x01 << 8) + (0x01 << 3) + 0x0 = 0x0108
Quoted 5 lines
It appears (device << 7) was used instead of (device << 3) when computing the example values.
Fixes bf585ba14726 ("perf/arm_cspmu: nvidia: Add Tegra410 PCIE PMU")Signed-off-by Saurav Sachidanand <[email protected]>
Thanks for the fix.
Quoted 31 lines
--- Documentation/admin-guide/perf/nvidia-tegra410-pmu.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Documentation/admin-guide/perf/nvidia-tegra410-pmu.rst +1
-2@@ -170,7 +170,7 @@ The list of event filters: devices in root port 0 to 3. * src_bdf: the BDF that will be monitored. This is a 16-bit value that follows formula: (bus << 8) + (device << 3) + (function). For example, the - value of BDF 27:01.1 is 0x2781. + value of BDF 27:01.1 is 0x2709. * src_bdf_en: enable the BDF filter. If this is set, the BDF filter value in "src_bdf" is used to filter the traffic.@@ -215,7 +215,7 @@ Example usage: * Count event id 0x4 from BDF 01:01.0 of PCIE RC-4 on socket 0 targeting all destinations:: - perf stat -a -envidia_pcie_pmu_0_rc_4/event=0x4,src_bdf=0x0180,src_bdf_en=0x1/
+ perf stat -a -e
nvidia_pcie_pmu_0_rc_4/event=0x4,src_bdf=0x0108,src_bdf_en=0x1/..
_NVIDIA_T410_PCIE_PMU_RC_Mapping_Section:--
2.47.3
Quoted 46 lines
-----Original Message-----
From: Saurav Sachidanand <[email protected]>
Sent: Monday, May 11, 2026 4:09 PM
To: Will Deacon <[email protected]>
Cc: Mark Rutland <[email protected]>; Besar Wicaksono <[email protected]>; Ilkka Koskinen <[email protected]>; Jon Hunter <[email protected]>; [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; Saurav Sachidanand <[email protected]>
Subject: [PATCH 2/3] perf/arm_cspmu: nvidia: handle empty resource list in PCIE-TGT initExternal email: Use caution opening links or attachments
When
acpi_dev_get_memory_resources()returns success but the resource list is empty (rentry is NULL),addr_filter_regremains NULL fromdevm_kzalloc. SinceIS_ERR(NULL)is false, the function proceeds without error and later dereferences the NULL pointer inpcie_tgt_pmu_config_addr_filter().Set
addr_filter_regtoERR_PTR(-ENODEV)when the resource list is empty so the existingIS_ERRcheck catches it.Fixes 3dd73022306b ("perf/arm_cspmu: nvidia: Add Tegra410 PCIE-TGTPMU")
Signed-off-by Saurav Sachidanand <[email protected]>--- drivers/perf/arm_cspmu/nvidia_cspmu.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/perf/arm_cspmu/nvidia_cspmu.c +1
-1@@ -555,14 +555,16 @@ static int pcie_tgt_init_data(struct arm_cspmu *cspmu) rentry =list_first_entry_or_null ( &resource_list, struct resource_entry, node); -if (rentry) { +if (rentry)
drivers/perf/arm_cspmu/nvidia_cspmu.c static int pcie_tgt_init_data(struct arm_cspmu · line 567
Quoted 10 lines
drivers/perf/arm_cspmu/nvidia_cspmu.c +3
-2data->addr_filter_reg =devm_ioremap_resource (dev, rentry->res); - ret =0 ; - } + else + data->addr_filter_reg = ERR_PTR(-ENODEV);if (IS_ERR (data->addr_filter_reg)) {dev_err (dev,"failed to get address filter resource\n" ); ret =PTR_ERR (data->addr_filter_reg); + }else {
Thanks for fixing.
Quoted 6 lines
drivers/perf/arm_cspmu/nvidia_cspmu.c +1
-0+ ret =0 ; }acpi_dev_free_resource_list(&resource_list);--
2.47.3
Will Deacon
maintainerQuoted 6 lines · Saurav Sachidanand
When
acpi_dev_get_memory_resources()returns success but the resource list is empty (rentry is NULL),addr_filter_regremains NULL fromdevm_kzalloc. SinceIS_ERR(NULL)is false, the function proceeds without error and later dereferences the NULL pointer inpcie_tgt_pmu_config_addr_filter().
Quoted 8 lines
Set
addr_filter_regtoERR_PTR(-ENODEV)when the resource list is empty so the existingIS_ERRcheck catches it.Fixes 3dd73022306b ("perf/arm_cspmu: nvidia: Add Tegra410 PCIE-TGT PMU")Signed-off-by Saurav Sachidanand <[email protected]>--- drivers/perf/arm_cspmu/nvidia_cspmu.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
What happened to patch 1/3? I don't have it in my inbox and it seems to be missing from the archive as well:
https://lore.kernel.org/all/[email protected]/
Please can you post a v2, with all three patches and the R-b tags from Besar?
Thanks,
Will