From patchwork Thu Aug 17 12:04:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 13356339 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3A5B6C27C7A for ; Thu, 17 Aug 2023 12:05:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=6GbvXjZWaKPcP6WOZ3RfdVS8aeVhTIkFTyaGRekumKE=; b=L7vRrbT82sv5t5 +xgbq3UsZbdiALpLWZuH8CIncVTiI+nBF2o7oy41oq1zjh/J3wk8mUWuuYjbGWaee/e0TBXZGflgO 9xhzJftGR6A0OAZxKVfJ00VcNAdsIOtzEt9qnGGA+SB+fz//EZjIUlsXVEeCwJQe0kuuQjPbMIhME NMGe3mIR9LbytNaUrq1+CAiPNA4LjZnDhu+/ZFiHNSi+JsDk6HsjT4RFriwhQdfXKsf/p2gdmPXfI tCkLI8Wlp70/uYiyJbDz47LMT2EDqTHj0XtEDFZezTT7y6BU0JX+um4b3s18YaNTbVe9dUWitIuRM mA4ftkkBE+f03epS5AUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qWbjx-006LP9-0q; Thu, 17 Aug 2023 12:04:37 +0000 Received: from pidgin.makrotopia.org ([185.142.180.65]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qWbju-006LOi-1A; Thu, 17 Aug 2023 12:04:35 +0000 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230817_050434_402911_091F8B41 X-CRM114-Status: GOOD ( 16.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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;