[PATCH] coresight: fix building with CONFIG_CPUMASK_OFFSTACK

Arnd Bergmann arnd at kernel.org
Fri Jun 20 04:09:28 PDT 2025


From: Arnd Bergmann <arnd at arndb.de>

Building with a ridiculous CONFIG_NR_CPUS shows that this function
fails to build because of incorrectly moving the mask offstack:

drivers/hwtracing/coresight/coresight-cpu-debug.c: In function ‘debug_enable_func’:
drivers/hwtracing/coresight/coresight-cpu-debug.c:452:1: error: the frame size of 8528 bytes is larger than 1536 bytes [-Werror=frame-larger-than=]

Use the recommended interface instead.

Fixes: 2227b7c74634 ("coresight: add support for CPU debug module")
Signed-off-by: Arnd Bergmann <arnd at arndb.de>
---
 drivers/hwtracing/coresight/coresight-cpu-debug.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-cpu-debug.c b/drivers/hwtracing/coresight/coresight-cpu-debug.c
index a871d997330b..6ecd8e755ef3 100644
--- a/drivers/hwtracing/coresight/coresight-cpu-debug.c
+++ b/drivers/hwtracing/coresight/coresight-cpu-debug.c
@@ -416,13 +416,16 @@ static int debug_enable_func(void)
 {
 	struct debug_drvdata *drvdata;
 	int cpu, ret = 0;
-	cpumask_t mask;
+	cpumask_var_t mask;
+
+	if (!alloc_cpumask_var(&mask, GFP_KERNEL))
+		return -ENOMEM;
 
 	/*
 	 * Use cpumask to track which debug power domains have
 	 * been powered on and use it to handle failure case.
 	 */
-	cpumask_clear(&mask);
+	cpumask_clear(mask);
 
 	for_each_possible_cpu(cpu) {
 		drvdata = per_cpu(debug_drvdata, cpu);
@@ -433,9 +436,10 @@ static int debug_enable_func(void)
 		if (ret < 0)
 			goto err;
 		else
-			cpumask_set_cpu(cpu, &mask);
+			cpumask_set_cpu(cpu, mask);
 	}
 
+	free_cpumask_var(mask);
 	return 0;
 
 err:
@@ -443,11 +447,12 @@ static int debug_enable_func(void)
 	 * If pm_runtime_get_sync() has failed, need rollback on
 	 * all the other CPUs that have been enabled before that.
 	 */
-	for_each_cpu(cpu, &mask) {
+	for_each_cpu(cpu, mask) {
 		drvdata = per_cpu(debug_drvdata, cpu);
 		pm_runtime_put_noidle(drvdata->dev);
 	}
 
+	free_cpumask_var(mask);
 	return ret;
 }
 
-- 
2.39.5




More information about the linux-arm-kernel mailing list