Article View: linux.kernel.netdev
Article #24901Re: [PATCH net 14/14] net: phy: as21xxx: Release reset before reading ID in match
From: netdev-bot+sashiko
Date: Tue, 01 Dec 2026 01:51
Date: Tue, 01 Dec 2026 01:51
154 lines
13285 bytes
13285 bytes
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
Technical Details
Message-ID:
<179608986208.3146.3404338359227024241@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374622-linux-kernel-netdev=dewy.ruReferences:
<20261130-as21xxx-fixes-v1-14-1bd2eae6ccbc@collabora.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374622-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net 14/14] net: phy: as21xxx: Release reset before reading ID in match Date: Tue, 01 Dec 2026 01:51:02 +0000 Organization: Usenet Network Message-ID: <179608986208.3146.3404338359227024241@kernel.org> References: <20261130-as21xxx-fixes-v1-14-1bd2eae6ccbc@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1587179"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:0UeHcoING67blrVd28xnYH2ogiQ= sha256:zCujZjV0uH69WDy3i11zCPBdiQLyNtTu9/cmk6hs93A= sha1:FXdwQP4aoRBJ68x3oqiJOynYNTA= sha256:8DuZ++4u9zpX0qe9UAflfg6WcAJFwVUVqwFxfAtL2Z4= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 1D3B11171F6; Tue, 1 Dec 2026 04:51:29 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.5 X-Spam-Status: No, score=-3.5 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id n5ah_Robwndq; Tue, 1 Dec 2026 04:51:25 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-374622-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 5C2691171EF; Tue, 1 Dec 2026 04:51:17 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 8474026D83; Tue, 1 Dec 2026 01:51:08 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796089864; b=O4cncSSF654k2HjTqNCzpq8R1J9/yF8kbaKE6Zpd7cPVcBh8cliLxKIJm+cwUIYznaTE uUZuOA0hgBdCwZdvbXo66mE5HDicmiJjoh8tluKSePisO3EMDNF04rPjodYwU+ChzmM13 gQOo9QO/sY+Rz2xd7yVkKEXHWpl0OQQh1V+CpJObIit6/niW8EQBxs+q0O7ukRDRqIo4y NVk8P5G0IPVKPvTFrs4jXJ/ye5bW1onHZc0bkiyH/+WsMHV1S+4GTeYIg4meFjfrmEIWR Z1dMallLkuI81tZ8QnKr67Y4se1PbnT8SHg/lpdNz/d4yZ4pZRB0OLhg1GKyttDowLg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796089864; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=4DlgHX0Hq1L5rg5PSWLZgIcJWEapKTP7QV3PayIaBxA=; b=Fb2Mu2Rucfen9w4trGA8lYOnQONlzdVI2mA0mfBDt+Ac/FTBRXXmnCoKbNNOz5DBRDNd darAprBiSddEM9oVEhYhxhFQDTgkhj+oXNhaymlp1/Y6q6u3aU8QcTTLMSLTUhGTZAGhG AqOEHMj+cG+DHjiUZUC/WNWUeqw5CpUGZ2FN6/+NckZDpalsGfXvyZ4FsDqp1QTegsxlJ tpAlpHeh6Df/8+JAnIr1n9jG0vsGsXdk74mqdE/K0Ve7p1+2kVO0B7Mfb5Pq/2f4Dly4R y0S8YUoeZ4TPGwhLZyFVUG5dskV03lOd4M10yFvxLSe1ZG3w8BSm2Z47XdYYELMhaDw== X-ARC-Authentication-Results: i=2; 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=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 92269606A32C; Tue, 1 Dec 2026 01:51:04 +0000 (UTC) X-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 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-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== X-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== X-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 X-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 <netdev@vger.kernel.org>; Tue, 1 Dec 2026 01:51:03 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E7331F00897; Tue, 1 Dec 2026 01:51:02 +0000 (UTC) X-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== X-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 X-In-Reply-To: <20261130-as21xxx-fixes-v1-14-1bd2eae6ccbc@collabora.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list