From nobody Fri Sep 25 00:41:18 2026 Received: from mail-wr2-f12.google.com (mail-wr2-f12.google.com [74.125.225.76]) (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 711D63C8700 for ; Fri, 18 Sep 2026 01:50:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.225.76 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789696248; cv=none; b=aXtT5XHqw0KKjnhhBZ6NCP/WUpri/0c2wPmtodMPDZkvUHM8hWmi5gehS+hfn/SL5yOa6RCgoXru4RZYxaMklsZno0ofZxtndE+LdAusiHUfdTQaj1gSu3Y+I6Bc13kPdzEVZEPrziuD0xzIx0LnzpNbv8xYPyfOgltoPrEWvqA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789696248; c=relaxed/simple; bh=ie+Fks8qvoH2s91CTwbbOujmR4Ipol0/ojc69WvScig=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PWo1af0lPQCADpxykpEEUSox4cNkfuY6NfXgqz6tmFZRAsVrPPYxl4nKyZFfs1H+YXdQwyMffmh1Jj5YDLcKNLpplZ0x01jpZsILN32yaUnwMKVxSDnVy7H3BvQ+1RMGHGaEUzxRQBwM4UNaWjGnOCuuer8zAz7Lp1+7qLfB2+0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=lex.la; spf=pass smtp.mailfrom=lex.la; dkim=pass (2048-bit key) header.d=lex.la header.i=@lex.la header.b=JUA9YVX0; arc=none smtp.client-ip=74.125.225.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=lex.la Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lex.la Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lex.la header.i=@lex.la header.b="JUA9YVX0" Received: by mail-wr2-f12.google.com with SMTP id ffacd0b85a97d-482f633cd78so71286f8f.1 for ; Thu, 17 Sep 2026 18:50:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lex.la; s=google; t=1789696233; x=1790301033; 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:content-type; bh=R3EdtN6qtnpTbUr6qyK3WOaZ6BRajWizEp8fE4gWzmw=; b=JUA9YVX0ffaOhhQIZVaEAVfFRKBtZ25S6uN5vhPH+sqxcWIWvkANdlYmLEPjXqAK0T dNcwODf4aZKX7ntsiXVEgvvhP30pA49uSw3CKPZynNXD8CGjxp2nVyRWV8FU9554IKr4 TH9/W3dyy0WMG0GRObiS4Kqgm8r2QBiZ5fZ57j/oLJT3qg92PpjgeZ/5JhWNkWRXKsAe H1EEma+IJeeChISGc9Y2zgqmdqYi8AINgVJkBp2GB0+33qS84A4ccxtdWcpN/J3XHy4p HbIjwyyNG/C460Md8itX/ELDN9ehRotAyeUL+ayp+9hXUxu5kIqI9RmQBypW/64kk+/o gBjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789696233; x=1790301033; 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:content-type; bh=R3EdtN6qtnpTbUr6qyK3WOaZ6BRajWizEp8fE4gWzmw=; b=MK0crh0XN7kV0Olf7TAFlNblQcBfqXZvnGvXwtMu93WOUCgMMTsa2nk92RHYWk2EMo pjEz9G+POC97HhZZRj82oFBM6fdW5p+xW9FXtZwIMn/C3ghORS+FOc5jzNWgWastSbp8 JGjmfLRXgUegkU7M1amT9hL7Yjr7yxO91l4AZzJfKiXL7vViA5a7gZYMiaLn7ttfPymI Dt8RGc3wNvn8BiSIfvohcVRcOSAkGul1eNVJbRZE6eqWb+kWuU0F2pvxkclLNyNddNE+ Q4adeQ3bc89oAzFuZj9L6ENdRd+evuSN/bVxgA7QY3N1tGNDEXo+yISgdd3DM4YzOv+P E6Lg== X-Forwarded-Encrypted: i=1; AKwUvBxW+gvm/aYcjrKH6cRAAwYFb3BH9YYDpRTgiCVI0MKrwP8ssIhUjRWEq9JvAjGhCoQ+tQa9OfBtgMGmbuY=@vger.kernel.org X-Gm-Message-State: AFuF++mj0jrfT9ET2SQdy5yDWHmlWG1hmIn0oMoVRKCIAba3Uu3ozwn8 59WBV6D9hm8fs0QKx9VeX2JhAEWJtbphJujB774qsNI7zg0uXpd8A9WvT0tGbRf1LZQ= X-Gm-Gg: AYBFou1Iv222LRR0UC3q7Yw0KJqZOX/dr7sEZ4BHWAJHZdgbfFYCMs7KaoKTJ4Jy3B+ 2SBRXHeL2saMHP/TkWvZdVCM8EdLFAc58GRb8UKz/ioDnakc0KoKkD/LE2fJD36LN1KOlUcRTze 1xsbS8QChRb6vWY+bQ/9VOGCKrYoFCYn8WXRdDgLjgjh1UjhXHqXeMRns0ZKWJmvkkRBrcOssdT X7oX2+lAbR8WnDWETIjGvTdUfaoXnfqcORgyG8TjEMGq01CihKATNusDnSM+9GRKqYFUBZR1s87 PJ+Mw05ng1ic8YE/pS4txw3OlChiVOYwSpA31eyxFuG6GJDhtE/YzI9gyp08be2vhB78nx3Jxos +eNYEvZwCADHsTyfDGanRZCZp4YaDDOjAFF+TnZ0nXG0VrtSlhjnTaPJu/R95BC71QAEwuhDJQK MoLLfYsInQS6qaFOqRqR+q+zgZNTEgbypkp9oakRiy22ywSt1YGA== X-Received: by 2002:adf:e187:0:b0:486:ed36:b9c with SMTP id ffacd0b85a97d-4871e269f3amr845004f8f.29.1789696233046; Thu, 17 Sep 2026 18:50:33 -0700 (PDT) Received: from remote-01 ([84.17.55.229]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-487200745b5sm64224f8f.26.2026.09.17.18.50.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2026 18:50:32 -0700 (PDT) From: Aleksei Sviridkin To: netdev@vger.kernel.org Cc: andrew@lunn.ch, andrew+netdev@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, olteanv@gmail.com, Thangaraj.S@microchip.com, UNGLinuxDriver@microchip.com, steve.glendinning@shawell.net, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Aleksei Sviridkin Subject: [PATCH net v8 1/4] net: usb: lan78xx: register the PHY interrupt with the MDIO bus Date: Fri, 18 Sep 2026 04:50:26 +0300 Message-ID: <20260918015029.2518425-2-f@lex.la> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260918015029.2518425-1-f@lex.la> References: <20260918015029.2518425-1-f@lex.la> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The interrupt this driver maps for its PHY is written only into phydev->irq, while the bus table mdiobus->irq[] keeps reading PHY_POLL for the same address. That table is where phylib records what the bus described - phy_device_create() seeds phydev->irq from it - so the number lives only as long as nothing else writes that one field. Put it where the bus keeps it and take phydev->irq from there. What the PHY is attached with does not change. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin --- Notes: Compile-tested only; I have no LAN78xx device. =20 No Fixes: tag on this one. On its own it fixes nothing - nothing reads = the bus table back until patch 3 - which is also why it sorts ahead of that patch rather than after it. =20 The else branch that forced PHY_POLL is dropped rather than moved to the table, for two reasons. It cannot run: lan78xx_setup_irq_domain() retur= ns -EINVAL when it cannot create the mapping, lan78xx_bind() gives up on t= hat return, and lan78xx_phy_init() only runs afterwards, so phyirq is always positive by the time this code is reached. And if it could run it would= be wrong in the other direction: this bus is registered with of_mdiobus_register(), so the table may already hold an interrupt the devicetree described, and forcing PHY_POLL over it would invert what patches 3 and 4 are for. =20 Teardown order keeps the number live for as long as it is read: lan78xx_disconnect() detaches the PHY through phylink_disconnect_phy(),= and lan78xx_unbind() calls lan78xx_remove_irq_domain() only afterwards. drivers/net/usb/lan78xx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index cb782d81d84f..d02e4ffcbbc1 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -2892,11 +2892,10 @@ static int lan78xx_phy_init(struct lan78xx_net *dev) return 0; } =20 - /* if phyirq is not set, use polling mode in phylib */ if (dev->domain_data.phyirq > 0) - phydev->irq =3D dev->domain_data.phyirq; - else - phydev->irq =3D PHY_POLL; + dev->mdiobus->irq[phydev->mdio.addr] =3D dev->domain_data.phyirq; + + phydev->irq =3D dev->mdiobus->irq[phydev->mdio.addr]; netdev_dbg(dev->net, "phydev->irq =3D %d\n", phydev->irq); =20 ret =3D phylink_connect_phy(dev->phylink, phydev); --=20 2.53.0 From nobody Fri Sep 25 00:41:18 2026 Received: from mail-wm2-f12.google.com (mail-wm2-f12.google.com [74.125.225.140]) (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 86D5A3C769B for ; Fri, 18 Sep 2026 01:50:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.225.140 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789696251; cv=none; b=VVUH4cRABf2V9wg2z6PbTM1EB//7OVAUIqCmnlxi+hLFYso3PCEVl0Ven93428ppzP/EAB2/TY9ClomNErBDbv2fyx0UR6Tv2/25AaciHZVyik3snhBtFBi02MnB3dsAHEl3aWg02mXwDXa1r9JaQAOSPlubdrdWLm6Obh0CTJg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789696251; c=relaxed/simple; bh=U6Ifbz5x0kVweq8mt/nG0FzHuV5MzqSu4AL+yPCKtnU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jikiOpawEfPoC3GRe/1wEvzhIOHr40zB0z6JUFHHHkHTZT1Tqvqy70xH5S/5vJ/QS06Os4pvhvFOYDyFfZgFefI2mVAtWynTGSN9DetKjpDmUDTSQOykZNQFXoaQ72TBD2jkn7AEWeH9Ah6OXQGja5KVc1Axx1MpMATyAlixbEg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=lex.la; spf=pass smtp.mailfrom=lex.la; dkim=pass (2048-bit key) header.d=lex.la header.i=@lex.la header.b=hSrFgtXA; arc=none smtp.client-ip=74.125.225.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=lex.la Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lex.la Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lex.la header.i=@lex.la header.b="hSrFgtXA" Received: by mail-wm2-f12.google.com with SMTP id 5b1f17b1804b1-49e66390995so1005615e9.2 for ; Thu, 17 Sep 2026 18:50:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lex.la; s=google; t=1789696234; x=1790301034; 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:content-type; bh=O4QKzdzhXx3trVjHguVbL/tPhlBogzEsqfZIRGP8UlI=; b=hSrFgtXABYXnSOExmVjFqhtGmU5DyE7hDkypLTvCcKKpqkFJWJnFee+IPpdiSX2+Pb UbwMInoJOpbsSc2WxidhFtjuwpeS1OYbFCByRh9O/mIKgPAmEzErQHlUhdDR7exurQu8 4PsgHOx/tkYaBOMjOfBLkkJzk134djbsJv/uUzwpGo5PKUxNO9ukVUnBiv5DrJkycLnL iz20N79ktm0wezPLKPUxz6aRpDg/z+uHyB5BVoVMC1c8MeXay7YXbKYeuXbCs6Bz5wNU by9A273MpD2OSkXP1e0ufghFo3JyQjfG1CNS+AVBHT9wFjnD3/GiJjZRvFoNbDBmb6GY 4rug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789696234; x=1790301034; 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:content-type; bh=O4QKzdzhXx3trVjHguVbL/tPhlBogzEsqfZIRGP8UlI=; b=UweMZ09xzGpcN8q1s5tTzNzJxpfsn5suQ6LIfNzC4w+/oUKHtqwCbAYNZlXNsVyXer 3rH+hwqd9sDCmjavRTWrDFbW7NrXINxQGDWsZ8iXttIafFGLEzUma1t5DTCgiR4Ql2mo yih76wys+532VX+6Mpuw5zfQI6vtjySqQ7HWptRPGeXPF3IaYv4mfYI5MVM29wmsdj6K uY2l0mIT54sQC0NOomJRAtV14B7kqUclzuiH2AhVqc75SIERx8+h48yGcGKGY7eHG1v2 QtSUv38aUIHDikCsrNbOEkylY37tLJumcu6QB3pYmoHOxZz/yQyxXJ/Tld3oDeArbiCL d5DQ== X-Forwarded-Encrypted: i=1; AKwUvByZh+EDSMBki9khWGO/ooqgV3R5jxmYagUvIoJewtJ7bFHM3oqZlV72Wrm61dDhkdM5LKNXTpTBRuonzkA=@vger.kernel.org X-Gm-Message-State: AFuF++lVuGhUyI0UJkY/jyeV4hi+DJRYffjk14lla30km3PuVT3WTk+x vVVkQVSKRgY3IUH+1gtQOyu+lNy9Ga6Qw61YTuDl7p+zyoB9/PV9qYuA0qLm9OaqOLU= X-Gm-Gg: AYBFou0uc/DSeSY0pbZUmajtx6QuIhjvxWwKv5ErBK1pebn++OQ3HmpxTaiPe5CalMN YiCgazf9U3P/vNwyXK1ljYVDvRq9HshSBA/z+/qXedgl0sB/pDMD8cJJpddEv5zr7xgEE/MQfdX 5qlZ6RBNUlbaDGhLKCCJwdBbdqWMnB69V6jamaCYgQRIwUfM8VhdpNH+KLty0lkLfqvva85TKJZ kAmqEf0RwvfrlwzGRqT41P1OsXQrsKLBZb5aFnI07BBWCz/3eIQEYEr5Q6Rl2+mJSBw5Hhlz163 3O6rspRHLHl75JgNkZuhfLuOK15VuUkXG0E2DtcLLhFd1MAvsJXfeyc9RrwuqBuElHNsSrdiNX2 TdUPeAkgonys23tebc4N2A5X27IaHubOHaI8gSUlsvNswRsEALzrXJXcWXm1idjd7NUwFjBhcAk QUSDV+RSif6EDk3f7g1nyB+NyP0JVNjGgXZWAD2s++tu5jCX42oQY= X-Received: by 2002:a05:600c:8b21:b0:49d:16f1:94a5 with SMTP id 5b1f17b1804b1-49fc57542b7mr7295435e9.25.1789696234474; Thu, 17 Sep 2026 18:50:34 -0700 (PDT) Received: from remote-01 ([84.17.55.229]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-487200745b5sm64224f8f.26.2026.09.17.18.50.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2026 18:50:34 -0700 (PDT) From: Aleksei Sviridkin To: netdev@vger.kernel.org Cc: andrew@lunn.ch, andrew+netdev@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, olteanv@gmail.com, Thangaraj.S@microchip.com, UNGLinuxDriver@microchip.com, steve.glendinning@shawell.net, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Aleksei Sviridkin Subject: [PATCH net v8 2/4] net: usb: smsc95xx: register the PHY interrupt with the MDIO bus Date: Fri, 18 Sep 2026 04:50:27 +0300 Message-ID: <20260918015029.2518425-3-f@lex.la> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260918015029.2518425-1-f@lex.la> References: <20260918015029.2518425-1-f@lex.la> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The interrupt this driver maps for its PHY is written only into phydev->irq, while the bus table mdiobus->irq[] keeps reading PHY_POLL for the same address. That table is where phylib records what the bus described - phy_device_create() seeds phydev->irq from it - so the number lives only as long as nothing else writes that one field. The bus is the one this function registered a few lines earlier, so record the number there as well. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin --- Notes: Compile-tested only; I have no LAN95xx device. =20 No Fixes: tag, for the same reason as patch 1: the write has no reader = until patch 3 lands. =20 Teardown order keeps the number live for as long as it is read: smsc95xx_unbind() disconnects the PHY before it disposes the interrupt mapping. drivers/net/usb/smsc95xx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 42e4048b574b..130a460c1f54 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -1252,6 +1252,7 @@ static int smsc95xx_bind(struct usbnet *dev, struct u= sb_interface *intf) goto unregister_mdio; } =20 + pdata->mdiobus->irq[pdata->phydev->mdio.addr] =3D phy_irq; pdata->phydev->irq =3D phy_irq; pdata->phydev->is_internal =3D pdata->is_internal_phy; =20 --=20 2.53.0 From nobody Fri Sep 25 00:41:18 2026 Received: from mail-wm2-f13.google.com (mail-wm2-f13.google.com [74.125.225.141]) (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 556FF3C819C for ; Fri, 18 Sep 2026 01:50:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.225.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789696249; cv=none; b=TQginVtsbEDO8pVhWkNlTBiYjybPaBA1YouaA9QBjwTP6bxh17FK33tAYzNluXeaoS/4gwXgiFL7SfBOpjmqiKMRxcvvRMeWMxRnl4NtSrLWu7ocBW40mDGcmb3emSvt+ATL1lQiLPThL3DZhNwyhoNFKfy+HKangBituFotp+w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789696249; c=relaxed/simple; bh=RVGN8hzTYET+YVR10seErUDioE6Go3OGl3hghfGt/to=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dYiz6Tp5gu9fRX+nZ8dJoJZL9WYG5dE8pE7m9zZTDVgc4L6BU5yvmXh0ZYqpusTOu2ZlCRYr3wvlyfYJ56u34yONdK33nrqtzhRcGCjrjPWsq6qscHuN3iEerJkv7krxyeKfYD+X6EVUCl3SKQK6O5zUbWLdAr98gudWiex2CB0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=lex.la; spf=pass smtp.mailfrom=lex.la; dkim=pass (2048-bit key) header.d=lex.la header.i=@lex.la header.b=Ap2oGuPE; arc=none smtp.client-ip=74.125.225.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=lex.la Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lex.la Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lex.la header.i=@lex.la header.b="Ap2oGuPE" Received: by mail-wm2-f13.google.com with SMTP id 5b1f17b1804b1-49e69b9e16aso2349055e9.1 for ; Thu, 17 Sep 2026 18:50:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lex.la; s=google; t=1789696236; x=1790301036; 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:content-type; bh=q158t0WkzY9BaWR+kDYunaW5YNuuwcBnK9ppmpGR5hY=; b=Ap2oGuPEDn85SG9pzCZymxuQCjqZWsy2efRxuW5htb0U5TlG4rgLi7u0l8NfybLjHw g/fqXmsvk4vOaX8joaiFk1xPIQUV4gaF1kOCDZudfotfufIzehZnhKJdb3TmkykjUCU7 M9s/AiI84wc+t9iE3ARVYnKwKHpHhv0IFCCkB/7uREG86IwKp3Yl9Z+u2viRYs2PKjsO jut3CcWGeRERCceKuEBd+gJ2G/nk1xZuiSrCEehqkl28TdgjzGJQF7AmoG1xhliggaCL GZt4x3y+njiF2JCy79lbNCrNSC4VeQtmvFEC44rdS3MsO1MPRF7Lu+vkPr5gy9PwV208 qbwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789696236; x=1790301036; 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:content-type; bh=q158t0WkzY9BaWR+kDYunaW5YNuuwcBnK9ppmpGR5hY=; b=N74gPROd3JJsg81L9SxjrYWOOgw1gFR1LloZ5gcowQDg9eCZdoQHeTWTabWKknxrZ3 bGqPyAfbtkQ0ZfEJwIiAiQUQN/CY6I2WQaOxdh42gxfkLFyZ/ESq72NDJjMWOn9skDiV VkCjy48P6H+gdh+VSMnR2sV3Z2W7h81j6XWNiNik3YWPHzl130JjLETJULuYOpxuLxw1 4YjL+W1E3htiQW3tCowE4CPHsJUt3dUhdywGcrcvM6IJAjN1RPogu5OQglxml2ujzON1 Kuxl0Bfj8zCNZFWCiJ3HxA/Ahn2f6+OraM7WHqSlC8iYASX3sQVAbkQWKXmv/s4ih1rA zfgQ== X-Forwarded-Encrypted: i=1; AKwUvBxcIsOCS8ZIuYoMVpQ7zMEgzRaaDkXhqxVexzVGDvzFidUPrgN4gktY74FBgMfEAwG+QsK6sTbflt/0Xlc=@vger.kernel.org X-Gm-Message-State: AFuF++nbg6He6WkGXT88u8aW1uAeM0LhO9XS2LWe0PFQp4OuVL21mE30 rneDUQmX3nMlHQ53GOTtOXvfUyhTNmaO1imAWDry8sBPZURq3MQiAB6qn8VC/fCMOGM= X-Gm-Gg: AYBFou1jgwbj+QH9effU02qtwW6eutXT3u+QXezWdUQRq+CdIUsuJCk8gyfzo/sZzja 09Le6sbA3fhU2S8k2Tl99EDG+k9HnMnNr0HA3c08fSvTtxFmo4MoPxfE8+yUFjKvQjFsslznWUU S+VLRsiupd1ynPXuQA3ev/J7xB0ObY5stZE7jrXgmu9QOi+DrVdMEhTBp6dFUSmEqAENLH8EKdu zINrGxkoqcgQ2Js+0vrDrnpryWxh38KjhWPMld6lYgzV+RVqgUVA7lzFIYOARIg+lXJgdb6EwGT ABGPFSfYOcStCB45RL3Ep0dgsMJo2BAY4jdTP37bn1u6YR1Hz/z+W1xJXma8/ro0pdzXSKTrv2/ eEF79t/zgPl31m6ZSjIL4xWJ6RSza2nXMDtd2u27LptuGtmeJB194ZHjYJkxwjSNrQKK7RDBKtt R1AdhC0A7g4XR+Ah1cUSaykRFf6WbxFs1SMpJZ3wcQwBJaqTSavQ== X-Received: by 2002:a05:600c:1c05:b0:49c:edfa:15a with SMTP id 5b1f17b1804b1-49fc56af038mr9801335e9.13.1789696236071; Thu, 17 Sep 2026 18:50:36 -0700 (PDT) Received: from remote-01 ([84.17.55.229]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-487200745b5sm64224f8f.26.2026.09.17.18.50.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2026 18:50:35 -0700 (PDT) From: Aleksei Sviridkin To: netdev@vger.kernel.org Cc: andrew@lunn.ch, andrew+netdev@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, olteanv@gmail.com, Thangaraj.S@microchip.com, UNGLinuxDriver@microchip.com, steve.glendinning@shawell.net, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Aleksei Sviridkin Subject: [PATCH net v8 3/4] net: phy: take the interrupt back from the bus on detach Date: Fri, 18 Sep 2026 04:50:28 +0300 Message-ID: <20260918015029.2518425-4-f@lex.la> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260918015029.2518425-1-f@lex.la> References: <20260918015029.2518425-1-f@lex.la> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A PHY whose own driver is a module on a filesystem that is not mounted when the MAC probes gets the generic driver first. phy_probe() replaces phydev->irq with PHY_POLL because that driver has no interrupt support, nothing puts it back, and the PHY polls for the rest of the uptime once its real driver takes over. Take the number back in phy_detach(), from mdiobus->irq[], which is where phy_device_create() seeded phydev->irq from and where the bus that described the interrupt still holds it. Do it before device_release_driver() rather than after. That call returns with the mdio device bindable and the device lock dropped, so from then on a phy_probe() on another CPU is the other writer of this field. Ahead of it the generic driver is still bound, and a driver registering meanwhile is turned away with -EBUSY before it can reach phy_probe(). Fixes: 00db8189d984 ("This patch adds a PHY Abstraction Layer to the Linux = Kernel, enabling ethernet drivers to remain as ignorant as is reasonable of= the connected PHY's design and operation details.") Assisted-by: LLM Signed-off-by: Aleksei Sviridkin --- Notes: Found and measured on an MT7981B board with an MT7531 switch and an Air= oha EN8811H behind lan4, whose interrupt the devicetree describes and whose driver is a module. =20 The one condition arranged for the run is that the PHY driver module lo= ads after the root filesystem rather than from the early boot list this distribution normally puts it in. The distribution's own late-PHY handl= ing was also removed, that being the one patch which could have changed the outcome; upstream has nothing like it. The kernel is still a distributi= on one and its remaining patches to phylink and phy_device do run on these paths - none of them writes phydev->irq. =20 DSA then sets the port up at 1.87 s, the generic driver is bound by han= d, phy_probe() replaces the interrupt with PHY_POLL, and phylink rejects 2500base-x against it: =20 lan4 (uninitialized): validation of 2500base-x ... failed: -EINVAL lan4 (uninitialized): failed to connect to PHY: -EINVAL =20 The real driver arrives between 13.4 and 13.6 s depending on the boot, = and binds. phydev->irq then reads -1 without this patch and 15 with it, 15 being what the devicetree gave that PHY. The three switch ports alongsi= de read 79, 80 and 81 in both runs, so the reading distinguishes rather th= an printing one answer. The field has no sysfs attribute of its own, so it= was read with a debug-only module parameter that walks the MDIO bus and pri= nts it. drivers/net/phy/phy_device.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 94b2e85e00a3..8e6b399f95d6 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -1959,6 +1959,9 @@ void phy_detach(struct phy_device *phydev) if (phydev->mdio.dev.driver) module_put(phydev->mdio.dev.driver->owner); =20 + /* The release below can hand this field to a probe on another CPU. */ + phydev->irq =3D phydev->mdio.bus->irq[phydev->mdio.addr]; + /* If the device had no specific driver before (i.e. - it * was using the generic driver), we unbind the device * from the generic driver so that there's a chance a --=20 2.53.0 From nobody Fri Sep 25 00:41:18 2026 Received: from mail-wr2-f12.google.com (mail-wr2-f12.google.com [74.125.225.76]) (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 EF77C3B6C01 for ; Fri, 18 Sep 2026 01:50:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.225.76 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789696251; cv=none; b=cA0Fm6u/Z1d7CVdbmDVEKul236t8jiFim7fK+AzQdD1zbAEwDvXOkFoSJVCuD4mL4wMDF3/AhvuvGefPFByDrghmDNa7EWr1QBGXFsRrgdWXpEx+OSXM6/vGFoFPwCSFOXt0tXkxYZn6XgUtwGgakE1Iq8ENE0E2PhP7UUUn/fQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789696251; c=relaxed/simple; bh=S7ePkob3/GuqIMG+tW2ujUp2bKDMmFOO3lJTaMe4SK8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F+r704U0qQ9fYTnctvuIrzOxh2oUrsHs2TKCvpCvIQijpqaWoOa0ykcWOPyPHLVdvqMlcrYfebF/ba1/ADaroFD5iB0G2SoiEwwupdHGBk9iesMcwOqlpSuXRkVwhwhX1W8/akmrbf+pTMY44fmH+ZNzDar3f3qOCMCFpukJ7e0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=lex.la; spf=pass smtp.mailfrom=lex.la; dkim=pass (2048-bit key) header.d=lex.la header.i=@lex.la header.b=Zgl5QKiV; arc=none smtp.client-ip=74.125.225.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=lex.la Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lex.la Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lex.la header.i=@lex.la header.b="Zgl5QKiV" Received: by mail-wr2-f12.google.com with SMTP id ffacd0b85a97d-482f633ecdeso143051f8f.2 for ; Thu, 17 Sep 2026 18:50:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lex.la; s=google; t=1789696238; x=1790301038; 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:content-type; bh=h8/QzaOvuYz09a1yMMjoP6+PjLyBemxWXi2J1WATJSo=; b=Zgl5QKiVtj1hgIc4V/+y1XbpXLiK554mF+zLr38RHx2xVNrz7DH2dAfhQOimSPhSN0 0WxGttnPHELPeZOL2FqkoJIDCKJp4zGTR2n79bXQA0drMXwivd7VU0d+IXFTwMYL6Qhb hSVNtTdQ5SKowrjuDKDw+IB9eOhQlMWg2OCbjKfTPiS0ZdN3HZHkdhY9kMLDeHMB5JMI D9YUV276/nUOqxyumpd3Jhi+I55+ViGFpf3fpDh/nnDZZQ0na7NwWV1//TfzZbRVZAPO f/fwwvXhRPA60vAL9/G6Trg0aULRRTXI4HibOH4sN8/LelYcpAdshbWxeMl8Qv6HsuSo jpcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789696238; x=1790301038; 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:content-type; bh=h8/QzaOvuYz09a1yMMjoP6+PjLyBemxWXi2J1WATJSo=; b=n/UfeSo6XC1x0V5hPUGSsjJL2Y8uzr7cTuJxoKgtC3IlgxrVve1pZV1rzrvaYoV1aP EvPlSarRr8wfSrfIt2Ae5H24ysn5IZQEkhI6RRyEnnx2qdBn6tPYMKkRnaEFLgiudoXX 0PFqYXgQ1nscn46T8mvmH9Esb0RO3Do3n3NL/V86eGPnFU/2Xx+Y+eO3yiw0FiEdR03R TVIUXGbhItujOMp/GnE8NqHNLNcphfRgoQHiaUN0UdI2ILIR5SQbnGL8vG8NUGCAuSRM H+UkhQJXqul30m8v06ex967FzBlUFbYrW38ZtwHvcbIhvhCRsyrvvFTkjFUoLiDU8SUn zutg== X-Forwarded-Encrypted: i=1; AKwUvBziq4KUwugGJQV3/2R5EyiirOwVdtCmYJ97zZU0qW4MKL4IaIgosRH0D4a7c7wypKBk9NG8i0yXwDVAX9E=@vger.kernel.org X-Gm-Message-State: AFuF++mRafXrtpyzDE4oa2i7TilSqyQ5M2be/cNV1f6xK4/e+zRWB1KF cffnzIWrSnyls/vVwInbqE6UKVUT/GTSILxsVKBJSupBtW6POh5f0xApe6IVKUuyfgY= X-Gm-Gg: AYBFou2xSYQ/nCo/CO2GLUmiNg02JrWfPWuLN6Slow4bmjOPCJU+nV6EvJvXzld2XXn FRpGis3mh/Nfmhu2PbLkgIhx9C1mI0EuBpAuxuOhJvqMEqfSvU9pbEDEPYEe3MJfRUmQlHDKSKg r7zRy4ceMX7PofccznVKTN25YhMx3UItbpvSbjbqMcP6391I3qbCkTGtGv/aUfZ3w+GJ2ijCQyb +qndkl+eGDLWq608JY8eCqz3nDrSmJxNb1nhEp8srHNhsh70uqczvELrt1mQtIcbuapnpPd1f1g QLj8NW4qTtvTwu+U/xm0cZbUBHByJ8TsYEmScf+sXX+/WvtqGIGJG8yo6SXwMP235SUKYepgLWj kt26e598blKsZ+xZ7uj0yb9rxi4MwslEz1dQo4WTw0cRIerjjgKfJFCTu3SDXk19jPI6Y39jlwl /DUdx9HyocQ9tOgQZ0EYwi+0L1XCfTtAKs1wsDQ+5r6GGYET5LUg== X-Received: by 2002:a05:6000:38d:b0:487:951:20 with SMTP id ffacd0b85a97d-4871e37394fmr837723f8f.46.1789696237739; Thu, 17 Sep 2026 18:50:37 -0700 (PDT) Received: from remote-01 ([84.17.55.229]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-487200745b5sm64224f8f.26.2026.09.17.18.50.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2026 18:50:37 -0700 (PDT) From: Aleksei Sviridkin To: netdev@vger.kernel.org Cc: andrew@lunn.ch, andrew+netdev@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, olteanv@gmail.com, Thangaraj.S@microchip.com, UNGLinuxDriver@microchip.com, steve.glendinning@shawell.net, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Aleksei Sviridkin Subject: [PATCH net v8 4/4] net: phy: restore the interrupt when the generic bind cycle fails Date: Fri, 18 Sep 2026 04:50:29 +0300 Message-ID: <20260918015029.2518425-5-f@lex.la> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260918015029.2518425-1-f@lex.la> References: <20260918015029.2518425-1-f@lex.la> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" phy_attach_direct() binds the generic driver by hand, and the probe it calls is phy_probe(), which replaces phydev->irq with PHY_POLL before either of the points it can fail at. That failure unwinds on a label of its own, which does not go through phy_detach(), so the substitution outlives a bind cycle that never completed and a later attach finds a PHY that can only be polled. Take the number back on that label as well, before it clears d->driver. That store is what reopens the device to the driver core: until it runs, a driver registering on another CPU is turned away with -EBUSY and phy_probe() cannot be the second writer of this field. Fixes: 6d9f66ac7fec ("net: phy: Fix PHY module checks and NULL deref in phy= _attach_direct()") Assisted-by: LLM Signed-off-by: Aleksei Sviridkin --- Notes: Both points the hand-bind can fail at are reachable. phy_probe() reaches genphy_read_abilities() through genphy_driver's .get_features, and that returns the error from phy_read(phydev, MII_BMSR); device_bind_driver() returns whatever driver_sysfs_add() got from sysfs_create_link(). =20 A failed genphy bind leaves the device with no driver bound at all, so = the next driver to arrive binds directly and never goes through phy_detach(= ). That is why patch 3 cannot cover this path, and why the Fixes: tag here= is 6d9f66ac7fec rather than the one patch 3 carries. That commit did not introduce the lost number - the substitution is far older - it created = this second exit from the bind cycle, splitting the failure off the label th= at calls phy_detach(). Before it, patch 3 alone would have covered this, so that is where the backport range for this one starts. =20 Exercised on the board described in patch 3, with a debug-only module parameter that fails the hand-bound generic probe once for one MDIO address. The connect then ends in -EIO rather than the -EINVAL of the validation path, so the unwind takes the label this patch touches. phydev->irq afterwards reads -1 with patch 3 alone and 15 with this one. =20 One difference between the injector and a real failure, since it does n= ot affect what was measured but should not be implied away: a genuine error inside phy_probe() leaves through its out: label, which re-asserts the = PHY reset before returning, while the injector returns earlier than that. Neither path touches phydev->irq. drivers/net/phy/phy_device.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 8e6b399f95d6..69d8911ea7f6 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -1896,6 +1896,8 @@ int phy_attach_direct(struct net_device *dev, struct = phy_device *phydev, =20 error_module_put: module_put(d->driver->owner); + /* Before the NULL below, which lets another probe reach this field. */ + phydev->irq =3D bus->irq[phydev->mdio.addr]; phydev->is_genphy_driven =3D 0; d->driver =3D NULL; error_put_device: --=20 2.53.0