From patchwork Wed Feb 21 13:04:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Gantois X-Patchwork-Id: 13565572 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 AAFEDC48BF6 for ; Wed, 21 Feb 2024 13:04:20 +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=KPSGVzyhL8Yh09llW6jIuBxipV1IadkwYqhXRyzHJso=; b=zPPt0XKmDUsc1J 9bOE77OlaA/zdUYNS7MPC2bpSTmEhwNpjlOSuXtO89JR2MOCAZ/7Ct3Td3X2v9birTqB/HW3HnWRE nvQ7QfVIDbik/Is+J27Usy6OcttEW+eZQaIovYJvYHJ207g0X9SOXdzZZl6zotNJoq6KmtuHeWHTO ZiAJmC7qz/KxCl9poi2qW/nwotUOWbtTaqH9mnlbJbUS5LmbHdRpWUXv+8QcJavm7upa4jFXnHFHJ rUdMWXwAhyLjWM9A0vqH+iDYs3aqFIzvksE4DBSsXqejOO3KnIBi+8qj6nI9KLmOw0RijskPRMDjC 6fXA9hzb9OOkIbUR1tOw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcmGc-00000000xBN-0BHs; Wed, 21 Feb 2024 13:04:06 +0000 Received: from relay4-d.mail.gandi.net ([2001:4b98:dc4:8::224]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcmGX-00000000x8d-3sUy for linux-arm-kernel@lists.infradead.org; Wed, 21 Feb 2024 13:04:04 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 2960AE0005; Wed, 21 Feb 2024 13:03:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708520639; 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=01GsuDPlFgc02VZRSE6Ri0zdyu1ks0DXXau7fkqJF6M=; b=f/MVobot3k6Km8R2lQBwAndwTMlbLdwEyv2UTEz65Nh+hGwBeyOVBk0ysqrdvqeG//k89R w4yGPyNaxZxRBhTsHi9dLGW0CE5J/ckJEB3zXpKmti6OAboi00X8zwToufd4P9KRRHYiZt T9IC+RqAiAUniSt668zmLdxgysllSB7pxHYZdZOiOCH7Zb5OLPYR8dP1/rgH/hTkwmGGgr qRLBGDIbGob9oEO1BlbNp1WAQkZ2zviCAX9GEJOsjuGs5rFhqlhrkkOoeTUR1jm21Q+2Xi StWohtjy8oBjCb/eHnXOZHDrAIOL84WzSlRJBi71c7fH1sZDc+6YLZjb/2x4mA== From: Romain Gantois Date: Wed, 21 Feb 2024 14:04:18 +0100 Subject: [PATCH net-next v4 1/7] net: phylink: add PHY_F_RXC_ALWAYS_ON to PHY dev flags MIME-Version: 1.0 Message-Id: <20240221-rxc_bugfix-v4-1-4883ee1cc7b1@bootlin.com> References: <20240221-rxc_bugfix-v4-0-4883ee1cc7b1@bootlin.com> In-Reply-To: <20240221-rxc_bugfix-v4-0-4883ee1cc7b1@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, 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-20240221_050402_451729_56B7355B X-CRM114-Status: GOOD ( 19.43 ) 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 From: Russell King Some MAC controllers (e.g. stmmac) require their connected PHY to continuously provide a receive clock signal. This can cause issues in two cases: 1. The clock signal hasn't been started yet by the time the MAC driver initializes its hardware. This can make the initialization fail, as in the case of the rzn1 GMAC1 driver. 2. The clock signal is cut during a power saving event. By the time the MAC is brought back up, the clock signal is still not active since phylink_start hasn't been called yet. This brings us back to case 1. If a PHY driver reads this flag, it should ensure that the receive clock signal is started as soon as possible, and that it isn't brought down when the PHY goes into suspend. Signed-off-by: Russell King [rgantois: commit log] Signed-off-by: Romain Gantois --- drivers/net/phy/phylink.c | 10 +++++++++- include/linux/phy.h | 1 + include/linux/phylink.h | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 503fd7c40523..2bb583543dea 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -1923,6 +1923,8 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy, static int phylink_attach_phy(struct phylink *pl, struct phy_device *phy, phy_interface_t interface) { + u32 flags = 0; + if (WARN_ON(pl->cfg_link_an_mode == MLO_AN_FIXED || (pl->cfg_link_an_mode == MLO_AN_INBAND && phy_interface_mode_is_8023z(interface) && !pl->sfp_bus))) @@ -1931,7 +1933,10 @@ static int phylink_attach_phy(struct phylink *pl, struct phy_device *phy, if (pl->phydev) return -EBUSY; - return phy_attach_direct(pl->netdev, phy, 0, interface); + if (pl->config->mac_requires_rxc) + flags |= PHY_F_RXC_ALWAYS_ON; + + return phy_attach_direct(pl->netdev, phy, flags, interface); } /** @@ -2034,6 +2039,9 @@ int phylink_fwnode_phy_connect(struct phylink *pl, pl->link_config.interface = pl->link_interface; } + if (pl->config->mac_requires_rxc) + flags |= PHY_F_RXC_ALWAYS_ON; + ret = phy_attach_direct(pl->netdev, phy_dev, flags, pl->link_interface); phy_device_free(phy_dev); diff --git a/include/linux/phy.h b/include/linux/phy.h index 2249cdb5957a..1fef852634bd 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -771,6 +771,7 @@ struct phy_device { /* Generic phy_device::dev_flags */ #define PHY_F_NO_IRQ 0x80000000 +#define PHY_F_RXC_ALWAYS_ON 0x40000000 static inline struct phy_device *to_phy_device(const struct device *dev) { diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 6ba411732a0d..019993e5f570 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -138,6 +138,9 @@ enum phylink_op_type { * @poll_fixed_state: if true, starts link_poll, * if MAC link is at %MLO_AN_FIXED mode. * @mac_managed_pm: if true, indicate the MAC driver is responsible for PHY PM. + * @mac_requires_rxc: if true, the MAC always requires a receive clock from PHY. + * The PHY driver should start the clock signal as soon as + * possible and avoid stopping it during suspend events. * @ovr_an_inband: if true, override PCS to MLO_AN_INBAND * @get_fixed_state: callback to execute to determine the fixed link state, * if MAC link is at %MLO_AN_FIXED mode. @@ -150,6 +153,7 @@ struct phylink_config { enum phylink_op_type type; bool poll_fixed_state; bool mac_managed_pm; + bool mac_requires_rxc; bool ovr_an_inband; void (*get_fixed_state)(struct phylink_config *config, struct phylink_link_state *state); From patchwork Wed Feb 21 13:04:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Gantois X-Patchwork-Id: 13565573 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 9F9E1C48BC3 for ; Wed, 21 Feb 2024 13:04:21 +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=7qYuIMopzCnZH+3g6y57gBux7HX9DQgNCOx+4ksaBoQ=; b=MgHZwEbZdd9Zpi HIJe/rsI5Zw/CchJbeDYHzXIN0hzDqZTLYKkGghMVxgBTL2KtZHm3VafuKW+GEFxfjbuXIqZyHEFL YtVTMKMMPUQE6oVMrktstzbFrPDxpw4nKhpMbxj8czY5bFatrT644RaU2fG5tWWRQNOpfRym9Wegq ee0108DD/1CxpZxtpNO6sx3LyiSuW1YEvf/GMwFZjn/m3lN0RHLkohwydr8tAmWU0OfCfQe1m+db6 bKVmiuOy7aIIDaY4GXndzNigu62pXr8CjAxLddKNgnZSSHGHV5ruBmXHn2k2J5+3yC35jNcXjyjaW Zi4ROWPu7deGE0CU0QFw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcmGd-00000000xCi-2qQz; Wed, 21 Feb 2024 13:04:07 +0000 Received: from relay4-d.mail.gandi.net ([217.70.183.196]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcmGX-00000000x8g-3yY4 for linux-arm-kernel@lists.infradead.org; Wed, 21 Feb 2024 13:04:04 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 26705E0004; Wed, 21 Feb 2024 13:03:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708520640; 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=TihZ+E5bRCt9eqbBQ5SrGYKdzNeo69DFCWBLyHM4SoE=; b=NID9xw5KJjHVsZnbq58Nox6xZOGQjitn2OssuAS0zkc0NZWwpPzSRxM/JQzkrbMBYoClWh zZMNeyaawLNvvs+bnEmUNUQj5a4PcAzUNSrnomR38DaMZYRRtVo032hTcDuGCjiscqIT0w TWAX2YNJO9rfHemGu9nHDdXXJmci+i/ekrLp+9kjnPrEFgfOgzwvrgkhEzVIy8Rl3p1iWB KRSRLHYP/sNxp9DqAbtFJayCZdSqpgJ1SYOxTXYceS9eqKmgkAXm/Qb5hmNm7XR9ASnfTI cGvVXMdJ0GLgbnvlCK0kELK+LLLS4LpBiyEDf8/Ke3mLOi2l5ghGSZYTmnRR7A== From: Romain Gantois Date: Wed, 21 Feb 2024 14:04:19 +0100 Subject: [PATCH net-next v4 2/7] net: phylink: add rxc_always_on flag to phylink_pcs MIME-Version: 1.0 Message-Id: <20240221-rxc_bugfix-v4-2-4883ee1cc7b1@bootlin.com> References: <20240221-rxc_bugfix-v4-0-4883ee1cc7b1@bootlin.com> In-Reply-To: <20240221-rxc_bugfix-v4-0-4883ee1cc7b1@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, 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-20240221_050402_451534_4FFA75A9 X-CRM114-Status: GOOD ( 22.59 ) 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 Some MAC drivers (e.g. stmmac) require a continuous receive clock signal to be generated by a PCS that is handled by a standalone PCS driver. Such a PCS driver does not have access to a PHY device, thus cannot check the PHY_F_RXC_ALWAYS_ON flag. They cannot check max_requires_rxc in the phylink config either, since it is a private member. Therefore, a new flag is needed to signal to the PCS that it should keep the RX clock signal up at all times. Suggested-by: Russell King Signed-off-by: Romain Gantois --- drivers/net/phy/phylink.c | 14 ++++++++++++++ include/linux/phylink.h | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 2bb583543dea..dad7462996ab 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -1042,6 +1042,20 @@ static void phylink_pcs_poll_start(struct phylink *pl) mod_timer(&pl->link_poll, jiffies + HZ); } +int phylink_pcs_pre_init(struct phylink *pl, struct phylink_pcs *pcs) +{ + int ret = 0; + + /* Signal to PCS driver that MAC requires RX clock for init */ + if (pl->config->mac_requires_rxc) + pcs->rxc_always_on = true; + + if (pcs->ops->pcs_pre_init) + ret = pcs->ops->pcs_pre_init(pcs); + + return ret; +} + static void phylink_mac_config(struct phylink *pl, const struct phylink_link_state *state) { diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 019993e5f570..f6ef5bc82179 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -396,6 +396,10 @@ struct phylink_pcs_ops; * @phylink: pointer to &struct phylink_config * @neg_mode: provide PCS neg mode via "mode" argument * @poll: poll the PCS for link changes + * @rxc_always_on: The MAC driver requires the reference clock + * to always be on. Standalone PCS drivers which + * do not have access to a PHY device can check + * this instead of PHY_F_RXC_ALWAYS_ON. * * This structure is designed to be embedded within the PCS private data, * and will be passed between phylink and the PCS. @@ -408,6 +412,7 @@ struct phylink_pcs { struct phylink *phylink; bool neg_mode; bool poll; + bool rxc_always_on; }; /** @@ -422,6 +427,8 @@ struct phylink_pcs { * @pcs_an_restart: restart 802.3z BaseX autonegotiation. * @pcs_link_up: program the PCS for the resolved link configuration * (where necessary). + * @pcs_pre_init: configure PCS components necessary for MAC hardware + * initialization e.g. RX clock for stmmac. */ struct phylink_pcs_ops { int (*pcs_validate)(struct phylink_pcs *pcs, unsigned long *supported, @@ -441,6 +448,7 @@ struct phylink_pcs_ops { void (*pcs_an_restart)(struct phylink_pcs *pcs); void (*pcs_link_up)(struct phylink_pcs *pcs, unsigned int neg_mode, phy_interface_t interface, int speed, int duplex); + int (*pcs_pre_init)(struct phylink_pcs *pcs); }; #if 0 /* For kernel-doc purposes only. */ @@ -549,6 +557,34 @@ void pcs_an_restart(struct phylink_pcs *pcs); */ void pcs_link_up(struct phylink_pcs *pcs, unsigned int neg_mode, phy_interface_t interface, int speed, int duplex); + +/** + * pcs_pre_init() - Configure PCS components necessary for MAC initialization + * @pcs: a pointer to a &struct phylink_pcs. + * + * This function can be called by MAC drivers through the + * phylink_pcs_pre_init() wrapper, before their hardware is initialized. It + * should not be called after the link is brought up, as reconfiguring the PCS + * at this point could break the link. + * + * Some MAC devices require specific hardware initialization to be performed by + * their associated PCS device before they can properly initialize their own + * hardware. An example of this is the initialization of stmmac controllers, + * which requires an active REF_CLK signal to be provided by the PHY/PCS. + * + * By calling phylink_pcs_pre_init(), MAC drivers can ensure that the PCS is + * setup in a way that allows for successful hardware initialization. + * + * The specific configuration performed by pcs_pre_init() is dependent on the + * model of PCS and the requirements of the MAC device attached to it. PCS + * driver authors should consider whether their target device is to be used in + * conjunction with a MAC device whose driver calls phylink_pcs_pre_init(). MAC + * driver authors should document their requirements for the PCS + * pre-initialization. + * + */ +int pcs_config(struct phylink_pcs *pcs); + #endif struct phylink *phylink_create(struct phylink_config *, @@ -568,6 +604,8 @@ void phylink_disconnect_phy(struct phylink *); void phylink_mac_change(struct phylink *, bool up); void phylink_pcs_change(struct phylink_pcs *, bool up); +int phylink_pcs_pre_init(struct phylink *pl, struct phylink_pcs *pcs); + void phylink_start(struct phylink *); void phylink_stop(struct phylink *); From patchwork Wed Feb 21 13:04:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Gantois X-Patchwork-Id: 13565574 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 42F4EC54788 for ; Wed, 21 Feb 2024 13:04:23 +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=ecp6Npb00KkcBBw6I6Jzyfu0xwv9Zk7lwVNRCCLOOhg=; b=kND9RyabKzQMW5 +Bqcv0ZsENBlhLgbPL+RyTKOPj6z7OrNL8wX0RfxUr3/a4uLH+ouhWrbZt+reJ1+mz26oJ3Q23t5o 0JwDKRIbkyYmeNjFngOrAJtCCeAaqI69wTD+1xYVpuvkZiriFPG9z/i68pYr3LK88LUAiPGXT8fTc C6gjtVrLJVMvIYPN2/qjcQeB8sDs59uXApqS5Wo11f74VV7dIIYMeoo6bS46ovGIY8BkkQjJRaKFt 1FacMd1T/6C6yXpvOUSrzIGTwCDq0Sniy7fKTsrvDYGiNvyPRZ5yh1U0maJulGz+JlRwMGtLhJbE9 kcYG0LJTQv2Jq0ySo6KQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcmGc-00000000xC4-3CyR; Wed, 21 Feb 2024 13:04:06 +0000 Received: from relay4-d.mail.gandi.net ([2001:4b98:dc4:8::224]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcmGY-00000000x8v-39Db for linux-arm-kernel@lists.infradead.org; Wed, 21 Feb 2024 13:04:04 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 3B728E000D; Wed, 21 Feb 2024 13:04:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708520641; 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=YRGNGZcqgoCOXv3VnpuOzxbccKn6jF8lp/JWdRUtrtM=; b=meQ8RTT38F8cz3r6Yc7dYhO6F62SSbh9v8w9KL7P9K+6OEayGmGz7xoJMmn6BURnso1Qoy 7W+q7qsfkLJXgd0AwYLNKSDRNLVsJeP7LgUpbrjOLEkhuqF+GhJZyumBAj20o6Tg4FyQ2Z c5QE0CXJ7jggwRKUNQuTiR9Pc9upNrcfteM/FpoQvOcysKqcI3lv1dHF4G9B6fgkeAYolF x2yI+NR5ndyjznK8kwftVSce3UPvKmr/KYcm8/6SdwZvtui1elu4A7iNSdDaJNeY9XDrlD HrkdlXfzpsS3d4BhsmancighrjB526vNCSmppKSbF8+lqjTlzhLa3IGHi1AFqQ== From: Romain Gantois Date: Wed, 21 Feb 2024 14:04:20 +0100 Subject: [PATCH net-next v4 3/7] net: stmmac: don't rely on lynx_pcs presence to check for a PHY MIME-Version: 1.0 Message-Id: <20240221-rxc_bugfix-v4-3-4883ee1cc7b1@bootlin.com> References: <20240221-rxc_bugfix-v4-0-4883ee1cc7b1@bootlin.com> In-Reply-To: <20240221-rxc_bugfix-v4-0-4883ee1cc7b1@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, 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-20240221_050403_070496_B976C2F5 X-CRM114-Status: GOOD ( 12.30 ) 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 From: Maxime Chevallier When initializing attached PHYs, there are some cases where we don't expect any PHY to be connected. The logic uses conditions based on various local PCS configuration, but also calls-in phylink_expects_phy() via stmmac_init_phy(), which is enough to ensure we don't try to initialize a PHY when using a Lynx PCS, as long as we have the phy_interface set to a 802.3z mode and are using inband negociation. Drop the lynx check, making the stmmac generic code more pcs_lynx-agnostic. Signed-off-by: Maxime Chevallier [rgantois: commit log] Signed-off-by: Romain Gantois --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 9159d93ceb03..47cd8666af43 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -3959,8 +3959,7 @@ static int __stmmac_open(struct net_device *dev, if (priv->hw->pcs != STMMAC_PCS_TBI && priv->hw->pcs != STMMAC_PCS_RTBI && (!priv->hw->xpcs || - xpcs_get_an_mode(priv->hw->xpcs, mode) != DW_AN_C73) && - !priv->hw->lynx_pcs) { + xpcs_get_an_mode(priv->hw->xpcs, mode) != DW_AN_C73)) { ret = stmmac_init_phy(dev); if (ret) { netdev_err(priv->dev, From patchwork Wed Feb 21 13:04:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Gantois X-Patchwork-Id: 13565577 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 2E821C48BF6 for ; Wed, 21 Feb 2024 13:05:05 +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=3KSC8TRuu0ei9w2CiscsdrwHHQnb9wmfgqbU8J36mPM=; b=i57TgMNH2vZ6Ee qPVn1HbU3HQD78F7bdtCOaAszdNGhUB1FgPuV8ZPRV8Ejk9fZQC53PJY657XINzH6/1e5IIaMBbyJ jFcYh5ld+kof/WlY7RTUWGsHN7sDBNTdxiDLVKvlpkc8yLCU3BEeRyurQL0yVRtyu2Oz4PV8nqqmq wxaSPVnaIw9s8VAjJz7UUJ7gIjVwlvihsVL0sXrwuPMPR2ilq0wORDAWiRuqo6CuDAh/+p/Vx4QXC Bpql3B/KPM6Eh+nvRtA+0Ppjv0ZvgWTtVQIQAjHl7y1A+S54uyVM0QIGlKl9AMDHIcrqjdNJoXOiE KV/6z7UNZmHcuTOFlRtA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcmHJ-00000000xZ5-1FUu; Wed, 21 Feb 2024 13:04:49 +0000 Received: from relay4-d.mail.gandi.net ([217.70.183.196]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcmGZ-00000000x9b-2U29 for linux-arm-kernel@lists.infradead.org; Wed, 21 Feb 2024 13:04:05 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 6C4BAE000F; Wed, 21 Feb 2024 13:04:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708520642; 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=uvjZHLMOPyZvhYtEiNXCG1LQjVmCDnKn5LrGq5/CUOY=; b=HiARg4DiqHiItZ3wZukllFiYv5qEDcnT0rH5wxmZyzTaNHyHa8A6zE3W2Ne8KhpGdOo5HV IitrzwGAfAeIb2BMRNcJfabcVMmojFIOJuPnXOFCDNpPm+Javm12m4/JBpmQvk3K0CcK24 z55rCDUXPxnIeHfyrbZNOoXXeJ7OW6VmfznBHrqc+CnUy8a89Nsbg9TayJwT2nDcLjoE87 FVyhIYetGfqyUFLVvwUthDt6pbAzGQ+C6p6OjpkGquIWPKb8ZYem/DTWe0KORMlPWR25vS s96daA1U0OcK5Q6Q7JOVBTn/cOB3gHw3WDxkokUqPPuW/mAw71am+gBZmWw27Q== From: Romain Gantois Date: Wed, 21 Feb 2024 14:04:21 +0100 Subject: [PATCH net-next v4 4/7] net: stmmac: Support a generic PCS field in mac_device_info MIME-Version: 1.0 Message-Id: <20240221-rxc_bugfix-v4-4-4883ee1cc7b1@bootlin.com> References: <20240221-rxc_bugfix-v4-0-4883ee1cc7b1@bootlin.com> In-Reply-To: <20240221-rxc_bugfix-v4-0-4883ee1cc7b1@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, 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-20240221_050403_931124_11DB6E4F X-CRM114-Status: GOOD ( 16.12 ) 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 Global stmmac support for early initialization of PCS devices requires a generic PCS reference that can be passed to phylink_pcs_pre_init(). Currently, the mac_device_info struct contains only one PCS field, which is specific to the Lynx model. As PCS models are hardware-specific, it is more appropriate to have a generic PCS field in the mac_device_info struct. Refactor the lynx_pcs field into a generic phylink_pcs field. Signed-off-by: Romain Gantois --- drivers/net/ethernet/stmicro/stmmac/common.h | 2 +- drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c | 8 ++++---- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +---- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h index a6fefe675ef1..f55cf09f0783 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h @@ -593,7 +593,7 @@ struct mac_device_info { const struct stmmac_mmc_ops *mmc; const struct stmmac_est_ops *est; struct dw_xpcs *xpcs; - struct phylink_pcs *lynx_pcs; /* Lynx external PCS */ + struct phylink_pcs *phylink_pcs; struct mii_regs mii; /* MII register Addresses */ struct mac_link link; void __iomem *pcsr; /* vpointer to device CSRs */ diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c index 68f85e4605cb..12b4a80ea3aa 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c @@ -479,9 +479,9 @@ static int socfpga_dwmac_probe(struct platform_device *pdev) goto err_dvr_remove; } - stpriv->hw->lynx_pcs = lynx_pcs_create_mdiodev(pcs_bus, 0); - if (IS_ERR(stpriv->hw->lynx_pcs)) { - ret = PTR_ERR(stpriv->hw->lynx_pcs); + stpriv->hw->phylink_pcs = lynx_pcs_create_mdiodev(pcs_bus, 0); + if (IS_ERR(stpriv->hw->phylink_pcs)) { + ret = PTR_ERR(stpriv->hw->phylink_pcs); goto err_dvr_remove; } } @@ -498,7 +498,7 @@ static void socfpga_dwmac_remove(struct platform_device *pdev) { struct net_device *ndev = platform_get_drvdata(pdev); struct stmmac_priv *priv = netdev_priv(ndev); - struct phylink_pcs *pcs = priv->hw->lynx_pcs; + struct phylink_pcs *pcs = priv->hw->phylink_pcs; stmmac_pltfr_remove(pdev); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 47cd8666af43..ec4f6377b5ee 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -944,10 +944,7 @@ static struct phylink_pcs *stmmac_mac_select_pcs(struct phylink_config *config, if (priv->hw->xpcs) return &priv->hw->xpcs->pcs; - if (priv->hw->lynx_pcs) - return priv->hw->lynx_pcs; - - return NULL; + return priv->hw->phylink_pcs; } static void stmmac_mac_config(struct phylink_config *config, unsigned int mode, From patchwork Wed Feb 21 13:04:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Romain Gantois X-Patchwork-Id: 13565576 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 0EFB5C48BC3 for ; Wed, 21 Feb 2024 13:05:05 +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=zJ6wKxwi7gDXtL SSEsHsouJBH19W0+rLvoOfMPHJvxrjdKUegwqoEBLVRueYYg4ENj95AInaEpLx/FQbOqcyr05n18/ /5Gf9OEu/Fj+L++8ig4ME0ojR5x86htA3mqvGL3vUocf1R4GtTcseT6z/2/fOI3RrfV3D5UGxL09u 1TEHJDmZG82JvD255fQdkUuDPK1xIIQJVCQqOh/T14Dkf0wFGAEkc/DzXixrTKq4+YiNNXre0e22Q ghhrWhluNmeJbBbALXxGRxqCAUCzPJUceY2pk8PmqbpoRbFIq58J3CO+XmZvPCVBoD2epDApb19uj pRUFejsVVXfZaP4RS/MQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcmHL-00000000xa5-0gkw; Wed, 21 Feb 2024 13:04:51 +0000 Received: from relay4-d.mail.gandi.net ([217.70.183.196]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcmGa-00000000xA2-2qA8 for linux-arm-kernel@lists.infradead.org; Wed, 21 Feb 2024 13:04:06 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 56D4FE0013; Wed, 21 Feb 2024 13:04:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708520643; 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=g7ML4NVY8iyT9O2/IjPMF/YYSbScra98V9Ku/KO8gL7/au/W7HCg8M22XpWJWII132xFR8 WubZeB1JEQLfXTlP/eqwbwRSNiOqHzkwpW+FPCkBFxJghKXNxdtZeq+h7zooCbAPf9MuzZ cbIh2QV1lplkkJW5Q06TYGiXnYgeJIc98H4SqygSyd47sFaCSFL7geSvILBm5IeWbyu0Cz EE9Aa6Wr1JNZWBJkBTh2sTmjBQDlC8Jneeotdg1so6HyXk0JAqur6YdEJ7iZmke7NTcooR lOBVHovuO6OKjc9fb/T94HsgBWh0S33TermwbQaCEFfAXJE+HfKX0s4kzZT62w== From: Romain Gantois Date: Wed, 21 Feb 2024 14:04:22 +0100 Subject: [PATCH net-next v4 5/7] net: stmmac: Signal to PHY/PCS drivers to keep RX clock on MIME-Version: 1.0 Message-Id: <20240221-rxc_bugfix-v4-5-4883ee1cc7b1@bootlin.com> References: <20240221-rxc_bugfix-v4-0-4883ee1cc7b1@bootlin.com> In-Reply-To: <20240221-rxc_bugfix-v4-0-4883ee1cc7b1@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-20240221_050405_005393_B22FAE75 X-CRM114-Status: GOOD ( 11.38 ) 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) { From patchwork Wed Feb 21 13:04:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Gantois X-Patchwork-Id: 13565578 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 DEC4BC48BC3 for ; Wed, 21 Feb 2024 13:05:09 +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=TDKr/jTyImlUCStV+11NakJy5TCdZoGAaDc9XRHGRxU=; b=eQMAVvUePsvzuF lkKslrN/uOT4pWaqd61rf0uO2yQNCCPfg63WTZGSOwuMZk6gpcO4UrEtfA4/vCLur+bY1RtikTV3S z1WFivmov6FIL7ZhyyjpSbMQ07RGAe4NlaBSFXLbguYekWK4cjo9PylFfYKDOE4uD8Vn/wS52MHU9 cfG7c9xHy8HvIzeHmLS5K0BPYYzzbr4vYW0qppNZWSv8qxvBfpavpn6WR/RvX/B8kSi/jWz5MEMQz LE4qSaBQDTm1yEjkm5D2XOs64I+lvpFR85tf3Q5J1I5KHucrTn9beRo+wj6bIjTDgZXhD/S/vVY1r YQ3FIeVZSj8dKWeazzug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcmHN-00000000xbV-2Nul; Wed, 21 Feb 2024 13:04:53 +0000 Received: from relay4-d.mail.gandi.net ([217.70.183.196]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcmGb-00000000xAb-2ZnM for linux-arm-kernel@lists.infradead.org; Wed, 21 Feb 2024 13:04:07 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 5CF2CE0018; Wed, 21 Feb 2024 13:04:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708520644; 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=nTYOICYJuQ5UIisiBLtAqZAhBd/IR4LXyUg6LvrTYmk=; b=IoHri9sxwMNAnWPqnA3xstbMYeRTaDORCIVdTDIdWSOOY46N5X0Q2/MueHepcQ6lBoZGsL tsgnufiv/ay44+kVWJvL3yNReTvtp9ZVowD0+F2qBUJXaa5Cc9uj+4SUMl0xwtMi03MhYe VjXtL55U7QvKlyMeDPdCKFzFV1ev3I2XX3pxgIVx/cCxkT7MDoyglrC8ZNlsEk0Vcz3qHB p8WFzaGRcjyijkCMn8G/JQVrWK5DsvTYhhyglASWI5OlVKPy/x+iG0xRB/EILqytIGz+lw 8+h4Qbe1M/ixyZHEARSTlE873B8Z3bLRvuMunsyjfyms2KcwtVAYXU56U2GwjQ== From: Romain Gantois Date: Wed, 21 Feb 2024 14:04:23 +0100 Subject: [PATCH net-next v4 6/7] net: phy: qcom: at803x: Avoid hibernating if MAC requires RX clock MIME-Version: 1.0 Message-Id: <20240221-rxc_bugfix-v4-6-4883ee1cc7b1@bootlin.com> References: <20240221-rxc_bugfix-v4-0-4883ee1cc7b1@bootlin.com> In-Reply-To: <20240221-rxc_bugfix-v4-0-4883ee1cc7b1@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-20240221_050405_831513_99A21BA3 X-CRM114-Status: GOOD ( 13.15 ) 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 From: Russell King Stmmac controllers connected to an at803x PHY cannot resume properly after suspend when WoL is enabled. This happens because the MAC requires an RX clock generated by the PHY to initialize its hardware properly. But the RX clock is cut when the PHY suspends and isn't brought up until the MAC driver resumes the phylink. Prevent the at803x PHY driver from going into suspend if the attached MAC driver always requires an RX clock signal. Reported-by: Clark Wang Link: https://lore.kernel.org/all/20230202081559.3553637-1-xiaoning.wang@nxp.com/ Signed-off-by: Russell King [rgantois: commit log] Signed-off-by: Romain Gantois --- drivers/net/phy/qcom/at803x.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/qcom/at803x.c b/drivers/net/phy/qcom/at803x.c index 4717c59d51d0..2a221b81cf37 100644 --- a/drivers/net/phy/qcom/at803x.c +++ b/drivers/net/phy/qcom/at803x.c @@ -426,7 +426,8 @@ static int at803x_hibernation_mode_config(struct phy_device *phydev) /* The default after hardware reset is hibernation mode enabled. After * software reset, the value is retained. */ - if (!(priv->flags & AT803X_DISABLE_HIBERNATION_MODE)) + if (!(priv->flags & AT803X_DISABLE_HIBERNATION_MODE) && + !(phydev->dev_flags & PHY_F_RXC_ALWAYS_ON)) return 0; return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_HIB_CTRL, From patchwork Wed Feb 21 13:04:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Romain Gantois X-Patchwork-Id: 13565579 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 322C7C48BF6 for ; Wed, 21 Feb 2024 13:05:10 +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=ppDWgnMbZbP8B9PQxtvZ8yoa//lZlZ1LTf7MJan5U0Y=; b=U0dZCVON3O0LLa F+B+cL3Y1pEH5di5kO8ihzFJ+hxf/hJXQ+xazUqVt+Ls4UxcEHBeurNMkIlx1lDYgpZev+jkeirxX 7wbJDs3E/NLYL1JWDN5apmcIIyzKlrv04jM3FrRbhUtrgSMC+jQhZEj1MdnCsHmDdgz+u3KgS9i4G 89kIGasmxTS5uuQAdvSjuXdLVVQdLbtcmSJfvJAJKvRvryXXqhBnmvzsnvBz2fYNkwZzNVolZMEb9 wpb+qRMehKwXkNUQZFeCDO1lBRKzTFVf47WwBWXaGLvSTs+Jk5dZtB9CObzGjExbdEP/I86OgvoJC 8DmqCPCPFzqgwl1LawCQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcmHP-00000000xdf-3Enu; Wed, 21 Feb 2024 13:04:55 +0000 Received: from relay4-d.mail.gandi.net ([2001:4b98:dc4:8::224]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcmGc-00000000xB2-3ASx for linux-arm-kernel@lists.infradead.org; Wed, 21 Feb 2024 13:04:08 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 59B55E0012; Wed, 21 Feb 2024 13:04:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708520645; 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=/HVv/irSZsVEd7MEnAXEKn02UcIst/9mjY7zWWotaAA=; b=GNa/TLIvrmKwcJiM1BoXd/8/HU7QEh7sVmGZPiKI2vsnY3woLYMhp1/3JXGbu0Ip9Ck9u7 2UmukJX4O2IudlUI3YtW0Vr+zMVRojXi80H5u0W0n7vq0epLfR5PU+BjzzKE5v63p8jJHa YVqRHmLCEB7F454fsGvX7agRfcjStaTIeH29XIt8jqqT2IBu70JVajiIQUpWOD+Wo6WaIU twVKw/EOfKtLlxQKvIQiBQuOZNz00rOQyx4dLmFVNAYIMYzzZYcZQiKGU0Ts6xRwiGvzX8 25XoSEHmO+uYmW1p8ocPFvdPc4rVV5hplamUOoHBAfv8Dz0ONXkOjj5CL5R3DA== From: Romain Gantois Date: Wed, 21 Feb 2024 14:04:24 +0100 Subject: [PATCH net-next v4 7/7] net: pcs: rzn1-miic: Init RX clock early if MAC requires it MIME-Version: 1.0 Message-Id: <20240221-rxc_bugfix-v4-7-4883ee1cc7b1@bootlin.com> References: <20240221-rxc_bugfix-v4-0-4883ee1cc7b1@bootlin.com> In-Reply-To: <20240221-rxc_bugfix-v4-0-4883ee1cc7b1@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, 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-20240221_050407_192918_E6ED11B3 X-CRM114-Status: GOOD ( 11.74 ) 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 The GMAC1 controller in the RZN1 IP requires the RX MII clock signal to be started before it initializes its own hardware, thus before it calls phylink_start. Implement the pcs_pre_init() callback so that the RX clock signal can be enabled early if necessary. Reported-by: Clément Léger Link: https://lore.kernel.org/linux-arm-kernel/20230116103926.276869-4-clement.leger@bootlin.com/ Signed-off-by: Romain Gantois --- drivers/net/pcs/pcs-rzn1-miic.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/net/pcs/pcs-rzn1-miic.c b/drivers/net/pcs/pcs-rzn1-miic.c index d93f84fbb1fd..8a683c76a0f2 100644 --- a/drivers/net/pcs/pcs-rzn1-miic.c +++ b/drivers/net/pcs/pcs-rzn1-miic.c @@ -279,10 +279,38 @@ static int miic_validate(struct phylink_pcs *pcs, unsigned long *supported, return -EINVAL; } +static int miic_pre_init(struct phylink_pcs *pcs) +{ + struct miic_port *miic_port = phylink_pcs_to_miic_port(pcs); + struct miic *miic = miic_port->miic; + u32 val, mask; + + /* Start RX clock if required */ + if (pcs->rxc_always_on) { + /* In MII through mode, the clock signals will be driven by the + * external PHY, which might not be initialized yet. Set RMII + * as default mode to ensure that a reference clock signal is + * generated. + */ + miic_port->interface = PHY_INTERFACE_MODE_RMII; + + val = FIELD_PREP(MIIC_CONVCTRL_CONV_MODE, CONV_MODE_RMII) | + FIELD_PREP(MIIC_CONVCTRL_CONV_SPEED, CONV_MODE_100MBPS); + mask = MIIC_CONVCTRL_CONV_MODE | MIIC_CONVCTRL_CONV_SPEED; + + miic_reg_rmw(miic, MIIC_CONVCTRL(miic_port->port), mask, val); + + miic_converter_enable(miic, miic_port->port, 1); + } + + return 0; +} + static const struct phylink_pcs_ops miic_phylink_ops = { .pcs_validate = miic_validate, .pcs_config = miic_config, .pcs_link_up = miic_link_up, + .pcs_pre_init = miic_pre_init, }; struct phylink_pcs *miic_create(struct device *dev, struct device_node *np)