From patchwork Mon Feb 8 13:55:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 12075591 Return-Path: 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=unavailable 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 30CBEC433E0 for ; Mon, 8 Feb 2021 14:11:14 +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 C1D3F64E6C for ; Mon, 8 Feb 2021 14:11:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C1D3F64E6C 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=quzKu2/EBw9R6cVRpZlDOjlKzlGeZd7BaZmUtXI19ps=; b=XfiVrUG10SAwjUmZa04oT91sqj rG2xmuFohnH6ixG0sO0ssfhi6XJlUaWyqPj/INgMId+6Fzk8zOXTuNWaAOhCmEv+/e2h2p5v7p+SW cl6FB1u123rDPLltIvGomNLri7rKEIPyKuSg80cLW+IrKZbzmZ9XFSzySYNXsROo31RgjTq8KQVjb 8N/1ri5+fSWvKz7qP+oTI6QOrxxMx0wAbGDZ21VOSv2tXeSLstn2kusLKoTRml7jpiVxDdDjQElIY raOTj5vhbz/ItAPWtLbI6ToQtp77O2CXau+U4I78dG/6n7sM6euPEM2O8OpR91SQt0XkU14HeRGVw 2UZ8t85Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l97EG-0005g6-HR; Mon, 08 Feb 2021 14:09:28 +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 1l97Au-00046j-BG for linux-arm-kernel@lists.infradead.org; Mon, 08 Feb 2021 14:06:05 +0000 From: Serge Semin To: Rob Herring , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Johan Hovold , Maxime Ripard , Joao Pinto , Lars Persson Subject: [PATCH v2 00/24] net: stmmac: Fix clocks/reset-related procedures Date: Mon, 8 Feb 2021 16:55:44 +0300 Message-ID: <20210208135609.7685-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_090603_673847_35E0AAC1 X-CRM114-Status: GOOD ( 24.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Serge Semin , Alexey Malahov , Serge Semin , Vyacheslav Mitrofanov , Pavel Parkhomenko , Maxime Coquelin , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Baikal-T1 SoC is equipped with two Synopsys DesignWare GMAC v3.73a-based ethernet interfaces with no internal Ethernet PHY attached. The IP-cores are configured as GMAC-AXI with CSR interface clocked by a dedicated signal. Each of which has got Rx/Tx FIFOs of 16KB, up to 8 MAC addresses capability, no embedded filter hash table logic, EEE enabled, IEEE 1588 and 1588-2008 Advanced timestamping capabilities, power management with remote wake-up, IP CSUM hardware acceleration, a single PHY interface - RGMII with MDIO bus, 1xGPI and 1xGPO. This is a very first series of patches with fixes we've found to be required in order to make things working well for our setup. The series has turned to be rather large, but most of the patches are trivial and some of them are just cleanups, so it shouldn't be that hard to review. The series starts with fixes of the PBL (Programmable DMA Burst length) DT-property, which is supposed to be defined for each DW *MAC IP-core, but not only for a Allwinner sun* GMAC and DW xGMAC. The number of possible PBL values need to be also extended in accordance with the DW *MAC manual. Then the TSO flag property should be also declared free of the vendor-specific conditional schema, because the driver expects the compatible string to have the IP-core version specified anyway and none of the glue-drivers refer to the property directly. Then we suggest to refactor the "snps,{axi,mtl-rx,mtl-tx}-config" properties/nodes declaration, so the configs would be able to be defined as the sub-nodes of the DW *MAC DT nodes. The reason is that the DW MAC DT-schema doesn't validate them at the moment and having them defined as separate from the DW MAC nodes isn't descriptive at all. (Please note the patch log, since the DT-schema tool needs to be fixed in order to make the change working). Another big modification of the DW *MAC bindings file is the generic DT-properties and generic DT-nodes schema splitting up. So in order to improve the DW *MAC bindings maintainability we suggest to leave the generic DW *MAC properties definition in the "snps,dwmac.yaml" file and move the bindings for the generic DW *MAC DT-nodes validation in the dedicated DT-schema "snps,dwmac-generic.yaml". Another concern has been related with the System/CSR clocks. We have discovered that currently the "stmmaceth" clocks are considered by the driver as the combined system+CSR clocks, while in fact CSR interface can be equipped with a dedicated clock source (this is our case). If so then the clock with "pclk" can be used to define the later one. But neither bindings are descriptive enough nor the DW *MAC driver is fixed to support that feature. So first we suggest to elaborate stmmaceth/pclk description in the bindings file and then fix the MDIO-bus clock selection procedure so pclk would be used there if specified. The DW QoS Eth MAC driver is also fixed in accordance with that modification. The biggest part of the series concerns adding the generic Tx/Rx clocks support to the DT-schema and to the DW MAC drivers and with fixed related to that. It is really a good decision to add the generic Tx/Rx clocks, because a lot of the glue-drivers expect them to be specified in the DT-node. So first we add the "tx"/"rx" clocks declaration in the generic DW MAC DT-schema. Then the glue-drivers like dwmac-rk/dwmac-sti/dwmac-stm32 remove() callbacks need to be fixed to call stmmac_remove_config_dt() otherwise the resources allocated in the stmmac_probe_config_dt() won't be freed on the device removal. A small modification needs to be provided for the cleanup-on-failure path of the stmmac_probe_config_dt() method in order to improve its maintainability. Then we've discovered that the "stmmaceth" and "pclk" clocks while being acquired and enabled in the stmmac_probe_config_dt() method are disabled in the stmmac_dvr_remove() function, which is erroneous for every cleanup-on-failure path of the glue-driver probe methods. Finally before adding the Tx/Rx clocks support we provide a set of optimizations of the "stmmaceth"/"pclk"/"ptp_clk" clocks and the "stmmaceth" reset procedures by removing the manual optional resources acquisition/enable/disable implementation with the one provided by the corresponding subsystems. Since the generic Tx/Rx clocks have been added we can freely remove the similar clocks handling from the glue-drivers. (Please note I have also discovered, but didn't try to fix the Allwinner Sun8i cleanup-on-failure path implemented in the DW MAC probe() procedure. It has been broken since don't know what time and it's a bit too complicated to be fixed with no hardware at hands.) That's it for now. The next series will concern the GPIOs support and Baikal-T1 SoC specific bindings. Link: https://lore.kernel.org/netdev/20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru Changelog v2: - Discard "snps" vendor-prefix from the new AXI/MTL-Tx/Rx config sub-nodes. - Add the new sub-nodes "axi-config", "mtl-rx-config" and "mtl-tx-config" to the DW *MAC bindings describing the nodes the now deprecated config-properties were supposed to refer to. - Fix invalid identation in the "snps,route-*" property settings. - Discard the patch [PATCH 15/25] net: stmmac: Use optional clock request method to get pclk since the corresponding functionality has already been integrated into the driver. - Rebase on top of the kernel 5.11-rc7. Fixes: d2ed0a7755fe ("net: ethernet: stmmac: fix of-node and fixed-link-phydev leaks") Fixes: f573c0b9c4e0 ("stmmac: move stmmac_clk, pclk, clk_ptp_ref and stmmac_rst to platform structure") Signed-off-by: Serge Semin Cc: Alexey Malahov Cc: Pavel Parkhomenko Cc: Vyacheslav Mitrofanov Cc: Maxime Coquelin Cc: netdev@vger.kernel.org Cc: linux-stm32@st-md-mailman.stormreply.com Cc: linux-arm-kernel@lists.infradead.org Cc: devicetree@vger.kernel.org Cc: linux-kernel@vger.kernel.org Serge Semin (24): dt-bindings: net: dwmac: Validate PBL for all IP-cores dt-bindings: net: dwmac: Extend number of PBL values dt-bindings: net: dwmac: Fix the TSO property declaration dt-bindings: net: dwmac: Refactor snps,*-config properties dt-bindings: net: dwmac: Elaborate stmmaceth/pclk description dt-bindings: net: dwmac: Add Tx/Rx clock sources dt-bindings: net: dwmac: Detach Generic DW MAC bindings net: stmmac: Add {axi,mtl-rx,mtl-tx}-config sub-nodes support net: stmmac: dwmac-rk: Cleanup STMMAC DT-config in remove cb net: stmmac: dwmac-sti: Cleanup STMMAC DT-config in remove cb net: stmmac: dwmac-stm32: Cleanup STMMAC DT-config in remove cb net: stmmac: Directly call reverse methods in stmmac_probe_config_dt() net: stmmac: Fix clocks left enabled on glue-probes failure net: stmmac: Use optional clock request method to get stmmaceth net: stmmac: Use optional clock request method to get ptp_clk net: stmmac: Use optional reset control API to work with stmmaceth net: stmmac: dwc-qos: Cleanup STMMAC platform data clock pointers net: stmmac: dwc-qos: Use dev_err_probe() for probe errors handling net: stmmac: Add Tx/Rx platform clocks support net: stmmac: dwc-qos: Discard Tx/Rx clocks request net: stmmac: dwmac-imx: Discard Tx clock request net: stmmac: Call stmmaceth clock as system clock in warn-message net: stmmac: Use pclk to set MDC clock frequency net: stmmac: dwc-qos: Save master/slave clocks in the plat-data .../bindings/net/snps,dwmac-generic.yaml | 154 +++++ .../devicetree/bindings/net/snps,dwmac.yaml | 578 ++++++++++-------- .../stmicro/stmmac/dwmac-dwc-qos-eth.c | 90 +-- .../net/ethernet/stmicro/stmmac/dwmac-imx.c | 21 +- .../net/ethernet/stmicro/stmmac/dwmac-intel.c | 2 + .../net/ethernet/stmicro/stmmac/dwmac-rk.c | 3 + .../net/ethernet/stmicro/stmmac/dwmac-sti.c | 3 + .../net/ethernet/stmicro/stmmac/dwmac-stm32.c | 2 + .../net/ethernet/stmicro/stmmac/stmmac_main.c | 31 +- .../ethernet/stmicro/stmmac/stmmac_platform.c | 85 ++- include/linux/stmmac.h | 2 + 11 files changed, 616 insertions(+), 355 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/snps,dwmac-generic.yaml