* [PATCH] drm/amdgpu/fence: Remove redundant 0 value initialization
@ 2025-08-19 8:25 Liao Yuanhong
2025-08-19 8:41 ` Christian König
2025-08-19 8:55 ` Markus Elfring
0 siblings, 2 replies; 5+ messages in thread
From: Liao Yuanhong @ 2025-08-19 8:25 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
Thomas Gleixner, Ingo Molnar, Srinivasan Shanmugam, Lijo Lazar,
open list:RADEON and AMDGPU DRM DRIVERS, open list:DRM DRIVERS,
open list
Cc: Liao Yuanhong
The amdgpu_fence struct is already zeroed by kzalloc(). It's redundant to
initialize am_fence->context to 0.
Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
index bcb74286a78a..fd8cca241da6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
@@ -120,7 +120,6 @@ int amdgpu_fence_emit(struct amdgpu_ring *ring, struct dma_fence **f,
am_fence = kzalloc(sizeof(*am_fence), GFP_KERNEL);
if (!am_fence)
return -ENOMEM;
- am_fence->context = 0;
} else {
am_fence = af;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/amdgpu/fence: Remove redundant 0 value initialization
2025-08-19 8:25 [PATCH] drm/amdgpu/fence: Remove redundant 0 value initialization Liao Yuanhong
@ 2025-08-19 8:41 ` Christian König
2025-08-19 11:34 ` Liao Yuanhong
2025-08-19 13:10 ` Alex Deucher
2025-08-19 8:55 ` Markus Elfring
1 sibling, 2 replies; 5+ messages in thread
From: Christian König @ 2025-08-19 8:41 UTC (permalink / raw)
To: Liao Yuanhong, Alex Deucher, David Airlie, Simona Vetter,
Thomas Gleixner, Ingo Molnar, Srinivasan Shanmugam, Lijo Lazar,
open list:RADEON and AMDGPU DRM DRIVERS, open list:DRM DRIVERS,
open list
On 19.08.25 10:25, Liao Yuanhong wrote:
> The amdgpu_fence struct is already zeroed by kzalloc(). It's redundant to
> initialize am_fence->context to 0.
>
> Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
If you want a challenge what we would really use is a scan of all the structures defined in drivers/gpu/drm/amd/amdgpu/*.[ch] for unused fields.
The UAPI and BIOS/HW header files are full of padding fields, but there shouldn't be any in the driver core defines and we sometimes forget to remove fields from structures when they are not used any more.
Regards,
Christian.
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> index bcb74286a78a..fd8cca241da6 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> @@ -120,7 +120,6 @@ int amdgpu_fence_emit(struct amdgpu_ring *ring, struct dma_fence **f,
> am_fence = kzalloc(sizeof(*am_fence), GFP_KERNEL);
> if (!am_fence)
> return -ENOMEM;
> - am_fence->context = 0;
> } else {
> am_fence = af;
> }
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/amdgpu/fence: Remove redundant 0 value initialization
2025-08-19 8:25 [PATCH] drm/amdgpu/fence: Remove redundant 0 value initialization Liao Yuanhong
2025-08-19 8:41 ` Christian König
@ 2025-08-19 8:55 ` Markus Elfring
1 sibling, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2025-08-19 8:55 UTC (permalink / raw)
To: Liao Yuanhong, amd-gfx, dri-devel
Cc: LKML, Alex Deucher, Christian König, David Airlie,
Ingo Molnar, Lijo Lazar, Simona Vetter, Srinivasan Shanmugam,
Thomas Gleixner
> The amdgpu_fence struct is already zeroed by kzalloc(). It's redundant to
> initialize am_fence->context to 0.
See also once more:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc2#n94
Regards,
Markus
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/amdgpu/fence: Remove redundant 0 value initialization
2025-08-19 8:41 ` Christian König
@ 2025-08-19 11:34 ` Liao Yuanhong
2025-08-19 13:10 ` Alex Deucher
1 sibling, 0 replies; 5+ messages in thread
From: Liao Yuanhong @ 2025-08-19 11:34 UTC (permalink / raw)
To: Christian König
Cc: Alex Deucher, David Airlie, Simona Vetter, Thomas Gleixner,
Ingo Molnar, Srinivasan Shanmugam, Lijo Lazar,
open list:RADEON and AMDGPU DRM DRIVERS, open list:DRM DRIVERS,
open list
On 8/19/2025 4:41 PM, Christian König wrote:
> On 19.08.25 10:25, Liao Yuanhong wrote:
>> The amdgpu_fence struct is already zeroed by kzalloc(). It's redundant to
>> initialize am_fence->context to 0.
>>
>> Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
> Reviewed-by: Christian König <christian.koenig@amd.com>
>
> If you want a challenge what we would really use is a scan of all the structures defined in drivers/gpu/drm/amd/amdgpu/*.[ch] for unused fields.
>
> The UAPI and BIOS/HW header files are full of padding fields, but there shouldn't be any in the driver core defines and we sometimes forget to remove fields from structures when they are not used any more.
>
> Regards,
> Christian.
Thank you for your suggestion! I will try to find it.
Regards,
Liao
>> ---
>> drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 1 -
>> 1 file changed, 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
>> index bcb74286a78a..fd8cca241da6 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
>> @@ -120,7 +120,6 @@ int amdgpu_fence_emit(struct amdgpu_ring *ring, struct dma_fence **f,
>> am_fence = kzalloc(sizeof(*am_fence), GFP_KERNEL);
>> if (!am_fence)
>> return -ENOMEM;
>> - am_fence->context = 0;
>> } else {
>> am_fence = af;
>> }
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/amdgpu/fence: Remove redundant 0 value initialization
2025-08-19 8:41 ` Christian König
2025-08-19 11:34 ` Liao Yuanhong
@ 2025-08-19 13:10 ` Alex Deucher
1 sibling, 0 replies; 5+ messages in thread
From: Alex Deucher @ 2025-08-19 13:10 UTC (permalink / raw)
To: Christian König
Cc: Liao Yuanhong, Alex Deucher, David Airlie, Simona Vetter,
Thomas Gleixner, Ingo Molnar, Srinivasan Shanmugam, Lijo Lazar,
open list:RADEON and AMDGPU DRM DRIVERS, open list:DRM DRIVERS,
open list
Applied. Thanks!
Alex
On Tue, Aug 19, 2025 at 4:41 AM Christian König
<christian.koenig@amd.com> wrote:
>
> On 19.08.25 10:25, Liao Yuanhong wrote:
> > The amdgpu_fence struct is already zeroed by kzalloc(). It's redundant to
> > initialize am_fence->context to 0.
> >
> > Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
>
> If you want a challenge what we would really use is a scan of all the structures defined in drivers/gpu/drm/amd/amdgpu/*.[ch] for unused fields.
>
> The UAPI and BIOS/HW header files are full of padding fields, but there shouldn't be any in the driver core defines and we sometimes forget to remove fields from structures when they are not used any more.
>
> Regards,
> Christian.
>
> > ---
> > drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 1 -
> > 1 file changed, 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> > index bcb74286a78a..fd8cca241da6 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> > @@ -120,7 +120,6 @@ int amdgpu_fence_emit(struct amdgpu_ring *ring, struct dma_fence **f,
> > am_fence = kzalloc(sizeof(*am_fence), GFP_KERNEL);
> > if (!am_fence)
> > return -ENOMEM;
> > - am_fence->context = 0;
> > } else {
> > am_fence = af;
> > }
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-08-19 13:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-19 8:25 [PATCH] drm/amdgpu/fence: Remove redundant 0 value initialization Liao Yuanhong
2025-08-19 8:41 ` Christian König
2025-08-19 11:34 ` Liao Yuanhong
2025-08-19 13:10 ` Alex Deucher
2025-08-19 8:55 ` Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).