From patchwork Tue Jan 30 09:28:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Romain Gantois X-Patchwork-Id: 13537090 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 EFEC0C46CD2 for ; Tue, 30 Jan 2024 09:28:55 +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=2t6iiwAk1jlHpsoLgpdyG0zaRQCTr2AgdytHe/X+kcE=; b=YVAqF9+EcX8QQD DNIdOoIR+lILL8mwC0HSjbcgmRCWrVkDlZWuUcBlM7DnW/q8y+hFM0JkYHqCezfZW1tix77Dm8XVV PIjCWqBQrLSWipB17WrdUXFiqb9gPO61No1Xkoj2k+NCudLvJykVrfHp3iY6qBGEiMI42bHVFn8R0 YKhVV7bS33HXXxNlbUX7T3T5SAg8YEKgCnHnXVVwDtqt8A88n7gdp8X4vDs5eX17WHvgZBOeoZdZE 7vyT1EpLcrUDKb1e3KoInVxFLHCHICo3vBmZDhHLAhIKMAhwxug8ke9ZA5aYiAbvgBbNacH9G+HuA Qq6880AFESZmKh5ry5gw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUkQ8-0000000Fvm7-2nun; Tue, 30 Jan 2024 09:28:44 +0000 Received: from relay3-d.mail.gandi.net ([217.70.183.195]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUkPk-0000000FvW4-0j6Z for linux-arm-kernel@lists.infradead.org; Tue, 30 Jan 2024 09:28:22 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 098146000C; Tue, 30 Jan 2024 09:28:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1706606898; 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=JCIN9PC5AsOKdJhE1Swz0j+trKxzzOsLjLL1WNO/OqY=; b=HU5gZCH6CXQVHnfIq3Vvhyl5nAG6Igh4uDVusx1iMqEvkXZbQtsVqDwoMgNGd32mKEbBHE moYX3f18TPUtVSb3ueEgVe1NoBNHZSTQcudeJ6QSfkGlFn0cXdRrBsFsqBk8MYxm2ZGrD6 1yMrE5eJfGx7lmI4PCzeFIgBSM2ki3KebrKfsTqX6NiUdo2TjStLLsxRYW9hJ9j1v6CHAP OMVTM1baaTQGBXcIFaE8tThrlvXHxW6yWS4rXKpGrExZwZn2je+Kqg/8igvQMDsFVMwt5Y yI5FM7E48EatQtLmLazotQ72v08O2F0Ppjbpox8XJboWCrw0c0BuPkBpw5pAaw== From: Romain Gantois Date: Tue, 30 Jan 2024 10:28:40 +0100 Subject: [PATCH net-next v2 5/7] net: stmmac: Signal to PHY/PCS drivers to keep RX clock on MIME-Version: 1.0 Message-Id: <20240130-rxc_bugfix-v2-5-5e6c3168e5f0@bootlin.com> References: <20240130-rxc_bugfix-v2-0-5e6c3168e5f0@bootlin.com> In-Reply-To: <20240130-rxc_bugfix-v2-0-5e6c3168e5f0@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-20240130_012820_503156_F1833D86 X-CRM114-Status: GOOD ( 11.58 ) 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 72e02ef0ee6b..7345e3fa07c4 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 = @@ -3402,6 +3405,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) {