netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/3] ethernet: fix some esoteric drivers after netdev->dev_addr constification
@ 2022-01-25 22:23 Jakub Kicinski
  2022-01-25 22:23 ` [PATCH net 1/3] ethernet: 3com/typhoon: don't write directly to netdev->dev_addr Jakub Kicinski
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Jakub Kicinski @ 2022-01-25 22:23 UTC (permalink / raw)
  To: davem; +Cc: netdev, dave, Jakub Kicinski

Looking at recent fixes for drivers which don't get included with
allmodconfig builds I thought it's worth grepping for more instances of:

  dev->dev_addr\[.*\] = 

This set contains the fixes.

Jakub Kicinski (3):
  ethernet: 3com/typhoon: don't write directly to netdev->dev_addr
  ethernet: tundra: don't write directly to netdev->dev_addr
  ethernet: broadcom/sb1250-mac: don't write directly to
    netdev->dev_addr

 drivers/net/ethernet/3com/typhoon.c        |  6 ++--
 drivers/net/ethernet/broadcom/sb1250-mac.c |  4 +--
 drivers/net/ethernet/tundra/tsi108_eth.c   | 35 +++++++++++-----------
 3 files changed, 23 insertions(+), 22 deletions(-)

-- 
2.34.1


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

* [PATCH net 1/3] ethernet: 3com/typhoon: don't write directly to netdev->dev_addr
  2022-01-25 22:23 [PATCH net 0/3] ethernet: fix some esoteric drivers after netdev->dev_addr constification Jakub Kicinski
@ 2022-01-25 22:23 ` Jakub Kicinski
  2022-01-26  3:07   ` David Dillow
  2022-01-25 22:23 ` [PATCH net 2/3] ethernet: tundra: " Jakub Kicinski
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Jakub Kicinski @ 2022-01-25 22:23 UTC (permalink / raw)
  To: davem; +Cc: netdev, dave, Jakub Kicinski

This driver casts off the const and writes directly to netdev->dev_addr.
This will result in a MAC address tree corruption and a warning.

Compile tested ppc6xx_defconfig.

Fixes: adeef3e32146 ("net: constify netdev->dev_addr")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/net/ethernet/3com/typhoon.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/3com/typhoon.c b/drivers/net/ethernet/3com/typhoon.c
index 481f1df3106c..8aec5d9fbfef 100644
--- a/drivers/net/ethernet/3com/typhoon.c
+++ b/drivers/net/ethernet/3com/typhoon.c
@@ -2278,6 +2278,7 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	struct net_device *dev;
 	struct typhoon *tp;
 	int card_id = (int) ent->driver_data;
+	u8 addr[ETH_ALEN] __aligned(4);
 	void __iomem *ioaddr;
 	void *shared;
 	dma_addr_t shared_dma;
@@ -2409,8 +2410,9 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 		goto error_out_reset;
 	}
 
