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=1796081155; b=J9tHBGibWdl274kiZXPyyCl3TjPZFsMpBh5OWS5/CMsRSJpPe8m1n7v2zDClUsOn93PK gxKzmBPg1E2tG6tXEF2Q1BfMyL5YI/xJvraSKyC8Ls69NeNszyg6/Xm0nq4wm2y0bjQOy zhOUOyV7/k/gs5SO66tljOaPDfMIlVvI233U1zzeKcUkDfcvZOaRx/MK7lE7zbHCLuxp9 DXUUGnkaUt3bxR9fU5swniNv3DOB4Fp3s8MC21UpV0jZRh8rvgAGmHNjqo9eOoC0GlA99 Y34xUioAfvWFArNQhtR9/FzQVjNenby76br1nvnjRQbrasZaCrUWoY/x17KTfxxkAcw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796081155; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=WUzO3MESdmE2fgJz2x4moLLkskdF4p0UkOrAM0z88pk=; b=k0AaPGIE1aG3/Vjv8ku6v6Dw479sDx4MYQN1/IYUTs0roc7AIrRJhdBvkXsYy3iMk5qD 0ovAbooNkrkbax7KWdrRIBbQGf/oDUS6owqkgqObq39DxN833ta1UteJctJsCgVshbD8l upMeQVWg0BwZcUuD8Up+LpP/woVey0TNiXLpopoyNsGjuh59E/8e1jYfij3Mbg3BF8Oqm nUalyoDuT2JXR7fvjcG5Tbp88I9c5HugS+EPQ26bX6IIFU6vZKW2OGgcuiGYYwVBTY2Me zhiZvz73Qxy4zQ29hO3Ka/Qih7ZPUtMd8LRwsiKy88S9XmpprmzoqZC/EyuWCKN98og== 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=jI3Iau3u; 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 963AF606A320 for ; Mon, 30 Nov 2026 23:25:55 +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=jI3Iau3u Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE4741F0092B; Mon, 30 Nov 2026 23:25:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796081155; bh=WUzO3MESdmE2fgJz2x4moLLkskdF4p0UkOrAM0z88pk=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=jI3Iau3ujChSk/BeuE10E9NT3YnvWoUQseMmXakQnYen/kxReV6JuQEupS37/ehId V+MHSnwyzy8oYYL7t+mKCb4ZqaVBebMpHbD3A5I94GiSYSaJ+n94Vg1iGizl4FVZ0R 4qJatK+/Cp5GchJM2IXY1adb7mUQYVQ+nQhbr6v2QecgkJCrxD9n3BbgLI2G5MHuq5 uwR55Rw+F6v8AxfOqwA/bB6PjQqGGl0mOe4h3E+e3IEwaTD+UMxkVOrbkc+oCBsZeP 0humh7W6pLFQAh93eJ8p6E240HnWQJh14PE8WpBL2Yo6Xfk1QefHTUV+grzpwUCLEK Ozx6DlET9GufA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH net-next v23 10/15] net: Document PCS subsystem 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-11-ansuelsmth@gmail.com> References: <20261129230558.612526-1-ansuelsmth@gmail.com> <20261129230558.612526-11-ansuelsmth@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 23:25:54 +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: doc: pcs: setting pcs_interfaces modes in supported_interfaces breaks gating - [Low] net: doc: pcs: unconditional PCS config in mac_setup_phylink() fails when count is 0 - [Low] net: doc: pcs: inaccurate ownership, notifier semantics, and Sphinx C references -- commit 90c76f7838a6fb884106472bf5d9e3dc365a66ee Author: Christian Marangi net: Document PCS subsystem This commit adds documentation for the PCS subsystem and its fwnode producer/consumer API, and updates the sfp-phylink porting guide to use num_possible_pcs and fill_available_pcs instead of mac_select_pcs. > diff --git a/Documentation/networking/pcs.rst b/Documentation/networking/= pcs.rst > new file mode 100644 > index 0000000000000..03b7de73a1065 > --- /dev/null > +++ b/Documentation/networking/pcs.rst > @@ -0,0 +1,257 @@ [ ... ] > +``supported_interfaces`` describes all interface modes supported by the = MAC, > +whereas ``pcs_interfaces`` identifies the subset that require PCS select= ion. [ ... ] > + static int mac_setup_phylink(struct net_device *netdev) > + { > + struct phylink_config *config; > + > + // ... > + > + config->dev =3D &netdev->dev; > + > + // ... > + > + // Parse possible PCS and fill num_possible_pcs > + config->num_possible_pcs =3D fwnode_phylink_pcs_count(dev_fwnode(&= netdev->dev)); > + config->fill_available_pcs =3D mac_fill_available_pcs; [Severity: Low] Will phylink_create() fail with -EINVAL in this example whenever fwnode_phylink_pcs_count() returns 0? phylink_create() requires pcs_interfaces, fill_available_pcs, and num_possible_pcs > 0 to either all be set or all be empty: drivers/net/phy/phylink.c:phylink_create() { ... if (has_pcs_interfaces !=3D has_pcs_callback || has_pcs_interfaces !=3D has_pcs_count) { dev_err(config->dev, "phylink: error: pcs_interfaces, num_possible_pcs and fill_available_pcs= must be set together\n"); return ERR_PTR(-EINVAL); } ... } In a MAC that supports modes such as SGMII without an external PCS and only requires a PCS for USXGMII, a board without a pcs-handle property (or a kernel built with CONFIG_FWNODE_PCS disabled) gets num_possible_pcs =3D=3D 0 while fill_available_pcs and pcs_interfaces are still populated, causing phylink_create() to fail. Step 12 in Documentation/networking/sfp-phylink.rst also tells drivers to populate num_possible_pcs and fill_available_pcs without mentioning that pcs_interfaces must be populated together with them when num_possible_pcs is non-zero. > + > + __set_bit(PHY_INTERFACE_MODE_INTERNAL, config->supported_interface= s); > + __set_bit(PHY_INTERFACE_MODE_SGMII, config->supported_interfaces); > + __set_bit(PHY_INTERFACE_MODE_1000BASEX, config->supported_interfac= es); > + __set_bit(PHY_INTERFACE_MODE_USXGMII, config->supported_interfaces= ); > + > + // PCS required only for USXGMII > + __set_bit(PHY_INTERFACE_MODE_USXGMII, config->pcs_interfaces); [Severity: Medium] Does setting PHY_INTERFACE_MODE_USXGMII in both config->supported_interfaces and config->pcs_interfaces (as also stated earlier where pcs_interfaces is described as a subset of supported_interfaces) prevent phylink from gating PCS-dependent modes on PCS availability? phylink_parse_supported_interfaces() copies config->supported_interfaces directly into pl->supported_interfaces without masking out config->pcs_interfaces before ORing in the interfaces supported by the currently registered PCS providers: drivers/net/phy/phylink.c:phylink_parse_supported_interfaces() { phy_interface_copy(pl->supported_interfaces, pl->config->supported_interfaces); list_for_each_entry(pcs, &pl->pcs_list, list) { phy_interface_and(interfaces, pl->config->pcs_interfaces, pcs->supported_interfaces); phy_interface_or(pl->supported_interfaces, pl->supported_interfaces, interfaces); } } If a driver sets a PCS-dependent mode in config->supported_interfaces, that mode remains present in pl->supported_interfaces even when no PCS is registered. As a result, phylink_validate_mac_and_pcs() validates the mode against MAC capabilities alone with no PCS attached, and phylink_sfp_module_insert() sees a non-empty intersection with pl->supported_interfaces and never defers optical SFP module insertion with -EAGAIN while waiting for a late PCS provider. [ ... ] > +The ``fill_available_pcs`` callback is called on :c:func:`phylink_create` > +and on provider notification and can be called multiple times. > +It's used to compose the available PCS list at the time of calling and > +will be called again when a PCS provider is released or a new one is att= ached. > +Ownership of PCS is held by phylink. [ ... ] > +The PCS fwnode implementation provides a notifier to which each phylink > +instance with a non-empty ``pcs_interfaces`` in :c:type:`phylink_config` > +registers. When a new PCS provider is registered, the notifier is called > +triggering the :c:func:`pcs_provider_notify` function. > + > +On receiving a PCS provider event, :c:func:`pcs_provider_notify` will > +reprase the available PCS by calling the ``fill_available_pcs`` callback > +and update the internal PCS list for the phylink instance with both the > +removed and the newly available PCS and a phylink major config is forced. [ ... ] > diff --git a/Documentation/networking/sfp-phylink.rst b/Documentation/net= working/sfp-phylink.rst > index 5bf285d73e8a1..306505118eba9 100644 > --- a/Documentation/networking/sfp-phylink.rst > +++ b/Documentation/networking/sfp-phylink.rst > @@ -311,33 +311,20 @@ this documentation. [ ... ] > +12. Populate the :c:var:`num_possible_pcs` value and > + :c:func:`fill_available_pcs` callback and add it to your > + :c:type:`struct phylink_config `. [Severity: Low] As reported by Jakub Kicinski on v22 [1], is "Ownership of PCS is held by phylink" accurate? phylink_add_pcs() and phylink_del_pcs() only link the struct phylink_pcs pointer into pl->pcs_list without taking a reference or freeing it, so the PCS provider or MAC driver retains ownership of the memory (and each struct phylink_pcs instance can only be attached to one phylink instance at a time via pcs->phylink). A few other details in these sections also do not match the code or Sphinx C domain markup: - In pcs_provider_notify() ("reprase" -> "reparse"), a major config is not always forced on provider events; phylink_del_pcs() and phylink_pcs_changed() only set pl->force_major_config when the currently active pl->pcs is removed or when pl->major_config_failed is set while phylink is not stopped. - The description of fwnode_phylink_pcs_parse() notes that missing PCS providers returning -ENODEV are skipped, but omits that fwnode_phylink_pcs_parse() itself returns -ENODEV when the pcs-handle property is absent on the fwnode. - In the "Looking up PCS Devices" section, the paragraph beginning "supported_interfaces describes all interface modes supported by the MAC" switches from struct phylink_pcs to struct phylink_config without naming struct phylink_config. - pcs_provider_notify is a static function in drivers/net/phy/phylink.c with no kernel-doc entry, and num_possible_pcs and fill_available_pcs in sfp-phylink.rst are struct phylink_config members rather than a global :c:var: and :c:func:. [1] https://lore.kernel.org/r/20261121232652.1365578-1-kuba@kernel.org --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261129230558.6125= 26-1-ansuelsmth@gmail.com?part=3D10