[PATCH 10/10] [RESEND 3] dma/contiguous: avoid warning about unused size_bytes

Arnd Bergmann posted 10 patches 10 months ago
Only 2 patches received!
[PATCH 10/10] [RESEND 3] dma/contiguous: avoid warning about unused size_bytes
Posted by Arnd Bergmann 10 months ago
From: Arnd Bergmann <arnd@arndb.de>

When building with W=1, this variable is unused for configs with
CONFIG_CMA_SIZE_SEL_PERCENTAGE=y:

kernel/dma/contiguous.c:67:26: error: 'size_bytes' defined but not used [-Werror=unused-const-variable=]

Change this to a macro to avoid the warning.

Fixes: c64be2bb1c6e ("drivers: add Contiguous Memory Allocator")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v3: use a macro instead of constant
v2: fix spelling mistake.
---
 kernel/dma/contiguous.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
index 055da410ac71..88888f4c1c73 100644
--- a/kernel/dma/contiguous.c
+++ b/kernel/dma/contiguous.c
@@ -64,8 +64,7 @@ struct cma *dma_contiguous_default_area;
  * Users, who want to set the size of global CMA area for their system
  * should use cma= kernel parameter.
  */
-static const phys_addr_t size_bytes __initconst =
-	(phys_addr_t)CMA_SIZE_MBYTES * SZ_1M;
+#define size_bytes (CMA_SIZE_MBYTES * SZ_1M)
 static phys_addr_t  size_cmdline __initdata = -1;
 static phys_addr_t base_cmdline __initdata;
 static phys_addr_t limit_cmdline __initdata;
-- 
2.39.5
Re: [PATCH 10/10] [RESEND 3] dma/contiguous: avoid warning about unused size_bytes
Posted by Marek Szyprowski 10 months ago
On 09.04.2025 14:24, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> When building with W=1, this variable is unused for configs with
> CONFIG_CMA_SIZE_SEL_PERCENTAGE=y:
>
> kernel/dma/contiguous.c:67:26: error: 'size_bytes' defined but not used [-Werror=unused-const-variable=]
>
> Change this to a macro to avoid the warning.
>
> Fixes: c64be2bb1c6e ("drivers: add Contiguous Memory Allocator")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>


Thanks, applied to dma-mapping-fixes branch.


> ---
> v3: use a macro instead of constant
> v2: fix spelling mistake.
> ---
>   kernel/dma/contiguous.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
> index 055da410ac71..88888f4c1c73 100644
> --- a/kernel/dma/contiguous.c
> +++ b/kernel/dma/contiguous.c
> @@ -64,8 +64,7 @@ struct cma *dma_contiguous_default_area;
>    * Users, who want to set the size of global CMA area for their system
>    * should use cma= kernel parameter.
>    */
> -static const phys_addr_t size_bytes __initconst =
> -	(phys_addr_t)CMA_SIZE_MBYTES * SZ_1M;
> +#define size_bytes (CMA_SIZE_MBYTES * SZ_1M)
>   static phys_addr_t  size_cmdline __initdata = -1;
>   static phys_addr_t base_cmdline __initdata;
>   static phys_addr_t limit_cmdline __initdata;

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland
Re: [PATCH 10/10] [RESEND 3] dma/contiguous: avoid warning about unused size_bytes
Posted by Andy Shevchenko 10 months ago
On Wed, Apr 09, 2025 at 04:35:57PM +0200, Marek Szyprowski wrote:
> On 09.04.2025 14:24, Arnd Bergmann wrote:
> > From: Arnd Bergmann <arnd@arndb.de>
> >
> > When building with W=1, this variable is unused for configs with
> > CONFIG_CMA_SIZE_SEL_PERCENTAGE=y:
> >
> > kernel/dma/contiguous.c:67:26: error: 'size_bytes' defined but not used [-Werror=unused-const-variable=]
> >
> > Change this to a macro to avoid the warning.

> > -static const phys_addr_t size_bytes __initconst =
> > -	(phys_addr_t)CMA_SIZE_MBYTES * SZ_1M;
> > +#define size_bytes (CMA_SIZE_MBYTES * SZ_1M)

This had phys_addr_t type before, do we still have the platforms when it can be
bigger than 32-bit integer?

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH 10/10] [RESEND 3] dma/contiguous: avoid warning about unused size_bytes
Posted by Arnd Bergmann 10 months ago
On Wed, Apr 9, 2025, at 16:43, Andy Shevchenko wrote:
> On Wed, Apr 09, 2025 at 04:35:57PM +0200, Marek Szyprowski wrote:
>> On 09.04.2025 14:24, Arnd Bergmann wrote:
>> > From: Arnd Bergmann <arnd@arndb.de>
>> >
>> > When building with W=1, this variable is unused for configs with
>> > CONFIG_CMA_SIZE_SEL_PERCENTAGE=y:
>> >
>> > kernel/dma/contiguous.c:67:26: error: 'size_bytes' defined but not used [-Werror=unused-const-variable=]
>> >
>> > Change this to a macro to avoid the warning.
>
>> > -static const phys_addr_t size_bytes __initconst =
>> > -	(phys_addr_t)CMA_SIZE_MBYTES * SZ_1M;
>> > +#define size_bytes (CMA_SIZE_MBYTES * SZ_1M)
>
> This had phys_addr_t type before, do we still have the platforms when it can be
> bigger than 32-bit integer?

It can certainly be larger on 64-bit systems, I think I messed it
up. Marek, can you fix this to put back the cast, or should I
send a patch on top?

      Arnd
Re: [PATCH 10/10] [RESEND 3] dma/contiguous: avoid warning about unused size_bytes
Posted by Marek Szyprowski 10 months ago
On 09.04.2025 16:51, Arnd Bergmann wrote:
> On Wed, Apr 9, 2025, at 16:43, Andy Shevchenko wrote:
>> On Wed, Apr 09, 2025 at 04:35:57PM +0200, Marek Szyprowski wrote:
>>> On 09.04.2025 14:24, Arnd Bergmann wrote:
>>>> From: Arnd Bergmann <arnd@arndb.de>
>>>>
>>>> When building with W=1, this variable is unused for configs with
>>>> CONFIG_CMA_SIZE_SEL_PERCENTAGE=y:
>>>>
>>>> kernel/dma/contiguous.c:67:26: error: 'size_bytes' defined but not used [-Werror=unused-const-variable=]
>>>>
>>>> Change this to a macro to avoid the warning.
>>>>
>>>> -static const phys_addr_t size_bytes __initconst =
>>>> -	(phys_addr_t)CMA_SIZE_MBYTES * SZ_1M;
>>>> +#define size_bytes (CMA_SIZE_MBYTES * SZ_1M)
>> This had phys_addr_t type before, do we still have the platforms when it can be
>> bigger than 32-bit integer?
> It can certainly be larger on 64-bit systems, I think I messed it
> up. Marek, can you fix this to put back the cast, or should I
> send a patch on top?

I will drop this one then as I didn't push my branch yet and apply v2, 
which seems to be fine.

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland