[PATCH] drm/amdgpu: Remove hidden double memset from amdgpu_vm_pt_clear()
Tvrtko Ursulin
tursulin at igalia.com
Tue Aug 13 14:08:35 UTC 2024
From: Tvrtko Ursulin <tvrtko.ursulin at igalia.com>
When CONFIG_INIT_STACK_ALL_ZERO is set and so -ftrivial-auto-var-init=zero
compiler option active, compiler fails to notice that later in
amdgpu_vm_pt_clear() there is a second memset to clear the same on stack
struct amdgpu_vm_update_params.
If we replace this memset with an explicit automatic variable initializer,
compiler can then see it and avoid clearing this struct twice.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at igalia.com>
---
This is perhaps a bit questionable, regardless of how annoying it is to
know there is this double memset.
---
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
index e39d6e7643bf..ecdc8fffe941 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
@@ -361,7 +361,7 @@ int amdgpu_vm_pt_clear(struct amdgpu_device *adev, struct amdgpu_vm *vm,
{
unsigned int level = adev->vm_manager.root_level;
struct ttm_operation_ctx ctx = { true, false };
- struct amdgpu_vm_update_params params;
+ struct amdgpu_vm_update_params params = { };
struct amdgpu_bo *ancestor = &vmbo->bo;
unsigned int entries;
struct amdgpu_bo *bo = &vmbo->bo;
@@ -398,7 +398,6 @@ int amdgpu_vm_pt_clear(struct amdgpu_device *adev, struct amdgpu_vm *vm,
if (r)
goto exit;
- memset(¶ms, 0, sizeof(params));
params.adev = adev;
params.vm = vm;
params.immediate = immediate;
--
2.44.0
More information about the amd-gfx
mailing list