From patchwork Sat Jul 22 20:33:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13323042 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 4DD1EC001DC for ; Sat, 22 Jul 2023 20:33:37 +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:Date:Message-Id: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-Owner; bh=BnrxApMhxq5fzYoe2P08f1+Y2rcYsfDwM8SI5b7gSCQ=; b=F3KRuiLi0u2EBD o5bYloJSwy34GJLjX1Y4Dcn8Oyq5Shue8oAljFklZKYLzDmq6euoSbWdt4jMcSuVzu384ixM7J0Jm vnC4JoRx9zf57+LNAkIY/8s+wqFBdOmVnP6zo2WKThONF2UhqwtxrLCDh4wKtzMAgO7nwNqKazU5t A+klQ4UKhBAq82ge136eJ3BJx33HjIsu24/UsB88ck+tGZnSSyYdId/I8VK/BU6i1aNmA8Oq9RkHp rFxgGVPFfMDEpDggmvP5wwfylYkxsaDXmcrc64PZa+ZA7Ou5PsztVLtZ80jHjHigXOqfn+Aa55OsD MZWy5Bsrc+B7yGO3yESQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qNJI1-00HGOi-0w; Sat, 22 Jul 2023 20:33:21 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qNJHo-00HGIs-2G; Sat, 22 Jul 2023 20:33:14 +0000 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=e8h5c4IGD+evHjEyWc3afvfJr4JlNQsLu1G4KhXqLYo=; b=CL7huplgKHPVa9AOVqEOky8oKJ ts7DYxjI5eOQw7sKrRkdv+oJUBNYDXyE1RD0Z3599iZTZLg3B4cGtVvGGISB6XKgQRy2pGlBmKzWM 3TbYCtAsoeOm4Acymc80Xck1KrEmorFKZPhIi8e+tVqEPqOsjPrCl21clWDcFrGiW4I9R2s8RVzFM iJofxdwsLHQa4Am1/VNZhroqVV4IIPTTXu/+GuRNbhk8vjSPTcLdCJlV+PN2bgjDmnDzZCdnD3+zm nXm9aqvNW/6fCmas/2Emaf0tOzp1WNHZO4A7F2aNYGho3f4Bjhvr/lGvqcaYM6YzXpQ6J1vAK4Fk5 cOWPBTmA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:51372 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.96) (envelope-from ) id 1qNJHl-00066r-0I; Sat, 22 Jul 2023 21:33:05 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qNJHl-000kFm-3K; Sat, 22 Jul 2023 21:33:05 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit , Daniel Golle , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , Frank Wunderlich , David Woodhouse Cc: AngeloGioacchino Del Regno , "David S. Miller" , Eric Dumazet , Felix Fietkau , Jakub Kicinski , John Crispin , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Lorenzo Bianconi , Mark Lee , Matthias Brugger , netdev@vger.kernel.org, Paolo Abeni , Sean Wang Subject: [PATCH net-next v2 4/4] net: phylink: explicitly invalidate link_state members in mac_config MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Sat, 22 Jul 2023 21:33:05 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230722_133308_737135_2455EAD6 X-CRM114-Status: UNSURE ( 9.94 ) X-CRM114-Notice: Please train this message. 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 Explicitly invalidate the phylink_link_state structure members in mac_config that do not contain reliable information for this function, thereby preventing their future incorrect use. Reviewed-by: Daniel Golle Tested-by: Daniel Golle Tested-by: Frank Wunderlich Signed-off-by: Russell King (Oracle) --- drivers/net/phy/phylink.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index df413fb15088..4f1c8bb199e9 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -1066,17 +1066,24 @@ static void phylink_pcs_poll_start(struct phylink *pl) static void phylink_mac_config(struct phylink *pl, const struct phylink_link_state *state) { + struct phylink_link_state st = *state; + + /* Stop drivers incorrectly using these */ + linkmode_zero(st.lp_advertising); + st.speed = SPEED_UNKNOWN; + st.duplex = DUPLEX_UNKNOWN; + st.an_complete = false; + st.link = false; + phylink_dbg(pl, - "%s: mode=%s/%s/%s/%s/%s adv=%*pb pause=%02x link=%u\n", + "%s: mode=%s/%s/%s adv=%*pb pause=%02x\n", __func__, phylink_an_mode_str(pl->cur_link_an_mode), - phy_modes(state->interface), - phy_speed_to_str(state->speed), - phy_duplex_to_str(state->duplex), - phy_rate_matching_to_str(state->rate_matching), - __ETHTOOL_LINK_MODE_MASK_NBITS, state->advertising, - state->pause, state->link); - - pl->mac_ops->mac_config(pl->config, pl->cur_link_an_mode, state); + phy_modes(st.interface), + phy_rate_matching_to_str(st.rate_matching), + __ETHTOOL_LINK_MODE_MASK_NBITS, st.advertising, + st.pause); + + pl->mac_ops->mac_config(pl->config, pl->cur_link_an_mode, &st); } static void phylink_pcs_an_restart(struct phylink *pl)