Netdev List
 help / color / mirror / Atom feed
From: Kyle Hsieh <kylehsieh1995@gmail.com>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
	 "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	 Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Kyle Hsieh <kylehsieh1995@gmail.com>
Subject: [PATCH net-next] net: ftgmac100: assign interface name from device tree alias
Date: Wed, 27 May 2026 14:31:51 +0800	[thread overview]
Message-ID: <20260527-addethalias-v1-1-24f5bd2d03cd@gmail.com> (raw)

Currently, the ftgmac100 driver relies on the probe order to assign network
interface names (e.g., eth0, eth1).

This patch allows the driver to fetch the "ethernet" alias ID from the
device tree via of_alias_get_id() and assign it to netdev->name before
registering the netdev.

This provides a standard and robust way to achieve deterministic interface
naming (e.g., ethernet0 -> eth0) directly from the device tree, preventing
potential userspace race conditions during network setup.

Signed-off-by: Kyle Hsieh <kylehsieh1995@gmail.com>
---
Hi all,

This patch series introduces deterministic interface naming for the 
ftgmac100 driver by utilizing device tree aliases.

Background:
Currently, ftgmac100 assigns interface names strictly based on probe order. 
On platforms like the ASPEED AST2600, this often leads to naming collisions 
(e.g., mac2 and mac3 defaulting to eth0 and eth1). 

While userspace tools like systemd-udevd are typically responsible for 
renaming, we encounter a severe race condition on BMC systems: the NCSI 
driver frequently brings the management interface UP before udev can rename 
it, resulting in the kernel locking the name and rejecting the rename 
request.

Solution:
By parsing the "ethernet" alias from the device tree during probe, the 
driver can now assign the correct name out-of-the-box, completely 
bypassing the userspace race condition.

Testing:
- Tested on ASPEED AST2600 BMC.
- Verified that device tree aliases (ethernet0 = &mac3, ethernet1 = &mac2) 
  are correctly applied at probe time.

Please review and consider for inclusion.

Thanks,
Kyle Hsieh
---
 drivers/net/ethernet/faraday/ftgmac100.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 6d2fe5c2f390..e058a10500ee 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -1949,6 +1949,7 @@ static int ftgmac100_probe(struct platform_device *pdev)
 	struct ftgmac100 *priv;
 	struct device_node *np;
 	int err = 0;
+	int alias_id;
 
 	np = pdev->dev.of_node;
 	if (np) {
@@ -1973,6 +1974,11 @@ static int ftgmac100_probe(struct platform_device *pdev)
 	if (!netdev)
 		return -ENOMEM;
 
+	/* Assign interface name based on DTS alias (e.g., ethernet0 -> eth0) */
+	alias_id = of_alias_get_id(pdev->dev.of_node, "ethernet");
+	if (alias_id >= 0)
+		snprintf(netdev->name, IFNAMSIZ, "eth%d", alias_id);
+
 	SET_NETDEV_DEV(netdev, &pdev->dev);
 
 	netdev->ethtool_ops = &ftgmac100_ethtool_ops;

---
base-commit: eb3f4b7426cfd2b79d65b7d37155480b32259a11
change-id: 20260527-addethalias-d25e2f188697

Best regards,
-- 
Kyle Hsieh <kylehsieh1995@gmail.com>


             reply	other threads:[~2026-05-27  6:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-27  6:31 Kyle Hsieh [this message]
2026-05-27 16:56 ` [PATCH net-next] net: ftgmac100: assign interface name from device tree alias Andrew Lunn

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=20260527-addethalias-v1-1-24f5bd2d03cd@gmail.com \
    --to=kylehsieh1995@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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