* [PATCH] drm/imagination: fix ARRAY_SIZE build error
@ 2024-01-10 0:23 Randy Dunlap
2024-01-18 9:38 ` Matt Coster
0 siblings, 1 reply; 3+ messages in thread
From: Randy Dunlap @ 2024-01-10 0:23 UTC (permalink / raw)
To: linux-kernel
Cc: Randy Dunlap, Donald Robson, Maxime Ripard, Frank Binns,
Matt Coster, Maarten Lankhorst, Thomas Zimmermann, David Airlie,
Daniel Vetter, dri-devel
Fix a build error when using GCC 13.2.0 from kernel.org crosstools
by changing ARRAY_SIZE() to the macro PVR_MIPS_PT_PAGE_COUNT:
drivers/gpu/drm/imagination/pvr_vm_mips.c: In function 'pvr_vm_mips_fini':
../include/linux/array_size.h:11:25: warning: overflow in conversion from 'long unsigned int' to 'int' changes value from '18446744073709551615' to '-1' [-Woverflow]
11 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
| ^
drivers/gpu/drm/imagination/pvr_vm_mips.c:105:24: note: in expansion of macro 'ARRAY_SIZE'
105 | for (page_nr = ARRAY_SIZE(mips_data->pt_pages) - 1; page_nr >= 0; page_nr--) {
| ^~~~~~~~~~
Fixes: 927f3e0253c1 ("drm/imagination: Implement MIPS firmware processor and MMU support")
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Donald Robson <donald.robson@imgtec.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Frank Binns <frank.binns@imgtec.com>
Cc: Matt Coster <matt.coster@imgtec.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: David Airlie <airlied@gmail.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org
---
drivers/gpu/drm/imagination/pvr_vm_mips.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff -- a/drivers/gpu/drm/imagination/pvr_vm_mips.c b/drivers/gpu/drm/imagination/pvr_vm_mips.c
--- a/drivers/gpu/drm/imagination/pvr_vm_mips.c
+++ b/drivers/gpu/drm/imagination/pvr_vm_mips.c
@@ -46,7 +46,7 @@ pvr_vm_mips_init(struct pvr_device *pvr_
if (!mips_data)
return -ENOMEM;
- for (page_nr = 0; page_nr < ARRAY_SIZE(mips_data->pt_pages); page_nr++) {
+ for (page_nr = 0; page_nr < PVR_MIPS_PT_PAGE_COUNT; page_nr++) {
mips_data->pt_pages[page_nr] = alloc_page(GFP_KERNEL | __GFP_ZERO);
if (!mips_data->pt_pages[page_nr]) {
err = -ENOMEM;
@@ -102,7 +102,7 @@ pvr_vm_mips_fini(struct pvr_device *pvr_
int page_nr;
vunmap(mips_data->pt);
- for (page_nr = ARRAY_SIZE(mips_data->pt_pages) - 1; page_nr >= 0; page_nr--) {
+ for (page_nr = PVR_MIPS_PT_PAGE_COUNT - 1; page_nr >= 0; page_nr--) {
dma_unmap_page(from_pvr_device(pvr_dev)->dev,
mips_data->pt_dma_addr[page_nr], PAGE_SIZE, DMA_TO_DEVICE);
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] drm/imagination: fix ARRAY_SIZE build error
2024-01-10 0:23 [PATCH] drm/imagination: fix ARRAY_SIZE build error Randy Dunlap
@ 2024-01-18 9:38 ` Matt Coster
2024-01-18 17:00 ` Randy Dunlap
0 siblings, 1 reply; 3+ messages in thread
From: Matt Coster @ 2024-01-18 9:38 UTC (permalink / raw)
To: Randy Dunlap
Cc: Maxime Ripard, Frank Binns, Maarten Lankhorst, Thomas Zimmermann,
David Airlie, Daniel Vetter, dri-devel, linux-kernel
[-- Attachment #1.1.1: Type: text/plain, Size: 2892 bytes --]
On 10/01/2024 00:23, Randy Dunlap wrote:
> Fix a build error when using GCC 13.2.0 from kernel.org crosstools
> by changing ARRAY_SIZE() to the macro PVR_MIPS_PT_PAGE_COUNT:
I assume you're referring to the x86_64 => aarch64 toolchain here?
> drivers/gpu/drm/imagination/pvr_vm_mips.c: In function 'pvr_vm_mips_fini':
> ../include/linux/array_size.h:11:25: warning: overflow in conversion from 'long unsigned int' to 'int' changes value from '18446744073709551615' to '-1' [-Woverflow]
> 11 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
> | ^
> drivers/gpu/drm/imagination/pvr_vm_mips.c:105:24: note: in expansion of macro 'ARRAY_SIZE'
> 105 | for (page_nr = ARRAY_SIZE(mips_data->pt_pages) - 1; page_nr >= 0; page_nr--) {
> | ^~~~~~~~~~
I can't seem to reproduce this using the above toolchain (or any other),
even with -Woverflow explicitly specified.
The use of ARRAY_SIZE() in loop bounds is a pretty common construction –
even within the pvr driver. Do you see similar warnings anywhere else?
Regards,
Matt
--
Matt Coster
Imagination Technologies
> Fixes: 927f3e0253c1 ("drm/imagination: Implement MIPS firmware processor and MMU support")
> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> Cc: Donald Robson <donald.robson@imgtec.com>
> Cc: Maxime Ripard <mripard@kernel.org>
> Cc: Frank Binns <frank.binns@imgtec.com>
> Cc: Matt Coster <matt.coster@imgtec.com>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: David Airlie <airlied@gmail.com>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: dri-devel@lists.freedesktop.org
> ---
> drivers/gpu/drm/imagination/pvr_vm_mips.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff -- a/drivers/gpu/drm/imagination/pvr_vm_mips.c b/drivers/gpu/drm/imagination/pvr_vm_mips.c
> --- a/drivers/gpu/drm/imagination/pvr_vm_mips.c
> +++ b/drivers/gpu/drm/imagination/pvr_vm_mips.c
> @@ -46,7 +46,7 @@ pvr_vm_mips_init(struct pvr_device *pvr_
> if (!mips_data)
> return -ENOMEM;
>
> - for (page_nr = 0; page_nr < ARRAY_SIZE(mips_data->pt_pages); page_nr++) {
> + for (page_nr = 0; page_nr < PVR_MIPS_PT_PAGE_COUNT; page_nr++) {
> mips_data->pt_pages[page_nr] = alloc_page(GFP_KERNEL | __GFP_ZERO);
> if (!mips_data->pt_pages[page_nr]) {
> err = -ENOMEM;
> @@ -102,7 +102,7 @@ pvr_vm_mips_fini(struct pvr_device *pvr_
> int page_nr;
>
> vunmap(mips_data->pt);
> - for (page_nr = ARRAY_SIZE(mips_data->pt_pages) - 1; page_nr >= 0; page_nr--) {
> + for (page_nr = PVR_MIPS_PT_PAGE_COUNT - 1; page_nr >= 0; page_nr--) {
> dma_unmap_page(from_pvr_device(pvr_dev)->dev,
> mips_data->pt_dma_addr[page_nr], PAGE_SIZE, DMA_TO_DEVICE);
>
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 1817 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] drm/imagination: fix ARRAY_SIZE build error
2024-01-18 9:38 ` Matt Coster
@ 2024-01-18 17:00 ` Randy Dunlap
0 siblings, 0 replies; 3+ messages in thread
From: Randy Dunlap @ 2024-01-18 17:00 UTC (permalink / raw)
To: Matt Coster
Cc: Maxime Ripard, Frank Binns, Maarten Lankhorst, Thomas Zimmermann,
David Airlie, Daniel Vetter, dri-devel, linux-kernel
Hi Matt,
On 1/18/24 01:38, Matt Coster wrote:
> On 10/01/2024 00:23, Randy Dunlap wrote:
>> Fix a build error when using GCC 13.2.0 from kernel.org crosstools
>> by changing ARRAY_SIZE() to the macro PVR_MIPS_PT_PAGE_COUNT:
>
> I assume you're referring to the x86_64 => aarch64 toolchain here?
Yes.
>
>> drivers/gpu/drm/imagination/pvr_vm_mips.c: In function 'pvr_vm_mips_fini':
>> ../include/linux/array_size.h:11:25: warning: overflow in conversion from 'long unsigned int' to 'int' changes value from '18446744073709551615' to '-1' [-Woverflow]
>> 11 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
>> | ^
>> drivers/gpu/drm/imagination/pvr_vm_mips.c:105:24: note: in expansion of macro 'ARRAY_SIZE'
>> 105 | for (page_nr = ARRAY_SIZE(mips_data->pt_pages) - 1; page_nr >= 0; page_nr--) {
>> | ^~~~~~~~~~
>
> I can't seem to reproduce this using the above toolchain (or any other),
> even with -Woverflow explicitly specified.
>
> The use of ARRAY_SIZE() in loop bounds is a pretty common construction –
> even within the pvr driver. Do you see similar warnings anywhere else?
No, this is the only place that I have seen this issue.
Thanks.
> --
> Matt Coster
> Imagination Technologies
>
>> Fixes: 927f3e0253c1 ("drm/imagination: Implement MIPS firmware processor and MMU support")
>> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
>> Cc: Donald Robson <donald.robson@imgtec.com>
>> Cc: Maxime Ripard <mripard@kernel.org>
>> Cc: Frank Binns <frank.binns@imgtec.com>
>> Cc: Matt Coster <matt.coster@imgtec.com>
>> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>> Cc: Thomas Zimmermann <tzimmermann@suse.de>
>> Cc: David Airlie <airlied@gmail.com>
>> Cc: Daniel Vetter <daniel@ffwll.ch>
>> Cc: dri-devel@lists.freedesktop.org
>> ---
>> drivers/gpu/drm/imagination/pvr_vm_mips.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff -- a/drivers/gpu/drm/imagination/pvr_vm_mips.c b/drivers/gpu/drm/imagination/pvr_vm_mips.c
>> --- a/drivers/gpu/drm/imagination/pvr_vm_mips.c
>> +++ b/drivers/gpu/drm/imagination/pvr_vm_mips.c
>> @@ -46,7 +46,7 @@ pvr_vm_mips_init(struct pvr_device *pvr_
>> if (!mips_data)
>> return -ENOMEM;
>> - for (page_nr = 0; page_nr < ARRAY_SIZE(mips_data->pt_pages); page_nr++) {
>> + for (page_nr = 0; page_nr < PVR_MIPS_PT_PAGE_COUNT; page_nr++) {
>> mips_data->pt_pages[page_nr] = alloc_page(GFP_KERNEL | __GFP_ZERO);
>> if (!mips_data->pt_pages[page_nr]) {
>> err = -ENOMEM;
>> @@ -102,7 +102,7 @@ pvr_vm_mips_fini(struct pvr_device *pvr_
>> int page_nr;
>> vunmap(mips_data->pt);
>> - for (page_nr = ARRAY_SIZE(mips_data->pt_pages) - 1; page_nr >= 0; page_nr--) {
>> + for (page_nr = PVR_MIPS_PT_PAGE_COUNT - 1; page_nr >= 0; page_nr--) {
>> dma_unmap_page(from_pvr_device(pvr_dev)->dev,
>> mips_data->pt_dma_addr[page_nr], PAGE_SIZE, DMA_TO_DEVICE);
>>
--
#Randy
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-01-18 17:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-10 0:23 [PATCH] drm/imagination: fix ARRAY_SIZE build error Randy Dunlap
2024-01-18 9:38 ` Matt Coster
2024-01-18 17:00 ` Randy Dunlap
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®