From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C6BC3E0C5E for ; Sat, 28 Feb 2026 23:23:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772320990; cv=none; b=Sy+2aVTEut2QzntU1rEk0qhiyWZ3142aDY+fVPRF8hnFYxwx624hxQzrwxDiLyAAflqEdJljDY5wPvOE7u59I/UfMk5N0+lWBPAk1Hlq9nqAK4nJGuMslEQ3QTjhIYE3/qP5vlUOW3bb1IZfKqxnkI6HU3YRQLMYE9vnf9hyBHE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772320990; c=relaxed/simple; bh=VLHiua2iLbiZ7Hk6ZHDZpitnvizx9Nykr+jwd3W0HG4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tcjSDwImoO4eyL1a2XI5lC8pBNCv3sjFugry+oozTld1pl6GAPv9iNkbyaBn0sDahbLzdHX0TNxxx5NeeufpjpHqLNjCS+7VnGzQonqZAqT1OpNkI9X+ZvENRmRFhbRo7wb/nEOaVdc4ZjKj0svAoKqjux+rNc2B3Kr4s8p2iEs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SCbiGF9U; arc=none smtp.client-ip=209.85.221.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SCbiGF9U" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-439ac15f35fso490991f8f.0 for ; Sat, 28 Feb 2026 15:23:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772320987; x=1772925787; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TtSinzVGJkzPvF9jByekTq6nORuTGb+Z3JsuJnZZQ7c=; b=SCbiGF9UIEOLCF+7xUb01le0+fKVUf/0ywWyTDAGn2Zi0JErN6Qfw0AnblUTXOT5hC p68qGrZcttEWOf1dQvpUzxchOfIpIczkBts0gJQ4KE0DMHgRbEYoI63D2mwHdLp3dUsN 4gZ2pooOhnIvPfy6S9Z/rnojfx9aH3pdogLZ/XydaotNGo8jw6bS2KpCXSH8He8Rfgcj Y3+qOiYtLAgqUUUC3fxgx3ZgZJk8AGYkM+c5pAJI0Gr3wT5LQYQIgW3itAVte6GiYIJd mchAPuwsDAbrsbfzgSkYwrHrxFljjUozdu7Jh723epdYEocQ6AONZxspMNKiSq4w33eW iJ3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772320987; x=1772925787; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=TtSinzVGJkzPvF9jByekTq6nORuTGb+Z3JsuJnZZQ7c=; b=E6AxVDMlctmB6eZa/5kwZPdFtHVm7DGsIUITGHJXbwVWGgOqwW+UWaCMmF2bv/4EEd QTOZzvmb6bw4kmw+vTpVKg5a1yaacXR0fWO1WHluDhlqnHMJL9SEdoszEvI0I1MBLmn5 cRHnUMl4W1poH5Lg+gN89pao37/4a8HrSUpC3eOiiLdlAkdyCOdMt05pbTj9VDBRWAXY 2OXJGtuxEqtuRTyvF2tR5HWSUV/yhCIGq0XqtLU21sJLFPYxs+2vwf48pHDfaAdX9S9C 0S6eUBxfTCNAGulSkNyfaeAQgVD1i7fKQnaHnl4tRurUi5mKDio9cKijUySNbhzxHy/j n83Q== X-Gm-Message-State: AOJu0YxOgORo1eqLtnX9qnU4IV+9cRnbxVXJ+7TRLi1GWiRTi5bNugDC qE+kf/itm/hLfD1F/vFsAr26+WObs+u80qQ5Elli0RIMkS6njETm1CJ/H7lvNlQobdA= X-Gm-Gg: ATEYQzwLJMzQarR40tskVMhNNFimfk+iRZC7rdeyQFEZK12zlSpvq2/7QbtiOm/yol9 UcZLDsDVSQOQEotpCJ/75vZSHX0wf0pLjBQX4t6pfO/HvDifbKee7/CTWfr7yz7NdmMv8Vee4i3 TL9mPMyfwICxIMY88xT4Adk98jHIkgtL4MlAoLCSwHembs8sDEbkh1s9e+PTXH1uM96j4S4p02b umQ7u1ms7p4VMVwtFGfl61lQfJuYux90qco6VnfSvgD8kuvBQpnnxcKWpblFwd881HRevA+oFZY HvXa9rT7dg+hBmnt8ds6LLOOLQBpvinj30U6ndbJG4wbeoMAFknwSqkMj/Fh/d7gAsmOo0t+BRF SJecS7RQ0MQdSqhhZeL3Dw4secoKozRVNKqiuQDEv6peEKR+rY1nwxfKvm+AEWq1/sWOhAGV1h3 6zZ360lX6etB8AUQ9Q1j/PaWO+88qvIhNxb724RL+pvEMoUNPjvWaFxzFC9ZY/Z2Cd5FprPks/R ypj/C4= X-Received: by 2002:a05:6000:2007:b0:437:6625:d0d7 with SMTP id ffacd0b85a97d-4399de3694fmr12066071f8f.42.1772320987140; Sat, 28 Feb 2026 15:23:07 -0800 (PST) Received: from pc-kuba-l13.. (snat-2.cgn.sat-an.net. [176.222.226.2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4399c70ed47sm18515680f8f.11.2026.02.28.15.23.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Feb 2026 15:23:06 -0800 (PST) From: =?UTF-8?q?Jakub=20Van=C4=9Bk?= To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Frank , Sai Krishna , Daniel Golle , =?UTF-8?q?Jakub=20Van=C4=9Bk?= Subject: [PATCH net-next v2 4/5] net: phy: Add infrastructure for PHY address 0 fixups Date: Sun, 1 Mar 2026 00:22:40 +0100 Message-ID: <20260228232241.1274236-5-linuxtardis@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260228232241.1274236-1-linuxtardis@gmail.com> References: <20260228232241.1274236-1-linuxtardis@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Certain PHYs incorrectly treat MDIO address 0 as a broadcast address and therefore respond both at address 0 and at their assigned address. As outlined in the code, this is problematic. Provide a way to disable this behaviour via a PHY fixup. It would be ideal to have these collisions prevented early by the bootloader, but there may be hardware (e.g. WiFi routers) out there where the bootloader doesn't do this and cannot be easily replaced. Signed-off-by: Jakub Vaněk --- drivers/net/phy/Makefile | 3 ++- drivers/net/phy/phy_common_fixups.c | 26 ++++++++++++++++++++++++++ drivers/net/phy/phy_device.c | 4 ++++ drivers/net/phy/phylib-internal.h | 2 ++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 drivers/net/phy/phy_common_fixups.c diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile index 3a34917adea7..3bf9ba208b90 100644 --- a/drivers/net/phy/Makefile +++ b/drivers/net/phy/Makefile @@ -3,7 +3,8 @@ libphy-y := phy.o phy-c45.o phy-core.o phy_device.o \ linkmode.o phy_link_topology.o \ - phy_caps.o mdio_bus_provider.o phy_port.o + phy_caps.o mdio_bus_provider.o phy_port.o \ + phy_common_fixups.o mdio-bus-y += mdio_bus.o mdio_device.o ifdef CONFIG_PHYLIB diff --git a/drivers/net/phy/phy_common_fixups.c b/drivers/net/phy/phy_common_fixups.c new file mode 100644 index 000000000000..fa51c6d7b25f --- /dev/null +++ b/drivers/net/phy/phy_common_fixups.c @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include + +#include "phylib-internal.h" + +/** + * phy_register_address_0_fixups - Register fixups for disabling MDIO + * broadcast address 0 + * + * Some vendors interpret MDIO address 0 as a broadcast address and so their + * PHYs initially respond both at address 0 as well as at their normal + * address. This is problematic: + * - Linux may create two struct phy_device for a single device. + * - MDIO address collision may occur if there is another PHY + * legitimately listening on address 0. + * + * The broadcast address can often be disabled through some internal + * PHY register. These fixups are designed to do just that -- + * they shall stop these PHYs from responding at address 0 before + * the MDIO address 0 is scanned for devices. + */ +int phy_register_address_0_fixups(void) +{ + return 0; +} diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index db187d370eaa..2d4f119b45b4 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -3969,6 +3969,10 @@ static int __init phy_init(void) if (rc) goto err_ethtool_phy_ops; + rc = phy_register_address_0_fixups(); + if (rc) + goto err_ethtool_phy_ops; + features_init(); rc = phy_driver_register(&genphy_c45_driver, THIS_MODULE); diff --git a/drivers/net/phy/phylib-internal.h b/drivers/net/phy/phylib-internal.h index dc9592c6bb8e..1e6ff8f2d721 100644 --- a/drivers/net/phy/phylib-internal.h +++ b/drivers/net/phy/phylib-internal.h @@ -22,4 +22,6 @@ void phy_check_downshift(struct phy_device *phydev); int genphy_c45_read_eee_adv(struct phy_device *phydev, unsigned long *adv); +int phy_register_address_0_fixups(void); + #endif /* __PHYLIB_INTERNAL_H */ -- 2.43.0