Message ID | 20210208140341.9271-1-Sergey.Semin@baikalelectronics.ru (mailing list archive) |
---|---|
Headers | show
Return-Path: <SRS0=U7wc=HK=lists.infradead.org=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@kernel.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18917C433E6 for <linux-arm-kernel@archiver.kernel.org>; Mon, 8 Feb 2021 14:06:08 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7B05264E24 for <linux-arm-kernel@archiver.kernel.org>; Mon, 8 Feb 2021 14:06:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7B05264E24 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baikalelectronics.ru Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=Eg1VFBgDVAVRQJ2tvGRXY/5Bbk/lH54ztJuHyWksYsY=; b=C++3JAEWUHbP3w4jFD8IQ4tv2w wESfC58XpPNgQlAGV4D5/xImSR3g+ozeZcKhwhwH2HI04fjVL3THjKX+21Fd5J7cu8NLGJmK0HbZr caFP5e3crVsNmVeHVD90QrMBmcXG3+RVNB4FyR7fKuNSLZgn4zlyucRlmlmu3ws8gP5cSigqznx+m RenoxAi/OvLG22ozqqbNyEW/EAzo8RLaWjXOCwAdSfLe6TCWw1U9e+FLDSYFN9BgrmNOfdmuh45Eh lz2KVCHikOQLuaV0b+5UEpkC/sUPwiH/EX5qYjRiwNjggWoaRQipzHOLuk6a8JiuE2RP8tmfi3Sph Zy25ACeg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l979G-0003FG-JK; Mon, 08 Feb 2021 14:04:18 +0000 Received: from mail.baikalelectronics.com ([87.245.175.226] helo=mail.baikalelectronics.ru) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l978k-00032x-Bm for linux-arm-kernel@lists.infradead.org; Mon, 08 Feb 2021 14:03:52 +0000 From: Serge Semin <Sergey.Semin@baikalelectronics.ru> To: Giuseppe Cavallaro <peppe.cavallaro@st.com>, Alexandre Torgue <alexandre.torgue@st.com>, Jose Abreu <joabreu@synopsys.com>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Joao Pinto <Joao.Pinto@synopsys.com>, Jose Abreu <Jose.Abreu@synopsys.com> Subject: [PATCH 00/20] net: stmmac: Obvious cleanups and several fixes Date: Mon, 8 Feb 2021 17:03:21 +0300 Message-ID: <20210208140341.9271-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 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-20210208_090346_805910_AE040CEA X-CRM114-Status: GOOD ( 16.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Cc: Andrew Lunn <andrew@lunn.ch>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Russell King <linux@armlinux.org.uk>, Serge Semin <fancer.lancer@gmail.com>, Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>, Serge Semin <Sergey.Semin@baikalelectronics.ru>, Vyacheslav Mitrofanov <Vyacheslav.Mitrofanov@baikalelectronics.ru>, Pavel Parkhomenko <Pavel.Parkhomenko@baikalelectronics.ru>, Maxime Coquelin <mcoquelin.stm32@gmail.com>, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, Heiner Kallweit <hkallweit1@gmail.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
net: stmmac: Obvious cleanups and several fixes
|
expand
|
This series consists of a preparation patches before adding DW MAC GPIOs and final Baikal-T1 GMAC support. (The later will be done in the framework of the Generic DW MAC glue-driver though.) It's mainly about cleaning the code up here and there by removing unused data and macro names, but also includes several bugs and design fixes. The patchset starts from fixing the Realtek PHYs driver. In particular it has been discovered that disabling RXC in LPI (EEE) causes RTL8211E PHY partial freeze until the next MDIO read operation from the PHY CSRs. We suggest to fix that problem by dummy reading from the MMD Data register each time the PC1R.10 bit is intended to be set. Then the series evolves in a set of bug fixes discovered in the main STMMAC driver code. First of all the cleanup-on-error path has been incorrectly implemented in the DMA descriptor allocation procedure due to which in case Tx DMA resources allocation failures the Rx DMA descriptors will be left unfreed. Secondly it has been discovered that the MTL IRQs handling procedure didn't do that quite well, so any MTL RX overflow errors will be handled for queues with higher order too, which most likely isn't what the code author originally intended. Thirdly the DW MAC reset control de-assetion should be performed after the MDIO-bus de-registration, because the later may need to access PHY registers, which is supposed to be done via the MAC SMA interface. Fourthly we've found out that DW MAC v4.x code was using a generic dwmac4_disable_dma_irq() method to disable DMA IRQs instead of having the dedicated dwmac410_disable_dma_irq() method utilized. That didn't cause any problem because the modified bits matches in both IP-core revisions, but for consistency we suggest to fix that. Fifthly for the same reason of the naming consistency the GMAC_INT_STATUS_PMT macro constant should be used instead of GMAC_INT_DISABLE_PMT to check the PMT IRQs status. Finally it's strange that the problem hasn't been discovered before, but it is most likely wrong to initialized Tx/Rx DMA descriptors, and then clean them up. That specifically concerns the Tx DMA descriptors initialization procedure in the Chain-mode. Please the patch for details. The patchset then proceed with multiple optimizations and cleanups performed here and there in the code: fix typo in the XGMAC_L3_ADDR3 macro name, discard unused mii_irq array from the private data, discard nothing changing Rx copybreak ethtool setting, discard redundant index variable usage in the dirty_rx initialization method, discard dwmac1000_dma_ops declaration from dwmac100.h, move DMA Tx/Rx init methods to the DW MAC lib since they match for DW MAC and DW GMA IP-cores, discard pointless STMMAC_RESETING flag, discard conditional service task execution since it's called from CMWQ anyway (it's also errors prone, since any event happening during the service task execution will be lost), add 'cause' arg to the service task executioner to generalize the deferred events handling interface. Finally in the framework of the code cleanup procedure we suggest to extend the stmmac_hw_teardown() functionality with all the necessary hardware cleanups, which for some reason were directly performed in the network device release callback. That concerns PTP clocks disabling, DMA channels and MAC Tx/Rx de-activation. Note the STMMAC driver is having much more weak design patterns and style problems (like calculating the total number of queues every time it's needed, or antagonist/cleanup methods absence while having the reversal code added in the remove/cleanup paths), than what is fixed in the framework of this series, which make the code hard to read, comprehend, maintain and extend with new features. Most likely the situation turned to be like that due to a long history of the driver evolving to support many different IP-core versions and vendor-specific MAC extensions. Anyway it would have taken not a single patches series to fix all of the problems. Since it hasn't been my primary target, here in this series I've introduced the cleanups and fixes, which prepared the corresponding parts of the code for easier alterations in the framework of adding the DW MAC GPIOs and Baikal-T1 GMAC support into the driver. The series is supposed to be applied on top of the last revision of the next patchset: Link: https://lore.kernel.org/netdev/20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru/ otherwise a few patches won't get merged in cleanly. Fixes: 7bac4e1ec3ca ("net: stmmac: stmmac interrupt treatment prepared for multiple queues") Fixes: 021bd5e36970 ("net: stmmac: Let TX and RX interrupts be independently enabled/disabled") Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru> Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru> Cc: Pavel Parkhomenko <Pavel.Parkhomenko@baikalelectronics.ru> Cc: Vyacheslav Mitrofanov <Vyacheslav.Mitrofanov@baikalelectronics.ru> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com> Cc: Russell King <linux@armlinux.org.uk> Cc: Andrew Lunn <andrew@lunn.ch> Cc: Heiner Kallweit <hkallweit1@gmail.com> Cc: netdev@vger.kernel.org Cc: linux-stm32@st-md-mailman.stormreply.com Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Serge Semin (20): net: phy: realtek: Fix events detection failure in LPI mode net: stmmac: Free Rx descs on Tx allocation failure net: stmmac: Fix false MTL RX overflow handling for higher queues net: stmmac: Assert reset control after MDIO de-registration net: stmmac: Use dwmac410_disable_dma_irq for DW MAC v4.10 DMA net: stmmac: Use LPI IRQ status-related macro in DW MAC1000 isr net: stmmac: Clear descriptors before initializing them net: stmmac: Fix typo in the XGMAC_L3_ADDR3 macro name net: stmmac: Discard mii_irq array from private data net: stmmac: Discard Rx copybreak ethtool setting net: stmmac: Discard index usage in the dirty_rx init net: stmmac: Discard dwmac1000_dma_ops declaration from dwmac100.h net: stmmac: Move DMA Tx/Rx init methods to DW MAC lib net: stmmac: Add DW GMAC disable LPI IRQ mask macro net: stmmac: Discard STMMAC_RESETING flag net: stmmac: Discard conditional service task execution net: stmmac: Add 'cause' arg to the service task executioner net: stmmac: Move PTP clock enabling to PTP-init method net: stmmac: Move DMA stop procedure to HW-setup antagonist net: stmmac: Move MAC Tx/Rx disabling to HW-setup antagonist .../net/ethernet/stmicro/stmmac/dwmac1000.h | 2 +- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 2 +- .../ethernet/stmicro/stmmac/dwmac1000_dma.c | 20 +---- .../ethernet/stmicro/stmmac/dwmac100_dma.c | 20 +---- .../net/ethernet/stmicro/stmmac/dwmac4_dma.c | 2 +- .../net/ethernet/stmicro/stmmac/dwmac_dma.h | 4 + .../net/ethernet/stmicro/stmmac/dwmac_lib.c | 14 ++++ .../net/ethernet/stmicro/stmmac/dwxgmac2.h | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 5 -- .../ethernet/stmicro/stmmac/stmmac_ethtool.c | 39 --------- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 81 +++++++++---------- drivers/net/phy/realtek.c | 37 +++++++++ 12 files changed, 102 insertions(+), 126 deletions(-)