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=1796082459; b=iYlQ7MRiPryia13+DDcc3zbmaRp0ReVoHruDJZctNLeF/L9xIZPWxdt4vXJuGF1t3Xmw 5e4zK9kJ9gslGjbiWjLEyPtMkeYgdVNHYoIGOZVcCdTqj8hKemNDZvJKoBtDxLA4LCv5O VvdmjMQAWeRWHXp1jSSYuOl3bCmbA6vO7kchgJBbPaDhhQJAVT1XHY2Gjwy4nIPPI5/00 /9GApKJK2a9v5xsnzZvMmk8WNOgVtU23ddqiKswGMP8tPs5OBTu1RjBiiIKY36U3K+FH+ gXecT2BoDI8oSq8jc7fTwUNKT3RPtwf+yXe45pUcssQjqI7/vE6Osh3od+51u5nRxMA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796082459; 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=j2Ct9/fQqnfPO56804LeVRNuEuW1RPq5noSLHPgRrX4=; b=CAP0SwME7qheKlpYp+ZUm+C1HrDjmradAgHRw6gu73+IYZ3xGxBpKWH3J8pZRjHYJ0Le wrfQCwNakS7yRD1yChmQZTDxwCDKF9qjZrqdPY8sG/x27LOAz8t0ON8lWII2Erj+DNMfq YFu78lWRs5zheJSVbxamyJl7V+W02qlsR7dKB1ER3Y2Defo066Sqw/Y1Vy1lcUGrE3yfL 2LaY0unrwxxYihPPK7KMT9cSDTSa7vf+lryvBuGGTUzbE5MaLlJWuXAnuH9bhp/XlllGX TMbs5h+UEi8eJ+oMA0payBszAFl4NfmiV73Zia5jZwtaRRv8EjKpe9wt/GOwPYzCdwg== 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=EYJ21b0X; 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 17795606A339; Mon, 30 Nov 2026 23:47:38 +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=EYJ21b0X Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14B611F00897; Mon, 30 Nov 2026 23:47:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796082458; bh=j2Ct9/fQqnfPO56804LeVRNuEuW1RPq5noSLHPgRrX4=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=EYJ21b0XbWCoDWKHJ2IJB+c0qbehb+NlJlA31lsvHLuGUax2Acmhu2vajIagMFAB9 4sickvy0HyQ+ytdnJ1/fIpdq+3hRld+rV2Et0N8ic6GqlwkkAEjtXWihwqsewq3Awa 0JB+fiKhO+6u6AhZbXOSwPWkSnnZSlUA7EA+YCfzvSCMtm3HyaAgSB0MWpUQQ4zUl2 wmdFBBlP1vRo1hLRCznmDKIObD6iBC2XxlRWccRrrkcIACschI8NshI0QJ4k/UUAfz hTPva7igPTskd1CQU5uck0IVsLjfx/xYgnvGqc4QMM/aDVF+nhxFfR7KCyKDfZCoWf U3f4w43FpZztQ== Subject: Re: [PATCH net-next v23 04/15] net: pcs: implement Firmware node support for PCS driver From: netdev-bot+sashiko@kernel.org To: ansuelsmth@gmail.com Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, willemb@google.com, horms@kernel.org, corbet@lwn.net, skhan@linuxfoundation.org, rdunlap@infradead.org, lorenzo@kernel.org, hkallweit1@gmail.com, linux@armlinux.org.uk, maxime.chevallier@bootlin.com, p.zabel@pengutronix.de, nathan@kernel.org, ndesaulniers@google.com, morbo@google.com, justinstitt@google.com, rmk+kernel@armlinux.org.uk, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, llvm@lists.linux.dev, zhengping.zhang@airoha.com Date: Mon, 30 Nov 2026 23:47:36 +0000 Message-ID: <179608245661.3146.13401336858923870000@kernel.org> In-Reply-To: <20261129230558.612526-5-ansuelsmth@gmail.com> References: <20261129230558.612526-5-ansuelsmth@gmail.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 5 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 helpers make `#pcs-cells` mandatory on every PCS node that `pcs-handle` points to. - [Low] `fwnode_phylink_pcs_count()` (drivers/net/pcs/pcs.c:229-241) stops at the first non-zero return from… - [Low] Concern: `fwnode_pcs_get()`/`fwnode_phylink_pcs_parse()` hand out raw `struct phylink_pcs` pointers with no reference count or put API,… - [Low] The `!CONFIG_FWNODE_PCS` stubs in include/linux/pcs/pcs.h return different error codes from the real implementation for the same… - [Low] `fwnode_parse_pcsspec()` has a name-based lookup branch (`if (name)` → `fwnode_property_match_string(fwnode, "pcs-handle-names",… - [Low] include/linux/pcs/pcs-provider.h does not compile on its own. -- net: pcs: implement Firmware node support for PCS driver This adds a small provider API. PCS drivers can register PCS instances against a firmware node with an xlate callback, and a devm variant is included. Consumers get fwnode_pcs_get(), and MAC drivers get fwnode_phylink_pcs_count() and fwnode_phylink_pcs_parse() for PCS described through the "pcs-handle" property. > diff --git a/drivers/net/pcs/pcs.c b/drivers/net/pcs/pcs.c > new file mode 100644 > index 0000000000000..a0b3681db54bf > --- /dev/null > +++ b/drivers/net/pcs/pcs.c > @@ -0,0 +1,279 @@ [ ... ] > +static void fwnode_pcs_free_provider(struct fwnode_pcs_provider *pp) > +{ > + struct phylink_pcs *pcs, *tmp; > + > + mutex_lock(&fwnode_pcs_mutex); > + list_for_each_entry_safe(pcs, tmp, &pp->pcss, provider_list) { > + list_del(&pcs->provider_list); > + pcs->provider = NULL; > + } > + mutex_unlock(&fwnode_pcs_mutex); [Severity: Low] fwnode_pcs_get() and fwnode_phylink_pcs_parse() return raw struct phylink_pcs pointers. They take no reference and there is no put API. On removal this only clears pcs->provider and provider_list. Could a consumer that stored the pointer keep using it after the provider frees its PCS? This patch has no consumer yet. Later in the series, "net: phylink: support PCS provider release" makes fwnode_pcs_del_provider() call a FWNODE_PCS_PROVIDER_DEL notifier before fwnode_pcs_free_provider(). phylink handles that notifier under pcs_list_mutex, so the intended consumer is covered. That leaves a non-phylink caller of the exported fwnode_pcs_get(), and there is none in the tree. Would it help to document that such callers have to handle provider removal themselves? [ ... ] > +static int fwnode_parse_pcsspec(const struct fwnode_handle *fwnode, > + unsigned int index, const char *name, > + struct fwnode_reference_args *out_args) > +{ > + if (!fwnode) > + return -EINVAL; > + > + if (name) { > + int ret; > + > + ret = fwnode_property_match_string(fwnode, "pcs-handle-names", > + name); [Severity: Low] This isn't a bug, but can this branch ever run? __fwnode_pcs_get() has only one caller, fwnode_pcs_get(), and it always passes con_id as NULL: return __fwnode_pcs_get(fwnode, index, NULL); Neither this patch nor the rest of the series adds a by-name lookup API, and the commit message doesn't mention name-based lookup. > + if (ret < 0) > + return ret; > + > + index = ret; > + } > + > + return fwnode_property_get_reference_args(fwnode, "pcs-handle", > + "#pcs-cells", 0, index, > + out_args); > +} [Severity: Medium] Does a non-NULL nargs_prop here make #pcs-cells mandatory on every node that pcs-handle points to? On OF, of_fwnode_get_reference_args() does: if (nargs_prop) ret = of_parse_phandle_with_args(to_of_node(fwnode), prop, nargs_prop, index, &of_args); else ret = of_parse_phandle_with_fixed_args(to_of_node(fwnode), prop, nargs, index, &of_args); So the nargs = 0 fallback is never used. of_parse_phandle_with_args() uses a cell_count of -1. If the target node has no #pcs-cells, of_phandle_iterator_next() logs "could not get #pcs-cells" and returns -EINVAL. The generic binding in ethernet-controller.yaml describes pcs-handle as bare phandles and doesn't mention #pcs-cells: pcs-handle: $ref: /schemas/types.yaml#/definitions/phandle-array items: maxItems: 1 None of the in-tree DTS files that use pcs-handle set #pcs-cells on the referenced node. On such a DT, wouldn't fwnode_pcs_get() return -EINVAL and fwnode_phylink_pcs_count() return 0? fwnode_phylink_pcs_parse() would pass the fwnode_property_present() check and then return -EINVAL to the MAC. The commit message says these helpers are: "provided for MAC drivers that declare PCS in DT or ACPI" but no existing PCS description seems to work with them. The custom xlate case also conflicts with the generic schema. Later in the series the Airoha binding gives airoha,an7581-pcs-pcie #pcs-cells = <1>, so a consumer needs pcs-handle = <&pcs N>. That is two cells per item, but ethernet-controller.yaml still has items: maxItems: 1 at the end of the series. Should the lookup fall back to 0 cells when #pcs-cells is absent? Or should the generic binding be updated in a way that still covers existing DTs? [ ... ] > +unsigned int fwnode_phylink_pcs_count(struct fwnode_handle *fwnode) > +{ > + struct fwnode_reference_args out_args; > + unsigned int index = 0; > + int ret; > + > + while (true) { > + ret = fwnode_property_get_reference_args(fwnode, "pcs-handle", > + "#pcs-cells", 0, index, > + &out_args); > + /* We expect to reach an -ENOENT error while counting */ > + if (ret) > + break; [Severity: Low] Is any error supposed to end the count here, or only -ENOENT? A missing #pcs-cells, a phandle that doesn't resolve, or a malformed cell count gives -EINVAL. In that case this returns the partial index, and the caller can't tell that anything went wrong. fwnode_phylink_pcs_parse() returns that same -EINVAL for the same node, so the two helpers disagree. The kernel-doc also says this counts all PCS references in the firmware node. Later in the series airoha_eth.c sets config->num_possible_pcs from fwnode_phylink_pcs_count(). A short count means the later entries are never scanned. A count of 0 makes phylink_create() fail with "pcs_interfaces, num_possible_pcs and fill_available_pcs must be set together" instead of reporting the real parse error. [ ... ] > diff --git a/include/linux/pcs/pcs-provider.h b/include/linux/pcs/pcs-provider.h > new file mode 100644 > index 0000000000000..6b03a635f73c0 > --- /dev/null > +++ b/include/linux/pcs/pcs-provider.h > @@ -0,0 +1,72 @@ > +/* SPDX-License-Identifier: GPL-2.0-or-later */ > +#ifndef __LINUX_PCS_PROVIDER_H > +#define __LINUX_PCS_PROVIDER_H > + > +struct fwnode_pcs_provider; > + [ ... ] > +struct phylink_pcs *fwnode_pcs_simple_xlate(struct fwnode_reference_args *pcsspec, > + void *data); [Severity: Low] This header has no includes and forward-declares only struct fwnode_pcs_provider. Its prototypes also use struct fwnode_reference_args, struct fwnode_handle, struct device and struct phylink_pcs. If a provider includes it before linux/fwnode.h, linux/device.h and linux/phylink.h, won't GCC warn that those structs are declared inside the parameter list? It would then report conflicting types against the real declarations. pcs.h has !CONFIG_FWNODE_PCS stubs, but this header doesn't, and pcs.o is only built for obj-$(CONFIG_FWNODE_PCS). Would a provider driver that doesn't select FWNODE_PCS fail to link against fwnode_pcs_add_provider(), devm_fwnode_pcs_add_provider() and fwnode_pcs_simple_xlate()? The users in this series only avoid both problems through their include order and the select FWNODE_PCS in PCS_AIROHA. [ ... ] > diff --git a/include/linux/pcs/pcs.h b/include/linux/pcs/pcs.h > new file mode 100644 > index 0000000000000..b3bb158002d5a > --- /dev/null > +++ b/include/linux/pcs/pcs.h > @@ -0,0 +1,74 @@ [ ... ] > +#else > +static inline struct phylink_pcs *fwnode_pcs_get(const struct fwnode_handle *fwnode, > + unsigned int index) > +{ > + return ERR_PTR(-ENOENT); > +} > + > +static inline unsigned int fwnode_phylink_pcs_count(struct fwnode_handle *fwnode) > +{ > + return 0; > +} > + > +static inline int fwnode_phylink_pcs_parse(struct fwnode_handle *fwnode, > + struct phylink_pcs **available_pcs, > + unsigned int num_pcs) > +{ > + return -EOPNOTSUPP; > +} > +#endif [Severity: Low] Should these stubs return the same error codes as the real implementation? The fwnode_pcs_get() stub returns -ENOENT. fwnode_phylink_pcs_parse() treats that code as the end of the pcs-handle list, while the kernel-doc gives -ENODEV for "no PCS available". The fwnode_phylink_pcs_parse() stub returns -EOPNOTSUPP. The real function returns -ENODEV when pcs-handle is absent: if (!fwnode_property_present(fwnode, "pcs-handle")) return -ENODEV; With FWNODE_PCS=n, a caller that treats -ENODEV as "no PCS described" would get -EOPNOTSUPP instead. The only in-tree consumer selects FWNODE_PCS, so nothing is affected today. -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261129230558.612526-1-ansuelsmth%40gmail.com