From nobody Fri Sep 20 11:47:49 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92661C27C7A for ; Thu, 17 Aug 2023 12:05:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347277AbjHQMFP (ORCPT ); Thu, 17 Aug 2023 08:05:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350720AbjHQMFE (ORCPT ); Thu, 17 Aug 2023 08:05:04 -0400 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C4663599; Thu, 17 Aug 2023 05:04:39 -0700 (PDT) Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1qWbjj-0001mN-0l; Thu, 17 Aug 2023 12:04:23 +0000 Date: Thu, 17 Aug 2023 13:04:06 +0100 From: Daniel Golle To: Alexander Couzens , Daniel Golle , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH net-next] net: pcs: lynxi: fully reconfigure if link is down Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On MT7988 When switching from 10GBase-R/5GBase-R/USXGMII to one of the interface modes provided by mtk-pcs-lynxi we need to make sure to always perform a full configuration of the PHYA. As the idea behind not doing that was mostly to prevent an existing link going down without any need for it to do so. Hence we can just always perform a full confinguration in case the link is down. Signed-off-by: Daniel Golle --- drivers/net/pcs/pcs-mtk-lynxi.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/net/pcs/pcs-mtk-lynxi.c b/drivers/net/pcs/pcs-mtk-lynx= i.c index b0f3ede945d96..788c2ccde064e 100644 --- a/drivers/net/pcs/pcs-mtk-lynxi.c +++ b/drivers/net/pcs/pcs-mtk-lynxi.c @@ -108,8 +108,8 @@ static int mtk_pcs_lynxi_config(struct phylink_pcs *pcs= , unsigned int neg_mode, bool permit_pause_to_mac) { struct mtk_pcs_lynxi *mpcs =3D pcs_to_mtk_pcs_lynxi(pcs); - bool mode_changed =3D false, changed; - unsigned int rgc3, sgm_mode, bmcr; + bool mode_changed =3D false, changed, link; + unsigned int bm, rgc3, sgm_mode, bmcr; int advertise, link_timer; =20 advertise =3D phylink_mii_c22_pcs_encode_advertisement(interface, @@ -117,6 +117,10 @@ static int mtk_pcs_lynxi_config(struct phylink_pcs *pc= s, unsigned int neg_mode, if (advertise < 0) return advertise; =20 + /* Check if link is currently up */ + regmap_read(mpcs->regmap, SGMSYS_PCS_CONTROL_1, &bm); + link =3D !!(FIELD_GET(SGMII_BMSR, bm) & BMSR_LSTATUS); + /* Clearing IF_MODE_BIT0 switches the PCS to BASE-X mode, and * we assume that fixes it's speed at bitrate =3D line rate (in * other words, 1000Mbps or 2500Mbps). @@ -137,7 +141,10 @@ static int mtk_pcs_lynxi_config(struct phylink_pcs *pc= s, unsigned int neg_mode, bmcr =3D 0; } =20 - if (mpcs->interface !=3D interface) { + /* Do a full reconfiguration only if the link is down or the interface + * mode has changed + */ + if (mpcs->interface !=3D interface || !link) { link_timer =3D phylink_get_link_timer_ns(interface); if (link_timer < 0) return link_timer; --=20 2.41.0