From: netdev-bot+sashiko@kernel.org
To: iustin.stolniceanu@analog.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,
parthiban.veerasooran@microchip.com, hkallweit1@gmail.com,
linux@armlinux.org.uk, marcelo.schmitt@analog.com,
alvin.sipraga@analog.com, ciprian.regus@analog.com,
Selvamani.Rajagopal@onsemi.com, netdev@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v3 3/7] net: ethernet: oa_tc6: Add support for MDIO indirect access
Date: Tue, 24 Nov 2026 12:02:46 +0000 [thread overview]
Message-ID: <179552176696.3135.1446966801724449711@kernel.org> (raw)
In-Reply-To: <20261123115743.29523-4-iustin.stolniceanu@analog.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
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] SPECULATIVE (this depends on MAC-PHY MDIOACC trigger semantics
that I could not check against the OA TC6 specification).
- [Low] In indirect mode, oa_tc6_mdiobus_register()
(drivers/net/ethernet/oa_tc6.c:674) installs read_c45/write_c45, which…
--
net: ethernet: oa_tc6: Add support for MDIO indirect access
This patch reads STDCAP when the OA TC6 MDIO bus is registered. If direct
PHY register access (DPRAC) is not supported but indirect access (IPRAC)
is, the Clause 22 and Clause 45 MDIO operations go through the MDIOACC
registers. On a turnaround error, reads return 0xffff so the PHY bus scan
skips the address, and writes return -EIO.
> diff --git a/drivers/net/ethernet/oa_tc6.c b/drivers/net/ethernet/oa_tc6.c
> index c05480b7920ea..ca33df9f045eb 100644
> --- a/drivers/net/ethernet/oa_tc6.c
> +++ b/drivers/net/ethernet/oa_tc6.c
[ ... ]
> @@ -434,24 +435,149 @@ int oa_tc6_write_register_mms(struct oa_tc6 *tc6, u8 mms, u16 address,
> }
> EXPORT_SYMBOL_GPL(oa_tc6_write_register_mms);
>
> -static int oa_tc6_check_phy_reg_direct_access_capability(struct oa_tc6 *tc6)
> +static void oa_tc6_handle_link_change(struct net_device *netdev)
> {
> - u32 regval;
> + phy_print_status(netdev->phydev);
> +}
> +
> +static int oa_tc6_mdioacc_wait_done(struct oa_tc6 *tc6, u32 *regval)
> +{
> + int ret, err;
> +
> + ret = read_poll_timeout(oa_tc6_read_register, err,
> + err || (*regval & OA_TC6_MDIOACC_TRDONE),
> + 100, 30000, false, tc6, OA_TC6_REG_MDIOACC(1),
> + regval);
> + if (ret)
> + return ret;
> +
> + return err;
> +}
[ ... ]
> - return 0;
> +static int oa_tc6_indirect_mdiobus_read_c45(struct oa_tc6 *tc6, int addr,
> + int devnum, int regnum)
> +{
> + u32 reg_val;
> + int ret;
> +
> + reg_val = FIELD_PREP(OA_TC6_MDIOACC_OP, OA_TC6_MDIOACC_OP_ADDR);
> + reg_val |= FIELD_PREP(OA_TC6_MDIOACC_ST, OA_TC6_MDIOACC_ST_C45);
> + reg_val |= FIELD_PREP(OA_TC6_MDIOACC_PRTAD, addr);
> + reg_val |= FIELD_PREP(OA_TC6_MDIOACC_DEVAD, devnum);
> + reg_val |= FIELD_PREP(OA_TC6_MDIOACC_DATA, regnum);
> +
> + ret = oa_tc6_write_register(tc6, OA_TC6_REG_MDIOACC(0), reg_val);
> + if (ret)
> + return ret;
> +
> + reg_val = FIELD_PREP(OA_TC6_MDIOACC_OP, OA_TC6_MDIOACC_OP_RD);
> + reg_val |= FIELD_PREP(OA_TC6_MDIOACC_ST, OA_TC6_MDIOACC_ST_C45);
> + reg_val |= FIELD_PREP(OA_TC6_MDIOACC_PRTAD, addr);
> + reg_val |= FIELD_PREP(OA_TC6_MDIOACC_DEVAD, devnum);
> +
> + ret = oa_tc6_write_register(tc6, OA_TC6_REG_MDIOACC(1), reg_val);
> + if (ret)
> + return ret;
> +
> + ret = oa_tc6_mdioacc_wait_done(tc6, ®_val);
[Severity: Medium]
This one depends on how a MAC-PHY executes the MDIOACC frames. The code
doesn't describe that, and I couldn't check it against the OA TC6
specification, so this may well be fine.
The ADDRESS frame is written to MDIOACC0 and the READ frame to MDIOACC1,
in two separate SPI control transactions. Nothing waits for TRDONE in
MDIOACC0, and oa_tc6_mdioacc_wait_done() only polls MDIOACC1.
oa_tc6_indirect_mdiobus_write_c45() uses the same split sequence.
For Clause 22, oa_tc6_indirect_mdiobus_read() and
oa_tc6_indirect_mdiobus_write() write their only frame to MDIOACC1:
ret = oa_tc6_write_register(tc6, OA_TC6_REG_MDIOACC(1), reg_val);
The adin1110.c driver uses the same register layout. It puts its single
C22 frame in MDIOACC0 (ADIN1110_MDIOACC, 0x20) and polls that register.
Suppose a MAC-PHY starts at MDIOACC0 and stops at the first entry that
already has TRDONE set. Would a C22 frame written only to MDIOACC1 ever
run? Would the C45 sequence stop after the ADDRESS frame, because MDIOACC1
still has TRDONE set from the previous transaction?
In that case oa_tc6_mdioacc_wait_done() would time out after 30ms. The
error would propagate out of the C22/C45 bus scan, and mdiobus_register()
and oa_tc6_init() would fail.
On a MAC-PHY that runs one frame per register write, could the MDIOACC1
write arrive while the ADDRESS frame is still on the wire?
This sequence apparently works on the ADIN1110. The framework, though,
claims support for any MAC-PHY that reports IPRAC. Would it be more robust
to write both C45 frames in one burst with
oa_tc6_write_registers(tc6, OA_TC6_REG_MDIOACC(0), vals, 2), and to use
MDIOACC0 for C22 as adin1110.c does? That would also save one SPI transfer
per C45 access.
> + if (ret)
> + return ret;
> +
> + return oa_tc6_mdioacc_read_data(reg_val);
> }
[ ... ]
> @@ -533,8 +673,21 @@ EXPORT_SYMBOL_GPL(oa_tc6_mdiobus_write_c45);
>
> static int oa_tc6_mdiobus_register(struct oa_tc6 *tc6)
> {
> + u32 regval;
> int ret;
>
> + ret = oa_tc6_read_register(tc6, OA_TC6_REG_STDCAP, ®val);
> + if (ret)
> + return ret;
> +
> + if (!(regval & OA_TC6_STDCAP_DIRECT_PHY_REG_ACCESS)) {
> + if (!(regval & OA_TC6_STDCAP_INDIRECT_PHY_REG_ACCESS)) {
> + netdev_err(tc6->netdev, "MDIO direct/indirect access not supported\n");
> + return -ENODEV;
> + }
> + tc6->mdio_indirect_mode = true;
> + }
[Severity: Low]
In indirect mode, oa_tc6_mdiobus_register() still installs read_c45 and
write_c45, and it doesn't set phy_mask. Does this make the phylib C45 bus
scan very expensive over SPI?
In direct mode, oa_tc6_mdiobus_read() ignores addr. The C22 scan fills
mdio_map[] at every address, and mdiobus_scan_bus_c45() then skips all of
them because they are already populated.
In indirect mode, PRTAD is encoded, so the integrated PHY answers at only
one address. __mdiobus_register() then runs the C45 scan over the other 31
addresses:
drivers/net/phy/mdio_bus_provider.c:__mdiobus_register() {
...
prevent_c45_scan = mdiobus_prevent_c45_scan(bus);
if (!prevent_c45_scan && bus->read_c45) {
err = mdiobus_scan_bus_c45(bus);
...
}
mdiobus_prevent_c45_scan() only blocks the scan for Micrel OUIs.
At each empty address, oa_tc6_mdioacc_read_data() returns 0xffff on
TAERR. get_phy_c45_ids() therefore sees devices-in-package as all ones and
walks every MMD, which is about 62 indirect C45 reads per address.
Each of those reads is an MDIOACC0 write, an MDIOACC1 write and at least
one MDIOACC1 poll read, usually with a 100us sleep in read_poll_timeout().
That comes to roughly 31 * 62 * 3, or more than 5,700 SPI control
transactions during probe.
adin1140.c sets phy_mask = GENMASK(31, 1) on its OA TC6 MDIO bus, and
adin1110.c sets phy_mask = ~GENMASK(2, 0). Could the scan be limited with
phy_mask here as well? Alternatively, could the C45 pass be skipped once
the C22 scan has found the PHY?
> tc6->mdiobus = mdiobus_alloc();
> if (!tc6->mdiobus) {
> netdev_err(tc6->netdev, "MDIO bus alloc failed\n");
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123115743.29523-1-iustin.stolniceanu%40analog.com
next prev parent reply other threads:[~2026-11-24 12:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 11:57 [PATCH net-next v3 0/7] net: ethernet: adi: adin1110: Add OPEN Alliance TC6 support Iustin Stolniceanu
2026-11-23 11:57 ` [PATCH net-next v3 1/7] net: ethernet: oa_tc6: Forward declare struct mii_bus Iustin Stolniceanu
2026-11-23 11:57 ` [PATCH net-next v3 2/7] net: ethernet: oa_tc6: Allow custom reset settle time values Iustin Stolniceanu
2026-11-23 11:57 ` [PATCH net-next v3 3/7] net: ethernet: oa_tc6: Add support for MDIO indirect access Iustin Stolniceanu
2026-11-24 12:02 ` netdev-bot+sashiko [this message]
2026-11-23 11:57 ` [PATCH net-next v3 4/7] net: phy: adin1100: Add separate driver entries for ADIN1110/ADIN2111 Iustin Stolniceanu
2026-11-23 11:57 ` [PATCH net-next v3 5/7] net: phy: adin1100: Skip the soft reset on ADIN1110/ADIN2111 Iustin Stolniceanu
2026-11-24 12:02 ` netdev-bot+sashiko
2026-11-23 11:57 ` [PATCH net-next v3 6/7] dt-bindings: net: adi,adin1110: Add adi,spi-oa-tc6 Iustin Stolniceanu
2026-11-23 11:57 ` [PATCH net-next v3 7/7] net: ethernet: adi: adin1110: Add OA TC6 protocol support for ADIN1110 Iustin Stolniceanu
2026-11-24 12:02 ` netdev-bot+sashiko
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=179552176696.3135.1446966801724449711@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=Selvamani.Rajagopal@onsemi.com \
--cc=alvin.sipraga@analog.com \
--cc=andrew+netdev@lunn.ch \
--cc=ciprian.regus@analog.com \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@kernel.org \
--cc=hkallweit1@gmail.com \
--cc=iustin.stolniceanu@analog.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=marcelo.schmitt@analog.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=parthiban.veerasooran@microchip.com \
--cc=robh@kernel.org \
/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
all inboxes | Powered by JetHome®