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: 13173417 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 8C63DC61DA4 for ; Mon, 13 Mar 2023 22:44:29 +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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fcDZ5DBLLuuyc4cYs7RYQmV/ugoS4YCsIhB/h3Dtt1k=; b=4p9aYjs7fq6ZeM u5MIGeS9kw16fmpUC71NN4X/wiTqg1HQS8hZs6VyIK+jG6EHPAI658UAiI4P86MscD+0xpUmY0dcC /u8I1FWpZp/wBFWIdHH8bXBlj2OWyaAgpbanGldVSc4U4qorObdl2Zdt1ltcf9/Smtq73xUaPz5r5 ZznJ2PnjewSszUE50882LLql3XWhJdeD3PX30kOnMc+uHkpyjPX5ULYkZgL5MxR14OBmk1fMSgjW2 m8mG5TiojjOGydTf3Eu8LZYi7Yt6XElUM1A1ahWPVDlFnDdn6W7SHMAh9l23jfF6iVSw64S7GHszT X/DG7cYR3YtUxDfGswDw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqtA-0086W3-4G; Mon, 13 Mar 2023 22:43:32 +0000 Received: from post.baikalelectronics.com ([213.79.110.86]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqsW-0086Cz-Aw for linux-arm-kernel@lists.infradead.org; Mon, 13 Mar 2023 22:42:56 +0000 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230313_154253_011887_B7EADAC3 X-CRM114-Status: GOOD ( 21.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 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: 13173414 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 C8FD3C6FD19 for ; Mon, 13 Mar 2023 22:43: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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4HWuJs2D9VIMXoRkWkl2Evmt/Q0qapuXX9ZzBypR20o=; b=3aeTGmaoPYK1hE aDMDV40eZe2CS8UkS94l36JOsbffYzw5AMfKlKN5l9u/wD6CBIjJUGt2ZwCkhULcvDGGNIPpOg1it 2i5aCjNQSJTZZ03V5GBlawRaITITCPrtiWwFRzB4XsESjeWc7JU7WnE0J14tTiIUx4TyEyahUQRjB M7bUfL4oF3CoPGCwZY5b6BuMF9JSSbDEWYXpOoutOiCZnYNWlLJ8AMFYDW6pqZ1GgBkhSwuXkuXah KyzkhuIPBH1kP2T5uCxYSdMji2pH76Q90skAPgCx6Ixtee3A4nxdRoKQZ0g2bT8uSYcPmh68Qs5kg 7NrwFyHIySMBgiQfL2Lg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqsc-0086Fy-1I; Mon, 13 Mar 2023 22:42:58 +0000 Received: from post.baikalelectronics.com ([213.79.110.86]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqsW-0086Db-Ax for linux-arm-kernel@lists.infradead.org; Mon, 13 Mar 2023 22:42:55 +0000 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230313_154252_977980_BB1EFEF2 X-CRM114-Status: GOOD ( 13.90 ) 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 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: 13173415 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 07F11C6FD19 for ; Mon, 13 Mar 2023 22:44:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=w6WV7JfOWwxIOctbpZRPYU4tC8fsfagnEx+P5TxTdWA=; b=u7NeprWOv+TO3U 8PXzyHEbVZZiMtH9EIASIC37TPtut+jf0ryn3n1pyBOdqzrpJdIibbG4z7SW/8t3sT7Qt+928U4pE XyUQ/NIRKptX0lXHOkNb2fUf1KEgXM17mAeVnVsg64/S8zc4pP0z+PZcH2BIsrlXiY9elLQXsD/nK CNedHHCahwW9VZM99cVLWZHR0m6g0T4mpZukznosh4EsPYPZ7hFmuPgOBTB41CmEp/QpHH2ojQn3W J1KJvw3EkfQyi9KB3pBDlngH5NacRaMJfCDIpGbXBaJb+WpGtPj4WRh7d0EonaPwmRLdbUdQk6Pmy 8OOS0a2QDJUE90JC8JfQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqsm-0086Mv-Sq; Mon, 13 Mar 2023 22:43:10 +0000 Received: from post.baikalelectronics.com ([213.79.110.86]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqsW-0086DA-Az for linux-arm-kernel@lists.infradead.org; Mon, 13 Mar 2023 22:42:56 +0000 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230313_154252_974444_37BF7C23 X-CRM114-Status: GOOD ( 14.88 ) 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 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: 13173416 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 70B10C6FD1D for ; Mon, 13 Mar 2023 22:44: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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JLFjAu15ECwJIj4gx4lspUv73QbSL1zv986AR7YWkdM=; b=Ok+gYja49kJkiP YyMGWwhDdv4VQH3DolBwbCpnsyYcCg/+CJCVS9G4YA4RrwCQveLVpppr6V4zEvBkjHpklDHFHCKQU zbmyOG3tilUz5p35nxDfXlQJRZRwZ1bM7ZXzc5vqsniZ0ibVQMkX0ArCaj7qmvDkJzp98LdPgYIFW jo+S+rRyV3vrqDtpfHZR/pIrPTrQakkgdGLq9YnqylYEnuZlPqKYzu1f1xm3dWJq5jclk1zl8EZ5F 3A9UxWUwdANHDDKEsc3vJ71uEcNdUcnMRpm2DAf9V4sMXAo7XIuGjEE4U9khg4Uk3pn1hpPtZY01h qO7YZq3NVf0PgHffPNLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqsw-0086Qc-M4; Mon, 13 Mar 2023 22:43:18 +0000 Received: from post.baikalelectronics.com ([213.79.110.86]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqsW-0086DW-Ay for linux-arm-kernel@lists.infradead.org; Mon, 13 Mar 2023 22:42:56 +0000 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230313_154252_964747_6B0E57CC X-CRM114-Status: GOOD ( 12.99 ) 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 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: 13173426 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 E9015C61DA4 for ; Mon, 13 Mar 2023 22:47:27 +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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ve4TqHV8MkqeQyz6QgiD6W0JutpzVC9v2cETzl7w4H4=; b=CbhU7zfmrZIPds cp7Ayjp6gr60bSXdTG71VkVTd1PDk0+gmxvJjn9vY0wsCIdWoDS05UaXeoyqt3onPzbY5fkgmx0w+ ZwLLFr1GuKuSD44voPLYnd7Oef/AVplJp8lotK5JcVTtrFwuHnaDTqcWvLaS7ANWz/mWdSZCEdNuz vDXnLxqhxvU+86drD45DT9qW64wpxZKasUJK8d3LzzW+vlWPn8FYye/jYWDA3XkJE6PBQVDQxgIhz ZDmhTAxoX5Ak25sZq/GmBHrdWVAd1lE5QwTWsjBqFcXx1e3qKYMjxupOYxtwuV38QrXvjXj1Zz1PZ Dl9ynczs2QDY1qGvEVgw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqvy-0088BZ-Um; Mon, 13 Mar 2023 22:46:27 +0000 Received: from post.baikalelectronics.com ([213.79.110.86]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqsd-0086IE-M4 for linux-arm-kernel@lists.infradead.org; Mon, 13 Mar 2023 22:43:02 +0000 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230313_154300_044866_C1AE2567 X-CRM114-Status: GOOD ( 15.70 ) 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 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: 13173421 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 E67C4C6FD19 for ; Mon, 13 Mar 2023 22:45:30 +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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Pmq5AFCTUJfzXjj5BZnKlckB/Jp3M7uOQIrDt8/MdWc=; b=CtoVzz3tfd9++9 QK1O4zyEiJDTpTwmbHPqT+n4mu+vppDpODEIDxoByQW8G669voOEL/JJGZJgL/4huihzA1wq1y6ne z//PZzccucfoOrnbshfws1EsQsQDCP9vsPZWE5XHmJSVo4mC+/EREFVtczZMfSy+9Ui3lSqMPDsCq TiCtD1AYvLl8fF2Uje6ViONohJc1cPu3niaOCAdgptusBNvUxTRplOF4Kfbzd2m5DQup9O+hxrfys cHFAV8EnQq2RmVWQLsPVQPc5FKlFUQ/a+WPAUdFmhbPDobrQvgLn/mJpnKgSNfCqKEDtrWA1LVfnc cQtwILhMByBJHVRg/I/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqu9-00877E-Bb; Mon, 13 Mar 2023 22:44:33 +0000 Received: from post.baikalelectronics.com ([213.79.110.86]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqsb-0086Fv-Dx for linux-arm-kernel@lists.infradead.org; Mon, 13 Mar 2023 22:43:00 +0000 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230313_154257_683358_3EF25529 X-CRM114-Status: GOOD ( 11.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 13173419 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 14B23C61DA4 for ; Mon, 13 Mar 2023 22:45:06 +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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qRHJI8E/U3slSk1DJ7TfTuk4+4Ajq/TeWOMlsg149x0=; b=sbJVgNCMmHBo9H g+A3IQFAjvQu2Qw2iyJP0MKUT4BZTRBMuslWg/7FYr5+3FQpGAPy8UoCDNafYCKS3ttNu/8gcVC5k aobtizF9QN71VIzDtsVSp5eFCYt9qGJ6wSRQG+CkqClygH3IrfE+lBdg7gBN9Iu9pHJx2T0xQNfQg xxtuqHN6eEb2/zEkpSbSVmeAZP5Ke/5+V5vGaC/MyNFbkH2Qy1sUaUTqydOXpgUQaRvzDZuv23L+S 5UeDOwlVCb1MxKgffz/UAorRR1v7Q9aBxgoLoZh6N2oy3x9Zpc5H5jBTt7Nbh4VbikI4LwfpdwxvW o4/svTwL6SByDcC3RsWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqth-0086q3-TH; Mon, 13 Mar 2023 22:44:06 +0000 Received: from post.baikalelectronics.com ([213.79.110.86]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqsb-0086Fo-55 for linux-arm-kernel@lists.infradead.org; Mon, 13 Mar 2023 22:42:58 +0000 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230313_154257_412455_F5A6F929 X-CRM114-Status: GOOD ( 11.93 ) 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 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 --- 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: 13173420 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 2CE4BC61DA4 for ; Mon, 13 Mar 2023 22:45:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xoz99WKX3pMcCpU81b1QdGI9FJEbAAO9nQo11uOGBDs=; b=4cFOIqxrwtnY89 N4l+L9UIiqMv6nSCJcHqVJezdj4vEW9IqzJerlaP9U1CDaixd8Ny2SXlESLXcVFB3dTkPPmZa288V YEJNdOmk47KDc3/LZcFE6B6gO/gLjQ/DLJL0O+n6wBEx+wA/IAn3zlPXf5siAZd8C5cBXg4qBAQmH Nj8FHmgL7G3JfYjsXBk8fka4uNOED/rZxXVmiqANohXx0wc2Ma7a40qtXTWNF0GvYdwk5F05kBF9Q Ud/i1cZxNPzMeKbSVDKVSdsl3x6uLZJXBESkDOLmPBBcqlD4g80APcgqzr2mIHbQ2PS0pjMValQ3O 5jTYTVl2QYQryLZfhKyw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqts-0086xg-W0; Mon, 13 Mar 2023 22:44:17 +0000 Received: from post.baikalelectronics.com ([213.79.110.86]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqsb-0086Fp-6A for linux-arm-kernel@lists.infradead.org; Mon, 13 Mar 2023 22:42:58 +0000 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230313_154257_429981_3D6DA279 X-CRM114-Status: GOOD ( 11.21 ) 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 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: 13173424 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 F1907C61DA4 for ; Mon, 13 Mar 2023 22:46:39 +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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CNqYxM02VUAFQi++o5J/z1LDYr+tyZncxnAYCMp/b8U=; b=VnCrXppqhfEIUD jyAXAaRLs3S+ct7CbUotz7NIuBG8oVpo58WN7ucePN0xwlgZKTVK8i2jXNN+NV6Tw5SsEoTu0oabk q9pUVivt80FmHx+vfR2ZvG0N00vq8MuZ09VncV1RV4T5pTGrICS2i6nC88EbVUwrvVTsj+9EFsadA wtCA5PfzsW9hu4c6/fh3EwQIs3MY3EOSKn4MWxcfWekLayswOW1lPVDyuBVdKajl2VlYCHdwZW4jP AOAu1Su1SiXZ1W98BLN3ID0NbcsKs/8G/OE358LobUnTlv7Lqqe06TGYlaNV0nJyijj11G0bLPKeS ljBl69iX4E1VTA48amPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqvF-0087lo-8I; Mon, 13 Mar 2023 22:45:41 +0000 Received: from post.baikalelectronics.com ([213.79.110.86]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqsc-0086Gp-Au for linux-arm-kernel@lists.infradead.org; Mon, 13 Mar 2023 22:43:01 +0000 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230313_154258_651910_65D408CA X-CRM114-Status: GOOD ( 14.28 ) 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 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: 13173425 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 A8A05C6FD19 for ; Mon, 13 Mar 2023 22:47:04 +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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Nw1xXt+yYabiZN3w/7NaDu8g6B/mzSNm/ZntGcg4GAM=; b=EM8+CoBlinTuoT l+m5CIcc3y+9oXH9lA4ozC1g5fJBmtWyuEDDbzplgvRPvnsmjrYsJziwXEvSJVdJLsnq0UQw9aBPA olrty5P4xOpFOJs6+lgKj0OLseKsGipC9je7P1fhEBi3NNtiMUEV7X0tOqh5Pwob6ldQ0k41jsswk 1gz/uxZGpbkWc1nYpOGTnW+Ck24FMut7YGp9taKLqQdqscwvwRjGS/N+CtO9gLeIfV8BTaBZEhA5M y5WK4rbcMDFwtyPEQ3sngJakwLlqUl+/0xpkkiIxAEw5q2tDYYr3Sk5McoxYn7+AK/8T5Qa5p1cgS c38LKTMOOXLhGfTv609w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqva-0087xf-2H; Mon, 13 Mar 2023 22:46:02 +0000 Received: from post.baikalelectronics.com ([213.79.110.86]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqsd-0086HV-2j for linux-arm-kernel@lists.infradead.org; Mon, 13 Mar 2023 22:43:02 +0000 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230313_154259_363966_5A65931B X-CRM114-Status: GOOD ( 17.26 ) 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 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: 13173423 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 6126EC6FD19 for ; Mon, 13 Mar 2023 22:46:16 +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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3gV6LJsFRXNZ70wMSqakTrX8Edped+WLjqb/ozldPsA=; b=AAzgj8E4GmVSE5 VocT39zvjnrdK5HIRZ81ffeaOkT+hqUwYOQRpLlzph5/Za96DhiAjAqT24P/TAkWfFx8lBkVwOAqQ Ofw7yEFAyNzQ4FsEa1CnHyxwkos2Zmu5mREuSILjxLkEiY+2nFYvPLP4qQNsJhx/7HaTo3Oh6HdJF egvUHj73/jbniDavebA5jQ0qGrMuRWddIGaDWnJ/bBTnhR91d4DpRoml03cpiotticNZeiLO89j4C 0IEo7njRiHwmqgEzc+OiIOaWn+w6/v5II8pGQ3or418ncOcPh/KHYfvUnBeDh8n6YPhaIiw0yC47J iP0sBqlpEaa1bmuiA/mA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbquv-0087aI-AF; Mon, 13 Mar 2023 22:45:21 +0000 Received: from post.baikalelectronics.com ([213.79.110.86]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqsb-0086G6-Nn for linux-arm-kernel@lists.infradead.org; Mon, 13 Mar 2023 22:43:01 +0000 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230313_154258_045627_B13F4535 X-CRM114-Status: GOOD ( 13.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 13173422 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 B4295C61DA4 for ; Mon, 13 Mar 2023 22:45:54 +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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GQQ/zotX4M2GECnKtWEC5XuVtitq/c4mS2aw6UBhbcs=; b=NwaArAvOqH8AhU 2RnozCFwTEybYSxkwv4MN/gCd8BGB21FyaNYvgQHHAp7OAYlKOgwE2A5LfA3ij5+HhxZgF55G9DVV faLAZlglSaLaXgmxxk+VWp07DbIW8Vs7UjXFbqQ48QR0UzXdGNlSPuyilWvy4Yd/vWZj8FyFbqwx3 jginHFmVDhoLrj9WuDEdBnB1jRh9IDZmAaJvVLG4CW/VQIsZc5bSMjR/lpqrrM5IdJecQ/acxlMG+ rccvCbs9tcgDK6A48Plwk2vtMXLYHjAFGZhVb/y1/bTSThgNhHYQbc5e7pcF7wOytSlaDa6q+O0pW 9j47sz0DZrWuklVM+cxA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbquX-0087ML-FN; Mon, 13 Mar 2023 22:44:57 +0000 Received: from post.baikalelectronics.com ([213.79.110.86]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqsc-0086Gq-BQ for linux-arm-kernel@lists.infradead.org; Mon, 13 Mar 2023 22:43:01 +0000 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230313_154258_656829_D2CED533 X-CRM114-Status: GOOD ( 14.50 ) 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 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: 13173427 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 376FEC61DA4 for ; Mon, 13 Mar 2023 22:47: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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Lf89+rBt+j+SBeK31gv12P1v+iQXNESvXbnZlO6deU4=; b=fu+FTNFSEW6kKO lipu1SzFpSgf3YK3jz7bHEwUranGir3LdWPud4QQ3Cw1vCPpamgFX73sO5fQjquh/TrYoQ67xvLsq j8utL/S6Ft5+aXch3wZPkUvI+xHZyu5TmpXUmZoI3wIYe1yLxodJOFZAAMc0riE1QEtS0Msq/Vmge S/p9LOGiQrTb2vO/vcrzVq9lDYNBayakoGmBDuTX9P8yTM8f37DF2olK+TAWk1bxt37Ku85OtbrRd 9bw4bx/+qTrGE5zHjldo7Tq7JIP9tRbYm2QltTO32dCsqzXi25zzVN5zvgoaDxGWe+9XpNO/pEXsy m9KF16qqxlz3p0OE2rnQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqwR-0088Q4-Gj; Mon, 13 Mar 2023 22:46:55 +0000 Received: from post.baikalelectronics.com ([213.79.110.86]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqsd-0086Fo-8t for linux-arm-kernel@lists.infradead.org; Mon, 13 Mar 2023 22:43:02 +0000 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230313_154259_567921_C141F000 X-CRM114-Status: GOOD ( 11.73 ) 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 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;