public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: dam.dejean@gmail.com
Cc: Jakub Kicinski <kuba@kernel.org>,
	robh@kernel.org, krzk+dt@kernel.org, andrew@lunn.ch,
	davem@davemloft.net, hkallweit1@gmail.com,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	pabeni@redhat.com, netdev@vger.kernel.org, edumazet@google.com
Subject: Re: [v4,2/4] net: phy: realtek: add RTL8224 pair order support
Date: Fri, 30 Jan 2026 17:53:20 -0800	[thread overview]
Message-ID: <20260131015320.971482-1-kuba@kernel.org> (raw)
In-Reply-To: <20260129101606.33972-2-dam.dejean@gmail.com>

This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.

For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
net: phy: realtek: add RTL8224 pair order support

This patch adds MDI pair order configuration support for the RTL8224 PHY,
allowing device tree configuration of pair swap (ABCD to DCBA) via the
enet-phy-lane-order property.

> diff --git a/drivers/net/phy/realtek/realtek_main.c b/drivers/net/phy/realtek/realtek_main.c
> --- a/drivers/net/phy/realtek/realtek_main.c
> +++ b/drivers/net/phy/realtek/realtek_main.c

[ ... ]

> +static int rtl8224_mdi_config_order(struct phy_device *phydev)
> +{
> +	struct device_node *np = phydev->mdio.dev.of_node;
> +	u8 port_offset = phydev->mdio.addr & 3;
> +	u32 order = 0;
> +	int ret, val;
> +
> +	ret = of_property_read_u32(np, "enet-phy-lane-order", &order);
> +
> +	/* Do nothing in case the property is not present */
> +	if (ret == -EINVAL)
> +		return 0;
> +
> +	if (ret)
> +		return ret;
> +
> +	if (order & ~1)
> +		return -EINVAL;
> +
> +	val = __phy_package_read_mmd(phydev, 0, MDIO_MMD_VEND1,
> +				     RTL8224_VND1_MDI_PAIR_SWAP);

Should the MDIO bus lock be held before calling __phy_package_read_mmd()?

The __phy_package_read_mmd() documentation states "Same calling rules as
for __phy_read()", and __phy_read() requires: "The caller must have taken
the MDIO bus lock."

Looking at __mdiobus_read(), there is a lockdep_assert_held_once() check
for bus->mdio_lock, which confirms this requirement.

Other PHY drivers using these APIs acquire the lock first. For example,
qca807x_phy_package_config_init_once() wraps its __phy_package_read_mmd()
calls with phy_lock_mdio_bus()/phy_unlock_mdio_bus().

Additionally, since this is a read-modify-write on a shared register that
contains bits for all 4 ports in the package, could concurrent config_init
calls from different ports race and overwrite each other's settings without
the lock protecting the entire sequence?

> +	if (val < 0)
> +		return val;
> +
> +	if (order)
> +		val |= (1 << port_offset);
> +	else
> +		val &= ~(1 << port_offset);
> +
> +	return __phy_package_write_mmd(phydev, 0, MDIO_MMD_VEND1,
> +				       RTL8224_VND1_MDI_PAIR_SWAP, val);
> +}
-- 
pw-bot: cr

  reply	other threads:[~2026-01-31  1:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-29 10:16 [PATCH v4 1/4] dt-bindings: net: ethernet-phy: add property enet-phy-lane-order Damien Dejean
2026-01-29 10:16 ` [PATCH v4 2/4] net: phy: realtek: add RTL8224 pair order support Damien Dejean
2026-01-31  1:53   ` Jakub Kicinski [this message]
2026-01-29 10:16 ` [PATCH v4 3/4] dt-bindings: net: ethernet-phy: add property enet-phy-lane-polarity Damien Dejean
2026-01-29 10:16 ` [PATCH v4 4/4] net: phy: realtek: add RTL8224 polarity support Damien Dejean
2026-01-31  1:53   ` [v4,4/4] " Jakub Kicinski

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=20260131015320.971482-1-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=dam.dejean@gmail.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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