Skip to contentSkip to conversation

drm/amdgpu/gmc: fix compiler errors [-Werror,-Wmissing-braces]

PATCH In review S, Shirish 5 participants 5 messages Dec 20, 2018 – Dec 21, 2018 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

S, Shirish

author
#0 lore raw

PATCH 1/1 drm/amdgpu/gmc: fix compiler errors [-Werror,-Wmissing-braces]

Initializing structures with { } is known to be problematic since it doesn't necessararily initializes all bytes, in case of padding, causing random failures when structures are memcmp().

This patch fixes the structure initialisation compiler error by memsetting the entire structure elements instead of only the first one.

---
 drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 3 ++-
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +2 -1
index 1ad7e6b..3444067 100644
@@ -1471,8 +1471,9 @@ static int gmc_v8_0_process_interrupt(struct amdgpu_device *adev,
 		gmc_v8_0_set_fault_enable_default(adev, false);
 
 	if (printk_ratelimit()) {
-		struct amdgpu_task_info task_info = { 0 };
+		struct amdgpu_task_info task_info;
 
+		memset(&task_info, 0, sizeof(struct amdgpu_task_info));
 		amdgpu_vm_get_task_info(adev, entry->pasid, &task_info);
 
 		dev_err(adev->dev, "GPU fault detected: %d 0x%08x for process %s pid %d thread %s pid %d\n",
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2 -1
index bacdaef..2bfddce 100644
@@ -320,8 +320,9 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev,
 	}
 
 	if (printk_ratelimit()) {
-		struct amdgpu_task_info task_info = { 0 };
+		struct amdgpu_task_info task_info;
 
+		memset(&task_info, 0, sizeof(amdgpu_task_info));
 		amdgpu_vm_get_task_info(adev, entry->pasid, &task_info);
 
 		dev_err(adev->dev,
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): 1545314475-7114-1-git-send-email-shirish.s-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#2 lore raw

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of S, Shirish <[email protected]>
Sent: Thursday, December 20, 2018 9:01:33 AM
To: Li, Sun peng (Leo); Wentland, Harry; Deucher, Alexander; Koenig, Christian
Cc: [email protected]; S, Shirish
Subject: [PATCH] drm/amdgpu/gmc: fix compiler errors [-Werror,-Wmissing-braces]

Initializing structures with { } is known to be problematic since it doesn't necessararily initializes all bytes, in case of padding, causing random failures when structures are memcmp().

This patch fixes the structure initialisation compiler error by memsetting the entire structure elements instead of only the first one.

---
 drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 3 ++-
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +2 -1
index 1ad7e6b..3444067 100644
@@ -1471,8 +1471,9 @@ static int gmc_v8_0_process_interrupt(struct amdgpu_device *adev,
                 gmc_v8_0_set_fault_enable_default(adev, false);
 
         if (printk_ratelimit()) {
-               struct amdgpu_task_info task_info = { 0 };
+               struct amdgpu_task_info task_info;
 
+               memset(&task_info, 0, sizeof(struct amdgpu_task_info));
                 amdgpu_vm_get_task_info(adev, entry->pasid, &task_info);
 
                 dev_err(adev->dev, "GPU fault detected: %d 0x%08x for process %s pid %d thread %s pid %d\n",
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2 -1
index bacdaef..2bfddce 100644
@@ -320,8 +320,9 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev,
         }
 
         if (printk_ratelimit()) {
-               struct amdgpu_task_info task_info = { 0 };
+               struct amdgpu_task_info task_info;
 
+               memset(&task_info, 0, sizeof(amdgpu_task_info));
                 amdgpu_vm_get_task_info(adev, entry->pasid, &task_info);
 
                 dev_err(adev->dev,

--
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

#3 lore raw
In reply to a message not in the archive
Quoted 16 lines · Shirish

Initializing structures with { } is known to be problematic since it doesn't necessararily initializes all bytes, in case of padding, causing random failures when structures are memcmp().

This patch fixes the structure initialisation compiler error by memsetting the entire structure elements instead of only the first one.

[...]

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -0
index bacdaef..2bfddce 100644

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev, · line 325

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2 -1
@@ -320,8 +320,9 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev,
 	}
 
 	if (printk_ratelimit()) {
-		struct amdgpu_task_info task_info = { 0 };
+		struct amdgpu_task_info task_info;
 
+		memset(&task_info, 0, sizeof(amdgpu_task_info));

This doesn't compile:

drivers/gpu/drm//amd/amdgpu/gmc_v9_0.c: In function ‘gmc_v9_0_process_interrupt’:
drivers/gpu/drm//amd/amdgpu/gmc_v9_0.c:325:32: error: ‘amdgpu_task_info’ undeclared (first use in this function)

   memset(&task_info, 0, sizeof(amdgpu_task_info));
                                ^~~~~~~~~~~~~~~~

(Needs to be "sizeof(struct amdgpu_task_info)")

I've reverted this on the internal amd-staging-drm-next branch.

Patches must be tested appropriately (against the target branch), ideally before submitting them for review. Reviewers are not expected to look for things which trivially break the build.

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
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): 4d04ab79-32ff-ab0d-4735-280bcedaa2a7-otUistvHUpPR7s880joybQ@public.gmane.org

#5 lore raw

Am 21.12.18 um 12:18 schrieb Michel Dänzer:

Quoted 26 lines · Shirish
Quoted 16 lines

Initializing structures with { } is known to be problematic since it doesn't necessararily initializes all bytes, in case of padding, causing random failures when structures are memcmp().

This patch fixes the structure initialisation compiler error by memsetting the entire structure elements instead of only the first one.

[...]

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -0
index bacdaef..2bfddce 100644

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev, · line 325

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2 -1
@@ -320,8 +320,9 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev,
  	}
 
  	if (printk_ratelimit()) {
-		struct amdgpu_task_info task_info = { 0 };
+		struct amdgpu_task_info task_info;
 
+		memset(&task_info, 0, sizeof(amdgpu_task_info));

This doesn't compile:

Quoted 6 lines

drivers/gpu/drm//amd/amdgpu/gmc_v9_0.c: In function ‘gmc_v9_0_process_interrupt’:
drivers/gpu/drm//amd/amdgpu/gmc_v9_0.c:325:32: error: ‘amdgpu_task_info’ undeclared (first use in this function)

    memset(&task_info, 0, sizeof(amdgpu_task_info));
                                 ^~~~~~~~~~~~~~~~

(Needs to be "sizeof(struct amdgpu_task_info)")

The coding style guide lines actually document that you should avoid types with sizeof and instead use the variables directly.

E.g. use "memset(&task_info, 0, sizeof(task_info));"

Quoted 5 lines

I've reverted this on the internal amd-staging-drm-next branch.

Patches must be tested appropriately (against the target branch), ideally before submitting them for review. Reviewers are not expected to look for things which trivially break the build.

Completely agree.

I mean I break things more often than not myself because of our limited QA resources, but at least such trivial things should not happen any more.

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

#6 lore raw
In reply to a message not in the archive

Have rectified it.

I had built it but seems some how i missed it while rebasing the patch from my internal kernel tree (which is a bit older) onto internal-staging tip.

Apologies for the troubles.

Have sent V2, please review.

Regards,

Shirish S

Quoted 41 lines · Michel Dänzer
Quoted 16 lines · Shirish

Initializing structures with { } is known to be problematic since it doesn't necessararily initializes all bytes, in case of padding, causing random failures when structures are memcmp().

This patch fixes the structure initialisation compiler error by memsetting the entire structure elements instead of only the first one.

[...]

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -0
index bacdaef..2bfddce 100644

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev, · line 325

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2 -1
@@ -320,8 +320,9 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev,
  	}
 
  	if (printk_ratelimit()) {
-		struct amdgpu_task_info task_info = { 0 };
+		struct amdgpu_task_info task_info;
 
+		memset(&task_info, 0, sizeof(amdgpu_task_info));

This doesn't compile:

drivers/gpu/drm//amd/amdgpu/gmc_v9_0.c: In function ‘gmc_v9_0_process_interrupt’:
drivers/gpu/drm//amd/amdgpu/gmc_v9_0.c:325:32: error: ‘amdgpu_task_info’ undeclared (first use in this function)

    memset(&task_info, 0, sizeof(amdgpu_task_info));
                                 ^~~~~~~~~~~~~~~~

(Needs to be "sizeof(struct amdgpu_task_info)")

I've reverted this on the internal amd-staging-drm-next branch.

Patches must be tested appropriately (against the target branch), ideally before submitting them for review. Reviewers are not expected to look for things which trivially break the build.

Signature · 7 lines
Regards,
Shirish S

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