Linux-mediatek Archive on lore.kernel.org
 help / color / mirror / Atom feed
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
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	[thread overview]
Message-ID: <179608245661.3146.13401336858923870000@kernel.org> (raw)
In-Reply-To: <20261129230558.612526-5-ansuelsmth@gmail.com>

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


  reply	other threads:[~2026-11-30 23:47 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29 23:05 [PATCH net-next v23 00/15] net: pcs: Introduce support for fwnode PCS Christian Marangi
2026-11-29 23:05 ` [PATCH net-next v23 01/15] net: phylink: make PCS phylink instance access RCU protected Christian Marangi
2026-11-30 23:47   ` netdev-bot+sashiko
2026-11-29 23:05 ` [PATCH net-next v23 02/15] net: phylink: keep and use MAC supported_interfaces in phylink struct Christian Marangi
2026-11-29 23:05 ` [PATCH net-next v23 03/15] net: phylink: introduce internal phylink PCS handling Christian Marangi
2026-11-30 23:47   ` netdev-bot+sashiko
2026-11-29 23:05 ` [PATCH net-next v23 04/15] net: pcs: implement Firmware node support for PCS driver Christian Marangi
2026-11-30 23:47   ` netdev-bot+sashiko [this message]
2026-11-29 23:05 ` [PATCH net-next v23 05/15] net: phylink: make phylink_validate state locked Christian Marangi
2026-11-30 23:47   ` netdev-bot+sashiko
2026-11-29 23:05 ` [PATCH net-next v23 06/15] net: phylink: add capabilities helpers and track modified advertising Christian Marangi
2026-11-30 23:47   ` netdev-bot+sashiko
2026-11-29 23:05 ` [PATCH net-next v23 07/15] net: sfp: support deferred module insertion Christian Marangi
2026-11-30 23:47   ` netdev-bot+sashiko
2026-11-29 23:05 ` [PATCH net-next v23 08/15] net: phylink: support PCS provider release Christian Marangi
2026-11-30 23:47   ` netdev-bot+sashiko
2026-11-29 23:05 ` [PATCH net-next v23 09/15] net: phylink: support late PCS provider attach Christian Marangi
2026-11-30 23:47   ` netdev-bot+sashiko
2026-11-29 23:05 ` [PATCH net-next v23 10/15] net: Document PCS subsystem Christian Marangi
2026-11-30 23:47   ` netdev-bot+sashiko
2026-11-29 23:05 ` [PATCH net-next v23 11/15] MAINTAINERS: add myself as PCS subsystem maintainer Christian Marangi
2026-11-29 23:05 ` [PATCH net-next v23 12/15] net: phylink: add .pcs_link_down PCS OP Christian Marangi
2026-11-30 23:47   ` netdev-bot+sashiko
2026-11-29 23:05 ` [PATCH net-next v23 13/15] dt-bindings: net: pcs: Document support for Airoha Ethernet PCS Christian Marangi
2026-11-30 23:47   ` netdev-bot+sashiko
2026-11-29 23:05 ` [PATCH net-next v23 14/15] net: pcs: airoha: add PCS driver for Airoha AN7581 SoC Christian Marangi
2026-11-30 23:47   ` netdev-bot+sashiko
2026-11-29 23:05 ` [PATCH net-next v23 15/15] net: airoha: add phylink support Christian Marangi
2026-11-30 23:48   ` netdev-bot+sashiko
2026-11-29 23:09 ` [PATCH net-next v23 00/15] net: pcs: Introduce support for fwnode PCS netdev-bot+sinfo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179608245661.3146.13401336858923870000@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=ansuelsmth@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@kernel.org \
    --cc=hkallweit1@gmail.com \
    --cc=horms@kernel.org \
    --cc=justinstitt@google.com \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux@armlinux.org.uk \
    --cc=llvm@lists.linux.dev \
    --cc=lorenzo@kernel.org \
    --cc=maxime.chevallier@bootlin.com \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=pabeni@redhat.com \
    --cc=rdunlap@infradead.org \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=robh@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=willemb@google.com \
    --cc=zhengping.zhang@airoha.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox