Skip to contentSkip to conversation

drm/amd/ras: omit redundant memset of already-zeroed buffers

PATCH In review Tobias Klauser 2 participants 2 messages Oct 23 – Oct 26

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/ras: omit redundant memset of already-zeroed buffers

Both of these are allocated with kzalloc() right before memset(), so the buffer is already zeroed and the memset() is redundant.

---
 drivers/gpu/drm/amd/ras/core/eeprom.c                 | 1 -
 drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_virt_ras_cmd.c | 2 --
 2 files changed, 3 deletions(-)
drivers/gpu/drm/amd/ras/core/eeprom.c +0 -1
index 40430f0b4d2e..cfefbe848033 100644
@@ -1091,7 +1091,6 @@ static int ras_eeprom_sw_init(struct ras_core_context *ras_core,
 		return -ENOMEM;
 
 	mgr->ras_eeprom = control;
-	memset(control, 0, sizeof(*control));
 
 	control->mgr = mgr;
 	control->max_read_len = param->max_i2c_read_len;
drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_virt_ras_cmd.c +0 -2
index 1e83cb5064ff..f021719ff0a8 100644
@@ -298,8 +298,6 @@ static int amdgpu_virt_ras_get_cper_records(struct ras_core_context *ras_core,
 		return RAS_CMD__ERROR_GENERIC;
 	}
 
-	memset(out_buf, 0, req->buf_size);
-
 	for (i = 0; i < req->cper_num; i++) {
 		batch_id = req->cper_start_id + i;
 		if (batch_id >= overview->last_batch_id)
Signature · 1 line
2.55.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Tobias Klauser

Both of these are allocated with kzalloc() right before memset(), so the buffer is already zeroed and the memset() is redundant.

and applied.

Alex

Quoted 33 lines
---
 drivers/gpu/drm/amd/ras/core/eeprom.c                 | 1 -
 drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_virt_ras_cmd.c | 2 --
 2 files changed, 3 deletions(-)
drivers/gpu/drm/amd/ras/core/eeprom.c +0 -1
index 40430f0b4d2e..cfefbe848033 100644
@@ -1091,7 +1091,6 @@ static int ras_eeprom_sw_init(struct ras_core_context *ras_core,
                return -ENOMEM;
 
        mgr->ras_eeprom = control;
-       memset(control, 0, sizeof(*control));
 
        control->mgr = mgr;
        control->max_read_len = param->max_i2c_read_len;
drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_virt_ras_cmd.c +0 -3
index 1e83cb5064ff..f021719ff0a8 100644
@@ -298,8 +298,6 @@ static int amdgpu_virt_ras_get_cper_records(struct ras_core_context *ras_core,
                return RAS_CMD__ERROR_GENERIC;
        }
 
-       memset(out_buf, 0, req->buf_size);
-
        for (i = 0; i < req->cper_num; i++) {
                batch_id = req->cper_start_id + i;
                if (batch_id >= overview->last_batch_id)
--

2.55.0