On 12/5/2025 5:45 PM, Srinivasan Shanmugam wrote:
ras_umc_handle_bad_pages() function used a large local array:
struct eeprom_umc_record records[MAX_ECC_NUM_PER_RETIREMENT];
Move this array off the stack by allocating it with kcalloc()
and freeing it before return.
This reduces the stack frame size of ras_umc_handle_bad_pages()
and avoids the frame size warning.
Fixes the below:
drivers/gpu/drm/amd/amdgpu/../ras/rascore/ras_umc.c:498:5: warning: stack frame
size (1208) exceeds limit (1024) in 'ras_umc_handle_bad_pages'
[-Wframe-larger-than]
Cc: Tao Zhou <[email protected]>
Cc: Hawking Zhang <[email protected]>
Cc: Christian König <[email protected]>
Cc: Alex Deucher <[email protected]>
Signed-off-by: Srinivasan Shanmugam <[email protected]>
---
drivers/gpu/drm/amd/ras/rascore/ras_umc.c | 31 ++++++++++++++++++-----
1 file changed, 24 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/amd/ras/rascore/ras_umc.c
b/drivers/gpu/drm/amd/ras/rascore/ras_umc.c
index 4dae64c424a2..6061776b894d 100644
--- a/drivers/gpu/drm/amd/ras/rascore/ras_umc.c
+++ b/drivers/gpu/drm/amd/ras/rascore/ras_umc.c
@@ -497,27 +497,44 @@ static int ras_umc_save_bad_pages(struct ras_core_context
*ras_core)
int ras_umc_handle_bad_pages(struct ras_core_context *ras_core, void *data)
{
- struct eeprom_umc_record records[MAX_ECC_NUM_PER_RETIREMENT];
+ struct eeprom_umc_record *records;
int count, ret;
+ records = kcalloc(MAX_ECC_NUM_PER_RETIREMENT,
+ sizeof(*records), GFP_KERNEL);
+ if (!records)
+ return -ENOMEM;
+
+ count = ras_umc_get_new_records(ras_core, records,
+ MAX_ECC_NUM_PER_RETIREMENT);
+
This looks unintentional, same function called below.
memset(records, 0, sizeof(records));
This is not required and can be skipped.
Thanks,
Lijo
- count = ras_umc_get_new_records(ras_core, records, ARRAY_SIZE(records));
- if (count <= 0)
- return -ENODATA;
+ count = ras_umc_get_new_records(ras_core, records,
+ MAX_ECC_NUM_PER_RETIREMENT);
+ if (count <= 0) {
+ ret = -ENODATA;
+ goto out;
+ }
ret = ras_umc_add_bad_pages(ras_core, records, count, false);
if (ret) {
RAS_DEV_ERR(ras_core->dev, "Failed to add ras bad page!\n");
- return -EINVAL;
+ ret = -EINVAL;
+ goto out;
}
ret = ras_umc_save_bad_pages(ras_core);
if (ret) {
RAS_DEV_ERR(ras_core->dev, "Failed to save ras bad page\n");
- return -EINVAL;
+ ret = -EINVAL;
+ goto out;
}
- return 0;
+ ret = 0;
+
+out:
+ kfree(records);
+ return ret;
}
int ras_umc_sw_init(struct ras_core_context *ras_core)