Message ID | 20240110002350.1096-1-rdunlap@infradead.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-21566-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp492193dyi; Tue, 9 Jan 2024 16:24:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IGM3lB43CAJVA1O65QqB2yEpzl+YWPl2OM780zO0mZWMIiGPlGeXzUGKeLKKs73vSeO0/Mq X-Received: by 2002:a05:6214:20e6:b0:680:cc75:403f with SMTP id 6-20020a05621420e600b00680cc75403fmr2169983qvk.20.1704846262601; Tue, 09 Jan 2024 16:24:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704846262; cv=none; d=google.com; s=arc-20160816; b=fo/GMkQkc4HL7W9dfEfIiQorFib+s12/3T9csM9njm9PQB5UoqV6lR8FrkN7BXCSjV X2IoZgfCeehs7310/B+GatKt9j4GuAknjkUCMxafU7964GcAEuVQH7nCUbm/ffiub+em w9pyQ5fTxSqWeX8D7j0BLoHglegyIF9g4HJh2oL9hwl5zYKUc59NFti1qm4S4ebwpbRO OlKO1++CYb3ZetoG1ZvNhLRcRiOzv/W9P8PQFB+UXuzlMP/vXs/jbCgCRYYtan84xFPw 9lsAHLTTOW1rB9/lq/XPG4PNEXR/fvzM8W1xd+Sj1LH61LGsGVsYtNiKm9KkNcwfgfm8 pTpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=n4CYXr1oNi+dZDLWsdacFcCrEhFzsoUs4khZSQo+nR8=; fh=Xc2aRv8n9oqu/f1row146INWDLsVxEWhVk/cSU1rJNg=; b=ZyL3mc/kiNV8m5AJ3N26Ffesq/7BtuOY1f8sVUF1OqLO7L+6DWhRBHyuj55wV8GJRP FyeRVsRsSTDLr9AG8c9vMMgLfiry2AnvkWJLQ5uz3tw1oK3Q12Gu5WNyBWgK2S7YjXVd Qipo65l6t/6nGkJ8GpCNQ3lZuTsU/Nw2+jzYtx9aoTD1Dp2KuWRGo4yR1FLowTASV77a GLAf9qzfDtvuLeWTKvP1hus/0qc7q4cEwhqdjE69BcrBifmYu0FYdy+EM9kI/BGa28ww PA6OM+H/QaVqt3Cul6S+0nQ6dae3VZt8QgSY87KSIjme4kjVdXyR6/hSRvzZviEfm4iS OX1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@infradead.org header.s=bombadil.20210309 header.b=JHqplrN0; spf=pass (google.com: domain of linux-kernel+bounces-21566-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21566-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id s1-20020a0ce301000000b00680ce50b84bsi3355914qvl.567.2024.01.09.16.24.22 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 16:24:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-21566-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@infradead.org header.s=bombadil.20210309 header.b=JHqplrN0; spf=pass (google.com: domain of linux-kernel+bounces-21566-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21566-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 65A071C25173 for <ouuuleilei@gmail.com>; Wed, 10 Jan 2024 00:24:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 58F7828F9; Wed, 10 Jan 2024 00:23:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="JHqplrN0" Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A622717E4 for <linux-kernel@vger.kernel.org>; Wed, 10 Jan 2024 00:23:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=bF0k0tFraimuHpTxlpeFxettK+6lOSjFaik485rQmnU=; b=JHqplrN0VLcDSd2g3cK40qKbMv bLTSFEiVSde18qwFh1nAeDYleqtxs8pdl9m2FAUGQlIrlh8Pd4YxbtxAjAuRob8Ch6MJ7NGCjotZE oJybtbIYRtRpKPoaXNqbf7DrOJNTMzJ4RNuQsIs5l9wPT2OQAau3OSRrCgySeHXMHsYbBd5W8jdIO sLRH93vL3eW3qMyegjvFmWrQcZNZUYXTZChBC1YR4H2dpHtpnOb/l3/8/kmN7w/6o+QNDKJ18jbvt kP0+FUDwwIvtCbTYsDAgjpLXyZdey9EtVrnl8LIrChtKcmlkKEAgUIfOqMnaqJUFnwxUx4yj1/N5T LJlQwORA==; Received: from [50.53.46.231] (helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rNMNr-009wAB-1h; Wed, 10 Jan 2024 00:23:51 +0000 From: Randy Dunlap <rdunlap@infradead.org> To: linux-kernel@vger.kernel.org Cc: Randy Dunlap <rdunlap@infradead.org>, Donald Robson <donald.robson@imgtec.com>, Maxime Ripard <mripard@kernel.org>, Frank Binns <frank.binns@imgtec.com>, Matt Coster <matt.coster@imgtec.com>, Maarten Lankhorst <maarten.lankhorst@linux.intel.com>, Thomas Zimmermann <tzimmermann@suse.de>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>, dri-devel@lists.freedesktop.org Subject: [PATCH] drm/imagination: fix ARRAY_SIZE build error Date: Tue, 9 Jan 2024 16:23:50 -0800 Message-ID: <20240110002350.1096-1-rdunlap@infradead.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787660874422466611 X-GMAIL-MSGID: 1787660874422466611 |
Series |
drm/imagination: fix ARRAY_SIZE build error
|
|
Commit Message
Randy Dunlap
Jan. 10, 2024, 12:23 a.m. UTC
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(-)
Comments
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); >
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); >>
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);