All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu/gmc: fix compiler errors [-Werror,-Wmissing-braces]
@ 2018-12-20 14:01 S, Shirish
       [not found] ` <1545314475-7114-1-git-send-email-shirish.s-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: S, Shirish @ 2018-12-20 14:01 UTC (permalink / raw)
  To: Li, Sun peng (Leo),
	Wentland, Harry, Deucher, Alexander, Koenig, Christian
  Cc: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, S, 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.

Signed-off-by: Shirish S <shirish.s@amd.com>
---
 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(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
index 1ad7e6b..3444067 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
@@ -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",
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
index bacdaef..2bfddce 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
@@ -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
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/amdgpu/gmc: fix compiler errors [-Werror,-Wmissing-braces]
       [not found] ` <1545314475-7114-1-git-send-email-shirish.s-5C7GfCeVMHo@public.gmane.org>
@ 2018-12-20 15:34   ` Deucher, Alexander
  2018-12-21 11:18   ` Michel Dänzer
  1 sibling, 0 replies; 5+ messages in thread
From: Deucher, Alexander @ 2018-12-20 15:34 UTC (permalink / raw)
  To: S, Shirish, Li, Sun peng (Leo), Wentland, Harry, Koenig, Christian
  Cc: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW


[-- Attachment #1.1: Type: text/plain, Size: 2722 bytes --]

Reviewed-by: Alex Deucher <alexander.deucher-5C7GfCeVMHo@public.gmane.org>

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of S, Shirish <Shirish.S-5C7GfCeVMHo@public.gmane.org>
Sent: Thursday, December 20, 2018 9:01:33 AM
To: Li, Sun peng (Leo); Wentland, Harry; Deucher, Alexander; Koenig, Christian
Cc: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org; 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.

Signed-off-by: Shirish S <shirish.s-5C7GfCeVMHo@public.gmane.org>
---
 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(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
index 1ad7e6b..3444067 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
@@ -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",
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
index bacdaef..2bfddce 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
@@ -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
amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[-- Attachment #1.2: Type: text/html, Size: 4840 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/amdgpu/gmc: fix compiler errors [-Werror,-Wmissing-braces]
       [not found] ` <1545314475-7114-1-git-send-email-shirish.s-5C7GfCeVMHo@public.gmane.org>
  2018-12-20 15:34   ` Deucher, Alexander
@ 2018-12-21 11:18   ` Michel Dänzer
       [not found]     ` <4d04ab79-32ff-ab0d-4735-280bcedaa2a7-otUistvHUpPR7s880joybQ@public.gmane.org>
  1 sibling, 1 reply; 5+ messages in thread
From: Michel Dänzer @ 2018-12-21 11:18 UTC (permalink / raw)
  To: S, Shirish, Li, Sun peng (Leo),
	Wentland, Harry, Deucher, Alexander, Koenig, Christian
  Cc: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On 2018-12-20 3:01 p.m., S, Shirish wrote:
> 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.
> 
> Signed-off-by: Shirish S <shirish.s@amd.com>
> 
> [...]
>  
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> index bacdaef..2bfddce 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> @@ -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.


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/amdgpu/gmc: fix compiler errors [-Werror,-Wmissing-braces]
       [not found]     ` <4d04ab79-32ff-ab0d-4735-280bcedaa2a7-otUistvHUpPR7s880joybQ@public.gmane.org>
@ 2018-12-21 13:41       ` Koenig, Christian
  2018-12-21 15:47       ` S
  1 sibling, 0 replies; 5+ messages in thread
From: Koenig, Christian @ 2018-12-21 13:41 UTC (permalink / raw)
  To: Michel Dänzer, S, Shirish, Li, Sun peng (Leo),
	Wentland, Harry, Deucher, Alexander
  Cc: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Am 21.12.18 um 12:18 schrieb Michel Dänzer:
> On 2018-12-20 3:01 p.m., S, Shirish wrote:
>> 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.
>>
>> Signed-off-by: Shirish S <shirish.s@amd.com>
>>
>> [...]
>>   
>> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
>> index bacdaef..2bfddce 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
>> @@ -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)")

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));"

> 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
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/amdgpu/gmc: fix compiler errors [-Werror,-Wmissing-braces]
       [not found]     ` <4d04ab79-32ff-ab0d-4735-280bcedaa2a7-otUistvHUpPR7s880joybQ@public.gmane.org>
  2018-12-21 13:41       ` Koenig, Christian
@ 2018-12-21 15:47       ` S
  1 sibling, 0 replies; 5+ messages in thread
From: S @ 2018-12-21 15:47 UTC (permalink / raw)
  To: Michel Dänzer, S, Shirish, Li, Sun peng (Leo),
	Wentland, Harry, Deucher, Alexander, Koenig, Christian
  Cc: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

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

On 12/21/2018 4:48 PM, Michel Dänzer wrote:
> On 2018-12-20 3:01 p.m., S, Shirish wrote:
>> 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.
>>
>> Signed-off-by: Shirish S <shirish.s@amd.com>
>>
>> [...]
>>   
>> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
>> index bacdaef..2bfddce 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
>> @@ -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.
>
>
-- 
Regards,
Shirish S

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-12-21 15:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-20 14:01 [PATCH] drm/amdgpu/gmc: fix compiler errors [-Werror,-Wmissing-braces] S, Shirish
     [not found] ` <1545314475-7114-1-git-send-email-shirish.s-5C7GfCeVMHo@public.gmane.org>
2018-12-20 15:34   ` Deucher, Alexander
2018-12-21 11:18   ` Michel Dänzer
     [not found]     ` <4d04ab79-32ff-ab0d-4735-280bcedaa2a7-otUistvHUpPR7s880joybQ@public.gmane.org>
2018-12-21 13:41       ` Koenig, Christian
2018-12-21 15:47       ` S

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.