Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp2226411rdb; Thu, 17 Aug 2023 14:49:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEQ8gSINONysdy1/6+OyQ0gWRI5V18Hf5ZVh6TrpXKoHjTkzK1vzRCcUDSvLseJocHwZbTK X-Received: by 2002:a17:903:1248:b0:1bb:d59d:8c57 with SMTP id u8-20020a170903124800b001bbd59d8c57mr685854plh.18.1692308999262; Thu, 17 Aug 2023 14:49:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692308999; cv=none; d=google.com; s=arc-20160816; b=h4zuUpkolDURgVsj/V6e/DXCc/gRQUowpwhhJx8ynQDxRK6WgpmaGLi82nHbVlUz4v nCk/evcHumdFC5XggRLvSeazomhb1VhI32BzQ0+aveFJkpTmLPMmHWKkCfsqqEFs8GFR Ps3cbsxPEBoJhix1lj+4u8J5Sb14v5vzr/IRSW/tsnXQRjWizDI95slpLDNT/GeYiNJQ nmlM2nWRrSv+Xcg9JqP1c54IevbkPYo0k5aQ+tR09ZfT2Krxfr+MjEPUWZMnQc4Zwgpd qU2LG5ax2FMGpuOSwQUyHpjYELngESabprTUUp9y+FUVB6xXqo/+YHtkCIRVqdqOuaVG Hmkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date; bh=brA8GoAvDNp8q8xbP+QJWVaL+zpV7fP9YmTxAqc9jSQ=; fh=UHMNjJiuxKuA03v9I9ZORlBFAtuL/SiP8nCBgfAAnpQ=; b=QIDkEcercBlCFO7oIjYY6IGiI2VbPwlmhnvqnP9QCCQLUKDrvEj/CzYBHIHW1106ae +N2gZdGETVhCmPBQSii8K0tBkVga+1+56GIKKmc9M4elgC/iAwsCIZtWu4fojVKhxtRM /CCP9AOSd9a5DU7x7wzPit4Wrb+7tDfbH4S1sV6mCMNBGUsCm3wZiWs53qZveGb/5vTC CaulIBsp72oIwjfuEscJI1pS1qMh5ILsUT+iEXnyMNn9rR5oEOir5t5y4if5WFj54vCc HYbbYIUNVczKRGcksisjiGM9XaOMJnvwOg9/2HFHVpUhz/D/WiOV3nOz2EB5XvFXrY8y 4w4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ng17-20020a17090b1a9100b002689d34ae8dsi2172539pjb.18.2023.08.17.14.49.37; Thu, 17 Aug 2023 14:49:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244223AbjHQMFO (ORCPT + 99 others); Thu, 17 Aug 2023 08:05:14 -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-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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-lynxi.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 = pcs_to_mtk_pcs_lynxi(pcs); - bool mode_changed = false, changed; - unsigned int rgc3, sgm_mode, bmcr; + bool mode_changed = false, changed, link; + unsigned int bm, rgc3, sgm_mode, bmcr; int advertise, link_timer; advertise = phylink_mii_c22_pcs_encode_advertisement(interface, @@ -117,6 +117,10 @@ static int mtk_pcs_lynxi_config(struct phylink_pcs *pcs, unsigned int neg_mode, if (advertise < 0) return advertise; + /* Check if link is currently up */ + regmap_read(mpcs->regmap, SGMSYS_PCS_CONTROL_1, &bm); + link = !!(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 = line rate (in * other words, 1000Mbps or 2500Mbps). @@ -137,7 +141,10 @@ static int mtk_pcs_lynxi_config(struct phylink_pcs *pcs, unsigned int neg_mode, bmcr = 0; } - if (mpcs->interface != interface) { + /* Do a full reconfiguration only if the link is down or the interface + * mode has changed + */ + if (mpcs->interface != interface || !link) { link_timer = phylink_get_link_timer_ns(interface); if (link_timer < 0) return link_timer; -- 2.41.0