From patchwork Mon Dec 14 09:15:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 343634 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=-13.7 required=3.0 tests=BAYES_00, 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 7D43FC4361B for ; Mon, 14 Dec 2020 09:31:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 33B9622583 for ; Mon, 14 Dec 2020 09:31:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728352AbgLNJal (ORCPT ); Mon, 14 Dec 2020 04:30:41 -0500 Received: from ns2.baikalelectronics.ru ([94.125.187.42]:46158 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2407403AbgLNJRK (ORCPT ); Mon, 14 Dec 2020 04:17:10 -0500 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 CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , Maxime Coquelin , , , , , Subject: [PATCH 01/25] dt-bindings: net: dwmac: Validate PBL for all IP-cores Date: Mon, 14 Dec 2020 12:15:51 +0300 Message-ID: <20201214091616.13545-2-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> References: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Indeed the maximum DMA burst length can be programmed not only for DW xGMACs, Allwinner EMACs and Spear SoC GMAC, but in accordance with [1] for Generic DW *MAC IP-cores. Moreover the STMMAC set of drivers parse the property and then apply the configuration for all supported DW MAC devices. All of that makes the property being available for all IP-cores the bindings supports. Let's make sure the PBL-related properties are validated for all of them by the common DW MAC DT schema. [1] DesignWare Cores Ethernet MAC Universal Databook, Revision 3.73a, October 2013, p. 380. Signed-off-by: Serge Semin Reviewed-by: Rob Herring --- .../devicetree/bindings/net/snps,dwmac.yaml | 69 +++++++------------ 1 file changed, 26 insertions(+), 43 deletions(-) diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml index 11a6fdb657c9..4b672499f20d 100644 --- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml +++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml @@ -262,6 +262,32 @@ properties: is supported. For example, this is used in case of SGMII and MAC2MAC connection. + snps,pbl: + description: + Programmable Burst Length (tx and rx) + $ref: /schemas/types.yaml#definitions/uint32 + enum: [2, 4, 8] + + snps,txpbl: + description: + Tx Programmable Burst Length. If set, DMA tx will use this + value rather than snps,pbl. + $ref: /schemas/types.yaml#definitions/uint32 + enum: [2, 4, 8] + + snps,rxpbl: + description: + Rx Programmable Burst Length. If set, DMA rx will use this + value rather than snps,pbl. + $ref: /schemas/types.yaml#definitions/uint32 + enum: [2, 4, 8] + + snps,no-pbl-x8: + $ref: /schemas/types.yaml#definitions/flag + description: + Don\'t multiply the pbl/txpbl/rxpbl values by 8. For core + rev < 3.50, don\'t multiply the values by 4. + mdio: type: object description: @@ -287,49 +313,6 @@ dependencies: allOf: - $ref: "ethernet-controller.yaml#" - - if: - properties: - compatible: - contains: - enum: - - allwinner,sun7i-a20-gmac - - allwinner,sun8i-a83t-emac - - allwinner,sun8i-h3-emac - - allwinner,sun8i-r40-emac - - allwinner,sun8i-v3s-emac - - allwinner,sun50i-a64-emac - - snps,dwxgmac - - snps,dwxgmac-2.10 - - st,spear600-gmac - - then: - properties: - snps,pbl: - description: - Programmable Burst Length (tx and rx) - $ref: /schemas/types.yaml#definitions/uint32 - enum: [2, 4, 8] - - snps,txpbl: - description: - Tx Programmable Burst Length. If set, DMA tx will use this - value rather than snps,pbl. - $ref: /schemas/types.yaml#definitions/uint32 - enum: [2, 4, 8] - - snps,rxpbl: - description: - Rx Programmable Burst Length. If set, DMA rx will use this - value rather than snps,pbl. - $ref: /schemas/types.yaml#definitions/uint32 - enum: [2, 4, 8] - - snps,no-pbl-x8: - $ref: /schemas/types.yaml#definitions/flag - description: - Don\'t multiply the pbl/txpbl/rxpbl values by 8. For core - rev < 3.50, don\'t multiply the values by 4. - - if: properties: compatible: From patchwork Mon Dec 14 09:15:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 343646 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=-13.7 required=3.0 tests=BAYES_00, 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 3E871C4361B for ; Mon, 14 Dec 2020 09:17:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EEEBC207AE for ; Mon, 14 Dec 2020 09:17:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407408AbgLNJRK (ORCPT ); Mon, 14 Dec 2020 04:17:10 -0500 Received: from ns2.baikalelectronics.ru ([94.125.187.42]:46194 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726166AbgLNJRK (ORCPT ); Mon, 14 Dec 2020 04:17:10 -0500 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 CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , Maxime Coquelin , , , , , Subject: [PATCH 02/25] dt-bindings: net: dwmac: Extend number of PBL values Date: Mon, 14 Dec 2020 12:15:52 +0300 Message-ID: <20201214091616.13545-3-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> References: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org In accordance with [1] the permitted PBL values can be set as one of [1, 2, 4, 8, 16, 32]. The rest of the values results in undefined behavior. At the same time some of the permitted values can be also invalid depending on the controller FIFOs size and the data bus width. Seeing due to having too many variables all the possible PBL property constraints can't be implemented in the bindings schema, let's extend the set of permitted PBL values to be as much as the configuration register supports leaving the undefined behaviour cases for developers to handle. [1] DesignWare Cores Ethernet MAC Universal Databook, Revision 3.73a, October 2013, p. 380. Signed-off-by: Serge Semin Reviewed-by: Rob Herring --- Documentation/devicetree/bindings/net/snps,dwmac.yaml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml index 4b672499f20d..e084fbbf976e 100644 --- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml +++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml @@ -264,23 +264,26 @@ properties: snps,pbl: description: - Programmable Burst Length (tx and rx) + Programmable Burst Length (tx and rx). Note some of these values + can be still invalid due to HW limitations connected with the data + bus width and the FIFOs depth, so a total length of a single DMA + burst shouldn't exceed half the FIFO depth. $ref: /schemas/types.yaml#definitions/uint32 - enum: [2, 4, 8] + enum: [1, 2, 4, 8, 16, 32] snps,txpbl: description: Tx Programmable Burst Length. If set, DMA tx will use this value rather than snps,pbl. $ref: /schemas/types.yaml#definitions/uint32 - enum: [2, 4, 8] + enum: [1, 2, 4, 8, 16, 32] snps,rxpbl: description: Rx Programmable Burst Length. If set, DMA rx will use this value rather than snps,pbl. $ref: /schemas/types.yaml#definitions/uint32 - enum: [2, 4, 8] + enum: [1, 2, 4, 8, 16, 32] snps,no-pbl-x8: $ref: /schemas/types.yaml#definitions/flag From patchwork Mon Dec 14 09:15:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 343639 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=-13.7 required=3.0 tests=BAYES_00, 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 7F21DC2BBD5 for ; Mon, 14 Dec 2020 09:22:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2EA26207B0 for ; Mon, 14 Dec 2020 09:22:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439694AbgLNJSG (ORCPT ); Mon, 14 Dec 2020 04:18:06 -0500 Received: from mx.baikalchip.com ([94.125.187.42]:46514 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2439649AbgLNJRx (ORCPT ); Mon, 14 Dec 2020 04:17:53 -0500 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 CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , Maxime Coquelin , , , , , Subject: [PATCH 05/25] dt-bindings: net: dwmac: Elaborate stmmaceth/pclk description Date: Mon, 14 Dec 2020 12:15:55 +0300 Message-ID: <20201214091616.13545-6-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> References: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Current clocks description doesn't provide a comprehensive notion about what "stmmaceth" and "pclk" actually represent from the IP-core manual point of view. The bindings file states: stmmaceth - "GMAC main clock", apb - "Peripheral registers interface clock". It isn't that easy to understand what they actually mean especially seeing the DW *MAC manual operates with clock definitions like Application, System, Host, CSR, Transmit, Receive, etc clocks. Moreover the clocks usage in the driver doesn't shade a full light on their essence. What inferred from there is that the "stmmaceth" name has been assigned to the common clock, which feeds both system and CSR interfaces. But what about "apb"? The bindings defines it as the clock for "peripheral registers interface". So it's close to the CSR clock in the IP-core manual notation. If so then when "apb" clock is specified aside with the "stmmaceth", it represents a case when the DW *MAC is synthesized with CSR_SLV_CLK=y (separate system and CSR clocks). But even though the "apb" clock is requested in the MAC driver, the driver doesn't actually use it as a separate CSR clock where the IP-core manual requires. All of that makes me thinking that the case of separate system and CSR clocks isn't correctly implemented in the driver. Let's start with elaborating the clocks description so anyone reading the DW *MAC bindings file would understand that "stmmaceth" is the system clock and "pclk" is actually the CSR clock. Indeed in accordance with sheets depicted in [1]: system/application clock can be either of: hclk_i, aclk_i, clk_app_i; CSR clock can be either of: hclk_i, aclk_i, clk_app_i, clk_csr_i. (Most likely the similar definitions present in the others IP-core manuals.) So the CSR clock can be tied to the application clock considering the later as the main clock, but not the other way around. In case if there is only "stmmaceth" clock specified in a DT node, then it will be considered as a source of clocks for both application and CSR. But if "pclk" is also specified in the list of the device clocks, then it will be perceived as the separate CSR clock. [1] DesignWare Cores Ethernet MAC Universal Databook, Revision 3.73a, October 2013, p. 564. Signed-off-by: Serge Semin --- .../devicetree/bindings/net/snps,dwmac.yaml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml index 44aa88151cba..e1ebe5c8b1da 100644 --- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml +++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml @@ -116,8 +116,16 @@ properties: maxItems: 5 additionalItems: true items: - - description: GMAC main clock - - description: Peripheral registers interface clock + - description: + GMAC main clock, also called as system/application clock. + This clock is used to provide a periodic signal for the DMA/MTL + interface and optionally for CSR, if the later isn't separately + clocked. + - description: + Peripheral registers interface clock, also called as CSR clock. + MCI, CSR and SMA interfaces run on this clock. If it's omitted, + the CSR interfaces are considered as synchronous to the system + clock domain. - description: PTP reference clock. This clock is used for programming the Timestamp Addend Register. If not passed then the system From patchwork Mon Dec 14 09:15:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 343638 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=-13.7 required=3.0 tests=BAYES_00, 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 72E27C3526E for ; Mon, 14 Dec 2020 09:22:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3E007207A2 for ; Mon, 14 Dec 2020 09:22:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729422AbgLNJR5 (ORCPT ); Mon, 14 Dec 2020 04:17:57 -0500 Received: from ns2.baikalelectronics.ru ([94.125.187.42]:46512 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729478AbgLNJRw (ORCPT ); Mon, 14 Dec 2020 04:17:52 -0500 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 CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , Maxime Coquelin , , , , , Subject: [PATCH 06/25] dt-bindings: net: dwmac: Add Tx/Rx clock sources Date: Mon, 14 Dec 2020 12:15:56 +0300 Message-ID: <20201214091616.13545-7-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> References: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Generic DW *MAC can be connected to an external Tramit and Receive clock generators. Add the corresponding clocks description and clock-names to the generic bindings schema so new DW *MAC-based bindings wouldn't declare its own names of the same clocks. Signed-off-by: Serge Semin Reviewed-by: Rob Herring --- .../devicetree/bindings/net/snps,dwmac.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml index e1ebe5c8b1da..74820f491346 100644 --- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml +++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml @@ -126,6 +126,18 @@ properties: MCI, CSR and SMA interfaces run on this clock. If it's omitted, the CSR interfaces are considered as synchronous to the system clock domain. + - description: + GMAC Tx clock or so called Transmit clock. The clock is supplied + by an external with respect to the DW MAC clock generator. + The clock source and its frequency depends on the DW MAC xMII mode. + In case if it's supplied by PHY/SerDes this property can be + omitted. + - description: + GMAC Rx clock or so called Receive clock. The clock is supplied + by an external with respect to the DW MAC clock generator. + The clock source and its frequency depends on the DW MAC xMII mode. + In case if it's supplied by PHY/SerDes or it's synchronous to + the Tx clock this property can be omitted. - description: PTP reference clock. This clock is used for programming the Timestamp Addend Register. If not passed then the system @@ -139,6 +151,8 @@ properties: enum: - stmmaceth - pclk + - tx + - rx - ptp_ref resets: From patchwork Mon Dec 14 09:16:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 343635 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=-13.7 required=3.0 tests=BAYES_00, 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 C7F41C4361B for ; Mon, 14 Dec 2020 09:29:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9A67722AAA for ; Mon, 14 Dec 2020 09:29:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732432AbgLNJW3 (ORCPT ); Mon, 14 Dec 2020 04:22:29 -0500 Received: from mx.baikalchip.ru ([94.125.187.42]:46520 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S2439674AbgLNJR7 (ORCPT ); Mon, 14 Dec 2020 04:17:59 -0500 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 , Maxime Coquelin CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , , , , , Subject: [PATCH 10/25] net: stmmac: dwmac-sti: Cleanup STMMAC DT-config in remove cb Date: Mon, 14 Dec 2020 12:16:00 +0300 Message-ID: <20201214091616.13545-11-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> References: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The stmmac_remove_config_dt() method needs to be called on the device remove procedure otherwise for at least some of device-nodes will be left requested. Fixes: d2ed0a7755fe ("net: ethernet: stmmac: fix of-node and fixed-link-phydev leaks") Signed-off-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c index e1b63df6f96f..3454c5eff822 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c @@ -370,11 +370,14 @@ static int sti_dwmac_probe(struct platform_device *pdev) static int sti_dwmac_remove(struct platform_device *pdev) { + struct stmmac_priv *priv = netdev_priv(platform_get_drvdata(pdev)); struct sti_dwmac *dwmac = get_stmmac_bsp_priv(&pdev->dev); int ret = stmmac_dvr_remove(&pdev->dev); clk_disable_unprepare(dwmac->clk); + stmmac_remove_config_dt(pdev, priv->plat); + return ret; } From patchwork Mon Dec 14 09:16:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 343640 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=-13.7 required=3.0 tests=BAYES_00, 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 D269CC3526A for ; Mon, 14 Dec 2020 09:22:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B1B4722B37 for ; Mon, 14 Dec 2020 09:22:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439686AbgLNJSF (ORCPT ); Mon, 14 Dec 2020 04:18:05 -0500 Received: from ns2.chip.baikal.ru ([94.125.187.42]:46526 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2439654AbgLNJRz (ORCPT ); Mon, 14 Dec 2020 04:17:55 -0500 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 , Maxime Coquelin CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , , , , , Subject: [PATCH 11/25] net: stmmac: dwmac-stm32: Cleanup STMMAC DT-config in remove cb Date: Mon, 14 Dec 2020 12:16:01 +0300 Message-ID: <20201214091616.13545-12-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> References: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The stmmac_remove_config_dt() method needs to be called on the device remove procedure otherwise for at least some of device-nodes will be left requested. Fixes: d2ed0a7755fe ("net: ethernet: stmmac: fix of-node and fixed-link-phydev leaks") Signed-off-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c index 5d4df4c5254e..b45aab38c7b0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c @@ -426,6 +426,8 @@ static int stm32_dwmac_remove(struct platform_device *pdev) stm32_dwmac_clk_disable(priv->plat->bsp_priv); + stmmac_remove_config_dt(pdev, priv->plat); + if (dwmac->irq_pwr_wakeup >= 0) { dev_pm_clear_wake_irq(&pdev->dev); device_init_wakeup(&pdev->dev, false); From patchwork Mon Dec 14 09:16:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 343641 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=-13.7 required=3.0 tests=BAYES_00, 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 11F37C2BBCA for ; Mon, 14 Dec 2020 09:22:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CB369207A2 for ; Mon, 14 Dec 2020 09:22:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439712AbgLNJSI (ORCPT ); Mon, 14 Dec 2020 04:18:08 -0500 Received: from ns2.baikalchip.ru ([94.125.187.42]:46524 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S2439675AbgLNJSB (ORCPT ); Mon, 14 Dec 2020 04:18:01 -0500 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 , Maxime Coquelin CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , , , , , Subject: [PATCH 12/25] net: stmmac: Directly call reverse methods in stmmac_probe_config_dt() Date: Mon, 14 Dec 2020 12:16:02 +0300 Message-ID: <20201214091616.13545-13-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> References: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Calling an antagonistic method from the corresponding protagonist isn't good from maintainability point of view, since prevents us from directly adding a functionality in the later, which needs to be reverted in the former. Since that's what we are about to do in order to fix the commit 573c0b9c4e0 ("stmmac: move stmmac_clk, pclk, clk_ptp_ref and stmmac_rst to platform structure"), let's replace the stmmac_remove_config_dt() method invocation in stmmac_probe_config_dt() with direct reversal procedures. Fixes: f573c0b9c4e0 ("stmmac: move stmmac_clk, pclk, clk_ptp_ref and stmmac_rst to platform structure") Signed-off-by: Serge Semin --- .../ethernet/stmicro/stmmac/stmmac_platform.c | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index b4720e477d90..5110545090d2 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -457,7 +457,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) /* To Configure PHY by using all device-tree supported properties */ rc = stmmac_dt_phy(plat, np, &pdev->dev); if (rc) - return ERR_PTR(rc); + goto error_dt_phy_parse; of_property_read_u32(np, "tx-fifo-depth", &plat->tx_fifo_size); @@ -535,8 +535,8 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*dma_cfg), GFP_KERNEL); if (!dma_cfg) { - stmmac_remove_config_dt(pdev, plat); - return ERR_PTR(-ENOMEM); + rc = -ENOMEM; + goto error_dma_cfg_alloc; } plat->dma_cfg = dma_cfg; @@ -563,10 +563,8 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) plat->axi = stmmac_axi_setup(pdev); rc = stmmac_mtl_setup(pdev, plat); - if (rc) { - stmmac_remove_config_dt(pdev, plat); - return ERR_PTR(rc); - } + if (rc) + goto error_dma_cfg_alloc; /* clock setup */ if (!of_device_is_compatible(np, "snps,dwc-qos-ethernet-4.10")) { @@ -581,8 +579,10 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) plat->pclk = devm_clk_get(&pdev->dev, "pclk"); if (IS_ERR(plat->pclk)) { - if (PTR_ERR(plat->pclk) == -EPROBE_DEFER) + if (PTR_ERR(plat->pclk) == -EPROBE_DEFER) { + rc = PTR_ERR(plat->pclk); goto error_pclk_get; + } plat->pclk = NULL; } @@ -602,8 +602,10 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) plat->stmmac_rst = devm_reset_control_get(&pdev->dev, STMMAC_RESOURCE_NAME); if (IS_ERR(plat->stmmac_rst)) { - if (PTR_ERR(plat->stmmac_rst) == -EPROBE_DEFER) + if (PTR_ERR(plat->stmmac_rst) == -EPROBE_DEFER) { + rc = PTR_ERR(plat->stmmac_rst); goto error_hw_init; + } dev_info(&pdev->dev, "no reset control found\n"); plat->stmmac_rst = NULL; @@ -615,8 +617,12 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) clk_disable_unprepare(plat->pclk); error_pclk_get: clk_disable_unprepare(plat->stmmac_clk); +error_dma_cfg_alloc: + of_node_put(plat->mdio_node); +error_dt_phy_parse: + of_node_put(plat->phy_node); - return ERR_PTR(-EPROBE_DEFER); + return ERR_PTR(rc); } /** From patchwork Mon Dec 14 09:16:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 343642 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=-13.7 required=3.0 tests=BAYES_00, 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 98C83C2BB40 for ; Mon, 14 Dec 2020 09:22:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 566AD22B3B for ; Mon, 14 Dec 2020 09:22:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439755AbgLNJSO (ORCPT ); Mon, 14 Dec 2020 04:18:14 -0500 Received: from ns2.baikalelectronics.ru ([94.125.187.42]:46512 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2439725AbgLNJSM (ORCPT ); Mon, 14 Dec 2020 04:18:12 -0500 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 , Maxime Coquelin CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , , , , , Subject: [PATCH 16/25] net: stmmac: Use optional clock request method to get ptp_clk Date: Mon, 14 Dec 2020 12:16:06 +0300 Message-ID: <20201214091616.13545-17-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> References: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Let's replace the manual implementation of the optional ptp_clk functionality with method devm_clk_get_optional() provided by the common clock kernel framework. First of all it will be better from maintainability point of view. Secondly by doing so we'll also fix a potential problem, which will come out if the PTP clock has been actually specified, but the clock framework failed to request it. Note since we are switching the code to using the optional common clock API, then there is no need in checking the clk_ptp_ref pointer for being not NULL before calling the clk_prepare_enable() method. The later will correctly handle it. So just discard the conditional statement of priv->plat->clk_ptp_ref pointer value testing in the stmmac_resume() method. Signed-off-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 +-- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 13681027dd09..e9003684efc8 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -5230,8 +5230,7 @@ int stmmac_resume(struct device *dev) /* enable the clk previously disabled */ clk_prepare_enable(priv->plat->stmmac_clk); clk_prepare_enable(priv->plat->pclk); - if (priv->plat->clk_ptp_ref) - clk_prepare_enable(priv->plat->clk_ptp_ref); + clk_prepare_enable(priv->plat->clk_ptp_ref); /* reset the phy so that it's ready */ if (priv->mii) stmmac_mdio_reset(priv->mii); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index 3809b00d3077..367d1458d66d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -589,10 +589,13 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) clk_prepare_enable(plat->pclk); /* Fall-back to main clock in case of no PTP ref is passed */ - plat->clk_ptp_ref = devm_clk_get(&pdev->dev, "ptp_ref"); + plat->clk_ptp_ref = devm_clk_get_optional(&pdev->dev, "ptp_ref"); if (IS_ERR(plat->clk_ptp_ref)) { + rc = PTR_ERR(plat->clk_ptp_ref); + dev_err_probe(&pdev->dev, rc, "Cannot get PTP clock\n"); + goto error_hw_init; + } else if (!plat->clk_ptp_ref) { plat->clk_ptp_rate = clk_get_rate(plat->stmmac_clk); - plat->clk_ptp_ref = NULL; dev_info(&pdev->dev, "PTP uses main clock\n"); } else { plat->clk_ptp_rate = clk_get_rate(plat->clk_ptp_ref); From patchwork Mon Dec 14 09:16:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 343644 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=-13.7 required=3.0 tests=BAYES_00, 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 26034C1B0D8 for ; Mon, 14 Dec 2020 09:20:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DBEE5207B0 for ; Mon, 14 Dec 2020 09:20:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439818AbgLNJSk (ORCPT ); Mon, 14 Dec 2020 04:18:40 -0500 Received: from mx.baikalelectronics.com ([94.125.187.42]:46532 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728732AbgLNJSh (ORCPT ); Mon, 14 Dec 2020 04:18:37 -0500 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 , Maxime Coquelin CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , , , , , Subject: [PATCH 17/25] net: stmmac: Use optional reset control API to work with stmmaceth Date: Mon, 14 Dec 2020 12:16:07 +0300 Message-ID: <20201214091616.13545-18-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> References: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Replace the manual implementation of the optional device reset control functionality with using the devm_reset_control_get_optional() method in order to improve the code maintainability and fix a potential bug. It will come out if the reset control handler has been specified, but the reset framework failed to request it. Note there is no need in checking the priv->plat->stmmac_rst pointer for being not NULL in order to perform the reset control assertion/deassertion because the passed NULL will be considered by the reset framework as absent optional reset control handler anyway. Signed-off-by: Serge Semin --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 19 ++++++++----------- .../ethernet/stmicro/stmmac/stmmac_platform.c | 14 +++++--------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index e9003684efc8..7f4d54d2fc72 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -4889,15 +4889,13 @@ int stmmac_dvr_probe(struct device *device, if ((phyaddr >= 0) && (phyaddr <= 31)) priv->plat->phy_addr = phyaddr; - if (priv->plat->stmmac_rst) { - ret = reset_control_assert(priv->plat->stmmac_rst); - reset_control_deassert(priv->plat->stmmac_rst); - /* Some reset controllers have only reset callback instead of - * assert + deassert callbacks pair. - */ - if (ret == -ENOTSUPP) - reset_control_reset(priv->plat->stmmac_rst); - } + ret = reset_control_assert(priv->plat->stmmac_rst); + reset_control_deassert(priv->plat->stmmac_rst); + /* Some reset controllers have only reset callback instead of + * assert + deassert callbacks pair. + */ + if (ret == -ENOTSUPP) + reset_control_reset(priv->plat->stmmac_rst); /* Init MAC and get the capabilities */ ret = stmmac_hw_init(priv); @@ -5101,8 +5099,7 @@ int stmmac_dvr_remove(struct device *dev) stmmac_exit_fs(ndev); #endif phylink_destroy(priv->phylink); - if (priv->plat->stmmac_rst) - reset_control_assert(priv->plat->stmmac_rst); + reset_control_assert(priv->plat->stmmac_rst); if (priv->hw->pcs != STMMAC_PCS_TBI && priv->hw->pcs != STMMAC_PCS_RTBI) stmmac_mdio_unregister(ndev); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index 367d1458d66d..38e8836861c4 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -602,16 +602,12 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) dev_dbg(&pdev->dev, "PTP rate %d\n", plat->clk_ptp_rate); } - plat->stmmac_rst = devm_reset_control_get(&pdev->dev, - STMMAC_RESOURCE_NAME); + plat->stmmac_rst = devm_reset_control_get_optional(&pdev->dev, + STMMAC_RESOURCE_NAME); if (IS_ERR(plat->stmmac_rst)) { - if (PTR_ERR(plat->stmmac_rst) == -EPROBE_DEFER) { - rc = PTR_ERR(plat->stmmac_rst); - goto error_hw_init; - } - - dev_info(&pdev->dev, "no reset control found\n"); - plat->stmmac_rst = NULL; + rc = PTR_ERR(plat->stmmac_rst); + dev_err_probe(&pdev->dev, rc, "Cannot get reset control\n"); + goto error_hw_init; } return plat; From patchwork Mon Dec 14 09:16:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 343643 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=-13.7 required=3.0 tests=BAYES_00, 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 86F58C1B0E3 for ; Mon, 14 Dec 2020 09:21:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3D0F1207A2 for ; Mon, 14 Dec 2020 09:21:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728243AbgLNJUy (ORCPT ); Mon, 14 Dec 2020 04:20:54 -0500 Received: from ns2.baikalchip.com ([94.125.187.42]:46536 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2439807AbgLNJSh (ORCPT ); Mon, 14 Dec 2020 04:18:37 -0500 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 , Maxime Coquelin CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , , , , , , Anson Huang Subject: [PATCH 19/25] net: stmmac: dwc-qos: Use dev_err_probe() for probe errors handling Date: Mon, 14 Dec 2020 12:16:09 +0300 Message-ID: <20201214091616.13545-20-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> References: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org There is a very handy dev_err_probe() method to handle the deferred probe error number. It reduces the code size, uniforms error handling, records the defer probe reason, etc. Use it to print the probe callback error message. Signed-off-by: Serge Semin Cc: Anson Huang --- drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c index 31ca299a1cfd..57f957898b60 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c @@ -473,11 +473,8 @@ static int dwc_eth_dwmac_probe(struct platform_device *pdev) priv = data->probe(pdev, plat_dat, &stmmac_res); if (IS_ERR(priv)) { ret = PTR_ERR(priv); - - if (ret != -EPROBE_DEFER) - dev_err(&pdev->dev, "failed to probe subdriver: %d\n", - ret); - + dev_err_probe(&pdev->dev, ret, "failed to probe subdriver: %d\n", + ret); goto remove_config; } From patchwork Mon Dec 14 09:16:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 343637 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=-13.7 required=3.0 tests=BAYES_00, 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 D0B4DC1B0E3 for ; Mon, 14 Dec 2020 09:29:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7BDC222AAA for ; Mon, 14 Dec 2020 09:29:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407566AbgLNJWd (ORCPT ); Mon, 14 Dec 2020 04:22:33 -0500 Received: from ns2.baikalelectronics.com ([94.125.187.42]:46530 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2439736AbgLNJSQ (ORCPT ); Mon, 14 Dec 2020 04:18:16 -0500 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 , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Maxime Coquelin CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , , , , , Subject: [PATCH 22/25] net: stmmac: dwmac-imx: Discard Tx clock request Date: Mon, 14 Dec 2020 12:16:12 +0300 Message-ID: <20201214091616.13545-23-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> References: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Since the Tx clock is now requested and enabled/disabled in the STMMAC DT-based platform config method, there is no need in duplicating the same procedures in the DW MAC iMX sub-driver. Signed-off-by: Serge Semin --- .../net/ethernet/stmicro/stmmac/dwmac-imx.c | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c index efef5476a577..7b4590670b4e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c @@ -40,7 +40,6 @@ struct imx_dwmac_ops { struct imx_priv_data { struct device *dev; - struct clk *clk_tx; struct clk *clk_mem; struct regmap *intf_regmap; u32 intf_reg_off; @@ -104,12 +103,6 @@ static int imx_dwmac_init(struct platform_device *pdev, void *priv) return ret; } - ret = clk_prepare_enable(dwmac->clk_tx); - if (ret) { - dev_err(&pdev->dev, "tx clock enable failed\n"); - goto clk_tx_en_failed; - } - if (dwmac->ops->set_intf_mode) { ret = dwmac->ops->set_intf_mode(plat_dat); if (ret) @@ -119,8 +112,6 @@ static int imx_dwmac_init(struct platform_device *pdev, void *priv) return 0; intf_mode_failed: - clk_disable_unprepare(dwmac->clk_tx); -clk_tx_en_failed: clk_disable_unprepare(dwmac->clk_mem); return ret; } @@ -129,7 +120,6 @@ static void imx_dwmac_exit(struct platform_device *pdev, void *priv) { struct imx_priv_data *dwmac = priv; - clk_disable_unprepare(dwmac->clk_tx); clk_disable_unprepare(dwmac->clk_mem); } @@ -162,7 +152,7 @@ static void imx_dwmac_fix_speed(void *priv, unsigned int speed) return; } - err = clk_set_rate(dwmac->clk_tx, rate); + err = clk_set_rate(plat_dat->tx_clk, rate); if (err < 0) dev_err(dwmac->dev, "failed to set tx rate %lu\n", rate); } @@ -176,10 +166,9 @@ imx_dwmac_parse_dt(struct imx_priv_data *dwmac, struct device *dev) if (of_get_property(np, "snps,rmii_refclk_ext", NULL)) dwmac->rmii_refclk_ext = true; - dwmac->clk_tx = devm_clk_get(dev, "tx"); - if (IS_ERR(dwmac->clk_tx)) { - dev_err(dev, "failed to get tx clock\n"); - return PTR_ERR(dwmac->clk_tx); + if (!dwmac->plat_dat->tx_clk) { + dev_err(dev, "no tx clock found\n"); + return -EINVAL; } dwmac->clk_mem = NULL; @@ -239,6 +228,7 @@ static int imx_dwmac_probe(struct platform_device *pdev) dwmac->ops = data; dwmac->dev = &pdev->dev; + dwmac->plat_dat = plat_dat; ret = imx_dwmac_parse_dt(dwmac, &pdev->dev); if (ret) { @@ -257,7 +247,6 @@ static int imx_dwmac_probe(struct platform_device *pdev) plat_dat->exit = imx_dwmac_exit; plat_dat->fix_mac_speed = imx_dwmac_fix_speed; plat_dat->bsp_priv = dwmac; - dwmac->plat_dat = plat_dat; ret = imx_dwmac_init(pdev, dwmac); if (ret) From patchwork Mon Dec 14 09:16:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 343636 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=-13.7 required=3.0 tests=BAYES_00, 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 A1642C2BB40 for ; Mon, 14 Dec 2020 09:29:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6598822AAA for ; Mon, 14 Dec 2020 09:29:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407328AbgLNJWb (ORCPT ); Mon, 14 Dec 2020 04:22:31 -0500 Received: from mx.baikalelectronics.com ([94.125.187.42]:46522 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2439741AbgLNJSO (ORCPT ); Mon, 14 Dec 2020 04:18:14 -0500 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 , Maxime Coquelin CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , , , , , Subject: [PATCH 25/25] net: stmmac: dwc-qos: Save master/slave clocks in the plat-data Date: Mon, 14 Dec 2020 12:16:15 +0300 Message-ID: <20201214091616.13545-26-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> References: <20201214091616.13545-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Currently the "master_bus" clock of the DW QoS Eth controller isn't preserved in the STMMAC platform data, while the "slave_bus" clock is assigned to the stmmaceth clock pointer. It isn't correct from the platform clock bindings point of view. The "stmmaceth" clock is supposed to be the system clock, which is responsible for clocking the DMA transfers from/to the controller FIFOs to/from the system memory and the CSR interface if the later isn't separately clocked. If it's clocked separately then the STMMAC platform code expects to also have "pclk" specified. So in order to have the STMMAC platform data properly initialized we need to set the "master_bus" clock handler to the "stmmaceth" clock pointer, and the "slave_bus" clock handler to the "pclk" clock pointer. Signed-off-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c index f53a78448988..b90d7e4c3d4a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c @@ -315,6 +315,8 @@ static void *tegra_eqos_probe(struct platform_device *pdev, if (err < 0) goto error; + data->stmmac_clk = eqos->clk_master; + eqos->clk_slave = devm_clk_get(&pdev->dev, "slave_bus"); if (IS_ERR(eqos->clk_slave)) { err = PTR_ERR(eqos->clk_slave); @@ -325,7 +327,7 @@ static void *tegra_eqos_probe(struct platform_device *pdev, if (err < 0) goto disable_master; - data->stmmac_clk = eqos->clk_slave; + data->pclk = eqos->clk_slave; eqos->reset = devm_gpiod_get(&pdev->dev, "phy-reset", GPIOD_OUT_HIGH); if (IS_ERR(eqos->reset)) { @@ -375,9 +377,10 @@ static void *tegra_eqos_probe(struct platform_device *pdev, gpiod_set_value(eqos->reset, 1); disable_slave: clk_disable_unprepare(eqos->clk_slave); - data->stmmac_clk = NULL; + data->pclk = NULL; disable_master: clk_disable_unprepare(eqos->clk_master); + data->stmmac_clk = NULL; error: eqos = ERR_PTR(err); goto out; @@ -397,6 +400,7 @@ static int tegra_eqos_remove(struct platform_device *pdev) * data so the stmmac_remove_config_dt() method wouldn't have disabled * the clocks too. */ + priv->plat->pclk = NULL; priv->plat->stmmac_clk = NULL; return 0;