2018-01-19 01:04:09

by Gustavo A. R. Silva

[permalink] [raw]
Subject: [PATCH] drm/amdkfd: Use ARRAY_SIZE macro in kfd_build_sysfs_node_entry

Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element.

This issue was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <[email protected]>
---
drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
index c6a7609..7783250 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
@@ -677,7 +677,7 @@ static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev,
}

/* All hardware blocks have the same number of attributes. */
- num_attrs = sizeof(perf_attr_iommu)/sizeof(struct kfd_perf_attr);
+ num_attrs = ARRAY_SIZE(perf_attr_iommu);
list_for_each_entry(perf, &dev->perf_props, list) {
perf->attr_group = kzalloc(sizeof(struct kfd_perf_attr)
* num_attrs + sizeof(struct attribute_group),
--
2.7.4



2018-01-19 22:20:43

by Felix Kuehling

[permalink] [raw]
Subject: Re: [PATCH] drm/amdkfd: Use ARRAY_SIZE macro in kfd_build_sysfs_node_entry

Looks good. This change is Reviewed-by: Felix Kuehling
<[email protected]>

Regards,
  Felix


On 2018-01-18 07:39 PM, Gustavo A. R. Silva wrote:
> Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element.
>
> This issue was detected with the help of Coccinelle.
>
> Signed-off-by: Gustavo A. R. Silva <[email protected]>
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
> index c6a7609..7783250 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
> @@ -677,7 +677,7 @@ static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev,
> }
>
> /* All hardware blocks have the same number of attributes. */
> - num_attrs = sizeof(perf_attr_iommu)/sizeof(struct kfd_perf_attr);
> + num_attrs = ARRAY_SIZE(perf_attr_iommu);
> list_for_each_entry(perf, &dev->perf_props, list) {
> perf->attr_group = kzalloc(sizeof(struct kfd_perf_attr)
> * num_attrs + sizeof(struct attribute_group),


2018-01-19 22:31:37

by Gustavo A. R. Silva

[permalink] [raw]
Subject: Re: [PATCH] drm/amdkfd: Use ARRAY_SIZE macro in kfd_build_sysfs_node_entry


Quoting Felix Kuehling <[email protected]>:

> Looks good. This change is Reviewed-by: Felix Kuehling
> <[email protected]>
>

Thanks Felix.
--
Gustavo






2018-01-31 16:21:06

by Oded Gabbay

[permalink] [raw]
Subject: Re: [PATCH] drm/amdkfd: Use ARRAY_SIZE macro in kfd_build_sysfs_node_entry

On Sat, Jan 20, 2018 at 12:30 AM, Gustavo A. R. Silva
<[email protected]> wrote:
>
> Quoting Felix Kuehling <[email protected]>:
>
>> Looks good. This change is Reviewed-by: Felix Kuehling
>> <[email protected]>
>>
>
> Thanks Felix.
> --
> Gustavo
>
Applied to -next
Oded

>
>
>
>

2018-02-14 21:31:53

by Gustavo A. R. Silva

[permalink] [raw]
Subject: Re: [PATCH] drm/amdkfd: Use ARRAY_SIZE macro in kfd_build_sysfs_node_entry

Hi all,

I was just wondering about the status of this patch.

Thanks
--
Gustavo

On 01/19/2018 04:18 PM, Felix Kuehling wrote:
> Looks good. This change is Reviewed-by: Felix Kuehling
> <[email protected]>
>
> Regards,
>   Felix
>
>
> On 2018-01-18 07:39 PM, Gustavo A. R. Silva wrote:
>> Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element.
>>
>> This issue was detected with the help of Coccinelle.
>>
>> Signed-off-by: Gustavo A. R. Silva <[email protected]>
>> ---
>> drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
>> index c6a7609..7783250 100644
>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
>> @@ -677,7 +677,7 @@ static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev,
>> }
>>
>> /* All hardware blocks have the same number of attributes. */
>> - num_attrs = sizeof(perf_attr_iommu)/sizeof(struct kfd_perf_attr);
>> + num_attrs = ARRAY_SIZE(perf_attr_iommu);
>> list_for_each_entry(perf, &dev->perf_props, list) {
>> perf->attr_group = kzalloc(sizeof(struct kfd_perf_attr)
>> * num_attrs + sizeof(struct attribute_group),
>


2018-02-15 10:10:36

by Oded Gabbay

[permalink] [raw]
Subject: Re: [PATCH] drm/amdkfd: Use ARRAY_SIZE macro in kfd_build_sysfs_node_entry

Hi Gustavo,
The patch is queued for the merge window of kernel 4.17 (opens in
about 7 weeks from now).

Oded

On Wed, Feb 14, 2018 at 11:30 PM, Gustavo A. R. Silva
<[email protected]> wrote:
> Hi all,
>
> I was just wondering about the status of this patch.
>
> Thanks
> --
> Gustavo
>
>
> On 01/19/2018 04:18 PM, Felix Kuehling wrote:
>>
>> Looks good. This change is Reviewed-by: Felix Kuehling
>> <[email protected]>
>>
>> Regards,
>> Felix
>>
>>
>> On 2018-01-18 07:39 PM, Gustavo A. R. Silva wrote:
>>>
>>> Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element.
>>>
>>> This issue was detected with the help of Coccinelle.
>>>
>>> Signed-off-by: Gustavo A. R. Silva <[email protected]>
>>> ---
>>> drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
>>> b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
>>> index c6a7609..7783250 100644
>>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
>>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
>>> @@ -677,7 +677,7 @@ static int kfd_build_sysfs_node_entry(struct
>>> kfd_topology_device *dev,
>>> }
>>> /* All hardware blocks have the same number of attributes. */
>>> - num_attrs = sizeof(perf_attr_iommu)/sizeof(struct kfd_perf_attr);
>>> + num_attrs = ARRAY_SIZE(perf_attr_iommu);
>>> list_for_each_entry(perf, &dev->perf_props, list) {
>>> perf->attr_group = kzalloc(sizeof(struct kfd_perf_attr)
>>> * num_attrs + sizeof(struct attribute_group),
>>
>>
>

2018-02-15 16:14:34

by Gustavo A. R. Silva

[permalink] [raw]
Subject: Re: [PATCH] drm/amdkfd: Use ARRAY_SIZE macro in kfd_build_sysfs_node_entry

Hi Oded,

On 02/15/2018 04:08 AM, Oded Gabbay wrote:
> Hi Gustavo,
> The patch is queued for the merge window of kernel 4.17 (opens in
> about 7 weeks from now).
>

Awesome.

Thanks for the info.
--
Gustavo

> Oded
>
> On Wed, Feb 14, 2018 at 11:30 PM, Gustavo A. R. Silva
> <[email protected]> wrote:
>> Hi all,
>>
>> I was just wondering about the status of this patch.
>>
>> Thanks
>> --
>> Gustavo
>>
>>
>> On 01/19/2018 04:18 PM, Felix Kuehling wrote:
>>>
>>> Looks good. This change is Reviewed-by: Felix Kuehling
>>> <[email protected]>
>>>
>>> Regards,
>>> Felix
>>>
>>>
>>> On 2018-01-18 07:39 PM, Gustavo A. R. Silva wrote:
>>>>
>>>> Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element.
>>>>
>>>> This issue was detected with the help of Coccinelle.
>>>>
>>>> Signed-off-by: Gustavo A. R. Silva <[email protected]>
>>>> ---
>>>> drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 2 +-
>>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
>>>> b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
>>>> index c6a7609..7783250 100644
>>>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
>>>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
>>>> @@ -677,7 +677,7 @@ static int kfd_build_sysfs_node_entry(struct
>>>> kfd_topology_device *dev,
>>>> }
>>>> /* All hardware blocks have the same number of attributes. */
>>>> - num_attrs = sizeof(perf_attr_iommu)/sizeof(struct kfd_perf_attr);
>>>> + num_attrs = ARRAY_SIZE(perf_attr_iommu);
>>>> list_for_each_entry(perf, &dev->perf_props, list) {
>>>> perf->attr_group = kzalloc(sizeof(struct kfd_perf_attr)
>>>> * num_attrs + sizeof(struct attribute_group),
>>>
>>>
>>