Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alex Elder" <elder@riscstar.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH net-next 2/5] net: pcs: pcs-xpcs-regmap: support XPCS memory-mapped MDIO bus via regmap
Date: Tue, 20 Oct 2026 03:01:57 +0000	[thread overview]
Message-ID: <sashiko-outbox-178427@kernel.org> (raw)
In-Reply-To: <20261019030129.1470307-3-elder@riscstar.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] net: pcs: MDIO bus ID collision in devm_xpcs_regmap_register()
--

commit f4103deca1c1d0d48e4d0e095369247a1ba3779b
Author: Daniel Thompson <daniel@riscstar.com>

net: pcs: pcs-xpcs-regmap: support XPCS memory-mapped MDIO bus via regmap

This commit introduces devm_xpcs_regmap_register() and indirect MDIO CSR
access helpers so drivers can register a DesignWare XPCS instance backed by a
regmap.

> diff --git a/drivers/net/pcs/pcs-xpcs-regmap.c b/drivers/net/pcs/pcs-xpcs-regmap.c
> new file mode 100644
> index 0000000000000..f3f3aaaf0b75a
> --- /dev/null
> +++ b/drivers/net/pcs/pcs-xpcs-regmap.c
> @@ -0,0 +1,169 @@

[ ... ]

> +struct dw_xpcs *devm_xpcs_regmap_register(struct device *dev,
> +					  struct regmap *regmap)
> +{
> +	static atomic_t id = ATOMIC_INIT(-1);
> +	struct dw_xpcs *xpcs;
> +	struct mii_bus *bus;
> +	int ret;
> +
> +	bus = devm_mdiobus_alloc_size(dev, 0);
> +	if (!bus)
> +		return ERR_PTR(-ENOMEM);
> +
> +	bus->name = "DW XPCS MCI/APB3";
> +	bus->read = xpcs_regmap_read_c22;
> +	bus->write = xpcs_regmap_write_c22;
> +	bus->read_c45 = xpcs_regmap_read_c45;
> +	bus->write_c45 = xpcs_regmap_write_c45;
> +	bus->phy_mask = ~0;
> +	bus->parent = dev;
> +	bus->priv = regmap;
> +
> +	snprintf(bus->id, sizeof(bus->id), "dwxpcs-%x", atomic_inc_return(&id));

[Severity: Medium]
Can bus->id collide with an existing platform DW XPCS bus here?

In drivers/net/pcs/pcs-xpcs-plat.c, xpcs_plat_init_bus() defines its own
separate static atomic counter and uses the identical "dwxpcs-%x" format
string:

drivers/net/pcs/pcs-xpcs-plat.c:xpcs_plat_init_bus() {
	static atomic_t id = ATOMIC_INIT(-1);
	...
	snprintf(pxpcs->bus->id, MII_BUS_ID_SIZE,
		 "dwxpcs-%x", atomic_inc_return(&id));
}

If a system probes both a platform DW XPCS via xpcs_plat_probe() ->
xpcs_plat_init_bus() and a regmap DW XPCS via devm_xpcs_regmap_register()
(for example, an SoC with a platform XPCS and a PCIe Toshiba TC9564 card),
both counters start at -1 and format their first bus->id as "dwxpcs-0".

When devm_mdiobus_register() calls __mdiobus_register() -> device_register(),
device_add_class_symlinks() tries to create the class symlink under
/sys/class/mdio_bus/dwxpcs-0, which fails with -EEXIST and causes
__mdiobus_register() to fail with -EINVAL.

Should devm_xpcs_regmap_register() use a distinct prefix (such as
"dwxpcs-regmap-%x") or share a common counter or IDA with
xpcs_plat_init_bus()?

> +
> +	/* MDIO-bus here serves as just a back-end engine abstracting out
> +	 * the MDIO and MCI/APB3 IO interfaces utilized for the DW XPCS CSRs
> +	 * access.
> +	 */
> +	ret = devm_mdiobus_register(dev, bus);

[ ... ]

> +}
> +EXPORT_SYMBOL_GPL(devm_xpcs_regmap_register);

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261019030129.1470307-1-elder@riscstar.com?part=2

  reply	other threads:[~2026-10-20  3:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19  3:01 [PATCH net-next 0/5] net: stmmac: enable Toshiba TC9564 Alex Elder
2026-10-19  3:01 ` [PATCH net-next 1/5] dt-bindings: net: add support for " Alex Elder
2026-10-19 12:41   ` Andrew Lunn
2026-10-20  3:01   ` sashiko-bot
2026-10-20 15:12   ` Rob Herring (Arm)
2026-10-19  3:01 ` [PATCH net-next 2/5] net: pcs: pcs-xpcs-regmap: support XPCS memory-mapped MDIO bus via regmap Alex Elder
2026-10-20  3:01   ` sashiko-bot [this message]
2026-10-19  3:01 ` [PATCH net-next 3/5] net: stmmac: dwxgmac2: Add XGMAC 3.01a support Alex Elder
2026-10-19  7:58   ` Maxime Chevallier
2026-10-19  3:01 ` [PATCH net-next 4/5] net: stmmac: dwxgmac2: export symbols for XGMAC 3.01a DMA Alex Elder
2026-10-19  3:01 ` [PATCH net-next 5/5] net: stmmac: support the TC9564 SoC Alex Elder
2026-10-19  7:52   ` Maxime Chevallier
2026-10-19  9:14   ` Mohd Ayaan Anwar
2026-10-20  3:01   ` sashiko-bot

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=sashiko-outbox-178427@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=elder@riscstar.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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