Skip to contentSkip to conversation

drm/amdgpu: remove redundant memset

PATCH In review Philip Yang 3 participants 3 messages Aug 29, 2018 – Aug 30, 2018 1 message not in the archive

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

PATCH 1/1 drm/amdgpu: remove redundant memset

kvmalloc_array uses __GFP_ZERO flag ensures that the returned address is zeroed already, memset it to zero again afterwards is unnecessary, and in this case buggy because we only clear the first entry.

Change-Id If94a59d3cbf2690dd2a1e2add71bc393df6a9686
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 1 -
 1 file changed, 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -1
index 153c9be..33d9ce2 100644
@@ -540,7 +540,6 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev,
 						   GFP_KERNEL | __GFP_ZERO);
 		if (!parent->entries)
 			return -ENOMEM;
-		memset(parent->entries, 0 , sizeof(struct amdgpu_vm_pt));
 	}
 
 	from = saddr >> shift;
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1535555864-2521-1-git-send-email-Philip.Yang-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#2 lore raw

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Philip Yang <[email protected]>
Sent: Wednesday, August 29, 2018 11:17:44 AM
To: [email protected]
Cc: Yang, Philip
Subject: [PATCH] drm/amdgpu: remove redundant memset

kvmalloc_array uses __GFP_ZERO flag ensures that the returned address is zeroed already, memset it to zero again afterwards is unnecessary, and in this case buggy because we only clear the first entry.

Change-Id If94a59d3cbf2690dd2a1e2add71bc393df6a9686
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 1 -
 1 file changed, 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -1
index 153c9be..33d9ce2 100644
@@ -540,7 +540,6 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev,
                                                    GFP_KERNEL | __GFP_ZERO);
                 if (!parent->entries)
                         return -ENOMEM;
-               memset(parent->entries, 0 , sizeof(struct amdgpu_vm_pt));
         }
 
         from = saddr >> shift;

--
2.7.4

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reviewed-by Junwei Zhang
#3 lore raw
In reply to a message not in the archive
Quoted 6 lines · Philip Yang

kvmalloc_array uses __GFP_ZERO flag ensures that the returned address is zeroed already, memset it to zero again afterwards is unnecessary, and in this case buggy because we only clear the first entry.

Change-Id If94a59d3cbf2690dd2a1e2add71bc393df6a9686

Good catch.

Quoted 10 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 1 -
  1 file changed, 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
index 153c9be..33d9ce2 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev, · line 545

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -1
@@ -540,7 +540,6 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev,
  						   GFP_KERNEL | __GFP_ZERO);
  		if (!parent->entries)
  			return -ENOMEM;
-		memset(parent->entries, 0 , sizeof(struct amdgpu_vm_pt));
  	}
 
  	from = saddr >> shift;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx