From patchwork Mon Jun 27 11:44:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12896544 X-Patchwork-Delegate: kuba@kernel.org 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 E29DBC433EF for ; Mon, 27 Jun 2022 11:54:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238647AbiF0Ly2 (ORCPT ); Mon, 27 Jun 2022 07:54:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238189AbiF0Lva (ORCPT ); Mon, 27 Jun 2022 07:51:30 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1F8865C6 for ; Mon, 27 Jun 2022 04:44:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=NgZ1jiznNa2GJB/i+Iv8XujiVJxtgZsHyRtQGD5URa0=; b=ouhFKaQp7vD/S+QxuwQoKAy3O/ MryK4T47WsAd5Wr9lsKDRGP9RAf/PaAj7EMIIb4gZclvDJsh6fQfzjYH5cfvfuINUfXWv/djeOegs rsMxZbI3VTJcvYGF/nNSIExEhxvspraEwZWkynYuN8VYNuwipPMjTunDJcBJPRR+8Ajr1AjPLMHGL y763Zy9Uk09521aOkwLavR6xuBeTeis/ZwZVGOGQxGPACT1Ww1/n1i0j4eZI3lA4wktd+atkIrIRZ KQI/c8Mf+vRTQC6oDIKS1CmAo1axVdGLzvXvMc5sr8FAsgoj2v6uONPlZu2eT0U8ASubswidqn7Q6 fy1M/6Fw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:53978 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1o5nAV-0000HO-BH; Mon, 27 Jun 2022 12:44:39 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1o5nAU-004RR7-Oh; Mon, 27 Jun 2022 12:44:38 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: "David S. Miller" , netdev@vger.kernel.org, Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH net-next 1/2] net: phylink: remove pcs_ops member MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Mon, 27 Jun 2022 12:44:38 +0100 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Remove the pcs_ops member from struct phylink, using the one stored in struct phylink_pcs instead. Reviewed-by: Andrew Lunn Signed-off-by: Russell King (Oracle) --- drivers/net/phy/phylink.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index e20cdab824db..0216ea978261 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -43,7 +43,6 @@ struct phylink { /* private: */ struct net_device *netdev; const struct phylink_mac_ops *mac_ops; - const struct phylink_pcs_ops *pcs_ops; struct phylink_config *config; struct phylink_pcs *pcs; struct device *dev; @@ -779,8 +778,8 @@ static void phylink_mac_pcs_an_restart(struct phylink *pl) if (pl->link_config.an_enabled && phy_interface_mode_is_8023z(pl->link_config.interface) && phylink_autoneg_inband(pl->cur_link_an_mode)) { - if (pl->pcs_ops) - pl->pcs_ops->pcs_an_restart(pl->pcs); + if (pl->pcs) + pl->pcs->ops->pcs_an_restart(pl->pcs); else if (pl->config->legacy_pre_march2020) pl->mac_ops->mac_an_restart(pl->config); } @@ -819,7 +818,6 @@ static void phylink_major_config(struct phylink *pl, bool restart, */ if (pcs) { pl->pcs = pcs; - pl->pcs_ops = pcs->ops; if (!pl->phylink_disable_state && pl->cfg_link_an_mode == MLO_AN_INBAND) { @@ -832,12 +830,12 @@ static void phylink_major_config(struct phylink *pl, bool restart, phylink_mac_config(pl, state); - if (pl->pcs_ops) { - err = pl->pcs_ops->pcs_config(pl->pcs, pl->cur_link_an_mode, - state->interface, - state->advertising, - !!(pl->link_config.pause & - MLO_PAUSE_AN)); + if (pl->pcs) { + err = pl->pcs->ops->pcs_config(pl->pcs, pl->cur_link_an_mode, + state->interface, + state->advertising, + !!(pl->link_config.pause & + MLO_PAUSE_AN)); if (err < 0) phylink_err(pl, "pcs_config failed: %pe\n", ERR_PTR(err)); @@ -869,7 +867,7 @@ static int phylink_change_inband_advert(struct phylink *pl) if (test_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state)) return 0; - if (!pl->pcs_ops && pl->config->legacy_pre_march2020) { + if (!pl->pcs && pl->config->legacy_pre_march2020) { /* Legacy method */ phylink_mac_config(pl, &pl->link_config); phylink_mac_pcs_an_restart(pl); @@ -886,10 +884,11 @@ static int phylink_change_inband_advert(struct phylink *pl) * restart negotiation if the pcs_config() helper indicates that * the programmed advertisement has changed. */ - ret = pl->pcs_ops->pcs_config(pl->pcs, pl->cur_link_an_mode, - pl->link_config.interface, - pl->link_config.advertising, - !!(pl->link_config.pause & MLO_PAUSE_AN)); + ret = pl->pcs->ops->pcs_config(pl->pcs, pl->cur_link_an_mode, + pl->link_config.interface, + pl->link_config.advertising, + !!(pl->link_config.pause & + MLO_PAUSE_AN)); if (ret < 0) return ret; @@ -918,8 +917,8 @@ static void phylink_mac_pcs_get_state(struct phylink *pl, state->an_complete = 0; state->link = 1; - if (pl->pcs_ops) - pl->pcs_ops->pcs_get_state(pl->pcs, state); + if (pl->pcs) + pl->pcs->ops->pcs_get_state(pl->pcs, state); else if (pl->mac_ops->mac_pcs_get_state && pl->config->legacy_pre_march2020) pl->mac_ops->mac_pcs_get_state(pl->config, state); @@ -992,8 +991,8 @@ static void phylink_link_up(struct phylink *pl, pl->cur_interface = link_state.interface; - if (pl->pcs_ops && pl->pcs_ops->pcs_link_up) - pl->pcs_ops->pcs_link_up(pl->pcs, pl->cur_link_an_mode, + if (pl->pcs && pl->pcs->ops->pcs_link_up) + pl->pcs->ops->pcs_link_up(pl->pcs, pl->cur_link_an_mode, pl->cur_interface, link_state.speed, link_state.duplex); @@ -1115,7 +1114,7 @@ static void phylink_resolve(struct work_struct *w) } phylink_major_config(pl, false, &link_state); pl->link_config.interface = link_state.interface; - } else if (!pl->pcs_ops && pl->config->legacy_pre_march2020) { + } else if (!pl->pcs && pl->config->legacy_pre_march2020) { /* The interface remains unchanged, only the speed, * duplex or pause settings have changed. Call the * old mac_config() method to configure the MAC/PCS From patchwork Mon Jun 27 11:44:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12896543 X-Patchwork-Delegate: kuba@kernel.org 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 7A33CCCA473 for ; Mon, 27 Jun 2022 11:54:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238532AbiF0LyZ (ORCPT ); Mon, 27 Jun 2022 07:54:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238601AbiF0Lvn (ORCPT ); Mon, 27 Jun 2022 07:51:43 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D202764D for ; Mon, 27 Jun 2022 04:44:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=8HI84ZhcG/Irsem7722IHiSFtPE+Ke/NIHiQtmDv1UE=; b=BgsYx783iMEf86ytIhbFHCyM9g oUa23qqnca15ScGKA0bASZ5+Br1+MeRcKmkK34lvlbw4MecwNaDydCQ0s+KI12RZQe3UTW6mRlPHn fud8ElYBC8rbeM38Gfivuc51CSED6IJhPzdwdgLfdooynAiNcfgEveDYVjzO6XMdBzzhIXlIlqkE7 17cJKyZA7qey0TmJiYY9KfUJCe/T81Bp+KG8Ph6Hu9YSsCM8Ta9xySIyTgQbfGpXm3YdOiz6h2AL0 N/HpcME931sgxowimgoKc4HVDbO5zgu2k0RMtlo+QLBjU0AeZ+joSOZrp4Sc6OYwr3rc7pKznjNvV jyAvHeGw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:53980 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1o5nAa-0000Ha-FG; Mon, 27 Jun 2022 12:44:44 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1o5nAZ-004RRE-So; Mon, 27 Jun 2022 12:44:43 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: "David S. Miller" , netdev@vger.kernel.org, Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH net-next 2/2] net: phylink: disable PCS polling over major configuration MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Mon, 27 Jun 2022 12:44:43 +0100 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org While we are performing a major configuration, there is no point having the PCS polling timer running. Stop it before we begin preparing for the configuration change, and restart it only once we've successfully completed the change. Reviewed-by: Andrew Lunn Signed-off-by: Russell King (Oracle) --- drivers/net/phy/phylink.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 0216ea978261..1a7550f5fdf5 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -758,6 +758,18 @@ static void phylink_resolve_flow(struct phylink_link_state *state) } } +static void phylink_pcs_poll_stop(struct phylink *pl) +{ + if (pl->cfg_link_an_mode == MLO_AN_INBAND) + del_timer(&pl->link_poll); +} + +static void phylink_pcs_poll_start(struct phylink *pl) +{ + if (pl->pcs->poll && pl->cfg_link_an_mode == MLO_AN_INBAND) + mod_timer(&pl->link_poll, jiffies + HZ); +} + static void phylink_mac_config(struct phylink *pl, const struct phylink_link_state *state) { @@ -789,6 +801,7 @@ static void phylink_major_config(struct phylink *pl, bool restart, const struct phylink_link_state *state) { struct phylink_pcs *pcs = NULL; + bool pcs_changed = false; int err; phylink_dbg(pl, "major config %s\n", phy_modes(state->interface)); @@ -801,8 +814,12 @@ static void phylink_major_config(struct phylink *pl, bool restart, pcs); return; } + + pcs_changed = pcs && pl->pcs != pcs; } + phylink_pcs_poll_stop(pl); + if (pl->mac_ops->mac_prepare) { err = pl->mac_ops->mac_prepare(pl->config, pl->cur_link_an_mode, state->interface); @@ -816,18 +833,9 @@ static void phylink_major_config(struct phylink *pl, bool restart, /* If we have a new PCS, switch to the new PCS after preparing the MAC * for the change. */ - if (pcs) { + if (pcs_changed) pl->pcs = pcs; - if (!pl->phylink_disable_state && - pl->cfg_link_an_mode == MLO_AN_INBAND) { - if (pcs->poll) - mod_timer(&pl->link_poll, jiffies + HZ); - else - del_timer(&pl->link_poll); - } - } - phylink_mac_config(pl, state); if (pl->pcs) { @@ -852,6 +860,8 @@ static void phylink_major_config(struct phylink *pl, bool restart, phylink_err(pl, "mac_finish failed: %pe\n", ERR_PTR(err)); } + + phylink_pcs_poll_start(pl); } /*