mirror of
https://github.com/torvalds/linux.git
synced 2026-05-25 15:41:52 +02:00
drm/amd/ras: Reduce stack usage in ras_umc_handle_bad_pages()
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] v2: Removed the duplicate ras_umc_get_new_records() invocation. (Lijo) Cc: Tao Zhou <tao.zhou1@amd.com> Cc: Hawking Zhang <Hawking.Zhang@amd.com> Cc: Christian König <christian.koenig@amd.com> Cc: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com> Reviewed-by: Tao Zhou <tao.zhou1@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
e3b8d8cc8c
commit
8b971ce0cb
|
|
@ -497,27 +497,40 @@ 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;
|
||||
|
||||
memset(records, 0, sizeof(records));
|
||||
count = ras_umc_get_new_records(ras_core, records, ARRAY_SIZE(records));
|
||||
if (count <= 0)
|
||||
return -ENODATA;
|
||||
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);
|
||||
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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user