public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] remoteproc: stm32: use correct format strings on 64-bit
@ 2023-06-09 12:05 Arnd Bergmann
  2023-06-12 14:10 ` Arnaud POULIQUEN
  2023-06-15 22:40 ` Randy Dunlap
  0 siblings, 2 replies; 6+ messages in thread
From: Arnd Bergmann @ 2023-06-09 12:05 UTC (permalink / raw)
  To: Bjorn Andersson, Mathieu Poirier, Maxime Coquelin,
	Alexandre Torgue
  Cc: Arnd Bergmann, Ben Levinsky, Tanmay Shah, Arnaud Pouliquen,
	Uwe Kleine-König, Dan Carpenter, linux-remoteproc,
	linux-kernel, linux-stm32, linux-arm-kernel

From: Arnd Bergmann <arnd@arndb.de>

With CONFIG_ARCH_STM32 making it into arch/arm64, a couple of format
strings no longer work, since they rely on size_t being compatible
with %x, or they print an 'int' using %z:

drivers/remoteproc/stm32_rproc.c: In function 'stm32_rproc_mem_alloc':
drivers/remoteproc/stm32_rproc.c:122:22: error: format '%x' expects argument of type 'unsigned int', but argument 5 has type 'size_t' {aka 'long unsigned int'} [-Werror=format=]
drivers/remoteproc/stm32_rproc.c:122:40: note: format string is defined here
  122 |         dev_dbg(dev, "map memory: %pa+%x\n", &mem->dma, mem->len);
      |                                       ~^
      |                                        |
      |                                        unsigned int
      |                                       %lx
