From patchwork Mon Mar 13 22:42:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13173400 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A056C61DA4 for ; Mon, 13 Mar 2023 22:42:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230038AbjCMWm4 (ORCPT ); Mon, 13 Mar 2023 18:42:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229832AbjCMWmz (ORCPT ); Mon, 13 Mar 2023 18:42:55 -0400 Received: from post.baikalelectronics.com (post.baikalelectronics.com [213.79.110.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8D4F0900AB; Mon, 13 Mar 2023 15:42:44 -0700 (PDT) Received: from post.baikalelectronics.com (localhost.localdomain [127.0.0.1]) by post.baikalelectronics.com (Proxmox) with ESMTP id 9D360E0EB2; Tue, 14 Mar 2023 01:42:43 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= baikalelectronics.ru; h=cc:cc:content-transfer-encoding :content-type:content-type:date:from:from:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=post; bh=MejpIP3Pe+jcP8366+eVMDkcIjinKML8YC4WSTSWguE=; b=Dj8jj1mEy84s 9tgcbqz2to37zCRCaIKQdQogsZI2Ua6U6cLkyM0MU06vBjm2aJPtgT361ac1rjWf fmpdnnIwOs4hHF8gV6SGNXFa5QdY4slLqZf3/JgS6Pon+Jhu2sH64dOAPYCoN+Bz 9LwGW88x8aCE3NNst/n6QqBAleQ33qs= Received: from mail.baikal.int (mail.baikal.int [192.168.51.25]) by post.baikalelectronics.com (Proxmox) with ESMTP id 77BA7E0E6A; Tue, 14 Mar 2023 01:42:43 +0300 (MSK) Received: from localhost (10.8.30.10) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 14 Mar 2023 01:42:42 +0300 From: Serge Semin To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Russell King , Andrew Lunn , Heiner Kallweit CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Christian Marangi , Biao Huang , Yang Yingliang , , , , Subject: [PATCH net 01/13] net: phy: realtek: Fix events detection failure in LPI mode Date: Tue, 14 Mar 2023 01:42:25 +0300 Message-ID: <20230313224237.28757-2-Sergey.Semin@baikalelectronics.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> References: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-Originating-IP: [10.8.30.10] X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org It has been noticed that RTL8211E PHY stops detecting and reporting events (cable plugging in/out, link state changes, etc) when EEE is successfully advertised and "RXC stopping in LPI" is enabled. The freeze happens right after 3.0.10 bit (PC1R "Clock Stop Enable" register) is set. At the same time LED2 stops blinking as if EEE mode has been disabled, interrupt pin doesn't change its state (signal tested by oscilloscope). Notably the network traffic still flows through the PHY with no obvious problem as long as a network cable is connected. But if any MDIO read/write procedure is performed after the "RXC stop in LPI" mode is enabled (even from a non-existent device on the MDIO bus) the PHY gets to be unfrozen, LED2 starts blinking and PHY interrupts happens again (even which have happened during the freeze). The problem has been noticed on RTL8211E PHY working together with DW GMAC 3.73a MAC and reporting its event via a dedicated DW MAC GPIO-IRQ signal. (Obviously the problem has been unnoticed in the polling mode, since it gets naturally fixed by the periodic MDIO read procedure from the PHY status register - BMSR.) In order to fix that problem we suggest to locally re-implement the MMD write method for RTL8211E PHY and perform a dummy read right after the PC1R register is accessed to enable the RXC stopping in LPI mode. Signed-off-by: Serge Semin Reviewed-by: Andrew Lunn --- Original patch: Link: https://lore.kernel.org/netdev/20210208140341.9271-2-Sergey.Semin@baikalelectronics.ru/ --- drivers/net/phy/realtek.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index 3d99fd6664d7..72ca06bcd53e 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -637,6 +637,42 @@ static int rtl822x_write_mmd(struct phy_device *phydev, int devnum, u16 regnum, return ret; } +static int rtl8211e_write_mmd(struct phy_device *phydev, int devnum, u16 regnum, + u16 val) +{ + int ret; + + /* Write to the MMD registers by using the standard control/data pair. + * The only difference is that we need to perform a dummy read after + * the PC1R.CLKSTOP_EN bit is set. It's required to workaround an issue + * of a partial core freeze so LED2 stops blinking in EEE mode, PHY + * stops detecting the link change and raising IRQs until any read from + * its registers performed. That happens only if and right after the PHY + * is enabled to stop RXC in LPI mode. + */ + ret = __phy_write(phydev, MII_MMD_CTRL, devnum); + if (ret) + return ret; + + ret = __phy_write(phydev, MII_MMD_DATA, regnum); + if (ret) + return ret; + + ret = __phy_write(phydev, MII_MMD_CTRL, devnum | MII_MMD_CTRL_NOINCR); + if (ret) + return ret; + + ret = __phy_write(phydev, MII_MMD_DATA, val); + if (ret) + return ret; + + if (devnum == MDIO_MMD_PCS && regnum == MDIO_CTRL1 && + val & MDIO_PCS_CTRL1_CLKSTOP_EN) + ret = __phy_read(phydev, MII_MMD_DATA); + + return ret < 0 ? ret : 0; +} + static int rtl822x_get_features(struct phy_device *phydev) { int val; @@ -919,6 +955,7 @@ static struct phy_driver realtek_drvs[] = { .resume = genphy_resume, .read_page = rtl821x_read_page, .write_page = rtl821x_write_page, + .write_mmd = rtl8211e_write_mmd, }, { PHY_ID_MATCH_EXACT(0x001cc916), .name = "RTL8211F Gigabit Ethernet", From patchwork Mon Mar 13 22:42:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13173401 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5AE8BC6FD19 for ; Mon, 13 Mar 2023 22:43:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230077AbjCMWm6 (ORCPT ); Mon, 13 Mar 2023 18:42:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229801AbjCMWmz (ORCPT ); Mon, 13 Mar 2023 18:42:55 -0400 Received: from post.baikalelectronics.com (post.baikalelectronics.com [213.79.110.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B15D7907BB; Mon, 13 Mar 2023 15:42:45 -0700 (PDT) Received: from post.baikalelectronics.com (localhost.localdomain [127.0.0.1]) by post.baikalelectronics.com (Proxmox) with ESMTP id C7A5BE0EB3; Tue, 14 Mar 2023 01:42:44 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= baikalelectronics.ru; h=cc:cc:content-transfer-encoding :content-type:content-type:date:from:from:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=post; bh=E+SweRvzgDjVFlkaravB0VQvVr+lr/xjXdJLlqkPtRU=; b=Wr1rvYXKZAuE j6DQqmf5SLfAA2Pc3RJbB+0xULqdMJ7qZ7uqLZYKwuh3IYjonb6V7PfWMi+mph90 wn1IdTZJHuaLYnG3D0fOMNiOGTBININL2TO/dcHkciSX15ERP9hOeTlhfvK67DAs jRLKtLkfGEhjQTi3Dv40RVUkkdZb12U= Received: from mail.baikal.int (mail.baikal.int [192.168.51.25]) by post.baikalelectronics.com (Proxmox) with ESMTP id A57FAE0E6A; Tue, 14 Mar 2023 01:42:44 +0300 (MSK) Received: from localhost (10.8.30.10) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 14 Mar 2023 01:42:44 +0300 From: Serge Semin To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Russell King , Andrew Lunn , Heiner Kallweit , Aaro Koskinen CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Christian Marangi , Biao Huang , Yang Yingliang , , , , Subject: [PATCH net 02/13] net: stmmac: Omit last desc flag for non-linear jumbos in chain-mode Date: Tue, 14 Mar 2023 01:42:26 +0300 Message-ID: <20230313224237.28757-3-Sergey.Semin@baikalelectronics.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> References: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-Originating-IP: [10.8.30.10] X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Indeed similar to the ring mode we need not to set the LS flag in a Tx DMA descriptor of the last chunk of the linear jumbo-SKB data if it's supposed to have additional fragments attached. That buffers will be used to initialized further Tx DMA descriptors later in the common stmmac_rx() code. The LS flag will be set for the last of them then. A similar fix has been introduced for the ring-mode in the commit 58f2ce6f6161 ("net: stmmac: fix jumbo frame sending with non-linear skbs"). But for some reason it hasn't been done for the chained descriptors. Fixes: 58f2ce6f6161 ("net: stmmac: fix jumbo frame sending with non-linear skbs") Signed-off-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/chain_mode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/chain_mode.c b/drivers/net/ethernet/stmicro/stmmac/chain_mode.c index 2e8744ac6b91..60e4fa5060ce 100644 --- a/drivers/net/ethernet/stmicro/stmmac/chain_mode.c +++ b/drivers/net/ethernet/stmicro/stmmac/chain_mode.c @@ -73,7 +73,8 @@ static int jumbo_frm(void *p, struct sk_buff *skb, int csum) tx_q->tx_skbuff_dma[entry].len = len; /* last descriptor can be set now */ stmmac_prepare_tx_desc(priv, desc, 0, len, csum, - STMMAC_CHAIN_MODE, 1, true, skb->len); + STMMAC_CHAIN_MODE, 1, + !skb_is_nonlinear(skb), skb->len); len = 0; } } From patchwork Mon Mar 13 22:42:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13173403 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97CDEC61DA4 for ; Mon, 13 Mar 2023 22:43:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230101AbjCMWnE (ORCPT ); Mon, 13 Mar 2023 18:43:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230079AbjCMWm6 (ORCPT ); Mon, 13 Mar 2023 18:42:58 -0400 Received: from post.baikalelectronics.com (post.baikalelectronics.com [213.79.110.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E994290B49; Mon, 13 Mar 2023 15:42:46 -0700 (PDT) Received: from post.baikalelectronics.com (localhost.localdomain [127.0.0.1]) by post.baikalelectronics.com (Proxmox) with ESMTP id 09F59E0EB4; Tue, 14 Mar 2023 01:42:46 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= baikalelectronics.ru; h=cc:cc:content-transfer-encoding :content-type:content-type:date:from:from:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=post; bh=US31HouRoyMBnlLGMU7EgoCsBVjhU1OheQVzY6/fVjc=; b=miFDaKRQpVIE QXS/35hUcrjATBciOUcMXd5hlqMi7XiMFL3QiW0Kn+k2Y5i2rtWDhP3BVmZJL6/B aaAdNDNrULgVgDzFWpW1rAita5YpsJ30mbrRha5SqBbGZHHeIGgKRwmcHDF+rQwL K0OLdT+wZu6nGBq/+Db+pN4BOMQd8xA= Received: from mail.baikal.int (mail.baikal.int [192.168.51.25]) by post.baikalelectronics.com (Proxmox) with ESMTP id E0312E0E6A; Tue, 14 Mar 2023 01:42:45 +0300 (MSK) Received: from localhost (10.8.30.10) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 14 Mar 2023 01:42:45 +0300 From: Serge Semin To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Russell King , Andrew Lunn , Heiner Kallweit CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Christian Marangi , Biao Huang , Yang Yingliang , , , , Subject: [PATCH net 03/13] net: stmmac: Fix extended descriptors usage for jumbos in chain-mode Date: Tue, 14 Mar 2023 01:42:27 +0300 Message-ID: <20230313224237.28757-4-Sergey.Semin@baikalelectronics.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> References: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-Originating-IP: [10.8.30.10] X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org If a DW MAC NIC is synthesized to support the extended descriptors, then the driver uses dma_etx pointer to keep an array of once in the Tx DMA Queue structures. For some reason the specific to the chained-mode jumbo_frm() referred to the dma_tx pointer of DMA Tx Queue descriptor in any case, which of course was initialized with NULL for the DW MACs expecting extended descriptors being specified. So any attempt to send a Jumbo frame in chain-mode caused "Unable to handle kernel paging request at virtual address" kernel crash. Fix that by selecting a proper descriptor pointer depending on whether the NIC supports extended descriptors or not. Fixes: c24602ef8664 ("stmmac: support extend descriptors") Signed-off-by: Serge Semin --- Yeah, that Normal/Enhanced access pattern really annoying. Food for thoughts about a more thorough cleanup of the driver. --- drivers/net/ethernet/stmicro/stmmac/chain_mode.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/chain_mode.c b/drivers/net/ethernet/stmicro/stmmac/chain_mode.c index 60e4fa5060ce..9a92f0c5e577 100644 --- a/drivers/net/ethernet/stmicro/stmmac/chain_mode.c +++ b/drivers/net/ethernet/stmicro/stmmac/chain_mode.c @@ -24,7 +24,10 @@ static int jumbo_frm(void *p, struct sk_buff *skb, int csum) unsigned int i = 1, len; struct dma_desc *desc; - desc = tx_q->dma_tx + entry; + if (priv->extend_desc) + desc = (struct dma_desc *)(tx_q->dma_etx + entry); + else + desc = tx_q->dma_tx + entry; if (priv->plat->enh_desc) bmax = BUF_SIZE_8KiB; @@ -47,7 +50,11 @@ static int jumbo_frm(void *p, struct sk_buff *skb, int csum) while (len != 0) { tx_q->tx_skbuff[entry] = NULL; entry = STMMAC_GET_ENTRY(entry, priv->dma_conf.dma_tx_size); - desc = tx_q->dma_tx + entry; + + if (priv->extend_desc) + desc = (struct dma_desc *)(tx_q->dma_etx + entry); + else + desc = tx_q->dma_tx + entry; if (len > bmax) { des2 = dma_map_single(priv->device, From patchwork Mon Mar 13 22:42:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13173404 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C76BDC61DA4 for ; Mon, 13 Mar 2023 22:43:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230105AbjCMWnS (ORCPT ); Mon, 13 Mar 2023 18:43:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230096AbjCMWnB (ORCPT ); Mon, 13 Mar 2023 18:43:01 -0400 Received: from post.baikalelectronics.com (post.baikalelectronics.com [213.79.110.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4321A90B62; Mon, 13 Mar 2023 15:42:48 -0700 (PDT) Received: from post.baikalelectronics.com (localhost.localdomain [127.0.0.1]) by post.baikalelectronics.com (Proxmox) with ESMTP id 31853E0EB5; Tue, 14 Mar 2023 01:42:47 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= baikalelectronics.ru; h=cc:cc:content-transfer-encoding :content-type:content-type:date:from:from:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=post; bh=wOzKOusTtlMsWWamfM/2/QzPDuvYuygc+l24RqCfb6Q=; b=AJnQvVAIvdqb 1xgNROwVMbSKWsdEgo2/eX0rf9imaVOGwfXKaTWR8ykWMd51tuYGdx50Ug6AqqYy aHeHL7zZw1lACZaLtwlb2jiMhoVdQA40a2wv4vr5XKUUD0q1PLZM4oPycyLstnsN QJTsqtMkCPeSMZGWiDElrgk6o+dFG+c= Received: from mail.baikal.int (mail.baikal.int [192.168.51.25]) by post.baikalelectronics.com (Proxmox) with ESMTP id 1A9A4E0E6A; Tue, 14 Mar 2023 01:42:47 +0300 (MSK) Received: from localhost (10.8.30.10) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 14 Mar 2023 01:42:46 +0300 From: Serge Semin To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Russell King , Andrew Lunn , Heiner Kallweit , LABBE Corentin CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Christian Marangi , Biao Huang , Yang Yingliang , , , , Subject: [PATCH net 04/13] net: stmmac: dwmac-sun8i: Don't modify chain-mode module parameter Date: Tue, 14 Mar 2023 01:42:28 +0300 Message-ID: <20230313224237.28757-5-Sergey.Semin@baikalelectronics.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> References: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-Originating-IP: [10.8.30.10] X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Doing so activates the chain-mode for any DW MAC-based NIC on the platform no matter with what parameter the module is loaded. Even if there is no any other network controller on the SoC it is logically incorrect. Fixes: 9f93ac8d4085 ("net-next: stmmac: Add dwmac-sun8i") Signed-off-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 8f543c3ab5c5..2ed63acaee5b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -6806,8 +6806,9 @@ static int stmmac_hw_init(struct stmmac_priv *priv) /* dwmac-sun8i only work in chain mode */ if (priv->plat->has_sun8i) - chain_mode = 1; - priv->chain_mode = chain_mode; + priv->chain_mode = 1; + else + priv->chain_mode = chain_mode; /* Initialize HW Interface */ ret = stmmac_hwif_init(priv); From patchwork Mon Mar 13 22:42:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13173407 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F309C6FD19 for ; Mon, 13 Mar 2023 22:43:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230229AbjCMWnq (ORCPT ); Mon, 13 Mar 2023 18:43:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229789AbjCMWnZ (ORCPT ); Mon, 13 Mar 2023 18:43:25 -0400 Received: from post.baikalelectronics.com (post.baikalelectronics.com [213.79.110.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 26F7B900AB; Mon, 13 Mar 2023 15:42:56 -0700 (PDT) Received: from post.baikalelectronics.com (localhost.localdomain [127.0.0.1]) by post.baikalelectronics.com (Proxmox) with ESMTP id 728ECE0EB6; Tue, 14 Mar 2023 01:42:48 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= baikalelectronics.ru; h=cc:cc:content-transfer-encoding :content-type:content-type:date:from:from:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=post; bh=Bs1amY+XsKSxbeDn+7iKOOqICBSFRydBCis7liFwu4M=; b=s5zEKbtDGfsz GMOXYO34rCQXnqbu/6HpjlHjQYT7qG5sah9NBsitvYdUzg5MXWvhy0KWhDLRdAmc jTmIL314/LxUWbEmhwsWmPv0H/zf9Iq5Ab6vZLq77jmEtx1fM/zEjWZDGe+CI7Ul lj6dxXk/4+cLAR4n+cNei4FUWrovtXo= Received: from mail.baikal.int (mail.baikal.int [192.168.51.25]) by post.baikalelectronics.com (Proxmox) with ESMTP id 57D7FE0E6A; Tue, 14 Mar 2023 01:42:48 +0300 (MSK) Received: from localhost (10.8.30.10) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 14 Mar 2023 01:42:47 +0300 From: Serge Semin To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Russell King , Andrew Lunn , Heiner Kallweit CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Christian Marangi , Biao Huang , Yang Yingliang , , , , Subject: [PATCH net 05/13] net: stmmac: Enable ATDS for chain-mode Date: Tue, 14 Mar 2023 01:42:29 +0300 Message-ID: <20230313224237.28757-6-Sergey.Semin@baikalelectronics.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> References: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-Originating-IP: [10.8.30.10] X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org It wasn't stated why the Alternate Descriptor Size shouldn't have been changed for the chained DMA descriptors, while the original commit did introduce some chain_mode.c modifications. So the ATDS-related change in commit c24602ef8664 ("stmmac: support extend descriptors") seems contradicting. Anyway from the DW MAC/GMAC hardware point of view there is no such limitation - whether the chained descriptors can't be used together with the extended alternate descriptors. Moreover not setting the BUS_MODE.ATDS flag will cause the driver malfunction in the framework of the IPC Full Checksum and Advanced Timestamp feature, since the later features require the additional 4-7 dwords of the DMA descriptor to set some flags and a timestamp. So to speak in order to have all these features working correctly in the chained mode too let's make sure the ATDS flag is set irrespectively from the DMA descriptors mode. Fixes: c24602ef8664 ("stmmac: support extend descriptors") Signed-off-by: Serge Semin Reviewed-by: Piotr Raczynski --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 2ed63acaee5b..ee4297a25521 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -2907,7 +2907,6 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv) struct stmmac_rx_queue *rx_q; struct stmmac_tx_queue *tx_q; u32 chan = 0; - int atds = 0; int ret = 0; if (!priv->plat->dma_cfg || !priv->plat->dma_cfg->pbl) { @@ -2915,9 +2914,6 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv) return -EINVAL; } - if (priv->extend_desc && (priv->mode == STMMAC_RING_MODE)) - atds = 1; - ret = stmmac_reset(priv, priv->ioaddr); if (ret) { dev_err(priv->device, "Failed to reset the dma\n"); @@ -2925,7 +2921,8 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv) } /* DMA Configuration */ - stmmac_dma_init(priv, priv->ioaddr, priv->plat->dma_cfg, atds); + stmmac_dma_init(priv, priv->ioaddr, priv->plat->dma_cfg, + priv->extend_desc); if (priv->plat->axi) stmmac_axi(priv, priv->ioaddr, priv->plat->axi); From patchwork Mon Mar 13 22:42:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13173405 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CDABEC6FD19 for ; Mon, 13 Mar 2023 22:43:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230187AbjCMWnm (ORCPT ); Mon, 13 Mar 2023 18:43:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230096AbjCMWnY (ORCPT ); Mon, 13 Mar 2023 18:43:24 -0400 Received: from post.baikalelectronics.com (post.baikalelectronics.com [213.79.110.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2894290B5A; Mon, 13 Mar 2023 15:42:55 -0700 (PDT) Received: from post.baikalelectronics.com (localhost.localdomain [127.0.0.1]) by post.baikalelectronics.com (Proxmox) with ESMTP id 9A924E0EB7; Tue, 14 Mar 2023 01:42:49 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= baikalelectronics.ru; h=cc:cc:content-transfer-encoding :content-type:content-type:date:from:from:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=post; bh=UBwRlpxjx2LCwbF2pseifbR70h2f/WK4HBXfWdEpoJM=; b=in1eMZuT/Ugr D2l0/iza7msPPk4K4FAVlDyf3kozMbRBIi7wYdXQ8GXI0E2TnLx9fI/39qTxB2Hx 33fZOCezw6x4luaIE+aqBqPcfjaNrfMPIYyArtiVdipb1nVV66WV+OTmlnTFrXUv lXt6pg0JrNrYtXg0fRkoYkLqXJowtuI= Received: from mail.baikal.int (mail.baikal.int [192.168.51.25]) by post.baikalelectronics.com (Proxmox) with ESMTP id 864F8E0E6A; Tue, 14 Mar 2023 01:42:49 +0300 (MSK) Received: from localhost (10.8.30.10) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 14 Mar 2023 01:42:48 +0300 From: Serge Semin To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Russell King , Andrew Lunn , Heiner Kallweit CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Christian Marangi , Biao Huang , Yang Yingliang , , , , , Jose Abreu Subject: [PATCH net 06/13] net: stmmac: Free temporary Rx SKB on request Date: Tue, 14 Mar 2023 01:42:30 +0300 Message-ID: <20230313224237.28757-7-Sergey.Semin@baikalelectronics.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> References: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-Originating-IP: [10.8.30.10] X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org In case if an incoming frame couldn't be finished in one stmmac_rx() method call an SKB used to collect data so far will be saved in the corresponding Rx-queue state buffer. If the network device is closed before the frame is completed the preserved SKB will be utilized on the next network interface link uprising cycle right on the first frame reception, which will cause having a confused set of SKB data. Let's free the allocated Rx SKB then when all Rx-buffers are requested to be freed. Fixes: ec222003bd94 ("net: stmmac: Prepare to add Split Header support") Signed-off-by: Serge Semin Reviewed-by: Piotr Raczynski --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index ee4297a25521..4d643b1bbf65 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1545,6 +1545,10 @@ static void dma_free_rx_skbufs(struct stmmac_priv *priv, for (i = 0; i < dma_conf->dma_rx_size; i++) stmmac_free_rx_buffer(priv, rx_q, i); + + if (rx_q->state_saved) + dev_kfree_skb(rx_q->state.skb); + rx_q->state_saved = false; } static int stmmac_alloc_rx_buffers(struct stmmac_priv *priv, From patchwork Mon Mar 13 22:42:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13173406 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4314C6FD1C for ; Mon, 13 Mar 2023 22:43:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229925AbjCMWno (ORCPT ); Mon, 13 Mar 2023 18:43:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230117AbjCMWnY (ORCPT ); Mon, 13 Mar 2023 18:43:24 -0400 Received: from post.baikalelectronics.com (post.baikalelectronics.com [213.79.110.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2C9D490B5B; Mon, 13 Mar 2023 15:42:55 -0700 (PDT) Received: from post.baikalelectronics.com (localhost.localdomain [127.0.0.1]) by post.baikalelectronics.com (Proxmox) with ESMTP id DF58AE0EB9; Tue, 14 Mar 2023 01:42:50 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= baikalelectronics.ru; h=cc:cc:content-transfer-encoding :content-type:content-type:date:from:from:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=post; bh=h2SMgr62uJx+Jx9OVQUkV1OFu3GoPC5DAo88P//755U=; b=dfGqymMpSmwS GZKQiZMcf9/zLVV9+uEDyd0pgL10Rb2Q3XMzu1KCUtPmYEJ/SSJb9D8onN3rPk3X Npn7eg6KdsLpePnqOMPTEXMFlMuV6TI8Udr9rq1i6a4KaOr9Y0uY8ZrynoPFZTVP V1uBX1f1CkVGeqBBS+kgEuTeb1o9ZXQ= Received: from mail.baikal.int (mail.baikal.int [192.168.51.25]) by post.baikalelectronics.com (Proxmox) with ESMTP id BEBBDE0E6A; Tue, 14 Mar 2023 01:42:50 +0300 (MSK) Received: from localhost (10.8.30.10) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 14 Mar 2023 01:42:50 +0300 From: Serge Semin To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Russell King , Andrew Lunn , Heiner Kallweit , Joao Pinto CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Christian Marangi , Biao Huang , Yang Yingliang , , , , Subject: [PATCH net 07/13] net: stmmac: Free Rx descs on Tx allocation failure Date: Tue, 14 Mar 2023 01:42:31 +0300 Message-ID: <20230313224237.28757-8-Sergey.Semin@baikalelectronics.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> References: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-Originating-IP: [10.8.30.10] X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Indeed in accordance with the alloc_dma_desc_resources() method logic the Rx descriptors will be left allocated if Tx descriptors allocation fails. Fix it by calling the free_dma_rx_desc_resources() in case if the alloc_dma_tx_desc_resources() method returns non-zero value. While at it refactor the method a bit. Just move the Rx descriptors allocation method invocation out of the local variables declaration block and discard a pointless comment from there. Fixes: 71fedb0198cb ("net: stmmac: break some functions into RX and TX scopes") Signed-off-by: Serge Semin Reviewed-by: Piotr Raczynski --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 4d643b1bbf65..229f827d7572 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -2182,13 +2182,15 @@ static int alloc_dma_tx_desc_resources(struct stmmac_priv *priv, static int alloc_dma_desc_resources(struct stmmac_priv *priv, struct stmmac_dma_conf *dma_conf) { - /* RX Allocation */ - int ret = alloc_dma_rx_desc_resources(priv, dma_conf); + int ret; + ret = alloc_dma_rx_desc_resources(priv, dma_conf); if (ret) return ret; ret = alloc_dma_tx_desc_resources(priv, dma_conf); + if (ret) + free_dma_rx_desc_resources(priv, dma_conf); return ret; } From patchwork Mon Mar 13 22:42:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13173411 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E74D5C7618B for ; Mon, 13 Mar 2023 22:43:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229897AbjCMWnz (ORCPT ); Mon, 13 Mar 2023 18:43:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230054AbjCMWnZ (ORCPT ); Mon, 13 Mar 2023 18:43:25 -0400 Received: from post.baikalelectronics.com (post.baikalelectronics.com [213.79.110.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4108090B68; Mon, 13 Mar 2023 15:42:55 -0700 (PDT) Received: from post.baikalelectronics.com (localhost.localdomain [127.0.0.1]) by post.baikalelectronics.com (Proxmox) with ESMTP id 0F365E0EBA; Tue, 14 Mar 2023 01:42:52 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= baikalelectronics.ru; h=cc:cc:content-transfer-encoding :content-type:content-type:date:from:from:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=post; bh=Dpl6MaxqP5WEy7Vh+oFSb0logDrpNZX6Oxq0pbGHndo=; b=j/VKpA/0OYyW ITllD/sgEyyJK3bhHohE8LZrDLjdh6jn/vhc+xSN595HWpgUaWghtGMd9G+PrEGW oX9Gk4Cj1zY8o2KfuD6Vlmv1c7wCr6IHdyw2gUEv4mfXQw4jOHnAm5YuuGqF8F7w CEJflcO/In1kXsWIDFU+Pwrd6MWqu+E= Received: from mail.baikal.int (mail.baikal.int [192.168.51.25]) by post.baikalelectronics.com (Proxmox) with ESMTP id F351DE0E6A; Tue, 14 Mar 2023 01:42:51 +0300 (MSK) Received: from localhost (10.8.30.10) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 14 Mar 2023 01:42:51 +0300 From: Serge Semin To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Russell King , Andrew Lunn , Heiner Kallweit CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Christian Marangi , Biao Huang , Yang Yingliang , , , , , Jose Abreu Subject: [PATCH net 08/13] net: stmmac: Fix Rx IC bit setting procedure for Rx-mitigation Date: Tue, 14 Mar 2023 01:42:32 +0300 Message-ID: <20230313224237.28757-9-Sergey.Semin@baikalelectronics.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> References: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-Originating-IP: [10.8.30.10] X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The WDT-less Rx-traffic mitigation is simple: enable the Rx-descriptor Completion interrupt only when a particular number of descriptors handled by the NIC. Alas it's broken now because the data variable rx_count_frames is always set to zero due to commit 6fa9d691b91a ("net: stmmac: Prevent divide-by-zero") (++rx_count_frames + rx_coal_frames > rx_coal_frames always if no overflow happens). So Rx IC will be enabled for each descriptor as soon as rx_coal_frames is non-zero or there is no Rx WDT available, which basically disables the Rx-mitigation in the framework of the number of received frames part. Fix that by discarding the statement: rx_q->rx_count_frames += priv->rx_coal_frames. Fixes: 6fa9d691b91a ("net: stmmac: Prevent divide-by-zero") Signed-off-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 229f827d7572..32aa7953d296 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -4627,7 +4627,6 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv, u32 queue) stmmac_refill_desc3(priv, rx_q, p); rx_q->rx_count_frames++; - rx_q->rx_count_frames += priv->rx_coal_frames[queue]; if (rx_q->rx_count_frames > priv->rx_coal_frames[queue]) rx_q->rx_count_frames = 0; @@ -4967,7 +4966,6 @@ static bool stmmac_rx_refill_zc(struct stmmac_priv *priv, u32 queue, u32 budget) stmmac_refill_desc3(priv, rx_q, rx_desc); rx_q->rx_count_frames++; - rx_q->rx_count_frames += priv->rx_coal_frames[queue]; if (rx_q->rx_count_frames > priv->rx_coal_frames[queue]) rx_q->rx_count_frames = 0; From patchwork Mon Mar 13 22:42:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13173408 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF1E2C6FD1C for ; Mon, 13 Mar 2023 22:43:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229929AbjCMWnt (ORCPT ); Mon, 13 Mar 2023 18:43:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229722AbjCMWnZ (ORCPT ); Mon, 13 Mar 2023 18:43:25 -0400 Received: from post.baikalelectronics.com (post.baikalelectronics.com [213.79.110.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4021D90B67; Mon, 13 Mar 2023 15:42:55 -0700 (PDT) Received: from post.baikalelectronics.com (localhost.localdomain [127.0.0.1]) by post.baikalelectronics.com (Proxmox) with ESMTP id 6A3CEE0EBC; Tue, 14 Mar 2023 01:42:53 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= baikalelectronics.ru; h=cc:cc:content-transfer-encoding :content-type:content-type:date:from:from:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=post; bh=+PN9j8i8CUqBkqlPL3X/wgal1M61lqlFSZNS8372LJI=; b=pVphkfQwoDW1 BfHfEzbCFY7bOtI0biMdcll4erACdeUdXN54+1wgnsA2DOnsCx1np44Sj7t3uxgE j+j9bWgjlJxtV5cNagVGdwJgQbdpp3Uw1pMPgnog/Woa9hbquURO4d0C0qDmUhNF UgjVPoQpQgn8GAvaMb0LFB8IT6rrhW4= Received: from mail.baikal.int (mail.baikal.int [192.168.51.25]) by post.baikalelectronics.com (Proxmox) with ESMTP id 565E3E0EBB; Tue, 14 Mar 2023 01:42:53 +0300 (MSK) Received: from localhost (10.8.30.10) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 14 Mar 2023 01:42:52 +0300 From: Serge Semin To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Russell King , Andrew Lunn , Heiner Kallweit CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Christian Marangi , Biao Huang , Yang Yingliang , , , , , Jose Abreu Subject: [PATCH net 09/13] net: stmmac: Remove default maxmtu DT-platform setting Date: Tue, 14 Mar 2023 01:42:33 +0300 Message-ID: <20230313224237.28757-10-Sergey.Semin@baikalelectronics.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> References: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-Originating-IP: [10.8.30.10] X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Initializing maxmtu platform parameter in the stmmac_probe_config_dt() method by default makes being pointless the DW MAC-specific maximum MTU selection algorithm implemented in the stmmac_dvr_probe() method. At least for xGMAC we'll always have a frame MTU limited with 9000 while it supports units up to 16KB. Let's remove the default initialization of the maxmtu platform setting then. We don't replace it with setting the maxmtu with some greater value because a default maximum MTU is calculated later in the stmmac_dvr_probe() anyway. That would have been a pointless limitation too. Instead from now the main STMMAC driver code will consider the out of bounds maxmtu value as invalid and will silently replace it with a maximum MTU value specific to the corresponding DW MAC. Note this alteration will only affect the xGMAC IP-cores due to the way the MTU autodetecion algorithm is implemented. So from now the driver will permit DW xGMACs to handle frames up to 16KB length (XGMAC_JUMBO_LEN). As before DW GMAC IP-cores of v4.0 and higher and IP-cores with enhanced descriptor support will be able to work with frames up to 8KB (JUMBO_LEN). The rest of the NICs will support frames of SKB_MAX_HEAD(NET_SKB_PAD + NET_IP_ALIGN) size. Fixes: 7d9e6c5afab6 ("net: stmmac: Integrate XGMAC into main driver flow") Signed-off-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ---- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 5 ----- 2 files changed, 9 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 32aa7953d296..e5cb4edc4e23 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -7252,10 +7252,6 @@ int stmmac_dvr_probe(struct device *device, if ((priv->plat->maxmtu < ndev->max_mtu) && (priv->plat->maxmtu >= ndev->min_mtu)) ndev->max_mtu = priv->plat->maxmtu; - else if (priv->plat->maxmtu < ndev->min_mtu) - dev_warn(priv->device, - "%s: warning: maxmtu having invalid value (%d)\n", - __func__, priv->plat->maxmtu); if (flow_ctrl) priv->flow_ctrl = FLOW_AUTO; /* RX/TX pause on */ diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index 067a40fe0a23..857411105a0a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -468,11 +468,6 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) plat->en_tx_lpi_clockgating = of_property_read_bool(np, "snps,en-tx-lpi-clockgating"); - /* Set the maxmtu to a default of JUMBO_LEN in case the - * parameter is not present in the device tree. - */ - plat->maxmtu = JUMBO_LEN; - /* Set default value for multicast hash bins */ plat->multicast_filter_bins = HASH_TABLE_SIZE; From patchwork Mon Mar 13 22:42:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13173409 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71498C61DA4 for ; Mon, 13 Mar 2023 22:43:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230104AbjCMWnv (ORCPT ); Mon, 13 Mar 2023 18:43:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229853AbjCMWnZ (ORCPT ); Mon, 13 Mar 2023 18:43:25 -0400 Received: from post.baikalelectronics.com (post.baikalelectronics.com [213.79.110.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 269D187A2D; Mon, 13 Mar 2023 15:42:56 -0700 (PDT) Received: from post.baikalelectronics.com (localhost.localdomain [127.0.0.1]) by post.baikalelectronics.com (Proxmox) with ESMTP id B5247E0EBD; Tue, 14 Mar 2023 01:42:54 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= baikalelectronics.ru; h=cc:cc:content-transfer-encoding :content-type:content-type:date:from:from:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=post; bh=nZ9yG0elRT6uL0+4AaOond5kO+hwjv7M4hDEo8ZCYAM=; b=FeqczvuB9KUR dQSzwn7YirRM436fADUn0EEbl2wqkSOPnkZO+RMPuVfw7ODFrNVdRJrhEx7hAVbo 4NX7UTUgW9C8KihED2TGQ28IZ7h0CQBS44vkj/fYABFnNClzQ9TmafRPiV0sUiOK dQM3MytNNuGvZmP8Fk5ntjAQ/UPUK5E= Received: from mail.baikal.int (mail.baikal.int [192.168.51.25]) by post.baikalelectronics.com (Proxmox) with ESMTP id 985A4E0EBB; Tue, 14 Mar 2023 01:42:54 +0300 (MSK) Received: from localhost (10.8.30.10) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 14 Mar 2023 01:42:53 +0300 From: Serge Semin To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Russell King , Andrew Lunn , Heiner Kallweit CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Christian Marangi , Biao Huang , Yang Yingliang , , , , Subject: [PATCH net 10/13] net: stmmac: Make buf_sz module parameter useful Date: Tue, 14 Mar 2023 01:42:34 +0300 Message-ID: <20230313224237.28757-11-Sergey.Semin@baikalelectronics.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> References: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-Originating-IP: [10.8.30.10] X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Since the first day of the driver been added to the kernel the Rx DMA-buffer size module parameter hasn't been utilized for something more-or-less useful. The STMMAC main code used to initialize the actual Rx DMA-buffer size (priv->dma_buf_sz) with it by default, but then overwrote it anyway in accordance with Network device MTU or with default DMA_BUFFER_SIZE/DEFAULT_BUFSIZE macro. Moreover in the both older and modern versions of the STMMAC driver the buf_sz module parameter was overwritten on each Net-dev open procedure with a value calculated in accordance with MTU and allowed maximum buffer size. Needless to say that even though it doesn't affect the driver functionality much, setting the generic parameter with a value specific to a private device is wrong, seeing each DW MAC may have different maximum buffer size on the same platform. In order to finally make the buf_sz (Rx DMA buffer size) parameter really useful let's stop setting it up with a value specific to a particular controller and use it to calculate the Rx DMA-buffer size instead of MTU if one is greater than the later. Thus we'll be able to tune the buffer size up when it's necessary. Fixes: 47dd7a540b8a ("net: add support for STMicroelectronics Ethernet controllers.") Signed-off-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index e5cb4edc4e23..12de84b7e90d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -100,10 +100,10 @@ static int tc = TC_DEFAULT; module_param(tc, int, 0644); MODULE_PARM_DESC(tc, "DMA threshold control value"); -#define DEFAULT_BUFSIZE 1536 -static int buf_sz = DEFAULT_BUFSIZE; -module_param(buf_sz, int, 0644); -MODULE_PARM_DESC(buf_sz, "DMA buffer size"); +#define DEFAULT_BUFSIZE 1536U +static unsigned int buf_sz = DEFAULT_BUFSIZE; +module_param(buf_sz, uint, 0644); +MODULE_PARM_DESC(buf_sz, "Rx DMA buffer size"); #define STMMAC_RX_COPYBREAK 256 @@ -3730,7 +3730,7 @@ stmmac_setup_dma_desc(struct stmmac_priv *priv, unsigned int mtu) bfsize = 0; if (bfsize < BUF_SIZE_16KiB) - bfsize = stmmac_set_bfsize(mtu, 0); + bfsize = stmmac_set_bfsize(max(buf_sz, mtu), 0); dma_conf->dma_buf_sz = bfsize; /* Chose the tx/rx size from the already defined one in the @@ -3817,7 +3817,6 @@ static int __stmmac_open(struct net_device *dev, priv->rx_copybreak = STMMAC_RX_COPYBREAK; - buf_sz = dma_conf->dma_buf_sz; memcpy(&priv->dma_conf, dma_conf, sizeof(*dma_conf)); stmmac_reset_queues_param(priv); From patchwork Mon Mar 13 22:42:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13173412 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2F47C61DA4 for ; Mon, 13 Mar 2023 22:43:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230284AbjCMWn5 (ORCPT ); Mon, 13 Mar 2023 18:43:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230079AbjCMWnZ (ORCPT ); Mon, 13 Mar 2023 18:43:25 -0400 Received: from post.baikalelectronics.com (post.baikalelectronics.com [213.79.110.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C4C9690B70; Mon, 13 Mar 2023 15:42:58 -0700 (PDT) Received: from post.baikalelectronics.com (localhost.localdomain [127.0.0.1]) by post.baikalelectronics.com (Proxmox) with ESMTP id 0A842E0EBE; Tue, 14 Mar 2023 01:42:56 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= baikalelectronics.ru; h=cc:cc:content-transfer-encoding :content-type:content-type:date:from:from:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=post; bh=MMTDeeiuyc0pzzHSuO/Rc/eYSTeHJthGjOCtbtYlG0E=; b=ZcThLAGsnX6J 8iB9AOckyNeuUTeNraGhpyZ0oUOH/iCOoD3adNkzyVp6sDtwNVOYvK3WDotdFTfd GtviYZIcRmH5c/2nb3trChdUzR5FaOlH5re8uSiFt+v+JCFXWkc0qmCn7WSV6J4/ K9x2+RIhvKM8Tbe7ynZoAwjrO7CvnLQ= Received: from mail.baikal.int (mail.baikal.int [192.168.51.25]) by post.baikalelectronics.com (Proxmox) with ESMTP id ED1A8E0EBB; Tue, 14 Mar 2023 01:42:55 +0300 (MSK) Received: from localhost (10.8.30.10) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 14 Mar 2023 01:42:55 +0300 From: Serge Semin To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Russell King , Andrew Lunn , Heiner Kallweit CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Christian Marangi , Biao Huang , Yang Yingliang , , , , , Jose Abreu Subject: [PATCH net 11/13] net: stmmac: gmac4: Use dwmac410_disable_dma_irq for DW MAC v4.10 DMA Date: Tue, 14 Mar 2023 01:42:35 +0300 Message-ID: <20230313224237.28757-12-Sergey.Semin@baikalelectronics.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> References: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-Originating-IP: [10.8.30.10] X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From the very beginning of the DW GMAC v4.10 IP support the driver has used an invalid DMA IRQ disable method to switch the DMA IRQs off. Since commit 021bd5e36970 ("net: stmmac: Let TX and RX interrupts be independently enabled/disabled") a valid method has been added to the dwmac4_lib.c module, but the commit author forgot to initialize the corresponding field of the DW MAC DMA operations descriptor with it. That mistake hasn't caused any problem so far just because the RIE/TIE fields match in both 4.x and 4.10 IPs. Anyway fix the inconsistency in order to at least have a coherent driver code. Fixes: 021bd5e36970 ("net: stmmac: Let TX and RX interrupts be independently enabled/disabled") Signed-off-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c index d99fa028c646..2b85819a560f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c @@ -557,7 +557,7 @@ const struct stmmac_dma_ops dwmac410_dma_ops = { .dma_rx_mode = dwmac4_dma_rx_chan_op_mode, .dma_tx_mode = dwmac4_dma_tx_chan_op_mode, .enable_dma_irq = dwmac410_enable_dma_irq, - .disable_dma_irq = dwmac4_disable_dma_irq, + .disable_dma_irq = dwmac410_disable_dma_irq, .start_tx = dwmac4_dma_start_tx, .stop_tx = dwmac4_dma_stop_tx, .start_rx = dwmac4_dma_start_rx, From patchwork Mon Mar 13 22:42:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13173410 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6ADDCC6FD1C for ; Mon, 13 Mar 2023 22:43:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230259AbjCMWnx (ORCPT ); Mon, 13 Mar 2023 18:43:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230023AbjCMWnZ (ORCPT ); Mon, 13 Mar 2023 18:43:25 -0400 Received: from post.baikalelectronics.com (post.baikalelectronics.com [213.79.110.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 939EA90B6B; Mon, 13 Mar 2023 15:42:58 -0700 (PDT) Received: from post.baikalelectronics.com (localhost.localdomain [127.0.0.1]) by post.baikalelectronics.com (Proxmox) with ESMTP id 601ECE0EBF; Tue, 14 Mar 2023 01:42:57 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= baikalelectronics.ru; h=cc:cc:content-transfer-encoding :content-type:content-type:date:from:from:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=post; bh=c91xgDA+xxkJQX7Ffet0DRolPx3vpd9nRj5buf/A0EU=; b=Ju2Ta6H/2Nh8 ijhmSvQmf0bjzvuSQmkhT7zEcVMJ7cOaScu7vLX19ALicrfdoaBXrKRgsECsc7fM 2JvJMbjcFw1yA6V7TMuPCvAcKDa5TNm7Eg/dR7bwWcyKu4vDEt45nX9/8x8K5biL xyQ881AlqgzhLXDriOpxPbOT2ACC9Hs= Received: from mail.baikal.int (mail.baikal.int [192.168.51.25]) by post.baikalelectronics.com (Proxmox) with ESMTP id 45D14E0EBB; Tue, 14 Mar 2023 01:42:57 +0300 (MSK) Received: from localhost (10.8.30.10) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 14 Mar 2023 01:42:56 +0300 From: Serge Semin To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Russell King , Andrew Lunn , Heiner Kallweit , Ong Boon Leong , Voon Weifeng , Wong Vee Khee , Tan Tee Min , Richard Cochran CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Christian Marangi , Biao Huang , Yang Yingliang , , , , , Jose Abreu Subject: [PATCH net 12/13] net: stmmac: Stop overriding the PTP clock info static instance Date: Tue, 14 Mar 2023 01:42:36 +0300 Message-ID: <20230313224237.28757-13-Sergey.Semin@baikalelectronics.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> References: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-Originating-IP: [10.8.30.10] X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org It had been defined as constant before commit 9a8a02c9d46d ("net: stmmac: Add Flexible PPS support"). But then it was converted to be just static, which fields may get to be modified on each stmmac_ptp_register() invocation. Since that method is called from the driver probe method, a concurrent DW *MAC NIC initialization causes the race condition for the updated stmmac_ptp_clock_ops fields. That also may lead to setting an inappropriate max_adj value, which was specific for one device, was written to the stmmac_ptp_clock_ops, but then copied to the private ptp_clock_info instance unmodified. So to speak let's leave the stmmac_ptp_clock_ops content untouched and just copy it to the device-specific instance of the ptp_clock_info structure, which fields could be then accordingly modified. After that we can get the const qualifier back to the stmmac_ptp_clock_ops instance definition. While at it remove pointless zero-initialization of the stmmac_ptp_clock_ops fields. It's redundant since the structure is static. Fixes: 9a8a02c9d46d ("net: stmmac: Add Flexible PPS support") Fixes: 190f73ab4c43 ("net: stmmac: setup higher frequency clk support for EHL & TGL") Fixes: f4da56529da6 ("net: stmmac: Add support for external trigger timestamping") Signed-off-by: Serge Semin --- .../net/ethernet/stmicro/stmmac/stmmac_ptp.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c index b4388ca8d211..19a28b1cc272 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c @@ -254,15 +254,10 @@ static int stmmac_getcrosststamp(struct ptp_clock_info *ptp, } /* structure describing a PTP hardware clock */ -static struct ptp_clock_info stmmac_ptp_clock_ops = { +static const struct ptp_clock_info stmmac_ptp_clock_ops = { .owner = THIS_MODULE, .name = "stmmac ptp", .max_adj = 62500000, - .n_alarm = 0, - .n_ext_ts = 0, /* will be overwritten in stmmac_ptp_register */ - .n_per_out = 0, /* will be overwritten in stmmac_ptp_register */ - .n_pins = 0, - .pps = 0, .adjfine = stmmac_adjust_freq, .adjtime = stmmac_adjust_time, .gettime64 = stmmac_get_time, @@ -287,21 +282,21 @@ void stmmac_ptp_register(struct stmmac_priv *priv) priv->pps[i].available = true; } - if (priv->plat->ptp_max_adj) - stmmac_ptp_clock_ops.max_adj = priv->plat->ptp_max_adj; - /* Calculate the clock domain crossing (CDC) error if necessary */ priv->plat->cdc_error_adj = 0; if (priv->plat->has_gmac4 && priv->plat->clk_ptp_rate) priv->plat->cdc_error_adj = (2 * NSEC_PER_SEC) / priv->plat->clk_ptp_rate; - stmmac_ptp_clock_ops.n_per_out = priv->dma_cap.pps_out_num; - stmmac_ptp_clock_ops.n_ext_ts = priv->dma_cap.aux_snapshot_n; - rwlock_init(&priv->ptp_lock); mutex_init(&priv->aux_ts_lock); priv->ptp_clock_ops = stmmac_ptp_clock_ops; + if (priv->plat->ptp_max_adj) + priv->ptp_clock_ops.max_adj = priv->plat->ptp_max_adj; + + priv->ptp_clock_ops.n_per_out = priv->dma_cap.pps_out_num; + priv->ptp_clock_ops.n_ext_ts = priv->dma_cap.aux_snapshot_n; + priv->ptp_clock = ptp_clock_register(&priv->ptp_clock_ops, priv->device); if (IS_ERR(priv->ptp_clock)) { From patchwork Mon Mar 13 22:42:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13173413 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19349C61DA4 for ; Mon, 13 Mar 2023 22:44:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229853AbjCMWoA (ORCPT ); Mon, 13 Mar 2023 18:44:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230149AbjCMWng (ORCPT ); Mon, 13 Mar 2023 18:43:36 -0400 Received: from post.baikalelectronics.com (post.baikalelectronics.com [213.79.110.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9A1A888EC2; Mon, 13 Mar 2023 15:43:01 -0700 (PDT) Received: from post.baikalelectronics.com (localhost.localdomain [127.0.0.1]) by post.baikalelectronics.com (Proxmox) with ESMTP id 96BE1E0EC0; Tue, 14 Mar 2023 01:42:58 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= baikalelectronics.ru; h=cc:cc:content-transfer-encoding :content-type:content-type:date:from:from:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=post; bh=X30LbXauYddYhvPhR7vBPQjq66bDYO15OSX1bv9lZMo=; b=WvFHDUqmG/WY MM86mbD2uV0YWPZk9HvGN0FI9p4d7KusEnmPHxCjCmUrLwxx2da6CymBgJVkpM2F 7/YOurxMXGfr3kG2S4xiG06/+sGOKXWSy+QYYZGOQpC7CN5d4BShK/ZSj5Mw45ff eIY5dXuhDxW4XcT0qHEtnWozxbZ3Ncw= Received: from mail.baikal.int (mail.baikal.int [192.168.51.25]) by post.baikalelectronics.com (Proxmox) with ESMTP id 73FEBE0EBB; Tue, 14 Mar 2023 01:42:58 +0300 (MSK) Received: from localhost (10.8.30.10) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 14 Mar 2023 01:42:57 +0300 From: Serge Semin To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Russell King , Andrew Lunn , Heiner Kallweit , Jiaxun Yang , Qing Zhang CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Christian Marangi , Biao Huang , Yang Yingliang , , , , Subject: [PATCH net 13/13] net: dwmac-loongson: Perceive zero IRQ as invalid Date: Tue, 14 Mar 2023 01:42:37 +0300 Message-ID: <20230313224237.28757-14-Sergey.Semin@baikalelectronics.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> References: <20230313224237.28757-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-Originating-IP: [10.8.30.10] X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Linux kernel defines zero IRQ number as invalid in case if IRQ couldn't be mapped. Fix that for Loongson PCI MAC specific IRQs request procedure. Fixes: 30bba69d7db4 ("stmmac: pci: Add dwmac support for Loongson") Signed-off-by: Serge Semin Reviewed-by: Piotr Raczynski --- drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c index a25c187d3185..907bdfcc07e9 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c @@ -127,20 +127,20 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id res.addr = pcim_iomap_table(pdev)[0]; res.irq = of_irq_get_byname(np, "macirq"); - if (res.irq < 0) { + if (res.irq <= 0) { dev_err(&pdev->dev, "IRQ macirq not found\n"); ret = -ENODEV; goto err_disable_msi; } res.wol_irq = of_irq_get_byname(np, "eth_wake_irq"); - if (res.wol_irq < 0) { + if (res.wol_irq <= 0) { dev_info(&pdev->dev, "IRQ eth_wake_irq not found, using macirq\n"); res.wol_irq = res.irq; } res.lpi_irq = of_irq_get_byname(np, "eth_lpi"); - if (res.lpi_irq < 0) { + if (res.lpi_irq <= 0) { dev_err(&pdev->dev, "IRQ eth_lpi not found\n"); ret = -ENODEV; goto err_disable_msi;