Skip to contentSkip to conversation

r8169: Avoid duplicate sysfs entry creation error

PATCH Applied Andre Przywara 3 participants 3 messages Jul 20, 2021 – Jul 21, 2021

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

PATCH v3 1/1 r8169: Avoid duplicate sysfs entry creation error

From: Sayanta Pattanayak <[email protected]>

When registering the MDIO bus for a r8169 device, we use the PCI bus/device specifier as a (seemingly) unique device identifier. However the very same BDF number can be used on another PCI segment, which makes the driver fail probing:

[ 27.544136] r8169 0002:07:00.0: enabling device (0000 -> 0003)
[ 27.559734] sysfs: cannot create duplicate filename '/class/mdio_bus/r8169-700'
....
[ 27.684858] libphy: mii_bus r8169-700 failed to register
[ 27.695602] r8169: probe of 0002:07:00.0 failed with error -22

Add the segment number to the device name to make it more unique.

This fixes operation on ARM N1SDP boards, with two boards connected together to form an SMP system, and all on-board devices showing up twice, just on different PCI segments. A similar issue would occur on large systems with many PCI slots and multiple RTL8169 NICs.

Fixes f1e911d5d0dfd ("r8169: add basic phylib support")
[Andre: expand commit message, use pci_domain_nr()]

---
Compile-tested on ARM, arm64, ppc64, sparc64, mips64, hppa, x86-64, i386. Tested on an AMD system with an on-board RTL8111 chip.

Changes v2 ... v3:
- Resent with Fixes tag and proper net: annotation

Changes v1 ... v2:
- use pci_domain_nr() wrapper to fix compilation on various arches

 drivers/net/ethernet/realtek/r8169_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/realtek/r8169_main.c +2 -1
index f744557c33a3..c7af5bc3b8af 100644
@@ -5084,7 +5084,8 @@ static int r8169_mdio_register(struct rtl8169_private *tp)
 	new_bus->priv = tp;
 	new_bus->parent = &pdev->dev;
 	new_bus->irq[0] = PHY_MAC_INTERRUPT;
-	snprintf(new_bus->id, MII_BUS_ID_SIZE, "r8169-%x", pci_dev_id(pdev));
+	snprintf(new_bus->id, MII_BUS_ID_SIZE, "r8169-%x-%x",
+		 pci_domain_nr(pdev->bus), pci_dev_id(pdev));
 
 	new_bus->read = r8169_mdio_read_reg;
 	new_bus->write = r8169_mdio_write_reg;
Signature · 1 line
2.17.6
maintainer Acked-by on v3 1/1
#1 lore raw
Quoted 43 lines · Andre Przywara

From: Sayanta Pattanayak <[email protected]>

When registering the MDIO bus for a r8169 device, we use the PCI bus/device specifier as a (seemingly) unique device identifier. However the very same BDF number can be used on another PCI segment, which makes the driver fail probing:

[ 27.544136] r8169 0002:07:00.0: enabling device (0000 -> 0003)
[ 27.559734] sysfs: cannot create duplicate filename '/class/mdio_bus/r8169-700'
....
[ 27.684858] libphy: mii_bus r8169-700 failed to register
[ 27.695602] r8169: probe of 0002:07:00.0 failed with error -22

Add the segment number to the device name to make it more unique.

This fixes operation on ARM N1SDP boards, with two boards connected together to form an SMP system, and all on-board devices showing up twice, just on different PCI segments. A similar issue would occur on large systems with many PCI slots and multiple RTL8169 NICs.

Fixes f1e911d5d0dfd ("r8169: add basic phylib support")
[Andre: expand commit message, use pci_domain_nr()]

---
Compile-tested on ARM, arm64, ppc64, sparc64, mips64, hppa, x86-64, i386. Tested on an AMD system with an on-board RTL8111 chip.

Changes v2 ... v3:
- Resent with Fixes tag and proper net: annotation

Changes v1 ... v2:
- use pci_domain_nr() wrapper to fix compilation on various arches

 drivers/net/ethernet/realtek/r8169_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/realtek/r8169_main.c +0 -0
index f744557c33a3..c7af5bc3b8af 100644

drivers/net/ethernet/realtek/r8169_main.c static int r8169_mdio_register(struct rtl8169_private *tp) · line 5091

Quoted 9 lines
drivers/net/ethernet/realtek/r8169_main.c +2 -1
@@ -5084,7 +5084,8 @@ static int r8169_mdio_register(struct rtl8169_private *tp)
 	new_bus->priv = tp;
 	new_bus->parent = &pdev->dev;
 	new_bus->irq[0] = PHY_MAC_INTERRUPT;
-	snprintf(new_bus->id, MII_BUS_ID_SIZE, "r8169-%x", pci_dev_id(pdev));
+	snprintf(new_bus->id, MII_BUS_ID_SIZE, "r8169-%x-%x",
+		 pci_domain_nr(pdev->bus), pci_dev_id(pdev));
 
 	new_bus->read = r8169_mdio_read_reg;
 	new_bus->write = r8169_mdio_write_reg;
#2 lore raw
In reply to Andre Przywara
This patch was applied to netdev/net.git (refs/heads/master):

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

Quoted 8 lines · On Tue, 20 Jul 2021 17:17:40 +0100 you wrote:

From: Sayanta Pattanayak <[email protected]>

When registering the MDIO bus for a r8169 device, we use the PCI bus/device specifier as a (seemingly) unique device identifier. However the very same BDF number can be used on another PCI segment, which makes the driver fail probing:

[...]

Here is the summary with links:
- [net,v3] r8169: Avoid duplicate sysfs entry creation error

    https://git.kernel.org/netdev/net/c/e9a72f874d5b

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html