From nobody Sun May 24 23:31:33 2026 Received: from mail-08.mail-europe.com (mail-08.mail-europe.com [57.129.93.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B86B2D97B8 for ; Wed, 20 May 2026 15:14:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=57.129.93.249 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779290061; cv=none; b=f/y/71ea0mAQrvxj5NjtByrzKGxAJwU2WAaatgHtfEVBD4pgkYvv3dLtQu6onG82jApWpdWr6SKbKzl4+S9ekDrbH7zQaeHee8Wzzhy0EcMEd7/cqW5zfgBJhFgSu9ntKYnLzl0ulqikMkT/aYNqzjewOuSDcOYxGYnu/P2BqwQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779290061; c=relaxed/simple; bh=tBU/y8NXwO+HznKDeUAhUrw6+S0levSMmkSBR0DWUOE=; h=Date:To:From:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=lk/ifeV5ylZ0wNd5Pc5iL/Ni0oYSMHDG1ohymaSdhKlnOkTqwTy7tTcw0YrbuS1KeMAlW8xZxw3UojPZeBLLQyU6y+QjrfEtv5tgmkqiWXkgMtUzXlFLVA2pdDl1P/K7JbQ672KdA+tCAAxiFe93GabpMAv4prCDuw/aM1/3eIY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me; spf=pass smtp.mailfrom=proton.me; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b=NKYi+8O2; arc=none smtp.client-ip=57.129.93.249 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=proton.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b="NKYi+8O2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1779290045; x=1779549245; bh=tBU/y8NXwO+HznKDeUAhUrw6+S0levSMmkSBR0DWUOE=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=NKYi+8O2U969qbeyTqpQH7SPY0E8UJibtW3e2OvwqrErFtgRMCynvKNGt19miZg1g e839TLKNeSRIJ3sYDHV0sbrKk8EzHh1QIDzjbBVWmF3qB5fo7jqVtMXpHpMcOv0LVg UhCMRybtwMcJecBy68ssQ+Nw0myoe677aNQX5h/OtS1pW1L7vrjZh773Quw+e5Gt7Y UmySrn1uMzfXOCv6vm1kSUOy123Up5vT+NvkR7FOyQjNJFjY/VYh6Lgjjf7sZQ++Ye byfAizxlX0wMmO9J/NwVaV4pvqFhDqRL2B13USGfD15GhwUiC45bVd1NliMFnFZafM HKjxTClv7ZY2A== Date: Wed, 20 May 2026 15:13:59 +0000 To: netdev@vger.kernel.org From: "leo.moerlein@proton.me" Cc: Hauke Mehrtens , =?utf-8?Q?Leonardo_M=C3=B6rlein?= , Russell King , Paolo Abeni , Buday Csaba , Andrew Lunn , linux-kernel@vger.kernel.org Subject: [PATCH net] net: phy: mdio_device: leave PHY reset deasserted on unregister Message-ID: <20260520151355.1371163-1-leo.moerlein@proton.me> Feedback-ID: 198615653:user:proton X-Pm-Message-ID: ebeb80a96ffe5828a66b7942284ec46f3495edd3 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" From: Leonardo M=C3=B6rlein Some PHY devices are discovered again after the MDIO bus is torn down and reprobed, for example when a parent driver first returns -EPROBE_DEFER and is probed again later. This breaks boards where external PHYs have per-device reset lines described through reset-gpios. mdiobus_register_device() acquires the reset GPIO and asserts reset, mdio_probe() later deasserts it for the active device, but mdiobus_unregister_device() used to release the GPIO descriptor without first driving the line back to the inactive state. If that descriptor was the last owner, then the PHY could remain held in reset across the next bus registration and disappear from the reprobe scan. On a Lantiq GSWIP based FRITZ!Box 7360 v2 this left PHYs 0 and 1 missing after a deferred reprobe, while PHYs without external reset lines were still found. DSA then failed to attach those ports with -ENODEV. Before releasing optional reset resources, deassert reset again for PHY devices so the hardware stays discoverable across a later reprobe. Link: https://github.com/openwrt/openwrt/issues/20629 Fixes: 8ea25274ebaf2 ("net: mdiobus: release reset_gpio in mdiobus_unregist= er_device()") Cc: stable@vger.kernel.org Signed-off-by: Leonardo M=C3=B6rlein Assisted-by: GitHubCopilot:GPT-5.4 --- drivers/net/phy/mdio_device.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/phy/mdio_device.c b/drivers/net/phy/mdio_device.c index 56080d3d2d25..9caeb9ea5248 100644 --- a/drivers/net/phy/mdio_device.c +++ b/drivers/net/phy/mdio_device.c @@ -215,6 +215,12 @@ int mdiobus_unregister_device(struct mdio_device *mdio= dev) if (mdiodev->bus->mdio_map[mdiodev->addr] !=3D mdiodev) return -EINVAL; =20 + /* + * Leave optional reset lines deasserted before releasing them so devices + * remain discoverable across a later bus reprobe. + */ + mdio_device_reset(mdiodev, 0); + mdio_device_unregister_reset(mdiodev); =20 mdiodev->bus->mdio_map[mdiodev->addr] =3D NULL; --=20 2.51.2