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=1796081149; b=1DUYJJqrkpKAQAHSFKfndzZO4D930HtwXZlPwJF+KA/iETiyXJMg6iW1k6BMNqD+p1/o PlRCun6SUWsYc8FO/oPKFUmNiNJKsiB0eLG1rti8q/TXi9PlfUY9d1qB4yB8TMILJm+KL GE22vI5AKTIL8xbkp2RKKAraYrH+B3yZLvXd7ZMtCq4nxtvBWuH/J6aDvRRv3B6G8b8v5 XryZWZF5VXzFbXbmBn03aTH1OqwcbprhXYlHiuJaGtFzCDAQhMH9GKY1wVGUNoaCl05rC tr+kqrTUWWt4VAO/CPB3yhabU0nZ9T/8woBpYCnr2+Ji+VMk39f+L2k9Qjgvw6S/JZQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796081149; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=lyEcdmO0mRo8Xy+yG9+HEfCg/WfOOS1gi4vinhorZRQ=; b=ouSulZxrToB5+s9DDSpZqdREr+Go36Ahq6l+Qi0GkdPrsP5reFgl6gHPr4MnsBWrgymt ZUDPDZWoyW6pxezC7S2jPwLIKCTmOM9Ibe9Sf5Ox3SiVbO2vq1mr0qgp0ziSwzDS5Sjeq 3F8qfYk3hxfajI4rxGMXvAroP37afXQAr5bqsCLqpniN2brEiyNEljCU8HCYnk/iNQejQ DZZ12WifNdgg8lb6+PcA+pXkS9uiCO+lILvCchxipuzlT0IJOm8vfGOQhyEFQxVYTRVfo L81b3/b2Tk894cSmcBp6DxVeOCbGvKNPPt38CefJqEW1HVdQ82uA3WbPGDVIaIIFXtA== 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=dbcn7pBp; 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 B5A83606A320 for ; Mon, 30 Nov 2026 23:25:49 +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=dbcn7pBp Received: by smtp.kernel.org (Postfix) with ESMTPSA id 207A71F0089A; Mon, 30 Nov 2026 23:25:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796081149; bh=lyEcdmO0mRo8Xy+yG9+HEfCg/WfOOS1gi4vinhorZRQ=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=dbcn7pBppD7xI2cjPcy0UAbFr5w3JxE+kjsKfVgDt0ksjuEjVfb922sBf/IsDhfOl 4ceFsHTWsHAmt3xVgRwynFsIo/sCPfZ3HMrbQyWuP63ZItSc9eBTI3JVZmzVs1eUXH cLATkMb+J0lNT3Q9z8r5rZcvyyUVXH91ErlCw+x0xkEnInvQC6pfJ5ISoVAUCoOxht W5o6Zh/tW6zxYuNGTtDU8AMCJg3JZcERXYx3RoL7qwZdpO0ZQwoLDEGMt9dA8l3eMK /MSN6nAK+E/epcGdFNo/+KKOHSzUXRWx/MC+O0SWbv/7ok/X9L18u2i/wWzE10ax+p ya0RksoB6VdZw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH net-next v23 03/15] net: phylink: introduce internal phylink PCS handling Reply-To: sashiko-reviews@lists.linux.dev To: "Christian Marangi" , devicetree@vger.kernel.org Cc: robh@kernel.org, conor+dt@kernel.org In-Reply-To: <20261129230558.612526-4-ansuelsmth@gmail.com> References: <20261129230558.612526-1-ansuelsmth@gmail.com> <20261129230558.612526-4-ansuelsmth@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 23:25:48 +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 3 potential issues to consider: - [Medium] net: phylink: unmasked pcs_interfaces in phylink_parse_supported_interfaces() - [Medium] net: phylink: missing error return in phylink_validate_mac_and_pcs() - [Low] net: phylink: duplicated PCS lookup logic across three functions -- commit c48ba0ce83717f538fa9d39f574827e8fe636c78 Author: Christian Marangi net: phylink: introduce internal phylink PCS handling This commit introduces an internal PCS list in phylink as an alternative to .mac_select_pcs, selecting a PCS based on config->pcs_interfaces and each PCS's supported_interfaces bitmap. > diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c > index 20759fe47eaa7..35e82cccd39a2 100644 > --- a/drivers/net/phy/phylink.c > +++ b/drivers/net/phy/phylink.c [ ... ] > @@ -536,6 +559,21 @@ static int phylink_validate_mac_and_pcs(struct phyli= nk *pl, > pcs =3D pl->mac_ops->mac_select_pcs(pl->config, state->interface); > if (IS_ERR(pcs)) > return PTR_ERR(pcs); > + /* > + * Find a PCS in available PCS list for the requested interface. > + * > + * Skip searching if the MAC doesn't require a dedicated PCS for > + * the requested interface. > + */ > + } else if (test_bit(state->interface, pl->config->pcs_interfaces)) { > + struct phylink_pcs *tmp; > + > + list_for_each_entry(tmp, &pl->pcs_list, list) { > + if (!phylink_validate_pcs_interface(tmp, state->interface)) { > + pcs =3D tmp; > + break; > + } > + } > } > =20 > if (pcs) { [Severity: Medium] Should phylink_validate_mac_and_pcs() return -EINVAL when state->interface = is set in pl->config->pcs_interfaces and no matching PCS is found in pl->pcs_list? When pcs remains NULL, phylink_validate_mac_and_pcs() skips PCS validation and validates state->interface against MAC capabilities alone, allowing a PCS-dependent mode without an available PCS to pass validation and later fa= il in phylink_major_config(). [ ... ] > @@ -969,12 +1004,22 @@ static void phylink_pcs_enable_eee(struct phylink_= pcs *pcs) > static unsigned int phylink_inband_caps(struct phylink *pl, > phy_interface_t interface) > { > - struct phylink_pcs *pcs; > + struct phylink_pcs *pcs =3D NULL; > =20 > - if (!pl->mac_ops->mac_select_pcs) > - return 0; > + if (pl->mac_ops->mac_select_pcs) { > + pcs =3D pl->mac_ops->mac_select_pcs(pl->config, > + interface); > + } else if (test_bit(interface, pl->config->pcs_interfaces)) { > + struct phylink_pcs *tmp; > + > + list_for_each_entry(tmp, &pl->pcs_list, list) { > + if (!phylink_validate_pcs_interface(tmp, interface)) { > + pcs =3D tmp; > + break; > + } > + } > + } > =20 > - pcs =3D pl->mac_ops->mac_select_pcs(pl->config, interface); > if (IS_ERR_OR_NULL(pcs)) > return 0; > =20 > @@ -1271,10 +1316,37 @@ static void phylink_major_config(struct phylink *= pl, bool restart, > pl->major_config_failed =3D true; > return; > } > + /* > + * Find a PCS in available PCS list for the requested interface. > + * This doesn't overwrite the previous .mac_select_pcs as either > + * .mac_select_pcs or PCS list implementation are permitted. > + * > + * Skip searching if the MAC doesn't require a dedicated PCS for > + * the requested interface. > + */ > + } else if (test_bit(state->interface, pl->config->pcs_interfaces)) { > + struct phylink_pcs *tmp; > + > + list_for_each_entry(tmp, &pl->pcs_list, list) { > + if (!phylink_validate_pcs_interface(tmp, > + state->interface)) { > + pcs =3D tmp; > + break; > + } > + } > + > + if (!pcs) { > + phylink_err(pl, > + "couldn't find a PCS for %s\n", > + phy_modes(state->interface)); > =20 > - pcs_changed =3D pl->pcs !=3D pcs; > + pl->major_config_failed =3D true; > + return; > + } > } [Severity: Low] This isn't a bug, but the PCS lookup loop across pl->pcs_list (and the mac_select_pcs vs. pcs_interfaces dispatch) is duplicated across phylink_validate_mac_and_pcs(), phylink_inband_caps(), and phylink_major_config(). Factoring this lookup into a helper would avoid the duplication and keep the missing-PCS error handling consistent. [ ... ] > @@ -2042,6 +2168,62 @@ void phylink_update_mac_pause_capabilities(struct = phylink *pl, unsigned long mac > } > EXPORT_SYMBOL_GPL(phylink_update_mac_pause_capabilities); > =20 > +static void phylink_parse_supported_interfaces(struct phylink *pl) > +{ > + struct phylink_pcs *pcs; > + > + phy_interface_copy(pl->supported_interfaces, > + pl->config->supported_interfaces); > + > + /* > + * Only add PCS-supported modes that phylink will select a PCS for. > + * Otherwise, phylink may accept a PCS-only mode and configure it witho= ut > + * a PCS. > + */ > + list_for_each_entry(pcs, &pl->pcs_list, list) { > + DECLARE_PHY_INTERFACE_MASK(pcs_interfaces); > + > + phy_interface_copy(pcs_interfaces, pl->config->pcs_interfaces); > + > + if (!phy_interface_empty(pcs->supported_interfaces)) > + phy_interface_and(pcs_interfaces, pcs_interfaces, > + pcs->supported_interfaces); > + > + phy_interface_or(pl->supported_interfaces, > + pl->supported_interfaces, > + pcs_interfaces); > + } > +} [Severity: Medium] Does phylink_parse_supported_interfaces() leave unavailable PCS modes set in pl->supported_interfaces? phylink_create() rejects an empty config->supported_interfaces before phylink_fill_available_pcs() runs, so MAC drivers that require a PCS for so= me or all modes populate those modes in config->supported_interfaces as well as config->pcs_interfaces. Because phylink_parse_supported_interfaces() copies pl->config->supported_interfaces into pl->supported_interfaces without first clearing pl->config->pcs_interfaces, any mode in config->pcs_interfaces that is also in config->supported_interfaces remains enabled in pl->supported_interfaces even when no attached PCS in pl->pcs_list supports it. Should pl->config->pcs_interfaces be masked out of pl->supported_interfaces with phy_interface_andnot() before ORing in the interfaces supported by the PCS instances in pl->pcs_list? --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261129230558.6125= 26-1-ansuelsmth@gmail.com?part=3D3