-	*(__be16 *)&dev->dev_addr[0] = htons(le16_to_cpu(xp_resp[0].parm1));
-	*(__be32 *)&dev->dev_addr[2] = htonl(le32_to_cpu(xp_resp[0].parm2));
+	*(__be16 *)&addr[0] = htons(le16_to_cpu(xp_resp[0].parm1));
+	*(__be32 *)&addr[2] = htonl(le32_to_cpu(xp_resp[0].parm2));
+	eth_hw_addr_set(dev, addr);
 
 	if (!is_valid_ether_addr(dev->dev_addr)) {
 		err_msg = "Could not obtain valid ethernet address, aborting";
-- 
2.34.1


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

* [PATCH net 2/3] ethernet: tundra: don't write directly to netdev->dev_addr
  2022-01-25 22:23 [PATCH net 0/3] ethernet: fix some esoteric drivers after netdev->dev_addr constification Jakub Kicinski
  2022-01-25 22:23 ` [PATCH net 1/3] ethernet: 3com/typhoon: don't write directly to netdev->dev_addr Jakub Kicinski
@ 2022-01-25 22:23 ` Jakub Kicinski
  2022-01-25 22:23 ` [PATCH net 3/3] ethernet: broadcom/sb1250-mac: " Jakub Kicinski
  2022-01-25 22:28 ` [PATCH net 0/3] ethernet: fix some esoteric drivers after netdev->dev_addr constification Jakub Kicinski
  3 siblings, 0 replies; 8+ messages in thread
From: Jakub Kicinski @ 2022-01-25 22:23 UTC (permalink / raw)
  To: davem; +Cc: netdev, dave, Jakub Kicinski

netdev->dev_addr is const now.

Maintain the questionable offsetting in ndo_set_mac_address.

Compile tested holly_defconfig and mpc7448_hpc2_defconfig.

Fixes: adeef3e32146 ("net: constify netdev->dev_addr")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/net/ethernet/tundra/tsi108_eth.c | 35 ++++++++++++------------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ethernet/tundra/tsi108_eth.c b/drivers/net/ethernet/tundra/tsi108_eth.c
index cf0917b29e30..5251fc324221 100644
--- a/drivers/net/ethernet/tundra/tsi108_eth.c
+++ b/drivers/net/ethernet/tundra/tsi108_eth.c
@@ -1091,20 +1091,22 @@ static int tsi108_get_mac(struct net_device *dev)
 	struct tsi108_prv_data *data = netdev_priv(dev);
 	u32 word1 = TSI_READ(TSI108_MAC_ADDR1);
 	u32 word2 = TSI_READ(TSI108_MAC_ADDR2);
+	u8 addr[ETH_ALEN];
 
 	/* Note that the octets are reversed from what the manual says,
 	 * producing an even weirder ordering...
 	 */
 	if (word2 == 0 && word1 == 0) {
-		dev->dev_addr[0] = 0x00;
-		dev->dev_addr[1] = 0x06;
-		dev->dev_addr[2] = 0xd2;
-		dev->dev_addr[3] = 0x00;
-		dev->dev_addr[4] = 0x00;
+		addr[0] = 0x00;
+		addr[1] = 0x06;
+		addr[2] = 0xd2;
+		addr[3] = 0x00;
+		addr[4] = 0x00;
 		if (0x8 == data->phy)
-			dev->dev_addr[5] = 0x01;
+			addr[5] = 0x01;
 		else
-			dev->dev_addr[5] = 0x02;
+			addr[5] = 0x02;
+		eth_hw_addr_set(dev, addr);
 
 		word2 = (dev->dev_addr[0] << 16) | (dev->dev_addr[1] << 24);
 
@@ -1114,12 +1116,13 @@ static int tsi108_get_mac(struct net_device *dev)
 		TSI_WRITE(TSI108_MAC_ADDR1, word1);
 		TSI_WRITE(TSI108_MAC_ADDR2, word2);
 	} else {
-		dev->dev_addr[0] = (word2 >> 16) & 0xff;
-		dev->dev_addr[1] = (word2 >> 24) & 0xff;
-		dev->dev_addr[2] = (word1 >> 0) & 0xff;
-		dev->dev_addr[3] = (word1 >> 8) & 0xff;
-		dev->dev_addr[4] = (word1 >> 16) & 0xff;
-		dev->dev_addr[5] = (word1 >> 24) & 0xff;
+		addr[0] = (word2 >> 16) & 0xff;
+		addr[1] = (word2 >> 24) & 0xff;
+		addr[2] = (word1 >> 0) & 0xff;
+		addr[3] = (word1 >> 8) & 0xff;
+		addr[4] = (word1 >> 16) & 0xff;
+		addr[5] = (word1 >> 24) & 0xff;
+		eth_hw_addr_set(dev, addr);
 	}
 
 	if (!is_valid_ether_addr(dev->dev_addr)) {
@@ -1136,14 +1139,12 @@ static int tsi108_set_mac(struct net_device *dev, void *addr)
 {
 	struct tsi108_prv_data *data = netdev_priv(dev);
 	u32 word1, word2;
-	int i;
 
 	if (!is_valid_ether_addr(addr))
 		return -EADDRNOTAVAIL;
 
-	for (i = 0; i < 6; i++)
-		/* +2 is for the offset of the HW addr type */
-		dev->dev_addr[i] = ((unsigned char *)addr)[i + 2];
+	/* +2 is for the offset of the HW addr type */
+	eth_hw_addr_set(dev, ((unsigned char *)addr) + 2);
 
 	word2 = (dev->dev_addr[0] << 16) | (dev->dev_addr[1] << 24);
 
-- 
2.34.1


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

* [PATCH net 3/3] ethernet: broadcom/sb1250-mac: don't write directly to netdev->dev_addr
  2022-01-25 22:23 [PATCH net 0/3] ethernet: fix some esoteric drivers after netdev->dev_addr constification Jakub Kicinski
  2022-01-25 22:23 ` [PATCH net 1/3] ethernet: 3com/typhoon: don't write directly to netdev->dev_addr Jakub Kicinski
  2022-01-25 22:23 ` [PATCH net 2/3] ethernet: tundra: " Jakub Kicinski
@ 2022-01-25 22:23 ` Jakub Kicinski
  2022-01-25 22:28 ` [PATCH net 0/3] ethernet: fix some esoteric drivers after netdev->dev_addr constification Jakub Kicinski
  3 siblings, 0 replies; 8+ messages in thread
From: Jakub Kicinski @ 2022-01-25 22:23 UTC (permalink / raw)
  To: davem; +Cc: netdev, dave, Jakub Kicinski

netdev->dev_addr is const now.

Compile tested bigsur_defconfig and sb1250_swarm_defconfig.

Fixes: adeef3e32146 ("net: constify netdev->dev_addr")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/net/ethernet/broadcom/sb1250-mac.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/sb1250-mac.c b/drivers/net/ethernet/broadcom/sb1250-mac.c
index f38f40eb966e..a1a38456c9a3 100644
--- a/drivers/net/ethernet/broadcom/sb1250-mac.c
+++ b/drivers/net/ethernet/broadcom/sb1250-mac.c
@@ -2183,9 +2183,7 @@ static int sbmac_init(struct platform_device *pldev, long long base)
 		ea_reg >>= 8;
 	}
 
-	for (i = 0; i < 6; i++) {
-		dev->dev_addr[i] = eaddr[i];
-	}
+	eth_hw_addr_set(dev, eaddr);
 
 	/*
 	 * Initialize context (get pointers to registers and stuff), then
-- 
2.34.1


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

* Re: [PATCH net 0/3] ethernet: fix some esoteric drivers after netdev->dev_addr constification
  2022-01-25 22:23 [PATCH net 0/3] ethernet: fix some esoteric drivers after netdev->dev_addr constification Jakub Kicinski
                   ` (2 preceding siblings ...)
  2022-01-25 22:23 ` [PATCH net 3/3] ethernet: broadcom/sb1250-mac: " Jakub Kicinski
@ 2022-01-25 22:28 ` Jakub Kicinski
  2022-01-25 23:59   ` Arnd Bergmann
  3 siblings, 1 reply; 8+ messages in thread
From: Jakub Kicinski @ 2022-01-25 22:28 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: davem, netdev, dave

On Tue, 25 Jan 2022 14:23:14 -0800 Jakub Kicinski wrote:
> Looking at recent fixes for drivers which don't get included with
> allmodconfig builds I thought it's worth grepping for more instances of:
> 
>   dev->dev_addr\[.*\] = 
> 
> This set contains the fixes.

Hi Arnd, there's another case in drivers/net/ethernet/i825xx/ether1.c
which will be broken in 5.17, it looks like only RiscPC includes that.
But when I do:

make ARCH=arm CROSS_COMPILE=$cross/arm-linux-gnueabi/bin/arm-linux-gnueabi- O=build_tmp/ rpc_defconfig

The resulting config is not for ARCH_RPC:

$ grep ARM_ETHER1 build_tmp/.config
$ grep RPC build_tmp/.config
# CONFIG_AF_RXRPC is not set
CONFIG_SUNRPC=y
# CONFIG_SUNRPC_DEBUG is not set
CONFIG_XZ_DEC_POWERPC=y
$ grep ACORN build_tmp/.config
# CONFIG_ACORN_PARTITION is not set
CONFIG_FONT_ACORN_8x8=y

Is there an extra smidgen of magic I need to produce a working config
here?  Is RPC dead and can we send it off to Valhalla?

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

* Re: [PATCH net 0/3] ethernet: fix some esoteric drivers after netdev->dev_addr constification
  2022-01-25 22:28 ` [PATCH net 0/3] ethernet: fix some esoteric drivers after netdev->dev_addr constification Jakub Kicinski
@ 2022-01-25 23:59   ` Arnd Bergmann
  2022-01-26  0:20     ` Jakub Kicinski
  0 siblings, 1 reply; 8+ messages in thread
From: Arnd Bergmann @ 2022-01-25 23:59 UTC (permalink / raw)
  To: Jakub Kicinski, Russell King - ARM Linux
  Cc: Arnd Bergmann, David Miller, Networking, dave

On Tue, Jan 25, 2022 at 11:28 PM Jakub Kicinski <kuba@kernel.org> wrote:
> On Tue, 25 Jan 2022 14:23:14 -0800 Jakub Kicinski wrote:
> > Looking at recent fixes for drivers which don't get included with
> > allmodconfig builds I thought it's worth grepping for more instances of:
> >
> >   dev->dev_addr\[.*\] =
> >
> > This set contains the fixes.
>
> Hi Arnd, there's another case in drivers/net/ethernet/i825xx/ether1.c
> which will be broken in 5.17, it looks like only RiscPC includes that.
> But when I do:
>
> make ARCH=arm CROSS_COMPILE=$cross/arm-linux-gnueabi/bin/arm-linux-gnueabi- O=build_tmp/ rpc_defconfig
>
> The resulting config is not for ARCH_RPC:
>
> $ grep ARM_ETHER1 build_tmp/.config
> $ grep RPC build_tmp/.config
> # CONFIG_AF_RXRPC is not set
> CONFIG_SUNRPC=y
> # CONFIG_SUNRPC_DEBUG is not set
> CONFIG_XZ_DEC_POWERPC=y
> $ grep ACORN build_tmp/.config
> # CONFIG_ACORN_PARTITION is not set
> CONFIG_FONT_ACORN_8x8=y
>
> Is there an extra smidgen of magic I need to produce a working config
> here?  Is RPC dead and can we send it off to Valhalla?

Support for ARMv3 was removed in gcc-9, so there is a Kconfig
dependency on the compiler version to prevent broken builds.
You can use the gcc-8 builds from kernel.org[1].

Russell still uses this machine with an older compiler though, and
I guess he will keep using newer kernels for as long as gcc-8 can
build them.

No idea which ethernet card he uses, there are at least three of them.

      Arnd

[1] https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/8.5.0/x86_64-gcc-8.5.0-nolibc-arm-linux-gnueabi.tar.gz

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

* Re: [PATCH net 0/3] ethernet: fix some esoteric drivers after netdev->dev_addr constification
  2022-01-25 23:59   ` Arnd Bergmann
@ 2022-01-26  0:20     ` Jakub Kicinski
  0 siblings, 0 replies; 8+ messages in thread
From: Jakub Kicinski @ 2022-01-26  0:20 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Russell King - ARM Linux, David Miller, Networking, dave

On Wed, 26 Jan 2022 00:59:47 +0100 Arnd Bergmann wrote:
> > Hi Arnd, there's another case in drivers/net/ethernet/i825xx/ether1.c
> > which will be broken in 5.17, it looks like only RiscPC includes that.
> > But when I do:
> >
> > make ARCH=arm CROSS_COMPILE=$cross/arm-linux-gnueabi/bin/arm-linux-gnueabi- O=build_tmp/ rpc_defconfig
> >
> > The resulting config is not for ARCH_RPC:
> >
> > $ grep ARM_ETHER1 build_tmp/.config
> > $ grep RPC build_tmp/.config
> > # CONFIG_AF_RXRPC is not set
> > CONFIG_SUNRPC=y
> > # CONFIG_SUNRPC_DEBUG is not set
> > CONFIG_XZ_DEC_POWERPC=y
> > $ grep ACORN build_tmp/.config
> > # CONFIG_ACORN_PARTITION is not set
> > CONFIG_FONT_ACORN_8x8=y
> >
> > Is there an extra smidgen of magic I need to produce a working config
> > here?  Is RPC dead and can we send it off to Valhalla?  
> 
> Support for ARMv3 was removed in gcc-9, so there is a Kconfig
> dependency on the compiler version to prevent broken builds.
> You can use the gcc-8 builds from kernel.org[1].

That worked! Thank you!

> Russell still uses this machine with an older compiler though, and
> I guess he will keep using newer kernels for as long as gcc-8 can
> build them.
> 
> No idea which ethernet card he uses, there are at least three of them.
> 
> [1] https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/8.5.0/x86_64-gcc-8.5.0-nolibc-arm-linux-gnueabi.tar.gz

If there are 3 I broke the build for all of them, it seems :)
I'll send the fixes shortly.

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

* Re: [PATCH net 1/3] ethernet: 3com/typhoon: don't write directly to netdev->dev_addr
  2022-01-25 22:23 ` [PATCH net 1/3] ethernet: 3com/typhoon: don't write directly to netdev->dev_addr Jakub Kicinski
@ 2022-01-26  3:07   ` David Dillow
  0 siblings, 0 replies; 8+ messages in thread
From: David Dillow @ 2022-01-26  3:07 UTC (permalink / raw)
  To: Jakub Kicinski, davem; +Cc: netdev

On Tue, 2022-01-25 at 14:23 -0800, Jakub Kicinski wrote:
> This driver casts off the const and writes directly to netdev-
> >dev_addr.
> This will result in a MAC address tree corruption and a warning.
> 
> Compile tested ppc6xx_defconfig.
> 
> Fixes: adeef3e32146 ("net: constify netdev->dev_addr")
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Thanks!

Acked-by: David Dillow <dave@thedillows.org>

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

end of thread, other threads:[~2022-01-26  4:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-25 22:23 [PATCH net 0/3] ethernet: fix some esoteric drivers after netdev->dev_addr constification Jakub Kicinski
2022-01-25 22:23 ` [PATCH net 1/3] ethernet: 3com/typhoon: don't write directly to netdev->dev_addr Jakub Kicinski
2022-01-26  3:07   ` David Dillow
2022-01-25 22:23 ` [PATCH net 2/3] ethernet: tundra: " Jakub Kicinski
2022-01-25 22:23 ` [PATCH net 3/3] ethernet: broadcom/sb1250-mac: " Jakub Kicinski
2022-01-25 22:28 ` [PATCH net 0/3] ethernet: fix some esoteric drivers after netdev->dev_addr constification Jakub Kicinski
2022-01-25 23:59   ` Arnd Bergmann
2022-01-26  0:20     ` Jakub Kicinski

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).