Article View: linux.kernel.netdev
Article #24845Re: [PATCH net-next v23 04/15] net: pcs: implement Firmware node support for PCS driver
From: netdev-bot+sashiko
Date: Mon, 30 Nov 2026 23:47
Date: Mon, 30 Nov 2026 23:47
282 lines
18005 bytes
18005 bytes
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
Technical Details
Message-ID:
<179608245661.3146.13401336858923870000@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374530-linux-kernel-netdev=dewy.ruReferences:
<20261129230558.612526-5-ansuelsmth@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374530-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v23 04/15] net: pcs: implement Firmware node support for PCS driver Date: Mon, 30 Nov 2026 23:47:36 +0000 Organization: Usenet Network Message-ID: <179608245661.3146.13401336858923870000@kernel.org> References: <20261129230558.612526-5-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1568525"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:zE6Vo3gz/rjwjhXg78zHDyNxj9g= sha256:MNV7BoJboKLLHGXn5B4H5+vb3/OlhstC6gSjIO/H1tE= sha1:fmmkqiNdezxXLWqOBgWdTpSjItw= sha256:b//CUBX+n64hkzbeOkbW5lYnTlvzz8yxGoFYD3qmZqE= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 20A46126018; Tue, 1 Dec 2026 02:48:11 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pjKWVDaEVTuT; Tue, 1 Dec 2026 02:48:07 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374530-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 1C6A0126017; Tue, 1 Dec 2026 02:47:58 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id E5ECB2B56B; Mon, 30 Nov 2026 23:47:42 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796082461; b=E3gk4/LQGs5nJaBA3N7YXCgDahAP6iGAEOekXWIJEHq0tDthexWSTnpMGTX6djpj7cLZ GJCykJSqSxBmku3Y5oUFtJasEtxXOBqFl8gwhRFS441CiikKv711i8QnIFzGe5fDVDD7P osscXHnsx1NEam6NMpOHaKsj85vklpa8fKxGTzBHUSgz7gjshqoTLX9VsVf2GjIV34lQT Rvm7j6TqabHTvzpyEjFbiFnOA+3NLRSsMzjubZYIMkSDvvdGsRW5gndiN0BXg95uD9EwC 6ioYvowyTqImHQAiLCGPLFYE4Gw3P+282MCJzA+9tJ6t2sK0+5+XwlnWx2G7cAU/vyw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796082461; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=j2Ct9/fQqnfPO56804LeVRNuEuW1RPq5noSLHPgRrX4=; b=iZacNtM6rGJgfwdxLupX/EHBMCHWKkGBwkdRZdMQOCNhans+ndN0sg25XagFXEGifrNu 8fe3vuS4sPejeuobB6z8FA/d/X1oozmgCnPZDuU25vmqpDWQnBV51bHCBQCNh2xl0Q+MN 6I9QNrji6KL1g+hNRDCYobCs7T93wl1gUqlTA28IrPwjsIWYGjA7g7rfpyqGo5cLwq2qz EYfKx2IxLrrW0FFF+NrpP4oT+k3kykj6ifBb1Wo6NODt3bMaA7MIhiTyq+R0qvtwCxMV9 sIWK6pb3DROteGx5FmqYRiwIohtHsUEBglOZgvvguwSA3Y3BMaDYMscywitc4zEPE/g== X-ARC-Authentication-Results: i=2; 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=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 77210606A32E; Mon, 30 Nov 2026 23:47:41 +0000 (UTC) X-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 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-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== X-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== X-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 X-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) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14B611F00897; Mon, 30 Nov 2026 23:47:37 +0000 (UTC) X-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== X-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 X-In-Reply-To: <20261129230558.612526-5-ansuelsmth@gmail.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list