Skip to contentSkip to conversation

mlxsw: fix warnings for big-endian 32-bit dma_addr_t

PATCH Superseded Arnd Bergmann 4 participants 7 messages Oct 6, 2015 – Oct 8, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mlxsw: fix warnings for big-endian 32-bit dma_addr_t

The recently added mlxsw driver produces warnings in ARM allmodconfig:

drivers/net/ethernet/mellanox/mlxsw/pci.c: In function 'mlxsw_pci_cmd_exec':
drivers/net/ethernet/mellanox/mlxsw/pci.c:1585:59: warning: right shift count >= width of type [-Wshift-count-overflow] linux/byteorder/big_endian.h:38:51: note: in definition of macro '__cpu_to_be32' drivers/net/ethernet/mellanox/mlxsw/pci.c:76:2: note: in expansion of macro 'iowrite32be'

This changes the type of the local variable to u64, which gets rid of the warning and seems nicer than adding #ifdefs.

Fixes eda6500a987a "mlxsw: Add PCI bus implementation"
drivers/net/ethernet/mellanox/mlxsw/pci.c +2 -2
index 462cea31ecbb..cd11e3591741 100644
@@ -1567,8 +1567,8 @@ static int mlxsw_pci_cmd_exec(void *bus_priv, u16 opcode, u8 opcode_mod,
 			      u8 *p_status)
 {
 	struct mlxsw_pci *mlxsw_pci = bus_priv;
-	dma_addr_t in_mapaddr = mlxsw_pci->cmd.in_mbox.mapaddr;
-	dma_addr_t out_mapaddr = mlxsw_pci->cmd.out_mbox.mapaddr;
+	u64 in_mapaddr = mlxsw_pci->cmd.in_mbox.mapaddr;
+	u64 out_mapaddr = mlxsw_pci->cmd.out_mbox.mapaddr;
 	bool evreq = mlxsw_pci->cmd.nopoll;
 	unsigned long timeout = msecs_to_jiffies(MLXSW_PCI_CIR_TIMEOUT_MSECS);
 	bool *p_wait_done = &mlxsw_pci->cmd.wait_done;
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · arnd at arndb.de

The recently added mlxsw driver produces warnings in ARM allmodconfig:

drivers/net/ethernet/mellanox/mlxsw/pci.c: In function 'mlxsw_pci_cmd_exec':
drivers/net/ethernet/mellanox/mlxsw/pci.c:1585:59: warning: right shift count >= width of type [-Wshift-count-overflow] linux/byteorder/big_endian.h:38:51: note: in definition of macro '__cpu_to_be32' drivers/net/ethernet/mellanox/mlxsw/pci.c:76:2: note: in expansion of macro 'iowrite32be'

Quoted 5 lines

This changes the type of the local variable to u64, which gets rid of the warning and seems nicer than adding #ifdefs.

Fixes eda6500a987a "mlxsw: Add PCI bus implementation"

Thanks!

#2 lore raw
In reply to Arnd Bergmann
Quoted 10 lines · Arnd Bergmann

The recently added mlxsw driver produces warnings in ARM allmodconfig:

drivers/net/ethernet/mellanox/mlxsw/pci.c: In function 'mlxsw_pci_cmd_exec':
drivers/net/ethernet/mellanox/mlxsw/pci.c:1585:59: warning: right shift count >= width of type [-Wshift-count-overflow] linux/byteorder/big_endian.h:38:51: note: in definition of macro '__cpu_to_be32' drivers/net/ethernet/mellanox/mlxsw/pci.c:76:2: note: in expansion of macro 'iowrite32be'

This changes the type of the local variable to u64, which gets rid of the warning and seems nicer than adding #ifdefs.

Using upper_32_bits instead of the shift might be
nicer than changing the type.

#3 lore raw
Quoted 9 lines · joe at perches.com
Quoted 8 lines · Arnd Bergmann

The recently added mlxsw driver produces warnings in ARM allmodconfig:

drivers/net/ethernet/mellanox/mlxsw/pci.c: In function 'mlxsw_pci_cmd_exec':
drivers/net/ethernet/mellanox/mlxsw/pci.c:1585:59: warning: right shift count >= width of type [-Wshift-count-overflow] linux/byteorder/big_endian.h:38:51: note: in definition of macro '__cpu_to_be32' drivers/net/ethernet/mellanox/mlxsw/pci.c:76:2: note: in expansion of macro 'iowrite32be'

Quoted 5 lines
Quoted 2 lines

This changes the type of the local variable to u64, which gets rid of the warning and seems nicer than adding #ifdefs.

Using upper_32_bits instead of the shift might be
nicer than changing the type.

Wasn't aware of this macro. Indeed this looks more appropriate. Thanks!

#4 lore raw

PATCH v2 1/1 mlxsw: fix warnings for big-endian 32-bit dma_addr_t

In reply to Joe Perches

The recently added mlxsw driver produces warnings in ARM allmodconfig:

drivers/net/ethernet/mellanox/mlxsw/pci.c: In function 'mlxsw_pci_cmd_exec':
drivers/net/ethernet/mellanox/mlxsw/pci.c:1585:59: warning: right shift count >= width of type [-Wshift-count-overflow] linux/byteorder/big_endian.h:38:51: note: in definition of macro '__cpu_to_be32' drivers/net/ethernet/mellanox/mlxsw/pci.c:76:2: note: in expansion of macro 'iowrite32be'

This uses upper_32_bits() to extract the bits while avoiding that warning.

Fixes eda6500a987a "mlxsw: Add PCI bus implementation"

---
I've kept Jiri's Ack despite having in effect a completely different patch here, as the effect and the changelog is the same for practical purposes. Hope that's ok.

drivers/net/ethernet/mellanox/mlxsw/pci.c +4 -4
index 462cea31ecbb..cef866c37648 100644
@@ -1582,11 +1582,11 @@ static int mlxsw_pci_cmd_exec(void *bus_priv, u16 opcode, u8 opcode_mod,
 
 	if (in_mbox)
 		memcpy(mlxsw_pci->cmd.in_mbox.buf, in_mbox, in_mbox_size);
-	mlxsw_pci_write32(mlxsw_pci, CIR_IN_PARAM_HI, in_mapaddr >> 32);
-	mlxsw_pci_write32(mlxsw_pci, CIR_IN_PARAM_LO, in_mapaddr);
+	mlxsw_pci_write32(mlxsw_pci, CIR_IN_PARAM_HI, upper_32_bits(in_mapaddr));
+	mlxsw_pci_write32(mlxsw_pci, CIR_IN_PARAM_LO, lower_32_bits(in_mapaddr));
 
-	mlxsw_pci_write32(mlxsw_pci, CIR_OUT_PARAM_HI, out_mapaddr >> 32);
-	mlxsw_pci_write32(mlxsw_pci, CIR_OUT_PARAM_LO, out_mapaddr);
+	mlxsw_pci_write32(mlxsw_pci, CIR_OUT_PARAM_HI, upper_32_bits(out_mapaddr));
+	mlxsw_pci_write32(mlxsw_pci, CIR_OUT_PARAM_LO, lower_32_bits(out_mapaddr));
 
 	mlxsw_pci_write32(mlxsw_pci, CIR_IN_MODIFIER, in_mod);
 	mlxsw_pci_write32(mlxsw_pci, CIR_TOKEN, 0);
#5 lore raw
Quoted 10 lines · arnd at arndb.de

The recently added mlxsw driver produces warnings in ARM allmodconfig:

drivers/net/ethernet/mellanox/mlxsw/pci.c: In function 'mlxsw_pci_cmd_exec':
drivers/net/ethernet/mellanox/mlxsw/pci.c:1585:59: warning: right shift count >= width of type [-Wshift-count-overflow] linux/byteorder/big_endian.h:38:51: note: in definition of macro '__cpu_to_be32' drivers/net/ethernet/mellanox/mlxsw/pci.c:76:2: note: in expansion of macro 'iowrite32be'

This uses upper_32_bits() to extract the bits while avoiding that warning.

Quoted 7 lines
Fixes eda6500a987a "mlxsw: Add PCI bus implementation"

---
I've kept Jiri's Ack despite having in effect a completely different patch here, as the effect and the changelog is the same for practical purposes. Hope that's ok.

It's ok, thanks.

maintainer Applied
#6 lore raw
In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>
Date: Wed, 07 Oct 2015 08:58:34 +0200

Quoted 8 lines

The recently added mlxsw driver produces warnings in ARM allmodconfig:

drivers/net/ethernet/mellanox/mlxsw/pci.c: In function 'mlxsw_pci_cmd_exec':
drivers/net/ethernet/mellanox/mlxsw/pci.c:1585:59: warning: right shift count >= width of type [-Wshift-count-overflow] linux/byteorder/big_endian.h:38:51: note: in definition of macro '__cpu_to_be32' drivers/net/ethernet/mellanox/mlxsw/pci.c:76:2: note: in expansion of macro 'iowrite32be'

Quoted 5 lines

This uses upper_32_bits() to extract the bits while avoiding that warning.

Fixes eda6500a987a "mlxsw: Add PCI bus implementation"

Applied, thanks.