Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rustam Adilov" <adilov@disroot.org>, devicetree@vger.kernel.org
Cc: robh@kernel.org, conor+dt@kernel.org
Subject: Re: [RFC PATCH net-next 6/6] net: phy: realtek: add support for RTL9607C internal PHYs
Date: Sat, 05 Dec 2026 18:29:43 +0000	[thread overview]
Message-ID: <sashiko-outbox-251797@kernel.org> (raw)
In-Reply-To: <20261204182553.33952-7-adilov@disroot.org>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] net: phy: realtek: duplicate netlink reports in
  rtl9607c_cable_test_report()
- [Low] net: phy: realtek: duplicate rtl8224 cable-test logic for
  rtl9607c
--

commit ee6721a09d284e396e48beee672a28d147c9b434
Author: Rustam Adilov <adilov@disroot.org>

net: phy: realtek: add support for RTL9607C internal PHYs

This commit adds phy_driver entries and cable-test reporting support for
the RTL9607C-VA and RTL9607C-VB internal Gigabit Ethernet PHYs.

> diff --git a/drivers/net/phy/realtek/realtek_main.c b/drivers/net/phy/realtek/realtek_main.c
> index 80efaaddc9869..5b01fb1af3fd4 100644
> --- a/drivers/net/phy/realtek/realtek_main.c
> +++ b/drivers/net/phy/realtek/realtek_main.c

[ ... ]

> @@ -3175,6 +3179,109 @@ static int rtl8365mb_read_status(struct phy_device *phydev)

[ ... ]

> +static int rtl9607c_cable_test_report_pair(struct phy_device *phydev, unsigned int pair)
> +{
> +	int fault_rslt;
> +	int ret;
> +
> +	ret = rtl8224_sram_read(phydev, RTL9607C_SRAM_RTCT_FAULT(pair));
> +	if (ret < 0)
> +		return ret;
> +
> +	fault_rslt = rtl9607c_cable_test_result_trans(ret);
> +	if (fault_rslt < 0)
> +		return fault_rslt;
> +
> +	ret = ethnl_cable_test_result(phydev, pair, fault_rslt);
> +	if (ret < 0)
> +		return ret;
> +
> +	switch (fault_rslt) {
> +	case ETHTOOL_A_CABLE_RESULT_CODE_OPEN:
> +	case ETHTOOL_A_CABLE_RESULT_CODE_SAME_SHORT:
> +	case ETHTOOL_A_CABLE_RESULT_CODE_IMPEDANCE_MISMATCH:
> +		ret = rtl9607c_pair_len_get(phydev, pair);
> +		if (ret < 0)
> +			return ret;
> +
> +		return ethnl_cable_test_fault_length(phydev, pair, ret);
> +	default:
> +		return  0;
> +	}
> +}
> +
> +static int rtl9607c_cable_test_report(struct phy_device *phydev, bool *finished)
> +{
> +	unsigned int pair;
> +	int ret;
> +
> +	for (pair = ETHTOOL_A_CABLE_PAIR_A; pair <= ETHTOOL_A_CABLE_PAIR_D; pair++) {
> +		ret = rtl9607c_cable_test_report_pair(phydev, pair);
> +		if (ret == -EBUSY) {
> +			*finished = false;
> +			return 0;
> +		}
> +
> +		if (ret < 0)
> +			return ret;
> +	}
> +
> +	return 0;
> +}

[Severity: Medium]
Can this emit duplicate netlink attributes into phydev->skb when a later
pair returns -EBUSY?

If pair A has RTL8224_SRAM_RTCT_FAULT_DONE set while a later pair does
not, rtl9607c_cable_test_report_pair() appends pair A to phydev->skb
before the loop returns 0 with *finished = false.  _phy_state_machine()
retains phydev->skb across polls, so the next poll appends pair A again.

Userspace then receives duplicate pair results, or phydev->skb fills up
and fails with -EMSGSIZE, aborting the cable test.  Verifying
RTL8224_SRAM_RTCT_FAULT_DONE on all four pairs before emitting any
netlink attributes would avoid partial reports.

> +
> +static int rtl9607c_cable_test_get_status(struct phy_device *phydev, bool *finished)
> +{
> +	int ret;
> +
> +	*finished = false;
> +
> +	ret = phy_read_mmd(phydev, MDIO_MMD_VEND2,
> +			   RTL822X_VND2_C22_REG(RTL8224_MII_RTCT));
> +	if (ret < 0)
> +		return ret;
> +
> +	if (!(ret & RTL8224_MII_RTCT_DONE))
> +		return 0;
> +
> +	*finished = true;
> +
> +	return rtl9607c_cable_test_report(phydev, finished);
> +}

[Severity: Low]
Can the cable-test polling and reporting path be shared with the existing
rtl8224_cable_test_*() helpers instead of duplicating it?

rtl9607c_cable_test_get_status(), rtl9607c_cable_test_report(),
rtl9607c_cable_test_report_pair(), and rtl9607c_cable_test_result_trans()
copy the rtl8224 counterparts almost verbatim, differing only in the SRAM
register addresses, one fault bit, length scaling, and -EBUSY handling.

A small per-PHY descriptor or callback helper would avoid duplicating
this logic and keep fixes in sync between RTL8224 and RTL9607C.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204182553.33952-1-adilov@disroot.org?part=6

      reply	other threads:[~2026-12-05 18:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 18:25 [RFC PATCH net-next 0/6] net: dsa: realtek: add support for RTL9607C switch Rustam Adilov
2026-12-04 18:25 ` [RFC PATCH net-next 1/6] net: dsa: tag_rtl8_4: add support for RTL9607C tag variant Rustam Adilov
2026-12-05 18:29   ` sashiko-bot
2026-12-04 18:25 ` [RFC PATCH net-next 2/6] net: dsa: realtek: add new mmio interface for drivers Rustam Adilov
2026-12-05 18:29   ` sashiko-bot
2026-12-04 18:25 ` [RFC PATCH net-next 3/6] dt-bindings: net: dsa: realtek: add new rtl9607c switch compatible Rustam Adilov
2026-12-05 18:29   ` sashiko-bot
2026-12-04 18:25 ` [RFC PATCH net-next 4/6] net: dsa: realtek: add support for RTL9607C switch Rustam Adilov
2026-12-05 18:29   ` sashiko-bot
2026-12-04 18:25 ` [RFC PATCH net-next 5/6] net: phy: realtek: use mdio.addr instead of 0 in rtlgen_read/write_vend2 Rustam Adilov
2026-12-04 18:25 ` [RFC PATCH net-next 6/6] net: phy: realtek: add support for RTL9607C internal PHYs Rustam Adilov
2026-12-05 18:29   ` sashiko-bot [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=sashiko-outbox-251797@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=adilov@disroot.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --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