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=1796468930; b=V++zzFhxx/HVu0EV3PV+5UmVsa+f0QmJ2etT+xK3qWkxDAwHQ5Dk6PR8dbYL0PqC2Ph+ ED7ZOHqdxV/CMUfsn8DaYavPQssqSzv3/WK1H72teCU3J1YQCpCyJk+zv9ttB6+wZHrRb nDWh/0MqOkbMIhPRHstU1LUWx8Pt/VC2CXhfbCTbI05kjrfJdmthUsVUttSnp5w1lN4kd kHoVNwG/LJFOIzM8mHVlkqHzAGqp9NMe27vLwC7wgenC90nE/Mgsmk/GziSPrU1r6cRVZ LQm+B/G1xLsgrKugOxbT0CyXZKq5QFdyHr4v3EH3hYqMrrxty9l8SHFIGKxGxl4MLtw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796468930; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=nFhO8axf/6O45rqd1eGFKrdI6R1OHvF5DqLXLRcJw0g=; b=HND7sd/2qSVQJTU3e0OtmLIxoAy8BlWlBia7FEPdtypJLZid80c8IXb0RjI4/e48YD/W JWYvs8JkapCLfZ+vZFSRLuB1Qs8aXVojwlBOCgAmZ3zHlZYj1qMv5y4u792fRU/r+R0Tb jUVhV08IeHOVhB483v2RLYc8q/5zMkzSXMF22dvXB8pJCEZ4KVXxgx2uw7kpnUw4Lj4NN BKJcMzI+0Ar60CyulbuPnilbSF2dGS1Ia/m5UFGM4Cw5BZHyqmZ+/Qf+yDYmdylLXrr5B s0QEdeoumPAjDwaNrMxGnuiVZIyz/ZExQrIIgiy6BVuDXadY6Gp9KFiwI9SfbSwcSdw== 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=F1oJgFLb; 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 89174606A330 for ; Sat, 5 Dec 2026 11:08:50 +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=F1oJgFLb Received: by smtp.kernel.org (Postfix) with ESMTPSA id 149561F00936; Sat, 5 Dec 2026 11:08:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796468930; bh=nFhO8axf/6O45rqd1eGFKrdI6R1OHvF5DqLXLRcJw0g=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=F1oJgFLbqEnSKuq7EHFfqElNL4AAS5jIJHIu5MnlvcyIH+cH3gNSrDgtn1ymvyFuP 8jVZASMi3d4z2oByJPq9Fz4bXyHU9YxQ2hecWD5ifNZvOw9NclFA8jb+q0rgc2EDK2 HnnM6nmmyZwbbv7xAkRR4jWYF+73Nev7jBFYAInx7IqzlrMHPUbKj1MNYt6a2DaNqm W4FU3tv4QeNcqycGmZfLYKWE8ffa9ZINp5D0kq/vbSyHkUh4NZ5vu1oU7Hcmzj80xZ FIvo+C4l4QJSmXKuvy24FQwqcIs1sPvLeH0zNbYE/1zZI4IGJM6J5n9paYADlJsMxP 3tTQ/RpHm7+/Q== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH net-next 05/12] net: phy: phy_mux: Add port selection logic Reply-To: sashiko-reviews@lists.linux.dev To: "Maxime Chevallier" Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org In-Reply-To: <20261204110622.1106492-6-maxime.chevallier@bootlin.com> References: <20261204110622.1106492-1-maxime.chevallier@bootlin.com> <20261204110622.1106492-6-maxime.chevallier@bootlin.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 11:08:49 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] net: phy: phy_mux: selected PHY is not resumed before pops->select() - [Medium] net: phy: unlocked phy_mux_detach() races with unregister and ethtool -- commit dc38119185f1b5ebf431eebfe3a9d57a7ea7cf22 Author: Maxime Chevallier net: phy: phy_mux: Add port selection logic This patch adds port selection and deselection logic to phy_mux, along with phy_mux_start(), phy_mux_stop(), and phy_mux_port_ops to power down deselected PHYs. > diff --git a/drivers/net/phy/phy_mux.c b/drivers/net/phy/phy_mux.c > index 691bca09e0af1..407269980edc1 100644 > --- a/drivers/net/phy/phy_mux.c > +++ b/drivers/net/phy/phy_mux.c [ ... ] > +static int __phy_mux_select_port(struct phy_mux *mux, > + struct phy_mux_port *port) > +{ > + int ret; > + > + if (mux->pops && mux->pops->select) { > + ret =3D mux->pops->select(mux, port, mux->parent_priv); > + phy_mux_port_set_parent_phy(mux, port, !ret); > + if (ret) > + return ret; > + } > + > + port->selected =3D true; > + > + return 0; > +} [Severity: High] Should port->phydev be resumed before calling mux->pops->select()? phy_mux_attach() and __phy_mux_deselect_port() suspend every PHY via phy_mux_phy_power_down() -> phy_suspend(), so mux->pops->select() runs against a powered-down PHY. When a parent like phylink runs phylink_bringup_phy(), EEE clock-stop configuration and phy_request_interrupt() execute before phy_start() calls __phy_resume(). On PHYs such as Broadcom BCM54xx, non-BMCR register writes are ignored while BMCR_PDOWN is set and bcm54xx_resume() re-runs bcm54xx_config_init(), leavi= ng hardware interrupts disabled and EEE settings lost. If pops->select is NULL or does not call phy_start() or phy_resume(), the selected PHY also remains suspended while port->selected is true. Adding a select callback in phy_mux_port_ops to call phy_resume() before mux->pops->select() would restore symmetry with phy_mux_port_deselect(). [ ... ] > @@ -188,13 +281,15 @@ EXPORT_SYMBOL_GPL(fwnode_phy_mux_attach); > * phy_mux_detach() - Detach the mux from its parent > * @mux: The mux > * > - * The PHYs behind the mux are detached. > + * The mux is stopped and its PHYs are detached. Caller must hold rtnl w= hen > + * the mux was started. > */ > void phy_mux_detach(struct phy_mux *mux) > { > if (!mux->netdev) > return; > =20 > + phy_mux_stop(mux); > phy_mux_detach_phys(mux); [Severity: Medium] Can calling phy_mux_detach() without rtnl_lock() race with phy_mux_unregister() and ethtool? phy_mux_attach() creates mux->devlink with DL_FLAG_STATELESS, which does not prevent the mux driver from unbinding while the parent MAC driver is bound. Because phy_mux_unregister() drops phy_mux_mutex before taking rtnl_lock(),= a caller that runs phy_mux_detach() without rtnl_lock() when the mux is stopp= ed (such as phylink_destroy() in mvpp2_port_remove() after an ndo_open() failure) has no lock in common with phy_mux_unregister(): CPU0 CPU1 phylink_destroy() phy_mux_detach(mux) if (!mux->netdev) // false phy_mux_unregister() rtnl_lock() mux->pops->detach(...) phy_mux_detach(mux) phy_mux_detach_phys(mux) phy_mux_detach_phys(mux) <-- double phy_detach() rtnl_unlock() phy_mux_free(mux) mux->netdev =3D NULL <-- use-after-free In addition, if the netdev is still NETREG_REGISTERED when phy_mux_detach() runs without rtnl_lock() (such as ucc_geth_remove() with devm_register_netdev()), phy_detach_internal() triggers a lockdep splat on dev->hwprov and phy_link_topo_del_phy() frees struct phy_device_node without RCU while concurrent ethtool queries in ethnl_req_get_phydev() expect rtnl_lock(). fwnode_phy_mux_attach() also serializes only on phy_mux_mutex and can be called without rtnl_lock() (for example from dsa_user_phy_setup()), leaving mux->netdev, mux->pops, and mux->parent_priv without a common lock between attach and detach. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204110622.1106= 492-1-maxime.chevallier@bootlin.com?part=3D5