[PATCH 2/8] ras: aest: Fix CE/UE error counts not incrementing in debugfs

Umang Chheda
2026-05-05T12:25:13Z

The error counts visible under:
/sys/kernel/debug/aest/<dev>/processor<cpu>/<node>/err_count

always reported zero, even though corrected errors (CEs) were being
serviced by the interrupt handler. aest_oncore_dev_init_debugfs() sets
up per CPU debugfs entries but wired them up incorrectly in two places:

- this_cpu_ptr(adev->adev_oncore) was used inside for_each_possible_cpu().
This always selects the slot for the CPU executing the init code, so all
debugfs files ended up referencing the same per CPU aest_device instance
instead of the CPU indicated by the loop variable.

- The code referenced adev->nodes[i], i.e. the template nodes allocated
before __setup_ppi, rather than the per-CPU copies at
percpu_dev->nodes[i]. The IRQ handler updates CE counters in the per-CPU
records created by __setup_ppi, the template records are never touched
at runtime, so err_count always read as zero.

Fix this by:

- Using per_cpu_ptr(adev->adev_oncore, cpu) when iterating over CPUs.
Wiring debugfs files to percpu_dev->nodes[i] so counters reflect the
data updated by the IRQ handler.

- Using adev->nodes[i].name for debugfs directory names. The per-CPU node
receives name via a shallow memcpy and is not the authoritative source.

Signed-off-by: Umang Chheda <umang.chheda@oss.qualcomm.com>
---
drivers/ras/aest/aest-sysfs.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/ras/aest/aest-sysfs.c b/drivers/ras/aest/aest-sysfs.c
index 66e9c1103f99..f710503e4d74 100644
--- a/drivers/ras/aest/aest-sysfs.c
+++ b/drivers/ras/aest/aest-sysfs.c
@@ -189,16 +189,23 @@ aest_oncore_dev_init_debugfs(struct aest_device *adev)
char name[16];

for_each_possible_cpu(cpu) {
- percpu_dev = this_cpu_ptr(adev->adev_oncore);
+ percpu_dev = per_cpu_ptr(adev->adev_oncore, cpu);

- snprintf(name, sizeof(name), "processor%u%u", cpu);
+ snprintf(name, sizeof(name), "processor%u", cpu);
percpu_dev->debugfs = debugfs_create_dir(name, adev->debugfs);

for (i = 0; i < adev->node_cnt; i++) {
- node = &adev->nodes[i];
-
- node->debugfs = debugfs_create_dir(node->name,
- percpu_dev->debugfs);
+ node = &percpu_dev->nodes[i];
+
+ /*
+ * Use adev->nodes[i].name (the original) rather than
+ * node->name from the per-CPU copy. The per-CPU copy
+ * receives node->name via shallow memcpy in __setup_ppi;
+ * the original is the authoritative, guaranteed-valid
+ * string.
+ */
+ node->debugfs = debugfs_create_dir(adev->nodes[i].name,
+ percpu_dev->debugfs);
aest_node_init_debugfs(node);
}
}

--
2.34.1