From patchwork Mon Feb 12 16:42:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Romain Gantois X-Patchwork-Id: 13553648 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 216F2C4829C for ; Mon, 12 Feb 2024 16:42:15 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=D1FkjF3Bb24HlJtKW4fDUavvvzgG7b8PJ3Q9LwaTcBE=; b=0tc2B5WMLcpU1r x6z13EGx2pVPESSKOG+aXB4FaPa4kXKyB3wqwJlv7iWCyA9sKdQWhacDowqhAAgqeaudO+87Oajsm QSNQUMI/L1tMKeG+cIWWxilLfkiprmH/cVWde3efyoXynXNNxQSQ2CrzR0XcGX6PQRGOZEOb1rW1D U4uFQIhdZ9TjlDGqixv2Wuaa7I2G5bz0ZcfqF14Ecs2xjA4iUAU6kObksp+7p90/Hst2aq3bynxub wxfgDxP+jWsneSVcl2Kl/jJAeUt2CI6qboreT88hk3SroUOcI5K8u3yMuSwTN3bCeJ8xg4xs9HSTX isa+/kiI7vFc1SkW+l0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZZNc-00000006D25-1zrN; Mon, 12 Feb 2024 16:42:04 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZZNU-00000006Cvg-13TE for linux-arm-kernel@bombadil.infradead.org; Mon, 12 Feb 2024 16:41:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=yRIMbE0unjYrvpCkfTYc04XJCl1PK7tAYUxBqamkw58=; b=dMMWAzU94sBx0G2Do0oWroA3fl QU/yhIHlaKbNUKgK9qP/dXOJC7xmE/IFzEfaBQXZmt6/kUoiKA3wQgPUmqo+B5nzeAD4xGXHtmkR4 6ANscC8tscuxhebREC0gbZvuecwOM8Tlw5ypwL/+L4RP6Zuc1jbk2lb2IFMpeBJQ0R/W12uwAcQdn tkzgJlhD4bnzhM9ZdHBhY7CwgFY/gpCwY7xwAtmDw0oXpt+YEwCQjWexwpDkJzbtu/LsJMtvl1TgE 3XFH8ccDmF3xf/hmLa/Vv2ip8yysuwbSqBzIA1YDBMwiO+x62A3MPkgxcH6nWrbgzbwGIcUPe8COp UncJp+iw==; Received: from relay2-d.mail.gandi.net ([2001:4b98:dc4:8::222]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZZNQ-0000000FMCO-3pXz for linux-arm-kernel@lists.infradead.org; Mon, 12 Feb 2024 16:41:55 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 68ABF4000C; Mon, 12 Feb 2024 16:41:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1707756109; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yRIMbE0unjYrvpCkfTYc04XJCl1PK7tAYUxBqamkw58=; b=SRVKwD5TC6/Q/eaZF0TKEEqglU/W26MWXFS0LesVfLHa/r8b4Bqs2Pr/fVFXoa4rUp0gqA cJC/8k6hbAEkuAG9Nw+UxdOqzXzvv54Hfw506EknpjJSlydEasazH1gM3biMrHyUUlXaNF qtrwepyhLN30iZoM+OJMUTmPhX49xDk3JqSJlAvmX5T+OSj+U8Wh82ezTLmFOHBOEmWW5k ZPwnTns+FH6Wsn4C7QLbkl4aAIEBVElezT59+mUT9iDNQae4DQM7gWexF+Yu/JcBI88Efz kCVgkXkRTkJ6bdO5imQ3DBJaNVLNN1gR85zREm0vlKuNsf9uebNloGTwkZAp5A== From: Romain Gantois Date: Mon, 12 Feb 2024 17:42:12 +0100 Subject: [PATCH net-next v3 5/7] net: stmmac: Signal to PHY/PCS drivers to keep RX clock on MIME-Version: 1.0 Message-Id: <20240212-rxc_bugfix-v3-5-e9f2eb6b3b05@bootlin.com> References: <20240212-rxc_bugfix-v3-0-e9f2eb6b3b05@bootlin.com> In-Reply-To: <20240212-rxc_bugfix-v3-0-e9f2eb6b3b05@bootlin.com> To: Russell King , Andrew Lunn , Heiner Kallweit , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexandre Torgue , Jose Abreu , Maxime Coquelin , =?utf-8?b?Q2zDqW1lbnQgTMOp?= =?utf-8?b?Z2Vy?= Cc: Maxime Chevallier , Miquel Raynal , Thomas Petazzoni , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-renesas-soc@vger.kernel.org, Clark Wang , Romain Gantois X-Mailer: b4 0.12.4 X-GND-Sasl: romain.gantois@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240212_164153_119225_8AF68364 X-CRM114-Status: GOOD ( 10.98 ) 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 There is a reocurring issue with stmmac controllers where the MAC fails to initialize its hardware if an RX clock signal isn't provided on the MAC/PHY link. This causes issues when PHY or PCS devices either go into suspend while cutting the RX clock or do not bring the clock signal up early enough for the MAC to initialize successfully. Set the mac_requires_rxc flag in the stmmac phylink config so that PHY/PCS drivers know to keep the RX clock up at all times. Reported-by: Clark Wang Link: https://lore.kernel.org/all/20230202081559.3553637-1-xiaoning.wang@nxp.com/ Reported-by: Clément Léger Link: https://lore.kernel.org/linux-arm-kernel/20230116103926.276869-4-clement.leger@bootlin.com/ Suggested-by: Russell King Signed-off-by: Romain Gantois --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index ec4f6377b5ee..caf71a502ff2 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1218,6 +1218,9 @@ static int stmmac_phy_setup(struct stmmac_priv *priv) priv->phylink_config.type = PHYLINK_NETDEV; priv->phylink_config.mac_managed_pm = true; + /* Stmmac always requires an RX clock for hardware initialization */ + priv->phylink_config.mac_requires_rxc = true; + mdio_bus_data = priv->plat->mdio_bus_data; if (mdio_bus_data) priv->phylink_config.ovr_an_inband = @@ -3407,6 +3410,10 @@ static int stmmac_hw_setup(struct net_device *dev, bool ptp_register) u32 chan; int ret; + /* Make sure RX clock is enabled */ + if (priv->hw->phylink_pcs) + phylink_pcs_pre_init(priv->phylink, priv->hw->phylink_pcs); + /* DMA initialization and SW reset */ ret = stmmac_init_dma_engine(priv); if (ret < 0) {