linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: nixge: fix warnings on 32-bit platforms
@ 2018-09-26 12:47 Arnd Bergmann
  2018-09-26 16:03 ` Moritz Fischer
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2018-09-26 12:47 UTC (permalink / raw)
  To: David S. Miller, Moritz Fischer; +Cc: Arnd Bergmann, netdev, linux-kernel

Making it work on 64-bit caused 32-bit builds to regress:

drivers/net/ethernet/ni/nixge.c: In function 'nixge_hw_dma_bd_release':
drivers/net/ethernet/ni/nixge.c:254:9: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
   skb = (struct sk_buff *)
         ^
In file included from include/linux/skbuff.h:17,
                 from include/linux/if_ether.h:23,
                 from include/linux/etherdevice.h:25,
                 from drivers/net/ethernet/ni/nixge.c:7:
drivers/net/ethernet/ni/nixge.c: In function 'nixge_hw_dma_bd_init':
drivers/net/ethernet/ni/nixge.c:130:37: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
   (bd)->field##_lo = lower_32_bits(((u64)addr)); \
                                     ^
include/linux/kernel.h:234:33: note: in definition of macro 'lower_32_bits'
 #define lower_32_bits(n) ((u32)(n))
                                 ^

Casting to a uintptr_t avoids all these warnings.

Fixes: 7e8d5755be0e ("net: nixge: Add support for 64-bit platforms")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/ethernet/ni/nixge.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/ni/nixge.c b/drivers/net/ethernet/ni/nixge.c
index 74cf52e3fb09..2e132f6a7c36 100644
--- a/drivers/net/ethernet/ni/nixge.c
+++ b/drivers/net/ethernet/ni/nixge.c
@@ -127,8 +127,8 @@ struct nixge_hw_dma_bd {
 #ifdef CONFIG_PHYS_ADDR_T_64BIT
 #define nixge_hw_dma_bd_set_addr(bd, field, addr) \
 	do { \
-		(bd)->field##_lo = lower_32_bits(((u64)addr)); \
-		(bd)->field##_hi = upper_32_bits(((u64)addr)); \
+		(bd)->field##_lo = lower_32_bits(((uintptr_t)addr)); \
+		(bd)->field##_hi = upper_32_bits(((uintptr_t)addr)); \
 	} while (0)
 #else
 #define nixge_hw_dma_bd_set_addr(bd, field, addr) \
@@ -251,7 +251,7 @@ static void nixge_hw_dma_bd_release(struct net_device *ndev)
 				 NIXGE_MAX_JUMBO_FRAME_SIZE,
 				 DMA_FROM_DEVICE);
 
-		skb = (struct sk_buff *)
+		skb = (struct sk_buff *)(uintptr_t)
 			nixge_hw_dma_bd_get_addr(&priv->rx_bd_v[i],
 						 sw_id_offset);
 		dev_kfree_skb(skb);
@@ -601,8 +601,8 @@ static int nixge_recv(struct net_device *ndev, int budget)
 		tail_p = priv->rx_bd_p + sizeof(*priv->rx_bd_v) *
 			 priv->rx_bd_ci;
 
-		skb = (struct sk_buff *)nixge_hw_dma_bd_get_addr(cur_p,
-								 sw_id_offset);
+		skb = (struct sk_buff *)(uintptr_t)
+			nixge_hw_dma_bd_get_addr(cur_p, sw_id_offset);
 
 		length = cur_p->status & XAXIDMA_BD_STS_ACTUAL_LEN_MASK;
 		if (length > NIXGE_MAX_JUMBO_FRAME_SIZE)
-- 
2.18.0


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

* Re: [PATCH] net: nixge: fix warnings on 32-bit platforms
  2018-09-26 12:47 [PATCH] net: nixge: fix warnings on 32-bit platforms Arnd Bergmann
@ 2018-09-26 16:03 ` Moritz Fischer
  2018-09-26 18:47   ` Arnd Bergmann
  0 siblings, 1 reply; 3+ messages in thread
From: Moritz Fischer @ 2018-09-26 16:03 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: David S. Miller, Moritz Fischer, netdev, linux-kernel

Hi Arnd,

On Wed, Sep 26, 2018 at 02:47:24PM +0200, Arnd Bergmann wrote:
> Making it work on 64-bit caused 32-bit builds to regress:
> 
> drivers/net/ethernet/ni/nixge.c: In function 'nixge_hw_dma_bd_release':
> drivers/net/ethernet/ni/nixge.c:254:9: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
>    skb = (struct sk_buff *)
>          ^
> In file included from include/linux/skbuff.h:17,
>                  from include/linux/if_ether.h:23,
>                  from include/linux/etherdevice.h:25,
>                  from drivers/net/ethernet/ni/nixge.c:7:
> drivers/net/ethernet/ni/nixge.c: In function 'nixge_hw_dma_bd_init':
> drivers/net/ethernet/ni/nixge.c:130:37: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
>    (bd)->field##_lo = lower_32_bits(((u64)addr)); \
>                                      ^
> include/linux/kernel.h:234:33: note: in definition of macro 'lower_32_bits'
>  #define lower_32_bits(n) ((u32)(n))
>                                  ^
> 
> Casting to a uintptr_t avoids all these warnings.
> 
> Fixes: 7e8d5755be0e ("net: nixge: Add support for 64-bit platforms")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/net/ethernet/ni/nixge.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ni/nixge.c b/drivers/net/ethernet/ni/nixge.c
> index 74cf52e3fb09..2e132f6a7c36 100644
> --- a/drivers/net/ethernet/ni/nixge.c
> +++ b/drivers/net/ethernet/ni/nixge.c
> @@ -127,8 +127,8 @@ struct nixge_hw_dma_bd {
>  #ifdef CONFIG_PHYS_ADDR_T_64BIT
>  #define nixge_hw_dma_bd_set_addr(bd, field, addr) \
>  	do { \
> -		(bd)->field##_lo = lower_32_bits(((u64)addr)); \
> -		(bd)->field##_hi = upper_32_bits(((u64)addr)); \
> +		(bd)->field##_lo = lower_32_bits(((uintptr_t)addr)); \
> +		(bd)->field##_hi = upper_32_bits(((uintptr_t)addr)); \
>  	} while (0)
>  #else
>  #define nixge_hw_dma_bd_set_addr(bd, field, addr) \
> @@ -251,7 +251,7 @@ static void nixge_hw_dma_bd_release(struct net_device *ndev)
>  				 NIXGE_MAX_JUMBO_FRAME_SIZE,
>  				 DMA_FROM_DEVICE);
>  
> -		skb = (struct sk_buff *)
> +		skb = (struct sk_buff *)(uintptr_t)
>  			nixge_hw_dma_bd_get_addr(&priv->rx_bd_v[i],
>  						 sw_id_offset);
>  		dev_kfree_skb(skb);
> @@ -601,8 +601,8 @@ static int nixge_recv(struct net_device *ndev, int budget)
>  		tail_p = priv->rx_bd_p + sizeof(*priv->rx_bd_v) *
>  			 priv->rx_bd_ci;
>  
> -		skb = (struct sk_buff *)nixge_hw_dma_bd_get_addr(cur_p,
> -								 sw_id_offset);
> +		skb = (struct sk_buff *)(uintptr_t)
> +			nixge_hw_dma_bd_get_addr(cur_p, sw_id_offset);
>  
>  		length = cur_p->status & XAXIDMA_BD_STS_ACTUAL_LEN_MASK;
>  		if (length > NIXGE_MAX_JUMBO_FRAME_SIZE)
> -- 
> 2.18.0
> 

I had submitted a similar patch https://lkml.org/lkml/2018/9/24/1719
here. I should probably add the Fixes tag yours has but other than that
they look largely equivalent. Comments?

Thanks,

Moritz

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

* Re: [PATCH] net: nixge: fix warnings on 32-bit platforms
  2018-09-26 16:03 ` Moritz Fischer
@ 2018-09-26 18:47   ` Arnd Bergmann
  0 siblings, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2018-09-26 18:47 UTC (permalink / raw)
  To: mdf; +Cc: David Miller, Networking, Linux Kernel Mailing List

On Wed, Sep 26, 2018 at 6:03 PM Moritz Fischer <mdf@kernel.org> wrote:
>
> Hi Arnd,
>
> On Wed, Sep 26, 2018 at 02:47:24PM +0200, Arnd Bergmann wrote:
> > Making it work on 64-bit caused 32-bit builds to regress:

> >
>
> I had submitted a similar patch https://lkml.org/lkml/2018/9/24/1719
> here. I should probably add the Fixes tag yours has but other than that
> they look largely equivalent. Comments?

Yes, I'm sure your version is fine as well, sorry for missing that.

Adding a fixes tag is generally a good idea, but no need to resend it.
We just need one of the two to get picked up into net-next.

[note: we both forgot to tag the patch as "[PATCH net-next]"]

       Arnd

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

end of thread, other threads:[~2018-09-26 18:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-26 12:47 [PATCH] net: nixge: fix warnings on 32-bit platforms Arnd Bergmann
2018-09-26 16:03 ` Moritz Fischer
2018-09-26 18:47   ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).