[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <e9831ec99acd5a8ab03c76fce87fa750c7041e60.1692273723.git.daniel@makrotopia.org>
Date: Thu, 17 Aug 2023 13:04:06 +0100
From: Daniel Golle <daniel@...rotopia.org>
To: Alexander Couzens <lynxis@...0.eu>,
Daniel Golle <daniel@...rotopia.org>,
Andrew Lunn <andrew@...n.ch>,
Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Matthias Brugger <matthias.bgg@...il.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org
Subject: [PATCH net-next] net: pcs: lynxi: fully reconfigure if link is down
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 <daniel@...rotopia.org>
---
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
Powered by blists - more mailing lists