[dpdk-dev] bus/fslmc: use PRIu64 instead of llX in format specifier

Message ID 5438d3242ebb9d995d0a52a63feba80efd783e6f.1523595487.git.gowrishankar.m@linux.vnet.ibm.com (mailing list archive)
State Superseded, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Gowrishankar April 13, 2018, 5:04 a.m. UTC
  From: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>

Instead of llX, use C99 standard "PRIu64" in format specifier. Former one
breaks compile in ppc64le.

Fixes: c2c167fdb3 ("bus/fslmc: support memory event callbacks for VFIO")

Signed-off-by: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
--
In file included from dpdk/drivers/bus/fslmc/fslmc_vfio.c:37:0:
dpdk/drivers/bus/fslmc/fslmc_vfio.c: In function ‘fslmc_map_dma’:
dpdk/drivers/bus/fslmc/fslmc_logs.h:18:44: error: format ‘%llX’ expects argument of type ‘long long unsigned int’, but argument 5 has type ‘__u64 {aka long unsigned int}’ [-Werror=format=]
  rte_log(RTE_LOG_DEBUG, dpaa2_logtype_bus, "fslmc: %s(): " fmt "\n", \
                                            ^
dpdk/drivers/bus/fslmc/fslmc_vfio.c:272:2: note: in expansion of macro ‘DPAA2_BUS_DEBUG’
  DPAA2_BUS_DEBUG("--> Map address: %llX, size: 0x%llX",
  ^~~~~~~~~~~~~~~
dpdk/drivers/bus/fslmc/fslmc_vfio.c:272:39: note: format string is defined here
  DPAA2_BUS_DEBUG("--> Map address: %llX, size: 0x%llX",
                                    ~~~^
                                    %lX

 drivers/bus/fslmc/fslmc_vfio.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Comments

Hemant Agrawal April 13, 2018, 7:09 a.m. UTC | #1
On 4/13/2018 12:40 PM, Shreyansh Jain wrote:
> On Friday 13 April 2018 10:34 AM, Gowrishankar wrote:
>> From: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
>>
>> Instead of llX, use C99 standard "PRIu64" in format specifier. Former one
>> breaks compile in ppc64le.
>>
>> Fixes: c2c167fdb3 ("bus/fslmc: support memory event callbacks for VFIO")
>>
>> Signed-off-by: Gowrishankar Muthukrishnan 
>> <gowrishankar.m@linux.vnet.ibm.com>
>> -- 
> 
> Thanks for fixing.
> 
> Acked-by: Shreyansh Jain <shreyansh.jain@nxp.com>
NACK

This is breaking the x86_64-native-linuxapp-gcc  compilation. I am 
looking into it.
  
Shreyansh Jain April 13, 2018, 7:10 a.m. UTC | #2
On Friday 13 April 2018 10:34 AM, Gowrishankar wrote:
> From: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
> 
> Instead of llX, use C99 standard "PRIu64" in format specifier. Former one
> breaks compile in ppc64le.
> 
> Fixes: c2c167fdb3 ("bus/fslmc: support memory event callbacks for VFIO")
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
> --

Thanks for fixing.

Acked-by: Shreyansh Jain <shreyansh.jain@nxp.com>
  
Hemant Agrawal April 13, 2018, 7:37 a.m. UTC | #3
Hi Gowrishankar,

On 4/13/2018 10:34 AM, Gowrishankar wrote:
> From: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
> 
> Instead of llX, use C99 standard "PRIu64" in format specifier. Former one
> breaks compile in ppc64le.
> 
> Fixes: c2c167fdb3 ("bus/fslmc: support memory event callbacks for VFIO")
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
> --
> In file included from dpdk/drivers/bus/fslmc/fslmc_vfio.c:37:0:
> dpdk/drivers/bus/fslmc/fslmc_vfio.c: In function ‘fslmc_map_dma’:
> dpdk/drivers/bus/fslmc/fslmc_logs.h:18:44: error: format ‘%llX’ expects argument of type ‘long long unsigned int’, but argument 5 has type ‘__u64 {aka long unsigned int}’ [-Werror=format=]

So, powerpc64LE is taking __u64 as long unsigned int, while x86_64 
compiler is taking it as long long unsigned it.

>    rte_log(RTE_LOG_DEBUG, dpaa2_logtype_bus, "fslmc: %s(): " fmt "\n", \
>                                              ^
> dpdk/drivers/bus/fslmc/fslmc_vfio.c:272:2: note: in expansion of macro ‘DPAA2_BUS_DEBUG’
>    DPAA2_BUS_DEBUG("--> Map address: %llX, size: 0x%llX",
>    ^~~~~~~~~~~~~~~
> dpdk/drivers/bus/fslmc/fslmc_vfio.c:272:39: note: format string is defined here
>    DPAA2_BUS_DEBUG("--> Map address: %llX, size: 0x%llX",
>                                      ~~~^
>                                      %lX
> 
>   drivers/bus/fslmc/fslmc_vfio.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
> index 4036e82..a003a7d 100644
> --- a/drivers/bus/fslmc/fslmc_vfio.c
> +++ b/drivers/bus/fslmc/fslmc_vfio.c
> @@ -270,7 +270,7 @@ static int vfio_map_irq_region(struct fslmc_vfio_group *group)
>   		return -1;
>   	}
>   
> -	DPAA2_BUS_DEBUG("--> Map address: %llX, size: 0x%llX",
> +	DPAA2_BUS_DEBUG("--> Map address: %"PRIu64", size: 0x%"PRIu64"",
>   			dma_map.vaddr, dma_map.size);

You should also type cast the variables to avoid compilation issue on x86.
-                       dma_map.vaddr, dma_map.size);
+                       (uint64_t)dma_map.vaddr, uint64_t)dma_map.size);

The same change is to be done at other two places as well in your patch.

Please check compilation for x86_64 and i686, the patchwork compilation 
check is running late.

>   	ret = ioctl(group->container->fd, VFIO_IOMMU_MAP_DMA, &dma_map);
>   	if (ret) {
> @@ -303,7 +303,7 @@ static int vfio_map_irq_region(struct fslmc_vfio_group *group)
>   		return -1;
>   	}
>   
> -	DPAA2_BUS_DEBUG("--> Unmap address: %llX, size: 0x%llX",
> +	DPAA2_BUS_DEBUG("--> Unmap address: %"PRIu64", size: 0x%"PRIu64"",
>   			dma_unmap.iova, dma_unmap.size);
>   	ret = ioctl(group->container->fd, VFIO_IOMMU_UNMAP_DMA, &dma_unmap);
>   	if (ret) {
> @@ -401,7 +401,7 @@ static int64_t vfio_map_mcp_obj(struct fslmc_vfio_group *group, char *mcp_obj)
>   		goto MC_FAILURE;
>   	}
>   
> -	DPAA2_BUS_DEBUG("Region offset = %llx  , region size = %llx",
> +	DPAA2_BUS_DEBUG("Region offset = %"PRIu64"  , region size = %"PRIu64"",
>   			reg_info.offset, reg_info.size);
>   
>   	v_addr = (size_t)mmap(NULL, reg_info.size,
>
  
Thomas Monjalon April 13, 2018, 7:41 a.m. UTC | #4
13/04/2018 07:04, Gowrishankar:
> -	DPAA2_BUS_DEBUG("--> Map address: %llX, size: 0x%llX",
> +	DPAA2_BUS_DEBUG("--> Map address: %"PRIu64", size: 0x%"PRIu64"",

You cannot replace hexadecimal by decimal.
You need to use PRIx64.
  
Gowrishankar April 13, 2018, 8:43 a.m. UTC | #5
On Friday 13 April 2018 02:26 PM, Shreyansh Jain wrote:
> On Friday 13 April 2018 01:11 PM, Thomas Monjalon wrote:
>> 13/04/2018 07:04, Gowrishankar:
>>> -    DPAA2_BUS_DEBUG("--> Map address: %llX, size: 0x%llX",
>>> +    DPAA2_BUS_DEBUG("--> Map address: %"PRIu64", size: 0x%"PRIu64"",
>>
>> You cannot replace hexadecimal by decimal.
>> You need to use PRIx64.
>>
>>
>
> Now that Thomas has pointed out, I think the log message can be 
> improved. Len as hex is not helpful and is out of sync with other 
> messages in this file.
>
> While on this, I think it should be corrected.
> I will fix this.
>
> @gowrishankar, I will post a patch in reply to your patch - can you 
> please help me with ppc64le check? I will take care of Hemant's comment.

Yup, I check for it. Thanks Shreyansh.

>
> -
> Shreyansh
>
  
Shreyansh Jain April 13, 2018, 8:56 a.m. UTC | #6
On Friday 13 April 2018 01:11 PM, Thomas Monjalon wrote:
> 13/04/2018 07:04, Gowrishankar:
>> -	DPAA2_BUS_DEBUG("--> Map address: %llX, size: 0x%llX",
>> +	DPAA2_BUS_DEBUG("--> Map address: %"PRIu64", size: 0x%"PRIu64"",
> 
> You cannot replace hexadecimal by decimal.
> You need to use PRIx64.
> 
> 

Now that Thomas has pointed out, I think the log message can be 
improved. Len as hex is not helpful and is out of sync with other 
messages in this file.

While on this, I think it should be corrected.
I will fix this.

@gowrishankar, I will post a patch in reply to your patch - can you 
please help me with ppc64le check? I will take care of Hemant's comment.

-
Shreyansh
  
Shreyansh Jain April 13, 2018, 10:37 a.m. UTC | #7
On Friday 13 April 2018 02:13 PM, gowrishankar muthukrishnan wrote:
> On Friday 13 April 2018 02:26 PM, Shreyansh Jain wrote:
>> On Friday 13 April 2018 01:11 PM, Thomas Monjalon wrote:
>>> 13/04/2018 07:04, Gowrishankar:
>>>> -    DPAA2_BUS_DEBUG("--> Map address: %llX, size: 0x%llX",
>>>> +    DPAA2_BUS_DEBUG("--> Map address: %"PRIu64", size: 0x%"PRIu64"",
>>>
>>> You cannot replace hexadecimal by decimal.
>>> You need to use PRIx64.
>>>
>>>
>>
>> Now that Thomas has pointed out, I think the log message can be 
>> improved. Len as hex is not helpful and is out of sync with other 
>> messages in this file.
>>
>> While on this, I think it should be corrected.
>> I will fix this.
>>
>> @gowrishankar, I will post a patch in reply to your patch - can you 
>> please help me with ppc64le check? I will take care of Hemant's comment.
> 
> Yup, I check for it. Thanks Shreyansh.
> 

Can you please check this:

--->8---
@@ -270,8 +270,8 @@ fslmc_map_dma(uint64_t vaddr, rte_iova_t iovaddr 
__rte_unused, size_t len)
                 return -1;
         }

-       DPAA2_BUS_DEBUG("--> Map address: %llX, size: 0x%llX",
-                       dma_map.vaddr, dma_map.size);
+       DPAA2_BUS_DEBUG("--> Map address: 0x%"PRIx64", size: %"PRIu64"",
+                       (uint64_t)dma_map.vaddr, (uint64_t)dma_map.size);
         ret = ioctl(group->container->fd, VFIO_IOMMU_MAP_DMA, &dma_map);
         if (ret) {
                 DPAA2_BUS_ERR("VFIO_IOMMU_MAP_DMA API(errno = %d)",
@@ -303,8 +303,8 @@ fslmc_unmap_dma(uint64_t vaddr, uint64_t iovaddr 
__rte_unused, size_t len)
                 return -1;
         }

-       DPAA2_BUS_DEBUG("--> Unmap address: %llX, size: 0x%llX",
-                       dma_unmap.iova, dma_unmap.size);
+       DPAA2_BUS_DEBUG("--> Unmap address: 0x%"PRIx64", size: %"PRIu64"",
+                       (uint64_t)dma_unmap.iova, (uint64_t)dma_unmap.size);
         ret = ioctl(group->container->fd, VFIO_IOMMU_UNMAP_DMA, 
&dma_unmap);
         if (ret) {
                 DPAA2_BUS_ERR("VFIO_IOMMU_UNMAP_DMA API(errno = %d)",
@@ -401,8 +401,8 @@ static int64_t vfio_map_mcp_obj(struct 
fslmc_vfio_group *group, char *mcp_obj)
                 goto MC_FAILURE;
         }

-       DPAA2_BUS_DEBUG("Region offset = %llx  , region size = %llx",
-                       reg_info.offset, reg_info.size);
+       DPAA2_BUS_DEBUG("Region offset = 0x%"PRIx64", region size = 
%"PRIu64"",
+                       (uint64_t)reg_info.offset, (uint64_t)reg_info.size);

         v_addr = (size_t)mmap(NULL, reg_info.size,
                 PROT_WRITE | PROT_READ, MAP_SHARED,
--->8---

gcc for i686/x86_64/ARM64 are compiling fine for me.

If this works fine, feel free to use it in your patch.

-
Shreyansh
  

Patch

diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index 4036e82..a003a7d 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -270,7 +270,7 @@  static int vfio_map_irq_region(struct fslmc_vfio_group *group)
 		return -1;
 	}
 
-	DPAA2_BUS_DEBUG("--> Map address: %llX, size: 0x%llX",
+	DPAA2_BUS_DEBUG("--> Map address: %"PRIu64", size: 0x%"PRIu64"",
 			dma_map.vaddr, dma_map.size);
 	ret = ioctl(group->container->fd, VFIO_IOMMU_MAP_DMA, &dma_map);
 	if (ret) {
@@ -303,7 +303,7 @@  static int vfio_map_irq_region(struct fslmc_vfio_group *group)
 		return -1;
 	}
 
-	DPAA2_BUS_DEBUG("--> Unmap address: %llX, size: 0x%llX",
+	DPAA2_BUS_DEBUG("--> Unmap address: %"PRIu64", size: 0x%"PRIu64"",
 			dma_unmap.iova, dma_unmap.size);
 	ret = ioctl(group->container->fd, VFIO_IOMMU_UNMAP_DMA, &dma_unmap);
 	if (ret) {
@@ -401,7 +401,7 @@  static int64_t vfio_map_mcp_obj(struct fslmc_vfio_group *group, char *mcp_obj)
 		goto MC_FAILURE;
 	}
 
-	DPAA2_BUS_DEBUG("Region offset = %llx  , region size = %llx",
+	DPAA2_BUS_DEBUG("Region offset = %"PRIu64"  , region size = %"PRIu64"",
 			reg_info.offset, reg_info.size);
 
 	v_addr = (size_t)mmap(NULL, reg_info.size,