From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796385162; b=yvB6DBqt+MRNR25w+lpsEElyUNEZtDRgfnVAmWcZgtLZZUNp9lTjC1qb54H6MBWQy+MQ jzEVkHbc0mc7uDHIPsWXwMTi2tGF8FwvrKNprjKsSIH9DAkQ81lzJETTGGTiXKHwM+muv FZsdSG38/mVvle5r3WR8Z9kegHWPOwU+iwe2ye4H189U4QLG1uyud/WorJfyXg6U2mSFq KEucC07BiGWO5Lt7kOCeQgUU0ZmN/gcgmnSd6i3BoxfWojm8eCqgUWhpaXjDgbnp/sCS4 tX2hmqsagMGqnsj3DIiVXmUbtEeuzJx5YZLirS2wCSAUWZAKSJbD7z8ZL3Y5xYzLkCg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385162; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=Irlcy2uO09nz8HVPJ7jsV2T2dGTqXzffBulXLkJ6aLw=; b=aDArGZIrEU3AUzkoP0S8UKi+mPTiLBugsY+CuhEPY15sLVqiw3QSlD9X3aTLuWO9xcTd dLH4/VB5sGoJ+ZFOhcXHE+8nvlU4KSSiVS89iKvo0yC1tjBWrbNJAkUB/c2RN3CdjlgVf UEkgqv4MMdzOWCyLLZtY4AX2SFRIklERTjMe30XxgqCfDMN6xZEtQu+ZaknmBNS1krgx4 QdNc7w/A/wZDbCCXJiiLPQIi8rMBqf2aucNp0JJAD7/x0VA7pu/9qzQ1JpuDEgCy/vrR/ n9evVK209IlqDT1fxk79Qscs1CAi4/w5EE0wqMvMDmqbaExbF5uJwugd49Hinpps8PA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b="VUR8TJ/E"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A88FB606A322; Fri, 4 Dec 2026 11:52:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=VUR8TJ/E Received: by smtp.kernel.org (Postfix) with ESMTPSA id 227AD1F000C2; Fri, 4 Dec 2026 11:52:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385162; bh=Irlcy2uO09nz8HVPJ7jsV2T2dGTqXzffBulXLkJ6aLw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=VUR8TJ/E3h7Ld6Es04EfzDmaptMAGLxgpXqVfLPMst36AFLK2d/lAjE6TFrhBuddw 6ZjCdufZNUOTTbxV07BWkirG49YwjzwIauxnI02Ww8Jf51ql4pf6DHC8VCZAoWZ2iB SOeOoshOQpSaJTuhqZb9RIQBM6qPLeubuBA8bgfM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Andrew Lunn , Yongzhao Chen , Paolo Abeni , Sasha Levin Subject: [PATCH 6.6 0443/1167] net: phy: qca83xx: read resolved QCA8337 link status Date: Fri, 4 Dec 2026 18:57:50 +0900 Message-ID: <20261204100713.554609926@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yongzhao Chen [ Upstream commit 42a91cbfc7a3ab99d05cb2ed0de5a24b9652cfed ] After a QCA8337 SmartSpeed downshift, genphy_read_status() can report 1000 Mbit/s from the advertised modes when the PHY is running at 100 Mbit/s. On a Redmi AX5400 running downstream OpenWrt Linux 6.18.52, this caused qca8k to program the user-port MAC for 1000 Mbit/s and traffic failed. An earlier prototype that read the resolved speed from the PHY restored traffic. Wrap genphy_read_status() and use at803x_read_specific_status() to replace its speed and duplex result when an autonegotiated link comes up. Resolve pause for the resulting duplex. Until the PHY reports a resolved speed and duplex, report the link as down so that the next poll reads them again, as marvell_read_status_page_an() does. In that case also clear the duplex, master/slave state and link partner modes that genphy_read_status() read for an up link. QCA8337's register layout matches the helper (data sheet 80-Y0619-3 Rev. D, pages 327-328). Keep the generic master/slave read order and the early return for a steady autonegotiated link. This avoids additional reads of the clear-on-read idle error count in MII_STAT1000. Forced mode continues to use BMCR. Report the MDI-X state read at link-up and invalidate it when the link goes down or autonegotiation is disabled. Clear mdix_ctrl because this driver does not implement MDI-X configuration. The QCA8327 entries keep genphy_read_status(). The AR8327 data sheet (MKG-15791 Rev. 1.0) lists the QCA8327-A PHY ID and documents the same PHY-specific status layout, with SmartSpeed enabled after a hardware reset, so those PHYs may have the same problem. That is untested on QCA8327 hardware, so limit this change to QCA8337. Fixes: b3591c2a3661 ("net: dsa: qca8k: Switch to PHYLINK instead of PHYLIB") Suggested-by: Andrew Lunn Signed-off-by: Yongzhao Chen Assisted-by: LLM Link: https://patch.msgid.link/20261013190339.51909-1-yongzhao.derek@gmail.com Signed-off-by: Paolo Abeni [ sashal: Added qca8337_read_status() to at803x.c instead of qca83xx.c, and called at803x_read_specific_status() without the mask argument since this tree's helper takes none. ] Signed-off-by: Sasha Levin --- drivers/net/phy/qcom/at803x.c | 54 +++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/drivers/net/phy/qcom/at803x.c b/drivers/net/phy/qcom/at803x.c index 0b01b6ff0a4b5..665adcb427d00 100644 --- a/drivers/net/phy/qcom/at803x.c +++ b/drivers/net/phy/qcom/at803x.c @@ -1591,6 +1591,59 @@ static int at803x_cable_test_start(struct phy_device *phydev) return 0; } +static int qca8337_read_status(struct phy_device *phydev) +{ + int ret, old_link = phydev->link; + + ret = genphy_read_status(phydev); + if (ret) + return ret; + + /* Keep the state resolved at link-up while the link stays up */ + if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link) + goto out; + + phydev->mdix = ETH_TP_MDI_INVALID; + + /* genphy_read_status() derives speed and duplex from the + * advertisements, which is wrong after a SmartSpeed downshift. + * Use what the PHY resolved instead. + */ + if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete && + phydev->link) { + phydev->speed = SPEED_UNKNOWN; + phydev->duplex = DUPLEX_UNKNOWN; + phydev->pause = false; + phydev->asym_pause = false; + + ret = at803x_read_specific_status(phydev); + if (ret) + return ret; + + /* Report the link down until speed and duplex are resolved, + * so that the next poll reads them again. Also clear what + * genphy_read_status() read for an up link, as the + * PHY_HALTED path of the state machine does. + */ + if (phydev->speed == SPEED_UNKNOWN || + phydev->duplex == DUPLEX_UNKNOWN) { + phydev->link = 0; + phydev->duplex = DUPLEX_UNKNOWN; + phydev->mdix = ETH_TP_MDI_INVALID; + phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN; + linkmode_zero(phydev->lp_advertising); + } else { + phy_resolve_aneg_pause(phydev); + } + } + +out: + /* MDI-X configuration is not implemented */ + phydev->mdix_ctrl = ETH_TP_MDI_INVALID; + + return 0; +} + static int qca83xx_config_init(struct phy_device *phydev) { u8 switch_revision; @@ -2168,6 +2221,7 @@ static struct phy_driver at803x_driver[] = { .flags = PHY_IS_INTERNAL, .config_init = qca83xx_config_init, .soft_reset = genphy_soft_reset, + .read_status = qca8337_read_status, .get_sset_count = at803x_get_sset_count, .get_strings = at803x_get_strings, .get_stats = at803x_get_stats, -- 2.53.0