All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Markus Stockhausen" <markus.stockhausen@gmx.de>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH net-next v12 05/11] net: mdio: realtek-rtl9300: Configure hardware polling during probing
Date: Tue, 04 Aug 2026 17:19:58 +0000	[thread overview]
Message-ID: <20260804171958.E57D01F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260803171853.507506-6-markus.stockhausen@gmx.de>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [High] notify_phy_attach aborts phy_attach_direct() for PHYs unmapped to switch ports

Pre-existing issues:
- [High] Hardware polling corrupts software C45-over-C22 MMD access sequences at runtime
--

--- Patch [5]: [PATCH net-next v12 05/11] net: mdio: realtek-rtl9300: Configure hardware polling during probing ---
commit b348a1eaa3ac89042c8633ae18e01b3be6294f9d
Author: Markus Stockhausen <markus.stockhausen@gmx.de>

net: mdio: realtek-rtl9300: Configure hardware polling during probing

During PHY probing and configuration complex configuration sequences
might be issued and firmware might be loaded. Hardware polling can
interfere badly with that. This patch disables polling for all ports
when the MDIO driver starts, reenables it after the PHY has been
attached, and disables it just before the PHY is detached.

Link: https://github.com/openwrt/openwrt/blob/main/target/linux/realtek/files-6.18/drivers/net/mdio/mdio-realtek-otto.c#L818
Link: https://lore.kernel.org/netdev/680696024a8648535ce6dee771fe4de67802e0e8.1769053496.git.daniel@makrotopia.org/

> diff --git a/drivers/net/mdio/mdio-realtek-rtl9300.c b/drivers/net/mdio/mdio-realtek-rtl9300.c
> index 1873928b362dd..210e570c09732 100644
> --- a/drivers/net/mdio/mdio-realtek-rtl9300.c
> +++ b/drivers/net/mdio/mdio-realtek-rtl9300.c

[ ... ]

> @@ -582,6 +591,33 @@ static int otto_emdio_9310_setup_controller(struct otto_emdio_priv *priv)
>  	return 0;
>  }
>  
> +static int otto_emdio_notify_phy_attach(struct phy_device *phydev)
> +{
> +	struct otto_emdio_priv *priv = otto_emdio_bus_to_priv(phydev->mdio.bus);
> +	int port = otto_emdio_phy_to_port(phydev->mdio.bus, phydev->mdio.addr);
> +
> +	if (port < 0)
> +		return port;

[Severity: High]
Are PHYs unmapped to switch ports handled correctly here?

By returning a negative error code (e.g., -ENOENT) instead of 0 here, it
looks like it will cause the generic phylib attachment sequence to abort.
A MAC driver calling phy_connect() for an unmapped PHY on the bus will
hit this when otto_emdio_phy_to_port() returns -ENOENT, leading
phy_attach_direct() to fatally abort the attachment and fail to bring up
the network interface.

Should this return 0 instead to allow non-switch PHYs to attach properly?

> +
> +	return otto_emdio_set_port_polling(priv, port, true);
> +}

[ ... ]

> @@ -611,6 +647,9 @@ static int otto_emdio_probe_one(struct device *dev, struct otto_emdio_priv *priv
>  		bus->write = otto_emdio_write_c22;

[Severity: High]
This is a pre-existing issue, but can the hardware polling engine corrupt
software C45-over-C22 MMD access sequences at runtime?

Since this patch re-enables hardware polling for a C22 PHY in
notify_phy_attach(), the unpaused hardware polling engine can interleave
with the 4-step software C45-over-C22 sequence used when phylib falls back
to standard C22 writes. This could overwrite the MMD address/data registers
(13 and 14).

Would it be safer to temporarily disable the hardware polling engine across
multi-register C45-over-C22 transactions in otto_emdio_write_c22() and
otto_emdio_read_c22() to prevent race conditions?

>  	}
>  	bus->parent = dev;
> +	bus->notify_phy_attach = otto_emdio_notify_phy_attach;
> +	bus->notify_phy_detach = otto_emdio_notify_phy_detach;
> +

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260803171853.507506-1-markus.stockhausen@gmx.de?part=5

  reply	other threads:[~2026-08-04 17:20 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03 17:18 [PATCH net-next v12 00/11] net: mdio: realtek-rtl9300: Add RTL83xx support Markus Stockhausen
2026-08-03 17:18 ` [PATCH net-next v12 01/11] dt-bindings: net: realtek,rtl9301-mdio: Add RTL83xx series Markus Stockhausen
2026-08-03 17:18 ` [PATCH net-next v12 02/11] net: mdio: realtek-rtl9300: Add polling documentation Markus Stockhausen
2026-08-03 17:18 ` [PATCH net-next v12 03/11] net: phy: add (*notify_phy_attach/detach)() hooks to struct mii_bus Markus Stockhausen
2026-08-04 17:19   ` sashiko-bot
2026-08-03 17:18 ` [PATCH net-next v12 04/11] net: mdio: realtek-rtl9300: suppress sysfs bind/unbind attributes Markus Stockhausen
2026-08-04 17:19   ` sashiko-bot
2026-08-03 17:18 ` [PATCH net-next v12 05/11] net: mdio: realtek-rtl9300: Configure hardware polling during probing Markus Stockhausen
2026-08-04 17:19   ` sashiko-bot [this message]
2026-08-03 17:18 ` [PATCH net-next v12 06/11] net: mdio: realtek-rtl9300: Add page tracking Markus Stockhausen
2026-08-03 17:18 ` [PATCH net-next v12 07/11] net: mdio: realtek-rtl9300: Increase MDIO timeout Markus Stockhausen
2026-08-03 17:18 ` [PATCH net-next v12 08/11] net: mdio: realtek-rtl9300: Check for C45 support during setup Markus Stockhausen
2026-08-03 17:18 ` [PATCH net-next v12 09/11] net: mdio: realtek-rtl9300: Add support for RTL838x Markus Stockhausen
2026-08-03 17:18 ` [PATCH net-next v12 10/11] net: mdio: realtek-rtl9300: Add support for RTL839x Markus Stockhausen
2026-08-03 17:18 ` [PATCH net-next v12 11/11] net: mdio: reword MDIO_REALTEK_RTL9300 Kconfig Markus Stockhausen
2026-08-03 20:07 ` [PATCH net-next v12 00/11] net: mdio: realtek-rtl9300: Add RTL83xx support Jakub Kicinski
2026-08-03 20:25   ` AW: " Markus Stockhausen

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=20260804171958.E57D01F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=markus.stockhausen@gmx.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.