From patchwork Mon Mar 11 09:55:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Gantois X-Patchwork-Id: 13588502 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 B6D3FC5475B for ; Mon, 11 Mar 2024 09:56:11 +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=J7RmDfqyEvM6zBI9Av4duldFzBVajdXa1fV5wiS5VNM=; b=d+k1lNgatcR2k6 j6igVvNTXFIvwQQXsd+lbsRUl86rnLZsyEDv7UQy5f5aNFAl07JzYPo1GdzYKDDpJlEDiCLI2OGM6 4s1m6u1fhLRWyH1zXNDVHjVYtCtbwS9gOiuqXUVOm0Lg+zfKhEcS2ZfDkFBp8OZUNlY3Z1VCftDXp dlHZfBASrDib1XxJsilNl8VDfwtrTLo1ngBG9ltdhdY+QdyidmU/fF59PET/idm/wCjWrH0YQXNA8 V6A6ABjCwW2dLsvVmDtiF/KfDvcJstJNq1CsY4p5dxzteUbkUxMMdG+iBu1WGGQjEw9H6QjkTx1nQ zN+OkgsxdovNFaM2ZPsw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjcNk-00000000xPU-2yRn; Mon, 11 Mar 2024 09:55:44 +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 1rjcNO-00000000xFO-0EPy for linux-arm-kernel@lists.infradead.org; Mon, 11 Mar 2024 09:55:29 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id BCD9BE0014; Mon, 11 Mar 2024 09:55:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1710150917; 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=reH5Y9/kNKAfvu+BXiWvV1KQNy7LF/jt01ZWfcoZ1TA=; b=l0zovk1Ag35AlQ5EPukGp8BEJpmPs+ltLVn6TOBpnVPPcy0Po7l91/s5rBnXEVSZM3xrt7 vFrFCZ8C+pJgTkje6QmTHYHybOAhS5fhwZGQd0y3a9y8zfglJRdEv9itGbMp5Xsw2jbCu5 fdyTqwn0XXdfRzML+Ni3yOfsmiVk3X18uhWn3aeLTwzueF6iHNAk2sxVyL4XRpaogoVIXY F26QWaT3P19ug6N0AVrZYsmVdpKP4r5No1PNKplnWxNQXLKdvqbRcp4TNBsjLASUeQl3ny wvZj6xDMghW/igMw7rOlFVb65w7WCFhWhRDzq1LRebvwsmagsDgj02OT/Uevwg== From: Romain Gantois Date: Mon, 11 Mar 2024 10:55:44 +0100 Subject: [PATCH net-next v6 1/7] net: phylink: add PHY_F_RXC_ALWAYS_ON to PHY dev flags MIME-Version: 1.0 Message-Id: <20240311-rxc_bugfix-v6-1-adf5133829a2@bootlin.com> References: <20240311-rxc_bugfix-v6-0-adf5133829a2@bootlin.com> In-Reply-To: <20240311-rxc_bugfix-v6-0-adf5133829a2@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, "Russell King (Oracle)" , Romain Gantois X-Mailer: b4 0.13.0 X-GND-Sasl: romain.gantois@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240311_025524_520452_0EB4D3D5 X-CRM114-Status: GOOD ( 19.13 ) 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 (Oracle)" 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 (Oracle) [rgantois: commit log] Signed-off-by: Romain Gantois Reviewed-by: Andrew Lunn --- 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 3f68b8239bb1..e6e83304558e 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -778,6 +778,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 9a57deefcb07..fef8ae66b988 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 Mon Mar 11 09:55:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Gantois X-Patchwork-Id: 13588498 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 28724C54E67 for ; Mon, 11 Mar 2024 09:55:58 +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=l5okYAo2nXSbdDVhEskOkG6acpITsVKArsU+wOMwRds=; b=rRDHHRmCH5jWqL gbYj99S9GsoCAdJnL6sq9fJPQ8CmJ5ePV1MvYKIopcxekiD+2XV++bUQfaP2zGLgNg5zhUfX/0zp2 ENTAqf4LrntB+os27QorFr+MpkQIr+gf7pvMZ9b3noCbnzHxYiOtLerO2xI7SrfaJxaLdtH8JqLlf 4H8YUcviRqA0+45kJYYaMhEWzDOHoWyRaffQYU/tNCyvd04HLaFV+pp6e2bxuirfnaxi1wxeSWsjf 5yYQ7gE+raEIX8aJ61+Zwpuyk9MM34+LAai1AFtzC8fubMEF5ZgH1C7iFp5Y2Hskgsj9C2mCdJSfO H41niLlsyMHIwPv2zhWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjcNe-00000000xLn-0biI; Mon, 11 Mar 2024 09:55:38 +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 1rjcNO-00000000xFV-0PMw for linux-arm-kernel@lists.infradead.org; Mon, 11 Mar 2024 09:55:29 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id B5420E0017; Mon, 11 Mar 2024 09:55:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1710150918; 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=HT0U0hZdCjwGO5RmmBAdtj/zbygQ1IY4opQKw8vGCBw=; b=mSvi5aSLjwD9anw+NJQpmjfcLrkoTONfbfCcKibv0OKgnT1h/V9/IlorLec5JOfZO5lP3K a9R05Gf39f8nQS7lmrkqIlRhgbIa5ZiifGmPyQmncPHRC+mkZzMEBwlcRjYKCfy0GQNC5S fZrTv3vQ+0ZzS8eT3vSL0nsYhbxGc1gq+OxHwTiwtkGpVhPuiJ+vPyz5D64lD0axCgABDr j7i6uXjSnaFdtSFsNmNUPXeHgkpXrG91uBcTl3C5FROADfVrFRHD4XlyqPsbOvWt/LOVBc sS+wEORbSpvbZEFT6qz1NAaNSWHuBAnKID2gMzM+PAuFBDz6oHd1bhaYTqcYSA== From: Romain Gantois Date: Mon, 11 Mar 2024 10:55:45 +0100 Subject: [PATCH net-next v6 2/7] net: phylink: add rxc_always_on flag to phylink_pcs MIME-Version: 1.0 Message-Id: <20240311-rxc_bugfix-v6-2-adf5133829a2@bootlin.com> References: <20240311-rxc_bugfix-v6-0-adf5133829a2@bootlin.com> In-Reply-To: <20240311-rxc_bugfix-v6-0-adf5133829a2@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, "Russell King (Oracle)" , Romain Gantois X-Mailer: b4 0.13.0 X-GND-Sasl: romain.gantois@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240311_025524_501267_DA6C0901 X-CRM114-Status: GOOD ( 22.17 ) 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. Co-developed-by: Russell King (Oracle) Signed-off-by: Russell King (Oracle) Signed-off-by: Romain Gantois Reviewed-by: Andrew Lunn --- drivers/net/phy/phylink.c | 15 +++++++++++++++ include/linux/phylink.h | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 2bb583543dea..84a97088dfc6 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -1042,6 +1042,21 @@ 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; +} +EXPORT_SYMBOL_GPL(phylink_pcs_pre_init); + 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 fef8ae66b988..5ea6b2ad2396 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. */ @@ -546,6 +554,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_pre_init(struct phylink_pcs *pcs); + #endif struct phylink *phylink_create(struct phylink_config *, @@ -565,6 +601,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 Mon Mar 11 09:55:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Gantois X-Patchwork-Id: 13588497 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 1355FC5475B for ; Mon, 11 Mar 2024 09:55:57 +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=Njt/pDvL6oFZyTuKxS7lDoVlTUH0o9x9HaQVUu0/YYw=; b=rhn5nMWBc55f+p 5Gq/M7Fqgu/xR/9D7s2mtClj9E/fQCwEK1RcGXFldZVOSAMOj+sWi/dWgMrCE2J794+6bn9KzHHNi R9U4ubPHv7J9MmEdLrg1U96AJlkubi3HwrCR74ltY9S2PwI3Sxw7EdgONayTkg20pKTSv+Kz1dd5I vHLHaK86MYPzA0J3cz9Uvutbdp9SONeV2rAFALXI+vXwvyDWva2OmmKlywm+qR7d2IUpMoZ3HtCwB hzZcRp8WKlNh3SZZxUBsA7GbjXtvm7ClaRRiMAgJNxzfGSyJ5a1SUWCdifVKGmJf8gPr4rHl/z8Fm M4iFkZDxOG/8ZhLbDGjw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjcNZ-00000000xK5-1ZWu; Mon, 11 Mar 2024 09:55:35 +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 1rjcNO-00000000xFa-2Akt for linux-arm-kernel@lists.infradead.org; Mon, 11 Mar 2024 09:55:27 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id B5DD9E001F; Mon, 11 Mar 2024 09:55:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1710150919; 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=8Hre9/21LZl4mrXvR33ftuCbpilsmjMQ6zHliMO3IS8=; b=MnOL9tJc+tSEQbs5tyBZvUYpKbrdxVmHPKvBoCcJXdRGak8Oh2MA2xD+KAvJn1QKU0O7VF rk3IBvgZ9moGcvM7WEvnt/P7+luGqY73sl28Ym46/xGv30eyjyo/IdsD8WQZ9Kq8MuKdn0 PM+NRLD3Pcrt3sleQbyZG1Xb1IDN4AFJIDvIAG2s3zy9mV3qTUOC5WRbIK+THVpkw58v/X YWzScwW/oT2fGiRp/7NRFDN/gHFxgmzsINiv6DinmWrMb4epYjSnevuiVFkVCqJyem8iG/ 1HcxDaURXXAIjdlXmMNGP1IN2KDhaRv1pTS7J5rSrB37k07z4RNcJuQMWEFnrQ== From: Romain Gantois Date: Mon, 11 Mar 2024 10:55:46 +0100 Subject: [PATCH net-next v6 3/7] net: stmmac: don't rely on lynx_pcs presence to check for a PHY MIME-Version: 1.0 Message-Id: <20240311-rxc_bugfix-v6-3-adf5133829a2@bootlin.com> References: <20240311-rxc_bugfix-v6-0-adf5133829a2@bootlin.com> In-Reply-To: <20240311-rxc_bugfix-v6-0-adf5133829a2@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.13.0 X-GND-Sasl: romain.gantois@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240311_025524_447861_36A223EE X-CRM114-Status: GOOD ( 11.89 ) 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 Reviewed-by: Andrew Lunn --- 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 24cd80490d19..d78c625d33eb 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -3960,8 +3960,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 Mon Mar 11 09:55:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Gantois X-Patchwork-Id: 13588496 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 93556C54E58 for ; Mon, 11 Mar 2024 09:55:57 +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=q1GLejPxUnE7qmBsK5aAxIaNGtLmV9khkfVFGcKvwlI=; b=ynSwY+zqgYHFiG SZIv6r6YT0QOiiEC7vQWefBN6auAWOKNDKB6sAJCle3tWZDAVRfJBkuwkM6Q28TPM0Q8HIMijRzBz 8yzUfQXb2XEFph4Kir6JBLjbvYrKK31A4uUbkcldopALOMT0rmjb4Oy1Y2q+GVo4zbZuMMImRcDOg spe+th/zuO5klqyBOMc3vaz5PN/+wKLWHhl7ifPYYNdk8irb/soMHddg9USJSDbVJNAk5HTs6/hQy 41go19ENSQMXbCS5WRH+qx1SAtoSaczfeLZRCRW2caoporMaqhVuqYUGIt8AgcMuukECWpmSP6fkK YrldgshVPARDEZXtCzcw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjcNc-00000000xKo-3J2U; Mon, 11 Mar 2024 09:55:37 +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 1rjcNP-00000000xFh-17k6 for linux-arm-kernel@lists.infradead.org; Mon, 11 Mar 2024 09:55:27 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id AA511E0007; Mon, 11 Mar 2024 09:55:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1710150920; 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=RdYU5edsmqTq3TQV0rJxnPr4ToW0H6XtNSbnaJa6X/A=; b=J19UWOOFl3NFNFqeR4/CENkukXl/36LYid+69nrz/p2a0y0FwYltL1/oSQ7DCBb3FGHoMZ QuFrwnQWwlj02pcBRdqzvg1kPYpGs2/G0Z1xQXHz0s+1+v5T+aOhUb8ztXDssXQPyBnY62 bMjkwYV0+7eedQu3UEPoKmLaLe2GhlVdL8X9dAgUiAg34Lzb8LayDvOhapDarfzXRxl3if Adei1LYTY7TzsYinfcxdVpm8VMz5KxWHmdclXxw2qo7HitTFGYXoQOTByPN8yGejOR1yri RaJqhhvGbMEPuzaJFhx9gSrikmuY1Q//dyHmtFVXqwxezYcQ9bQjZEKecs7slQ== From: Romain Gantois Date: Mon, 11 Mar 2024 10:55:47 +0100 Subject: [PATCH net-next v6 4/7] net: stmmac: Support a generic PCS field in mac_device_info MIME-Version: 1.0 Message-Id: <20240311-rxc_bugfix-v6-4-adf5133829a2@bootlin.com> References: <20240311-rxc_bugfix-v6-0-adf5133829a2@bootlin.com> In-Reply-To: <20240311-rxc_bugfix-v6-0-adf5133829a2@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.13.0 X-GND-Sasl: romain.gantois@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240311_025524_483258_25DF0717 X-CRM114-Status: GOOD ( 15.82 ) 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 Reviewed-by: Andrew Lunn --- 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 d78c625d33eb..79844dbe4258 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 Mon Mar 11 09:55:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Romain Gantois X-Patchwork-Id: 13588501 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 7321FC54E58 for ; Mon, 11 Mar 2024 09:56:08 +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=srpxQYYxcJTGnEQGHBG1P4Klv0TjmPU51HXRB/1jMkk=; b=1D5WwNSO24hoOk zorDIupK1nyJ2DYiMS3H5Ga7nP2/Vve8L56iFU+CJqW6V2W0bCPdDlg8j5U5f7h1QPkNxP9gozuf1 /9Wxf3AXougjK/Q+Y/HHhKFQ9JhCUG2lhTl9QJR+XUBw3XKfEABT6BcfYbRyFXXflPBTcaKDR+exN gDQjDtujKCjZ3iKJ81a1rM+N/M2mzXtqx9o2xaumw+SM0sCkgYqHHPmH9QhXE6p4aNYfQdlREumvJ SBUzmq2ppAhm02k4Q/IOqJdtzgCWqr47kV/CUH7V5AkP093jqx6G/+8MlLFdLlsZ0iHNv3Azz/vKZ urMMeKXz7/a27H9WFDTQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjcNi-00000000xOI-23fu; Mon, 11 Mar 2024 09:55:43 +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 1rjcNP-00000000xFk-0Zvz for linux-arm-kernel@lists.infradead.org; Mon, 11 Mar 2024 09:55:29 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id B45F2E0002; Mon, 11 Mar 2024 09:55:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1710150921; 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=5X4Vqf5dMNOvdBRrjTCmAMrnSKF3wTY7sOX12e/v6N8=; b=VHq2XSWyLTwqugolTBbNtNpUUrcQfUiEapqyjnr+XWAqQp7Bg9DlDhgbRGEm3KW/JYFDuA KJXTrUrEQhlpbZR4FdIHzGGh+wc4AbijpAtSkKs809PvURwbvs2CrxGdraLqked3FgNnKu d6IOHl/FjmC8uuuVqp+eAy9YvVUXw00IvNTKTTvD71r+tJcMhyCZIxl1k78E4f2i3RMPxy JBMOk8qbbgygfA17A6dGnBVMZYt0hvpP2WP1n0EFGoOw7q5Y+MOHY7bL4qXMUoSEyElp0X iv5YTFSEhFGpM8HtvuAnRix8QqGs8fTn8U8Wtp4XzPv1jJtn3a3ftQv0XuSSfw== From: Romain Gantois Date: Mon, 11 Mar 2024 10:55:48 +0100 Subject: [PATCH net-next v6 5/7] net: stmmac: Signal to PHY/PCS drivers to keep RX clock on MIME-Version: 1.0 Message-Id: <20240311-rxc_bugfix-v6-5-adf5133829a2@bootlin.com> References: <20240311-rxc_bugfix-v6-0-adf5133829a2@bootlin.com> In-Reply-To: <20240311-rxc_bugfix-v6-0-adf5133829a2@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 , "Russell King (Oracle)" , Romain Gantois X-Mailer: b4 0.13.0 X-GND-Sasl: romain.gantois@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240311_025524_531619_04216D94 X-CRM114-Status: GOOD ( 11.10 ) 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/ Co-developed-by: Russell King (Oracle) Signed-off-by: Russell King (Oracle) Signed-off-by: Romain Gantois Reviewed-by: Andrew Lunn --- 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 79844dbe4258..2290f4808d7e 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 = @@ -3408,6 +3411,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 Mon Mar 11 09:55:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Gantois X-Patchwork-Id: 13588500 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 849D8C54E5D for ; Mon, 11 Mar 2024 09:56:07 +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=//xTSc+w+krGJIRPvgtyzUuLX1yVSJQE2ZIopoOIjbQ=; b=meB2E+Y4uP24ns ZjVL8d94OiBXtROuu0b4Y09+kXfF0C/aNi63mF5hRqkLLPvS6a/rXNguvtD4tbkLjW5aKFYsA5jMP ETw8sJoQDX2jhEljAigggdcTt+nd/bXxpusa7qU3GsQ5A8KTnxsslBzdTueJgtB0KbWHjIp8pvyW5 AEROtFKD3G1RmddrhVeuLa+riUh+Oip6ioXYeVZXx6IspjwvfcFhj0TcHnxISRF2anh7RFOSw/GCh GXPr5nRc/devSJEsrtKeC2GiLCVdkWWQDCzFTs0sZvMMSHyBhLdVyTayCPw1bkzdxbz3+wq/n5BDI SjR840eb2sON1MsqwFWQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjcNh-00000000xNB-0QdD; Mon, 11 Mar 2024 09:55:41 +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 1rjcNQ-00000000xFl-1HB3 for linux-arm-kernel@lists.infradead.org; Mon, 11 Mar 2024 09:55:29 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id C7BF9E0009; Mon, 11 Mar 2024 09:55:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1710150923; 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=kOpNMTW/vA5X/6RU5HQH0KSBKcCLzUFZqJhHW5arx8w=; b=P06NKASvvtTJHKCRwMq+LaEKG+9ZSn3II8sLtWeUmx0WxdeinCoubLSStj1Z5EKk2mukdy TYZlfbWC2+d8DHAvlzZYwqvdUKenfpzUeNgOZ+xFjcuAXj/N7BQ9J6ZTF6QknNUonZTYdN +OHh18q08x7h/fhRCy3Y5PFkXZPvpotLt51DID0hlPuPKZRb6OSy64aMe4ahS69rRNggdw WpV8Z1ESImEI6a89o9YPa/iS+HgnmxiIuaomywmJ4qusxXNb3iGr23VIb0N3jt8MWItusM oWyQpcvF1xKnD3k51jETvqsqVgDf4VxSyxGQMp+AkwhmohJ4kEqv3nn761rKTA== From: Romain Gantois Date: Mon, 11 Mar 2024 10:55:49 +0100 Subject: [PATCH net-next v6 6/7] net: phy: qcom: at803x: Avoid hibernating if MAC requires RX clock MIME-Version: 1.0 Message-Id: <20240311-rxc_bugfix-v6-6-adf5133829a2@bootlin.com> References: <20240311-rxc_bugfix-v6-0-adf5133829a2@bootlin.com> In-Reply-To: <20240311-rxc_bugfix-v6-0-adf5133829a2@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, "Russell King (Oracle)" , Clark Wang , Romain Gantois X-Mailer: b4 0.13.0 X-GND-Sasl: romain.gantois@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240311_025525_171819_A25081EA X-CRM114-Status: GOOD ( 12.85 ) 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 (Oracle)" 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 (Oracle) [rgantois: commit log] Signed-off-by: Romain Gantois Reviewed-by: Andrew Lunn --- 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 Mon Mar 11 09:55:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Romain Gantois X-Patchwork-Id: 13588503 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 A5524C54E5D for ; Mon, 11 Mar 2024 09:56:13 +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=BVXWiPQCN9jKwXWPGpMVU5FJt87CR9QgSqWq4N9ZGzE=; b=jHm3ulRvLs8yzC V55rFnnnA+zbMEh4NdubqzikpEdnc1oLm2Svl9cp8ShAccq8/9sYx0/XmNuICyPlG/myxgGGADL2R VaH7+wtskxJVudvFNK8w5MU27tg4tYztuypvfw7+u47ae7vG5Gg+ZCTH5ECgymtwTI3AqrhZ9zaDg G1DD++BTInIbyvGVI9oclsm3r3YBrU6rkT4+w6rFUgbEqY6ZTZ3bMa9Yw/yiMegPzeKcSldK/9dZB gIFdLBvkcXMX39V1Z/RsdT78/KvU7ozYebsJoN3Bvi5fw7+XFiOyNmG4SDNxPjxmos+XVrrrqntiW DszNDoPzJNPyoUDQKVvA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjcNl-00000000xQH-4AMY; Mon, 11 Mar 2024 09:55:46 +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 1rjcNR-00000000xG5-255k for linux-arm-kernel@lists.infradead.org; Mon, 11 Mar 2024 09:55:30 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 11D90E000D; Mon, 11 Mar 2024 09:55:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1710150924; 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=O8MBjRw+XjYP4AGNDE/5givq5CD6fzEROYjULWNw0vo=; b=l17wbK5BJQVM/h4alNuTUS8p+qSeFP7D1MlWeKY2o2Cg9O8EDoYZJ/f0yBObu85uB5f7pI 6V16FTiSYweJHOvvXHzX32krAApJW2nbNYsErNmxPbHvz1ywAD2ymt97W3yFQ3hDBJos+E u5W3UwwpbAkS8FTuAF/hxWiZBi1dUs+/HM+5EAfVzkP/aBKvo8k6K1hSJlhh7sbGvPuqcJ dxf2nRBmCChBX97MF+jfqJ2ocbklsWobhU4m4wSOUNTUxUlKjd28F7Wqbn+V3CSbhHN7Ly SMVPBQ85E5xafPp4YU0IMBbmtu2QDYWDzkCP3mLs3g1m3qUPLElFt+QjhAOm9g== From: Romain Gantois Date: Mon, 11 Mar 2024 10:55:50 +0100 Subject: [PATCH net-next v6 7/7] net: pcs: rzn1-miic: Init RX clock early if MAC requires it MIME-Version: 1.0 Message-Id: <20240311-rxc_bugfix-v6-7-adf5133829a2@bootlin.com> References: <20240311-rxc_bugfix-v6-0-adf5133829a2@bootlin.com> In-Reply-To: <20240311-rxc_bugfix-v6-0-adf5133829a2@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.13.0 X-GND-Sasl: romain.gantois@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240311_025525_847860_E764BF4E X-CRM114-Status: GOOD ( 11.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 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 Reviewed-by: Andrew Lunn --- 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 4bd66fdde367..d0a722d43368 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)