From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796089863; b=HPCmNtSLhl2PZt/x4qxIguEXsVDun9N49x3hinXPf/zi5C6xMrmw5MCffEfOt5rpyEcC STGnHhCe2eUEfaMty/yfRmh6NsBVlCJayTcOr1EGEjdjKZnw+2iXjCVvmMbnd7pdnO+EL iv7hpVdd2rAZQT0w8oAy9Vhem+Q6mc65XtOHI5zERhf2+7Ucm3DQBGj4Fz4CLjhFHWe6k j9wNGA0juKFEELFcWYKHplfVt/DrsvoNKFhc02ZR+eQI4SHb/udCiu6iVcUwbBjUxs927 zo1EWm9G7jEo9Hatam7GM8olFch94T7icLwDTGOshzNcBRpw262BohYcBhZEi1+UPSw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796089863; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=4DlgHX0Hq1L5rg5PSWLZgIcJWEapKTP7QV3PayIaBxA=; b=CCmaLbKU209y5VkNGZDEPmtfaHDNRLnxHl2GGEL+UKnsa7T5LgMQTsr9mIiLpxc5zpTe iYw7SYGypeNEWwDSp7PyU77328ZFImaFhmxhVleXlha8J6ZjBjXlE9lKQobi02rqp6OPZ 4pkhZgeUDPLlNPJMj6SO+2the0k/iTkg5bXU1iegUVuvNthjw5K/dX6jMb1IyCudJuquo wqEn6iTfJQt8Q7VE46cwVVmfkVIgebbLIZGKFu8B6unDsEMDi39wyZFyJ/vgrxgUh5pBu mvScefsrb/khU7xB5cf/Zx9zqW6HsxuH1CyTsQc6oB8qi4OJFwTK4x+bSMnbHMrNT9g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=IjbHkHUX; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B054D606A32F for ; Tue, 1 Dec 2026 01:51:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=IjbHkHUX Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E7331F00897; Tue, 1 Dec 2026 01:51:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796089863; bh=4DlgHX0Hq1L5rg5PSWLZgIcJWEapKTP7QV3PayIaBxA=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=IjbHkHUXx7sTFVOndz7LWb0NEzc30QebwmWZMwYAPdB7m3WI00jhqT9uktmjDvzyS DrXhSmpbhcZ2mME95IyOstl/AxABC+rTCytEw93h+F2Td7cOJAfrR2Q02G20Acdiaw YO1eTS63wPZRjq0G1CBgxPZPCC6KOnczmJWrFLJWtAE1OpeeLCdOqNX+Zt729gEG5J 1En/ZZ+dXQPnM/gWKRgKFFIhdT5YBdSahWXN7F/WJn+igtlf3iboydxEthgB+dGmES wtZjFc1rgvGBriyRDpNB2nOmeV3TDm6e8Y7L6zj2UMH1orRMSturo/92oi2b8TMpB0 SLkjGyHv3917w== Subject: Re: [PATCH net 14/14] net: phy: as21xxx: Release reset before reading ID in match From: netdev-bot+sashiko@kernel.org To: cristian.ciocaltea@collabora.com Cc: ansuelsmth@gmail.com, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, kernel@collabora.com, netdev@vger.kernel.org Date: Tue, 01 Dec 2026 01:51:02 +0000 Message-ID: <179608986208.3146.3404338359227024241@kernel.org> In-Reply-To: <20261130-as21xxx-fixes-v1-14-1bd2eae6ccbc@collabora.com> References: <20261130-as21xxx-fixes-v1-14-1bd2eae6ccbc@collabora.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 0 (1) · Medium: 1 · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] The new phy_device_reset(phydev, 0) call in as21xxx_match_phy_device() (as21xxx.c:1203) writes the reset line and… Pre-existing issues: - [High] This problem wasn't introduced by this patch, but it is a serious one. -- net: phy: as21xxx: Release reset before reading ID in match This patch deasserts the PHY reset in as21xxx_match_phy_device() before the PHY ID is read from the hardware. Without it, a PHY that phy_remove() left in reset reports an invalid ID on rebind and never matches. Once out of reset, the PHY reports the generic ID again and the existing firmware loading path runs. > diff --git a/drivers/net/phy/as21xxx.c b/drivers/net/phy/as21xxx.c > index 5eea6baa75bfc..761458c606a26 100644 > --- a/drivers/net/phy/as21xxx.c > +++ b/drivers/net/phy/as21xxx.c > @@ -1196,6 +1196,12 @@ static int as21xxx_match_phy_device(struct phy_device *phydev, > PHY_VENDOR_AEONSEMI)) > return genphy_match_phy_device(phydev, phydrv); > > + /* phy_remove() leaves the PHY in reset and only phy_probe() releases > + * it, so release it here to be able to read the ID on rebind. No-op > + * if there is no reset or it is already released. > + */ > + phy_device_reset(phydev, 0); [Severity: High] This is a pre-existing issue and was not introduced by this patch. The comment above says "only phy_probe() releases it". Doesn't phy_init_hw() also release the reset on a PHY that is still bound to the as21xxx driver? phy_detach() always asserts the reset, but it only releases the driver when genphy is in use: drivers/net/phy/phy_device.c:phy_detach() { ... if (phydev->is_genphy_driven) { ... device_release_driver(&phydev->mdio.dev); phydev->is_genphy_driven = 0; } /* Assert the reset signal */ phy_device_reset(phydev, 1); ... } On the next phy_attach_direct(), the as21xxx driver is still bound, so neither match nor probe runs. phy_init_hw() then deasserts the reset: drivers/net/phy/phy_device.c:phy_init_hw() { ... /* Deassert the reset signal */ phy_device_reset(phydev, 0); ... } The commit message says the PHY comes out of reset with its firmware unloaded. aeon_firmware_load() is only called from as21xxx_match_phy_device(), and the driver has no .soft_reset. as21xxx_config_init() only clears priv->top_spd: drivers/net/phy/as21xxx.c:as21xxx_config_init() { ... priv->top_spd = 0; return 0; } Would the bound driver then send IPC commands (config_aneg, LEDs and so on) to a PHY with no firmware running? In that case aeon_ipc_wait_cmd() would time out, and priv->parity_status would no longer match the hardware. The IPC parity sync, PTP clock enable and DPC RA setup done in as21xxx_probe() would also be lost and never set up again. A plain ifdown/ifup looks enough to reach this on MACs that connect the PHY in ndo_open and disconnect it in ndo_stop. stmmac is one example: it calls stmmac_init_phy() at open and phylink_disconnect_phy() at release. It needs a board that describes a reset GPIO or reset controller for the PHY. The match-time deassert added here does not cover that path. [Severity: Medium] Can this new call race with other reset writers on the same PHY? as21xxx_match_phy_device() is called through __driver_attach()->driver_match_device()->phy_bus_match() before device_lock is taken. phy_attach_direct() probes genphy through phy_probe()->phy_device_reset(0), and phy_detach() asserts the reset. Both run under RTNL only, so nothing seems to serialize them against the match path. mdio_device_reset() does an unlocked check-then-act. It only stores reset_state after it has driven the line and slept: drivers/net/phy/mdio_device.c:mdio_device_reset() { ... if (mdiodev->reset_state == value) return; if (mdiodev->reset_gpio) gpiod_set_value_cansleep(mdiodev->reset_gpio, value); ... d = value ? mdiodev->reset_assert_delay : mdiodev->reset_deassert_delay; if (d) fsleep(d); mdiodev->reset_state = value; } Take an unbound PHY held in reset (reset_state == 1). Could this sequence happen? match path (modprobe) ifup / ifdown path mdio_device_reset(0) GPIO = 0 fsleep() phy_probe()->mdio_device_reset(0) GPIO = 0, reset_state = 0 phy_detach()->mdio_device_reset(1) GPIO = 1, reset_state = 1 reset_state = 0 The line would then be asserted while reset_state says it is released. Every later phy_device_reset(phydev, 0) from phy_probe(), phy_init_hw() or this match call would return early. Wouldn't that leave the PHY stuck in reset, which is the state this patch is meant to fix? Before this patch, the match path only did MDIO reads under the bus lock and never touched reset_state. -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130-as21xxx-fixes-v1-0-1bd2eae6ccbc%40collabora.com