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,4/4] net: phy: realtek: add RTL8224 polarity support
Date: Fri, 30 Jan 2026 17:53:22 -0800 [thread overview]
Message-ID: <20260131015322.971509-1-kuba@kernel.org> (raw)
In-Reply-To: <20260129101606.33972-4-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 polarity support
This patch adds MDI polarity swap support for RTL8224. The polarity
configuration uses 4 bits per port (one for each pair A-D) and is read
from the device tree property enet-phy-lane-polarity.
> 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_polarity(struct phy_device *phydev)
> +{
> + struct device_node *np = phydev->mdio.dev.of_node;
> + u8 port_offset = phydev->mdio.addr & 3;
> + u32 polarity = 0;
> + int ret, val;
> +
> + ret = of_property_read_u32(np, "enet-phy-lane-polarity", &polarity);
> +
> + /* Do nothing if the property is not present */
> + if (ret == -EINVAL)
> + return 0;
> +
> + if (ret)
> + return ret;
> +
> + if (polarity & ~0xf)
> + return -EINVAL;
> +
> + val = __phy_package_read_mmd(phydev, 0, MDIO_MMD_VEND1,
> + RTL8224_VND1_MDI_POLARITY_SWAP);
> + if (val < 0)
> + return val;
> +
> + val &= ~(0xf << port_offset);
> + val |= polarity << port_offset;
^^^^^^^^^^^^^^^^^^^^^^^^
The shift amount appears incorrect for a 4-bit-per-port register layout.
Since polarity uses 4 bits (for pairs A-D) and port_offset ranges from
0 to 3, should the shift be (port_offset * 4) rather than just port_offset?
With the current code:
- Port 0 (offset=0): writes to bits 0-3 (correct)
- Port 1 (offset=1): writes to bits 1-4 (overlaps port 0)
- Port 2 (offset=2): writes to bits 2-5 (overlaps ports 0-1)
- Port 3 (offset=3): writes to bits 3-6 (overlaps ports 0-2)
The earlier v1 patch posted to lore used "(phydev->mdio.addr & 3) * 4"
for the offset calculation. Was the multiplication by 4 accidentally
dropped during refactoring?
For comparison, rtl8224_mdi_config_order() uses "1 << port_offset" which
is correct for a 1-bit-per-port layout, but the polarity register needs
4 bits per port.
> + return __phy_package_write_mmd(phydev, 0, MDIO_MMD_VEND1,
> + RTL8224_VND1_MDI_POLARITY_SWAP, val);
> +}
prev parent 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 ` [v4,2/4] " Jakub Kicinski
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 ` Jakub Kicinski [this message]
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=20260131015322.971509-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