drivers/remoteproc/stm32_rproc.c:125:30: error: format '%x' expects argument of type 'unsigned int', but argument 4 has type 'size_t' {aka 'long unsigned int'} [-Werror=format=]
drivers/remoteproc/stm32_rproc.c:125:65: note: format string is defined here
  125 |                 dev_err(dev, "Unable to map memory region: %pa+%x\n",
      |                                                                ~^
      |                                                                 |
      |                                                                 unsigned int
      |                                                                %lx
drivers/remoteproc/stm32_rproc.c: In function 'stm32_rproc_get_loaded_rsc_table':
drivers/remoteproc/stm32_rproc.c:646:30: error: format '%zx' expects argument of type 'size_t', but argument 4 has type 'int' [-Werror=format=]
drivers/remoteproc/stm32_rproc.c:646:66: note: format string is defined here
  646 |                 dev_err(dev, "Unable to map memory region: %pa+%zx\n",
      |                                                                ~~^
      |                                                                  |
      |                                                                  long unsigned int
      |                                                                %x

Fix up all three instances to work across architectures, and enable
compile testing for this driver to ensure it builds everywhere.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/remoteproc/Kconfig       | 2 +-
 drivers/remoteproc/stm32_rproc.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index a850e9f486dd6..48845dc8fa852 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -313,7 +313,7 @@ config ST_SLIM_REMOTEPROC
 
 config STM32_RPROC
 	tristate "STM32 remoteproc support"
-	depends on ARCH_STM32
+	depends on ARCH_STM32 || COMPILE_TEST
 	depends on REMOTEPROC
 	select MAILBOX
 	help
diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c
index a7457777aae43..cf073bac79f73 100644
--- a/drivers/remoteproc/stm32_rproc.c
+++ b/drivers/remoteproc/stm32_rproc.c
@@ -119,10 +119,10 @@ static int stm32_rproc_mem_alloc(struct rproc *rproc,
 	struct device *dev = rproc->dev.parent;
 	void *va;
 
-	dev_dbg(dev, "map memory: %pa+%x\n", &mem->dma, mem->len);
+	dev_dbg(dev, "map memory: %pad+%zx\n", &mem->dma, mem->len);
 	va = ioremap_wc(mem->dma, mem->len);
 	if (IS_ERR_OR_NULL(va)) {
-		dev_err(dev, "Unable to map memory region: %pa+%x\n",
+		dev_err(dev, "Unable to map memory region: %pad+0x%zx\n",
 			&mem->dma, mem->len);
 		return -ENOMEM;
 	}
@@ -643,7 +643,7 @@ stm32_rproc_get_loaded_rsc_table(struct rproc *rproc, size_t *table_sz)
 
 	ddata->rsc_va = devm_ioremap_wc(dev, rsc_pa, RSC_TBL_SIZE);
 	if (IS_ERR_OR_NULL(ddata->rsc_va)) {
-		dev_err(dev, "Unable to map memory region: %pa+%zx\n",
+		dev_err(dev, "Unable to map memory region: %pa+%x\n",
 			&rsc_pa, RSC_TBL_SIZE);
 		ddata->rsc_va = NULL;
 		return ERR_PTR(-ENOMEM);
-- 
2.39.2


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

* Re: [PATCH] remoteproc: stm32: use correct format strings on 64-bit
  2023-06-09 12:05 [PATCH] remoteproc: stm32: use correct format strings on 64-bit Arnd Bergmann
@ 2023-06-12 14:10 ` Arnaud POULIQUEN
  2023-06-12 14:17   ` Arnd Bergmann
  2023-06-15 22:40 ` Randy Dunlap
  1 sibling, 1 reply; 6+ messages in thread
From: Arnaud POULIQUEN @ 2023-06-12 14:10 UTC (permalink / raw)
  To: Arnd Bergmann, Bjorn Andersson, Mathieu Poirier, Maxime Coquelin,
	Alexandre Torgue
  Cc: Arnd Bergmann, Ben Levinsky, Tanmay Shah, Uwe Kleine-König,
	Dan Carpenter, linux-remoteproc, linux-kernel, linux-stm32,
	linux-arm-kernel

Hi Arnd

On 6/9/23 14:05, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> With CONFIG_ARCH_STM32 making it into arch/arm64, a couple of format
> strings no longer work, since they rely on size_t being compatible
> with %x, or they print an 'int' using %z:
> 
> drivers/remoteproc/stm32_rproc.c: In function 'stm32_rproc_mem_alloc':
> drivers/remoteproc/stm32_rproc.c:122:22: error: format '%x' expects argument of type 'unsigned int', but argument 5 has type 'size_t' {aka 'long unsigned int'} [-Werror=format=]
> drivers/remoteproc/stm32_rproc.c:122:40: note: format string is defined here
>   122 |         dev_dbg(dev, "map memory: %pa+%x\n", &mem->dma, mem->len);
>       |                                       ~^
>       |                                        |
>       |                                        unsigned int
>       |                                       %lx
> drivers/remoteproc/stm32_rproc.c:125:30: error: format '%x' expects argument of type 'unsigned int', but argument 4 has type 'size_t' {aka 'long unsigned int'} [-Werror=format=]
> drivers/remoteproc/stm32_rproc.c:125:65: note: format string is defined here
>   125 |                 dev_err(dev, "Unable to map memory region: %pa+%x\n",
>       |                                                                ~^
>       |                                                                 |
>       |                                                                 unsigned int
>       |                                                                %lx
> drivers/remoteproc/stm32_rproc.c: In function 'stm32_rproc_get_loaded_rsc_table':
> drivers/remoteproc/stm32_rproc.c:646:30: error: format '%zx' expects argument of type 'size_t', but argument 4 has type 'int' [-Werror=format=]
> drivers/remoteproc/stm32_rproc.c:646:66: note: format string is defined here
>   646 |                 dev_err(dev, "Unable to map memory region: %pa+%zx\n",
>       |                                                                ~~^
>       |                                                                  |
>       |                                                                  long unsigned int
>       |                                                                %x
> 
> Fix up all three instances to work across architectures, and enable
> compile testing for this driver to ensure it builds everywhere.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>


I also have it for the stm32mp2 :)

Please find a remark below , with or without that

Reviewed-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>

> ---
>  drivers/remoteproc/Kconfig       | 2 +-
>  drivers/remoteproc/stm32_rproc.c | 6 +++---
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
> index a850e9f486dd6..48845dc8fa852 100644
> --- a/drivers/remoteproc/Kconfig
> +++ b/drivers/remoteproc/Kconfig
> @@ -313,7 +313,7 @@ config ST_SLIM_REMOTEPROC
>  
>  config STM32_RPROC
>  	tristate "STM32 remoteproc support"
> -	depends on ARCH_STM32
> +	depends on ARCH_STM32 || COMPILE_TEST
>  	depends on REMOTEPROC
>  	select MAILBOX
>  	help
> diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c
> index a7457777aae43..cf073bac79f73 100644
> --- a/drivers/remoteproc/stm32_rproc.c
> +++ b/drivers/remoteproc/stm32_rproc.c
> @@ -119,10 +119,10 @@ static int stm32_rproc_mem_alloc(struct rproc *rproc,
>  	struct device *dev = rproc->dev.parent;
>  	void *va;
>  
> -	dev_dbg(dev, "map memory: %pa+%x\n", &mem->dma, mem->len);
> +	dev_dbg(dev, "map memory: %pad+%zx\n", &mem->dma, mem->len);
>  	va = ioremap_wc(mem->dma, mem->len);
>  	if (IS_ERR_OR_NULL(va)) {
> -		dev_err(dev, "Unable to map memory region: %pa+%x\n",
> +		dev_err(dev, "Unable to map memory region: %pad+0x%zx\n",
>  			&mem->dma, mem->len);
>  		return -ENOMEM;
>  	}
> @@ -643,7 +643,7 @@ stm32_rproc_get_loaded_rsc_table(struct rproc *rproc, size_t *table_sz)
>  
>  	ddata->rsc_va = devm_ioremap_wc(dev, rsc_pa, RSC_TBL_SIZE);
>  	if (IS_ERR_OR_NULL(ddata->rsc_va)) {
> -		dev_err(dev, "Unable to map memory region: %pa+%zx\n",
> +		dev_err(dev, "Unable to map memory region: %pa+%x\n",
>  			&rsc_pa, RSC_TBL_SIZE);

What about cast the RSC_TBL_SIZE define instead to ensure to be independent from
the arch and to match with the use of RSC_TBL_SIZE?

#define RSC_TBL_SIZE		((size_t)1024)

Thanks,
Arnaud

>  		ddata->rsc_va = NULL;
>  		return ERR_PTR(-ENOMEM);

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

* Re: [PATCH] remoteproc: stm32: use correct format strings on 64-bit
  2023-06-12 14:10 ` Arnaud POULIQUEN
@ 2023-06-12 14:17   ` Arnd Bergmann
  2023-06-13 10:05     ` Arnaud POULIQUEN
  2023-06-13 10:05     ` Alexandre TORGUE
  0 siblings, 2 replies; 6+ messages in thread
From: Arnd Bergmann @ 2023-06-12 14:17 UTC (permalink / raw)
  To: Arnaud POULIQUEN, Arnd Bergmann, Bjorn Andersson, Mathieu Poirier,
	Maxime Coquelin, Alexandre Torgue
  Cc: Ben Levinsky, Tanmay Shah, Uwe Kleine-König, Dan Carpenter,
	linux-remoteproc, linux-kernel, linux-stm32, linux-arm-kernel

On Mon, Jun 12, 2023, at 16:10, Arnaud POULIQUEN wrote:

>>  	ddata->rsc_va = devm_ioremap_wc(dev, rsc_pa, RSC_TBL_SIZE);
>>  	if (IS_ERR_OR_NULL(ddata->rsc_va)) {
>> -		dev_err(dev, "Unable to map memory region: %pa+%zx\n",
>> +		dev_err(dev, "Unable to map memory region: %pa+%x\n",
>>  			&rsc_pa, RSC_TBL_SIZE);
>
> What about cast the RSC_TBL_SIZE define instead to ensure to be independent from
> the arch and to match with the use of RSC_TBL_SIZE?
>
> #define RSC_TBL_SIZE		((size_t)1024)

I have no objection to that, but I don't see it doing anything good either,
as this is a constant value that will always work.

     Arnd

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

* Re: [PATCH] remoteproc: stm32: use correct format strings on 64-bit
  2023-06-12 14:17   ` Arnd Bergmann
@ 2023-06-13 10:05     ` Arnaud POULIQUEN
  2023-06-13 10:05     ` Alexandre TORGUE
  1 sibling, 0 replies; 6+ messages in thread
From: Arnaud POULIQUEN @ 2023-06-13 10:05 UTC (permalink / raw)
  To: Arnd Bergmann, Arnd Bergmann, Bjorn Andersson, Mathieu Poirier,
	Maxime Coquelin, Alexandre Torgue
  Cc: Ben Levinsky, Tanmay Shah, Uwe Kleine-König, Dan Carpenter,
	linux-remoteproc, linux-kernel, linux-stm32, linux-arm-kernel



On 6/12/23 16:17, Arnd Bergmann wrote:
> On Mon, Jun 12, 2023, at 16:10, Arnaud POULIQUEN wrote:
> 
>>>  	ddata->rsc_va = devm_ioremap_wc(dev, rsc_pa, RSC_TBL_SIZE);
>>>  	if (IS_ERR_OR_NULL(ddata->rsc_va)) {
>>> -		dev_err(dev, "Unable to map memory region: %pa+%zx\n",
>>> +		dev_err(dev, "Unable to map memory region: %pa+%x\n",
>>>  			&rsc_pa, RSC_TBL_SIZE);
>>
>> What about cast the RSC_TBL_SIZE define instead to ensure to be independent from
>> the arch and to match with the use of RSC_TBL_SIZE?
>>
>> #define RSC_TBL_SIZE		((size_t)1024)
> 
> I have no objection to that, but I don't see it doing anything good either,
> as this is a constant value that will always work.
> 
>      Arnd

It was just to avoid to have the constant used with different types in the code
But that's nitpicking, let's keep your proposal.

Thanks,
Arnaud

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

* Re: [PATCH] remoteproc: stm32: use correct format strings on 64-bit
  2023-06-12 14:17   ` Arnd Bergmann
  2023-06-13 10:05     ` Arnaud POULIQUEN
@ 2023-06-13 10:05     ` Alexandre TORGUE
  1 sibling, 0 replies; 6+ messages in thread
From: Alexandre TORGUE @ 2023-06-13 10:05 UTC (permalink / raw)
  To: Arnd Bergmann, Arnaud POULIQUEN, Arnd Bergmann, Bjorn Andersson,
	Mathieu Poirier, Maxime Coquelin
  Cc: Ben Levinsky, Tanmay Shah, Uwe Kleine-König, Dan Carpenter,
	linux-remoteproc, linux-kernel, linux-stm32, linux-arm-kernel

Hi Arnd

On 6/12/23 16:17, Arnd Bergmann wrote:
> On Mon, Jun 12, 2023, at 16:10, Arnaud POULIQUEN wrote:
> 
>>>   	ddata->rsc_va = devm_ioremap_wc(dev, rsc_pa, RSC_TBL_SIZE);
>>>   	if (IS_ERR_OR_NULL(ddata->rsc_va)) {
>>> -		dev_err(dev, "Unable to map memory region: %pa+%zx\n",
>>> +		dev_err(dev, "Unable to map memory region: %pa+%x\n",
>>>   			&rsc_pa, RSC_TBL_SIZE);
>>
>> What about cast the RSC_TBL_SIZE define instead to ensure to be independent from
>> the arch and to match with the use of RSC_TBL_SIZE?
>>
>> #define RSC_TBL_SIZE		((size_t)1024)
> 
> I have no objection to that, but I don't see it doing anything good either,
> as this is a constant value that will always work.
> 
>       Arnd

The kernel robot shot me for my STM32MP25  PR due to this issue. Do I 
have to resend something ?

Thanks
Alex

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

* Re: [PATCH] remoteproc: stm32: use correct format strings on 64-bit
  2023-06-09 12:05 [PATCH] remoteproc: stm32: use correct format strings on 64-bit Arnd Bergmann
  2023-06-12 14:10 ` Arnaud POULIQUEN
@ 2023-06-15 22:40 ` Randy Dunlap
  1 sibling, 0 replies; 6+ messages in thread
From: Randy Dunlap @ 2023-06-15 22:40 UTC (permalink / raw)
  To: Arnd Bergmann, Bjorn Andersson, Mathieu Poirier, Maxime Coquelin,
	Alexandre Torgue
  Cc: Arnd Bergmann, Ben Levinsky, Tanmay Shah, Arnaud Pouliquen,
	Uwe Kleine-König, Dan Carpenter, linux-remoteproc,
	linux-kernel, linux-stm32, linux-arm-kernel



On 6/9/23 05:05, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> With CONFIG_ARCH_STM32 making it into arch/arm64, a couple of format
> strings no longer work, since they rely on size_t being compatible
> with %x, or they print an 'int' using %z:
> 
> drivers/remoteproc/stm32_rproc.c: In function 'stm32_rproc_mem_alloc':
> drivers/remoteproc/stm32_rproc.c:122:22: error: format '%x' expects argument of type 'unsigned int', but argument 5 has type 'size_t' {aka 'long unsigned int'} [-Werror=format=]
> drivers/remoteproc/stm32_rproc.c:122:40: note: format string is defined here
>   122 |         dev_dbg(dev, "map memory: %pa+%x\n", &mem->dma, mem->len);
>       |                                       ~^
>       |                                        |
>       |                                        unsigned int
>       |                                       %lx
> drivers/remoteproc/stm32_rproc.c:125:30: error: format '%x' expects argument of type 'unsigned int', but argument 4 has type 'size_t' {aka 'long unsigned int'} [-Werror=format=]
> drivers/remoteproc/stm32_rproc.c:125:65: note: format string is defined here
>   125 |                 dev_err(dev, "Unable to map memory region: %pa+%x\n",
>       |                                                                ~^
>       |                                                                 |
>       |                                                                 unsigned int
>       |                                                                %lx
> drivers/remoteproc/stm32_rproc.c: In function 'stm32_rproc_get_loaded_rsc_table':
> drivers/remoteproc/stm32_rproc.c:646:30: error: format '%zx' expects argument of type 'size_t', but argument 4 has type 'int' [-Werror=format=]
> drivers/remoteproc/stm32_rproc.c:646:66: note: format string is defined here
>   646 |                 dev_err(dev, "Unable to map memory region: %pa+%zx\n",
>       |                                                                ~~^
>       |                                                                  |
>       |                                                                  long unsigned int
>       |                                                                %x
> 
> Fix up all three instances to work across architectures, and enable
> compile testing for this driver to ensure it builds everywhere.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Acked-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org> # build-tested

Thanks.

> ---
>  drivers/remoteproc/Kconfig       | 2 +-
>  drivers/remoteproc/stm32_rproc.c | 6 +++---
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
> index a850e9f486dd6..48845dc8fa852 100644
> --- a/drivers/remoteproc/Kconfig
> +++ b/drivers/remoteproc/Kconfig
> @@ -313,7 +313,7 @@ config ST_SLIM_REMOTEPROC
>  
>  config STM32_RPROC
>  	tristate "STM32 remoteproc support"
> -	depends on ARCH_STM32
> +	depends on ARCH_STM32 || COMPILE_TEST
>  	depends on REMOTEPROC
>  	select MAILBOX
>  	help
> diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c
> index a7457777aae43..cf073bac79f73 100644
> --- a/drivers/remoteproc/stm32_rproc.c
> +++ b/drivers/remoteproc/stm32_rproc.c
> @@ -119,10 +119,10 @@ static int stm32_rproc_mem_alloc(struct rproc *rproc,
>  	struct device *dev = rproc->dev.parent;
>  	void *va;
>  
> -	dev_dbg(dev, "map memory: %pa+%x\n", &mem->dma, mem->len);
> +	dev_dbg(dev, "map memory: %pad+%zx\n", &mem->dma, mem->len);
>  	va = ioremap_wc(mem->dma, mem->len);
>  	if (IS_ERR_OR_NULL(va)) {
> -		dev_err(dev, "Unable to map memory region: %pa+%x\n",
> +		dev_err(dev, "Unable to map memory region: %pad+0x%zx\n",
>  			&mem->dma, mem->len);
>  		return -ENOMEM;
>  	}
> @@ -643,7 +643,7 @@ stm32_rproc_get_loaded_rsc_table(struct rproc *rproc, size_t *table_sz)
>  
>  	ddata->rsc_va = devm_ioremap_wc(dev, rsc_pa, RSC_TBL_SIZE);
>  	if (IS_ERR_OR_NULL(ddata->rsc_va)) {
> -		dev_err(dev, "Unable to map memory region: %pa+%zx\n",
> +		dev_err(dev, "Unable to map memory region: %pa+%x\n",
>  			&rsc_pa, RSC_TBL_SIZE);
>  		ddata->rsc_va = NULL;
>  		return ERR_PTR(-ENOMEM);

-- 
~Randy

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

end of thread, other threads:[~2023-06-15 22:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-09 12:05 [PATCH] remoteproc: stm32: use correct format strings on 64-bit Arnd Bergmann
2023-06-12 14:10 ` Arnaud POULIQUEN
2023-06-12 14:17   ` Arnd Bergmann
2023-06-13 10:05     ` Arnaud POULIQUEN
2023-06-13 10:05     ` Alexandre TORGUE
2023-06-15 22:40 ` Randy Dunlap

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox