Skip to contentSkip to conversation

remoteproc: omap_remoteproc: Fix compile errors about casting

PATCH In review Yuan Can 3 participants 4 messages Nov 18, 2022 – Dec 15, 2022 Remote processor (remoteproc)

lore
Share & tools
lore

Yuan Can

author
#0 lore raw

PATCH 1/1 remoteproc: omap_remoteproc: Fix compile errors about casting

The following errors was given when compiling
drivers/remoteproc/omap_remoteproc.c:

drivers/remoteproc/omap_remoteproc.c: In function ‘omap_rproc_mbox_callback’:
drivers/remoteproc/omap_remoteproc.c:497:12: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]

  u32 msg = (u32)data;
            ^
drivers/remoteproc/omap_remoteproc.c: In function ‘omap_rproc_kick’:
drivers/remoteproc/omap_remoteproc.c:548:39: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
  ret = mbox_send_message(oproc->mbox, (void *)vqid);
                                       ^
drivers/remoteproc/omap_remoteproc.c: In function ‘_omap_rproc_suspend’:
drivers/remoteproc/omap_remoteproc.c:783:39: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
  ret = mbox_send_message(oproc->mbox, (void *)suspend_msg);
                                       ^
In file included from ./include/linux/device.h:15,
                 from ./include/linux/node.h:18,
                 from ./include/linux/cpu.h:17,
                 from ./include/linux/of_device.h:5,
                 from drivers/remoteproc/omap_remoteproc.c:22:
drivers/remoteproc/omap_remoteproc.c: In function ‘omap_rproc_of_get_internal_memories’:
drivers/remoteproc/omap_remoteproc.c:1211:16: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 6 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=]
   dev_dbg(dev, "memory %8s: bus addr %pa size 0x%x va %pK da 0x%x\n",
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fixes 8841a66aaa7c ("mailbox/omap: adapt to the new mailbox framework")
Fixes 5f31b232c674 ("remoteproc/omap: Add support for runtime auto-suspend/resume")
Fixes 4a032199d3f7 ("remoteproc/omap: Add support to parse internal memories from DT")
---
 drivers/remoteproc/omap_remoteproc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/remoteproc/omap_remoteproc.c +4 -4
index 430fab0266ed..be43b5d85e2b 100644
@@ -494,7 +494,7 @@ static void omap_rproc_mbox_callback(struct mbox_client *client, void *data)
 						client);
 	struct device *dev = oproc->rproc->dev.parent;
 	const char *name = oproc->rproc->name;
-	u32 msg = (u32)data;
+	u32 msg = (u32)(unsigned long)data;
 
 	dev_dbg(dev, "mbox msg: 0x%x\n", msg);
 
@@ -545,7 +545,7 @@ static void omap_rproc_kick(struct rproc *rproc, int vqid)
 	}
 
 	/* send the index of the triggered virtqueue in the mailbox payload */
-	ret = mbox_send_message(oproc->mbox, (void *)vqid);
+	ret = mbox_send_message(oproc->mbox, (void *)(unsigned long)vqid);
 	if (ret < 0)
 		dev_err(dev, "failed to send mailbox message, status = %d\n",
 			ret);
@@ -780,7 +780,7 @@ static int _omap_rproc_suspend(struct rproc *rproc, bool auto_suspend)
 
 	reinit_completion(&oproc->pm_comp);
 	oproc->suspend_acked = false;
-	ret = mbox_send_message(oproc->mbox, (void *)suspend_msg);
+	ret = mbox_send_message(oproc->mbox, (void *)(unsigned long)suspend_msg);
 	if (ret < 0) {
 		dev_err(dev, "PM mbox_send_message failed: %d\n", ret);
 		return ret;
@@ -1208,7 +1208,7 @@ static int omap_rproc_of_get_internal_memories(struct platform_device *pdev,
 		oproc->mem[i].dev_addr = data->mems[i].dev_addr;
 		oproc->mem[i].size = resource_size(res);
 
-		dev_dbg(dev, "memory %8s: bus addr %pa size 0x%x va %pK da 0x%x\n",
+		dev_dbg(dev, "memory %8s: bus addr %pa size 0x%zx va %pK da 0x%x\n",
 			data->mems[i].name, &oproc->mem[i].bus_addr,
 			oproc->mem[i].size, oproc->mem[i].cpu_addr,
 			oproc->mem[i].dev_addr);
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 16 lines · Yuan Can

The following errors was given when compiling
drivers/remoteproc/omap_remoteproc.c:

drivers/remoteproc/omap_remoteproc.c: In function ‘omap_rproc_mbox_callback’:
drivers/remoteproc/omap_remoteproc.c:497:12: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]

  u32 msg = (u32)data;
            ^
drivers/remoteproc/omap_remoteproc.c: In function ‘omap_rproc_kick’:
drivers/remoteproc/omap_remoteproc.c:548:39: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
  ret = mbox_send_message(oproc->mbox, (void *)vqid);
                                       ^
drivers/remoteproc/omap_remoteproc.c: In function ‘_omap_rproc_suspend’:
drivers/remoteproc/omap_remoteproc.c:783:39: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
  ret = mbox_send_message(oproc->mbox, (void *)suspend_msg);
                                       ^

In file included from ./include/linux/device.h:15,

Quoted 9 lines
                 from ./include/linux/node.h:18,
                 from ./include/linux/cpu.h:17,
                 from ./include/linux/of_device.h:5,
                 from drivers/remoteproc/omap_remoteproc.c:22:
drivers/remoteproc/omap_remoteproc.c: In function ‘omap_rproc_of_get_internal_memories’:
drivers/remoteproc/omap_remoteproc.c:1211:16: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 6 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=]
   dev_dbg(dev, "memory %8s: bus addr %pa size 0x%x va %pK da 0x%x\n",
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I am not seeing any of this on my side with gcc 9.4.0:

$ arm-linux-gnueabihf-gcc --version
arm-linux-gnueabihf-gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0

What version do you use?

Thanks,
Mathieu

Quoted 51 lines
Fixes 8841a66aaa7c ("mailbox/omap: adapt to the new mailbox framework")
Fixes 5f31b232c674 ("remoteproc/omap: Add support for runtime auto-suspend/resume")
Fixes 4a032199d3f7 ("remoteproc/omap: Add support to parse internal memories from DT")
---
 drivers/remoteproc/omap_remoteproc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/remoteproc/omap_remoteproc.c +4 -4
index 430fab0266ed..be43b5d85e2b 100644
@@ -494,7 +494,7 @@ static void omap_rproc_mbox_callback(struct mbox_client *client, void *data)
 						client);
 	struct device *dev = oproc->rproc->dev.parent;
 	const char *name = oproc->rproc->name;
-	u32 msg = (u32)data;
+	u32 msg = (u32)(unsigned long)data;
 
 	dev_dbg(dev, "mbox msg: 0x%x\n", msg);
 
@@ -545,7 +545,7 @@ static void omap_rproc_kick(struct rproc *rproc, int vqid)
 	}
 
 	/* send the index of the triggered virtqueue in the mailbox payload */
-	ret = mbox_send_message(oproc->mbox, (void *)vqid);
+	ret = mbox_send_message(oproc->mbox, (void *)(unsigned long)vqid);
 	if (ret < 0)
 		dev_err(dev, "failed to send mailbox message, status = %d\n",
 			ret);
@@ -780,7 +780,7 @@ static int _omap_rproc_suspend(struct rproc *rproc, bool auto_suspend)
 
 	reinit_completion(&oproc->pm_comp);
 	oproc->suspend_acked = false;
-	ret = mbox_send_message(oproc->mbox, (void *)suspend_msg);
+	ret = mbox_send_message(oproc->mbox, (void *)(unsigned long)suspend_msg);
 	if (ret < 0) {
 		dev_err(dev, "PM mbox_send_message failed: %d\n", ret);
 		return ret;
@@ -1208,7 +1208,7 @@ static int omap_rproc_of_get_internal_memories(struct platform_device *pdev,
 		oproc->mem[i].dev_addr = data->mems[i].dev_addr;
 		oproc->mem[i].size = resource_size(res);
 
-		dev_dbg(dev, "memory %8s: bus addr %pa size 0x%x va %pK da 0x%x\n",
+		dev_dbg(dev, "memory %8s: bus addr %pa size 0x%zx va %pK da 0x%x\n",
 			data->mems[i].name, &oproc->mem[i].bus_addr,
 			oproc->mem[i].size, oproc->mem[i].cpu_addr,
 			oproc->mem[i].dev_addr);
Signature · 1 line
2.17.1
author
#2 lore raw
Quoted 26 lines · Mathieu Poirier
Quoted 16 lines · Yuan Can

The following errors was given when compiling
drivers/remoteproc/omap_remoteproc.c:

drivers/remoteproc/omap_remoteproc.c: In function ‘omap_rproc_mbox_callback’:
drivers/remoteproc/omap_remoteproc.c:497:12: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]

   u32 msg = (u32)data;
             ^
drivers/remoteproc/omap_remoteproc.c: In function ‘omap_rproc_kick’:
drivers/remoteproc/omap_remoteproc.c:548:39: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
   ret = mbox_send_message(oproc->mbox, (void *)vqid);
                                        ^
drivers/remoteproc/omap_remoteproc.c: In function ‘_omap_rproc_suspend’:
drivers/remoteproc/omap_remoteproc.c:783:39: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
   ret = mbox_send_message(oproc->mbox, (void *)suspend_msg);
                                        ^

In file included from ./include/linux/device.h:15,

Quoted 9 lines
                  from ./include/linux/node.h:18,
                  from ./include/linux/cpu.h:17,
                  from ./include/linux/of_device.h:5,
                  from drivers/remoteproc/omap_remoteproc.c:22:
drivers/remoteproc/omap_remoteproc.c: In function ‘omap_rproc_of_get_internal_memories’:
drivers/remoteproc/omap_remoteproc.c:1211:16: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 6 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=]
    dev_dbg(dev, "memory %8s: bus addr %pa size 0x%x va %pK da 0x%x\n",
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 6 lines

I am not seeing any of this on my side with gcc 9.4.0:

$ arm-linux-gnueabihf-gcc --version
arm-linux-gnueabihf-gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0

What version do you use?

Thanks for the reply, I was working with the wrong cross compiler, sorry about the noise.

Signature · 2 lines
Best regards,
Yuan Can
#3 lore raw

Hi Yuan,

Quoted 27 lines · Yuan Can
Quoted 26 lines · Mathieu Poirier
Quoted 25 lines · Yuan Can

The following errors was given when compiling
drivers/remoteproc/omap_remoteproc.c:

drivers/remoteproc/omap_remoteproc.c: In function ‘omap_rproc_mbox_callback’:
drivers/remoteproc/omap_remoteproc.c:497:12: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
   u32 msg = (u32)data;
             ^
drivers/remoteproc/omap_remoteproc.c: In function ‘omap_rproc_kick’:
drivers/remoteproc/omap_remoteproc.c:548:39: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
   ret = mbox_send_message(oproc->mbox, (void *)vqid);
                                        ^
drivers/remoteproc/omap_remoteproc.c: In function ‘_omap_rproc_suspend’:
drivers/remoteproc/omap_remoteproc.c:783:39: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
   ret = mbox_send_message(oproc->mbox, (void *)suspend_msg);
                                        ^
In file included from ./include/linux/device.h:15,
                  from ./include/linux/node.h:18,
                  from ./include/linux/cpu.h:17,
                  from ./include/linux/of_device.h:5,
                  from drivers/remoteproc/omap_remoteproc.c:22:
drivers/remoteproc/omap_remoteproc.c: In function ‘omap_rproc_of_get_internal_memories’:
drivers/remoteproc/omap_remoteproc.c:1211:16: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 6 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=] dev_dbg(dev, "memory %8s: bus addr %pa size 0x%x va %pK da 0x%x\n",
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Quoted 7 lines
Quoted 6 lines

I am not seeing any of this on my side with gcc 9.4.0:

$ arm-linux-gnueabihf-gcc --version
arm-linux-gnueabihf-gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0

What version do you use?

Thanks for the reply, I was working with the wrong cross compiler, sorry about the noise.

Don't worry about being noisy ;) What would have helped here is if you mentioned the version of the compiler you used in the commit description (usually the output of '$CC --version').

Back to your patch content, the format string fix is correct (the 3rd hunk).

Regard,

Phil.