Netdev List
 help / color / mirror / Atom feed
From: Ivan Delalande <colona@arista.com>
To: Jakub Kicinski <kuba@kernel.org>,
	Michael Chan <michael.chan@broadcom.com>,
	Pavan Chebbi <pavan.chebbi@broadcom.com>
Cc: netdev@vger.kernel.org, Vincent MORVAN <vinc@42.fr>,
	Atharva Tiwari <atharvatiwarilinuxdev@gmail.com>
Subject: [PATCH net v3] tg3: use random MAC address when tg3_get_device_address fails
Date: Thu, 17 Sep 2026 15:34:16 -0700	[thread overview]
Message-ID: <20260917223416.GA245819@visor> (raw)

Some of the tg3 NICs we use (BCM57762) reset the SRAM MAC address to the
placeholder address on link flaps, tg3_chip_reset, etc. We've typically
fixed it from userspace, but since e4c00ba7274b ("tg3: replace
placeholder MAC address with device property") was merged, tg3 just
fails probe as we don't have a way to get it through the generic
device_get_mac_address infrastructure as fallback on our systems.

Make the driver assign a random address in this condition instead of
being fatal for probe.

Fixes: e4c00ba7274b ("tg3: replace placeholder MAC address with device property")
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Link: https://lore.kernel.org/netdev/20260909191751.651aa5c4@kernel.org/
Signed-off-by: Ivan Delalande <colona@arista.com>
---
v3: handle EPROBE_DEFER, set deferred_reason through dev_err_probe.
v2: https://lore.kernel.org/netdev/20260914230521.GA1400582@visor/t/
    assign random address instead of changing the logic in
    tg3_get_device_address.
v1: https://lore.kernel.org/netdev/20260903233255.GA4109366@visor/t/
---
 drivers/net/ethernet/broadcom/tg3.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 73a4b569b03e..813181590bce 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -17914,12 +17914,17 @@ static int tg3_init_one(struct pci_dev *pdev,
 	}
 
 	err = tg3_get_device_address(tp, addr);
-	if (err) {
-		dev_err(&pdev->dev,
-			"Could not obtain valid ethernet address, aborting\n");
+	if (err == -EPROBE_DEFER) {
+		dev_err_probe(&pdev->dev, err, "ethernet address provider not ready\n");
 		goto err_out_apeunmap;
 	}
-	eth_hw_addr_set(dev, addr);
+	if (err) {
+		dev_warn(&pdev->dev,
+			 "Could not obtain valid ethernet address, using a random address\n");
+		eth_hw_addr_random(dev);
+	} else {
+		eth_hw_addr_set(dev, addr);
+	}
 
 	intmbx = MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW;
 	rcvmbx = MAILBOX_RCVRET_CON_IDX_0 + TG3_64BIT_REG_LOW;
-- 
2.43.0

             reply	other threads:[~2026-09-17 22:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17 22:34 Ivan Delalande [this message]
2026-09-18  2:30 ` [PATCH net v3] tg3: use random MAC address when tg3_get_device_address fails Andrew Lunn
2026-09-21 23:43 ` netdev-bot+sashiko
2026-09-22  0:23   ` Ivan Delalande

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260917223416.GA245819@visor \
    --to=colona@arista.com \
    --cc=atharvatiwarilinuxdev@gmail.com \
    --cc=kuba@kernel.org \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=pavan.chebbi@broadcom.com \
    --cc=vinc@42.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox