[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <565a8248-c4d1-f135-2499-6bbfe76def53@suse.de>
Date: Thu, 17 Aug 2023 16:13:44 +0300
From: Denis Kirjanov <dkirjanov@...e.de>
To: Daniel Golle <daniel@...rotopia.org>,
Alexander Couzens <lynxis@...0.eu>,
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: Re: [PATCH net-next] net: pcs: lynxi: fully reconfigure if link is
down
On 8/17/23 15:04, Daniel Golle wrote:
> 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) {
btw is it a thread-safe to check the mpcs->interface member?
I've quick checked and phylink_pcs_config can be invoked from different places
and the code below does the following assignment:
mpcs->interface = interface;
> link_timer = phylink_get_link_timer_ns(interface);
> if (link_timer < 0)
> return link_timer;
Powered by blists - more mailing lists