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: 343866 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 7D8F7C4361B for ; Mon, 14 Dec 2020 09:30:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 46B0A22AAA for ; Mon, 14 Dec 2020 09:30:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729417AbgLNJaw (ORCPT ); Mon, 14 Dec 2020 04:30:52 -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: netdev@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:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 343879 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 638E8C1B0D8 for ; Mon, 14 Dec 2020 09:18:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E39F7207AE for ; Mon, 14 Dec 2020 09:18:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407478AbgLNJRU (ORCPT ); Mon, 14 Dec 2020 04:17:20 -0500 Received: from mx.chip.baikal.ru ([94.125.187.42]:46234 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2407405AbgLNJRN (ORCPT ); Mon, 14 Dec 2020 04:17:13 -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 04/25] dt-bindings: net: dwmac: Refactor snps, *-config properties Date: Mon, 14 Dec 2020 12:15:54 +0300 Message-ID: <20201214091616.13545-5-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: netdev@vger.kernel.org Currently the "snps,axi-config", "snps,mtl-rx-config" and "snps,mtl-tx-config" properties are declared as a single phandle reference to a node with corresponding parameters defined. That's not good for several reasons. First of all scattering around a device tree some particular device-specific configs with no visual relation to that device isn't suitable from maintainability point of view. That leads to a disturbed representation of the actual device tree mixing actual device nodes and some vendor-specific configs. Secondly using the same configs set for several device nodes doesn't represent well the devices structure, since the interfaces these configs describe in hardware belong to different devices and may actually differ. In the later case having the configs node separated from the corresponding device nodes gets to be even unjustified. So instead of having a separate DW *MAC configs nodes we suggest to define them as sub-nodes of the device nodes, which interfaces they actually describe. By doing so we'll make the DW *MAC nodes visually correct describing all the aspects of the IP-core configuration. Thus we'll be able to describe the configs sub-nodes bindings right in the snps,dwmac.yaml file. Note the former "snps,axi-config", "snps,mtl-rx-config" and "snps,mtl-tx-config" bindings have been marked as deprecated. Signed-off-by: Serge Semin --- Note the current DT schema tool requires the vendor-specific properties to be defined in accordance with the schema: dtschema/meta-schemas/vendor-props.yaml It means the property can be; - boolean, - string, - defined with $ref and additional constraints, - defined with allOf: [ $ref ] and additional constraints. The modification provided by this commit needs to extend that definition to make the DT schema tool correctly parse this schema. That is we need to let the vendors-specific properties to also accept the oneOf-based combined sub-schema. Like this: --- a/dtschema/meta-schemas/vendor-props.yaml +++ b/dtschema/meta-schemas/vendor-props.yaml @@ -48,15 +48,24 @@ - properties: # A property with a type and additional constraints $ref: pattern: "types.yaml#[\/]{0,1}definitions\/.*" - allOf: - items: - - properties: + + if: + not: + required: + - $ref + then: + patternProperties: + "^(all|one)Of$": + contains: + properties: $ref: pattern: "types.yaml#[\/]{0,1}definitions\/.*" required: - $ref - oneOf: + + anyOf: - required: [ $ref ] - required: [ allOf ] + - required: [ oneOf ] ... --- .../devicetree/bindings/net/snps,dwmac.yaml | 380 +++++++++++++----- 1 file changed, 288 insertions(+), 92 deletions(-) diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml index 0dd543c6c08e..44aa88151cba 100644 --- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml +++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml @@ -150,69 +150,251 @@ properties: in a different mode than the PHY in order to function. snps,axi-config: - $ref: /schemas/types.yaml#definitions/phandle - description: - AXI BUS Mode parameters. Phandle to a node that can contain the - following properties - * snps,lpi_en, enable Low Power Interface - * snps,xit_frm, unlock on WoL - * snps,wr_osr_lmt, max write outstanding req. limit - * snps,rd_osr_lmt, max read outstanding req. limit - * snps,kbbe, do not cross 1KiB boundary. - * snps,blen, this is a vector of supported burst length. - * snps,fb, fixed-burst - * snps,mb, mixed-burst - * snps,rb, rebuild INCRx Burst + description: AXI BUS Mode parameters + oneOf: + - deprecated: true + $ref: /schemas/types.yaml#definitions/phandle + - type: object + properties: + snps,lpi_en: + $ref: /schemas/types.yaml#definitions/flag + description: Enable Low Power Interface + + snps,xit_frm: + $ref: /schemas/types.yaml#definitions/flag + description: Unlock on WoL + + snps,wr_osr_lmt: + $ref: /schemas/types.yaml#definitions/uint32 + description: Max write outstanding req. limit + default: 1 + minimum: 0 + maximum: 15 + + snps,rd_osr_lmt: + $ref: /schemas/types.yaml#definitions/uint32 + description: Max read outstanding req. limit + default: 1 + minimum: 0 + maximum: 15 + + snps,kbbe: + $ref: /schemas/types.yaml#definitions/flag + description: Do not cross 1KiB boundary + + snps,blen: + $ref: /schemas/types.yaml#definitions/uint32-array + description: A vector of supported burst lengths + minItems: 7 + maxItems: 7 + items: + enum: [256, 128, 64, 32, 16, 8, 4, 0] + + snps,fb: + $ref: /schemas/types.yaml#definitions/flag + description: Fixed-burst + + snps,mb: + $ref: /schemas/types.yaml#definitions/flag + description: Mixed-burst + + snps,rb: + $ref: /schemas/types.yaml#definitions/flag + description: Rebuild INCRx Burst + + additionalProperties: false snps,mtl-rx-config: - $ref: /schemas/types.yaml#definitions/phandle description: - Multiple RX Queues parameters. Phandle to a node that can - contain the following properties - * snps,rx-queues-to-use, number of RX queues to be used in the - driver - * Choose one of these RX scheduling algorithms - * snps,rx-sched-sp, Strict priority - * snps,rx-sched-wsp, Weighted Strict priority - * For each RX queue - * Choose one of these modes - * snps,dcb-algorithm, Queue to be enabled as DCB - * snps,avb-algorithm, Queue to be enabled as AVB - * snps,map-to-dma-channel, Channel to map - * Specifiy specific packet routing - * snps,route-avcp, AV Untagged Control packets - * snps,route-ptp, PTP Packets - * snps,route-dcbcp, DCB Control Packets - * snps,route-up, Untagged Packets - * snps,route-multi-broad, Multicast & Broadcast Packets - * snps,priority, RX queue priority (Range 0x0 to 0xF) + Multiple RX Queues parameters + oneOf: + - deprecated: true + $ref: /schemas/types.yaml#definitions/phandle + - type: object + properties: + snps,rx-queues-to-use: + $ref: /schemas/types.yaml#definitions/uint32 + description: Number of RX queues to be used in the driver + default: 1 + minimum: 1 + + patternProperties: + "^snps,rx-sched-(sp|wsp)$": + $ref: /schemas/types.yaml#definitions/flag + description: Strict/Weighted Strict RX scheduling priority + + "^queue[0-9]$": + type: object + description: Each RX Queue parameters + + properties: + snps,map-to-dma-channel: + $ref: /schemas/types.yaml#definitions/uint32 + description: DMA channel to map + + snps,priority: + $ref: /schemas/types.yaml#definitions/uint32 + description: RX queue priority + minimum: 0 + maximum: 15 + + patternProperties: + "^snps,(dcb|avb)-algorithm$": + $ref: /schemas/types.yaml#definitions/flag + description: Enable Queue as DCB/AVB + + "^snps,route-(avcp|ptp|dcbcp|up|multi-broad)$": + $ref: /schemas/types.yaml#definitions/flag + description: + AV Untagged/PTP/DCB Control/Untagged/Multicast & Broadcast + packets routing respectively. + + additionalProperties: false + + # Choose only one of the Queue modes and the packets routing + allOf: + - not: + required: + - snps,dcb-algorithm + - snps,avb-algorithm + - oneOf: + - required: + - snps,route-avcp + - required: + - snps,route-ptp + - required: + - snps,route-dcbcp + - required: + - snps,route-up + - required: + - snps,route-multi-broad + - not: + anyOf: + - required: + - snps,route-avcp + - required: + - snps,route-ptp + - required: + - snps,route-dcbcp + - required: + - snps,route-up + - required: + - snps,route-multi-broad + + additionalProperties: false + + # Choose one of the RX scheduling algorithms + not: + required: + - snps,rx-sched-sp + - snps,rx-sched-wsp snps,mtl-tx-config: - $ref: /schemas/types.yaml#definitions/phandle description: - Multiple TX Queues parameters. Phandle to a node that can - contain the following properties - * snps,tx-queues-to-use, number of TX queues to be used in the - driver - * Choose one of these TX scheduling algorithms - * snps,tx-sched-wrr, Weighted Round Robin - * snps,tx-sched-wfq, Weighted Fair Queuing - * snps,tx-sched-dwrr, Deficit Weighted Round Robin - * snps,tx-sched-sp, Strict priority - * For each TX queue - * snps,weight, TX queue weight (if using a DCB weight - algorithm) - * Choose one of these modes - * snps,dcb-algorithm, TX queue will be working in DCB - * snps,avb-algorithm, TX queue will be working in AVB - [Attention] Queue 0 is reserved for legacy traffic - and so no AVB is available in this queue. - * Configure Credit Base Shaper (if AVB Mode selected) - * snps,send_slope, enable Low Power Interface - * snps,idle_slope, unlock on WoL - * snps,high_credit, max write outstanding req. limit - * snps,low_credit, max read outstanding req. limit - * snps,priority, TX queue priority (Range 0x0 to 0xF) + Multiple TX Queues parameters + oneOf: + - deprecated: true + $ref: /schemas/types.yaml#definitions/phandle + - type: object + properties: + snps,tx-queues-to-use: + $ref: /schemas/types.yaml#definitions/uint32 + description: Number of TX queues to be used in the driver + default: 1 + minimum: 1 + + patternProperties: + "^snps,tx-sched-(wrr|wfq|dwrr|sp)$": + $ref: /schemas/types.yaml#definitions/flag + description: + Weighted Round Robin, Weighted Fair Queuing, + Deficit Weighted Round Robin or Strict TX scheduling priority. + + "^queue[0-9]$": + type: object + description: Each TX Queue parameters + + properties: + snps,priority: + $ref: /schemas/types.yaml#definitions/uint32 + description: TX queue priority + minimum: 0 + maximum: 15 + + snps,weight: + $ref: /schemas/types.yaml#definitions/uint32 + description: TX queue weight (if using a DCB weight algorithm) + minimum: 0 + maximum: 0x1FFFFF + + snps,send_slope: + $ref: /schemas/types.yaml#definitions/uint32 + description: Enable Low Power Interface + minimum: 0 + maximum: 0x3FFF + + snps,idle_slope: + $ref: /schemas/types.yaml#definitions/uint32 + description: Unlock on WoL + minimum: 0 + maximum: 0x1FFFFF + + snps,high_credit: + $ref: /schemas/types.yaml#definitions/uint32 + description: Max write outstanding req. limit + minimum: 0 + maximum: 0x1FFFFFFF + + snps,low_credit: + $ref: /schemas/types.yaml#definitions/uint32 + description: Max read outstanding req. limit + minimum: 0 + maximum: 0x1FFFFFFF + + patternProperties: + "^snps,(dcb|avb)-algorithm$": + $ref: /schemas/types.yaml#definitions/flag + description: + Enable Queue as DCB/AVB. Note Queue 0 is reserved for legacy + traffic and so no AVB is available in this queue. + + additionalProperties: false + + # Choose only one of the Queue modes + not: + required: + - snps,dcb-algorithm + - snps,avb-algorithm + + # Credit Base Shaper is configurable for AVB Mode only + dependencies: + snps,send_slope: ["snps,avb-algorithm"] + snps,idle_slope: ["snps,avb-algorithm"] + snps,high_credit: ["snps,avb-algorithm"] + snps,low_credit: ["snps,avb-algorithm"] + + additionalProperties: false + + # Choose one of the TX scheduling algorithms + oneOf: + - required: + - snps,tx-sched-wrr + - required: + - snps,tx-sched-wfq + - required: + - snps,tx-sched-dwrr + - required: + - snps,tx-sched-sp + - not: + anyOf: + - required: + - snps,tx-sched-wrr + - required: + - snps,tx-sched-wfq + - required: + - snps,tx-sched-dwrr + - required: + - snps,tx-sched-sp snps,reset-gpio: deprecated: true @@ -342,41 +524,6 @@ additionalProperties: true examples: - | - stmmac_axi_setup: stmmac-axi-config { - snps,wr_osr_lmt = <0xf>; - snps,rd_osr_lmt = <0xf>; - snps,blen = <256 128 64 32 0 0 0>; - }; - - mtl_rx_setup: rx-queues-config { - snps,rx-queues-to-use = <1>; - snps,rx-sched-sp; - queue0 { - snps,dcb-algorithm; - snps,map-to-dma-channel = <0x0>; - snps,priority = <0x0>; - }; - }; - - mtl_tx_setup: tx-queues-config { - snps,tx-queues-to-use = <2>; - snps,tx-sched-wrr; - queue0 { - snps,weight = <0x10>; - snps,dcb-algorithm; - snps,priority = <0x0>; - }; - - queue1 { - snps,avb-algorithm; - snps,send_slope = <0x1000>; - snps,idle_slope = <0x1000>; - snps,high_credit = <0x3E800>; - snps,low_credit = <0xFFC18000>; - snps,priority = <0x1>; - }; - }; - gmac0: ethernet@e0800000 { compatible = "snps,dwxgmac-2.10", "snps,dwxgmac"; reg = <0xe0800000 0x8000>; @@ -404,6 +551,55 @@ examples: }; }; }; + - | + gmac1: ethernet@f8010000 { + compatible = "snps,dwmac-4.10a", "snps,dwmac"; + reg = <0xf8010000 0x4000>; + interrupts = <0 98 4>; + interrupt-names = "macirq"; + clock-names = "stmmaceth", "ptp_ref"; + clocks = <&clock 4>, <&clock 5>; + phy-mode = "rgmii"; + snps,txpbl = <8>; + snps,rxpbl = <2>; + snps,aal; + snps,tso; + + snps,axi-config { + snps,wr_osr_lmt = <0xf>; + snps,rd_osr_lmt = <0xf>; + snps,blen = <256 128 64 32 0 0 0>; + }; + + snps,mtl-rx-config { + snps,rx-queues-to-use = <1>; + snps,rx-sched-sp; + queue0 { + snps,dcb-algorithm; + snps,map-to-dma-channel = <0x0>; + snps,priority = <0x0>; + }; + }; + + snps,mtl-tx-config { + snps,tx-queues-to-use = <2>; + snps,tx-sched-wrr; + queue0 { + snps,weight = <0x10>; + snps,dcb-algorithm; + snps,priority = <0x0>; + }; + + queue1 { + snps,avb-algorithm; + snps,send_slope = <0x1000>; + snps,idle_slope = <0x1000>; + snps,high_credit = <0x3E800>; + snps,low_credit = <0xFFC18000>; + snps,priority = <0x1>; + }; + }; + }; # FIXME: We should set it, but it would report all the generic # properties as additional properties. 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: 343871 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 1928FC3526D 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 D073A22AED for ; Mon, 14 Dec 2020 09:22:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439691AbgLNJSF (ORCPT ); Mon, 14 Dec 2020 04:18:05 -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: netdev@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:15:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 343877 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=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 22565C2BB48 for ; Mon, 14 Dec 2020 09:18:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D815222AAA for ; Mon, 14 Dec 2020 09:18:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439778AbgLNJSY (ORCPT ); Mon, 14 Dec 2020 04:18:24 -0500 Received: from ns2.baikalchip.ru ([94.125.187.42]:46518 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S2439664AbgLNJSB (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 CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , Maxime Coquelin , , , , , Subject: [PATCH 07/25] dt-bindings: net: dwmac: Detach Generic DW MAC bindings Date: Mon, 14 Dec 2020 12:15:57 +0300 Message-ID: <20201214091616.13545-8-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: netdev@vger.kernel.org Currently the snps,dwmac.yaml DT bindings file is used for both DT nodes describing generic DW MAC devices and as DT schema with common properties to be evaluated against a vendor-specific DW MAC IP-cores. Due to such dual-purpose design the "compatible" property of the common DW MAC schema needs to contain the vendor-specific strings to successfully pass the schema evaluation in case if it's referenced from the vendor-specific DT bindings. That's a bad design from maintainability point of view, since adding/removing any DW MAC-based device bindings requires the common schema modification. In order to fix that let's detach the schema which provides the generic DW MAC DT nodes evaluation into a dedicated DT bindings file preserving the common DW MAC properties declaration in the snps,dwmac.yaml file. By doing so we'll still provide a common properties evaluation for each vendor-specific MAC bindings which refer to the common bindings file, while the generic DW MAC DT nodes will be checked against the new snps,dwmac-generic.yaml DT schema. Signed-off-by: Serge Semin --- .../bindings/net/snps,dwmac-generic.yaml | 148 ++++++++++++++++++ .../devicetree/bindings/net/snps,dwmac.yaml | 139 +--------------- 2 files changed, 149 insertions(+), 138 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/snps,dwmac-generic.yaml diff --git a/Documentation/devicetree/bindings/net/snps,dwmac-generic.yaml b/Documentation/devicetree/bindings/net/snps,dwmac-generic.yaml new file mode 100644 index 000000000000..f1b387911390 --- /dev/null +++ b/Documentation/devicetree/bindings/net/snps,dwmac-generic.yaml @@ -0,0 +1,148 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/snps,dwmac-generic.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Synopsys DesignWare Generic MAC Device Tree Bindings + +maintainers: + - Alexandre Torgue + - Giuseppe Cavallaro + - Jose Abreu + +# Select the DT nodes, which have got compatible strings either as just a +# single string with IP-core name optionally followed by the IP version or +# two strings: one with IP-core name plus the IP version, another as just +# the IP-core name. +select: + properties: + compatible: + oneOf: + - items: + - pattern: "^snps,dw(xg)+mac(-[0-9]+\\.[0-9]+a?)?$" + - items: + - pattern: "^snps,dwmac-[0-9]+\\.[0-9]+a?$" + - const: snps,dwmac + - items: + - pattern: "^snps,dwxgmac-[0-9]+\\.[0-9]+a?$" + - const: snps,dwxgmac + + required: + - compatible + +allOf: + - $ref: snps,dwmac.yaml# + +properties: + compatible: + oneOf: + - description: Generic Synopsys DW MAC + oneOf: + - items: + - enum: + - snps,dwmac-3.50a + - snps,dwmac-3.610 + - snps,dwmac-3.70a + - snps,dwmac-3.710 + - snps,dwmac-4.00 + - snps,dwmac-4.10a + - snps,dwmac-4.20a + - const: snps,dwmac + - const: snps,dwmac + - description: Generic Synopsys DW xGMAC + oneOf: + - items: + - enum: + - snps,dwxgmac-2.10 + - const: snps,dwxgmac + - const: snps,dwxgmac + - description: ST SPEAr SoC Family GMAC + deprecated: true + const: st,spear600-gmac + + reg: + maxItems: 1 + +unevaluatedProperties: false + +examples: + - | + gmac0: ethernet@e0800000 { + compatible = "snps,dwxgmac-2.10", "snps,dwxgmac"; + reg = <0xe0800000 0x8000>; + interrupt-parent = <&vic1>; + interrupts = <24 23 22>; + interrupt-names = "macirq", "eth_wake_irq", "eth_lpi"; + mac-address = [000000000000]; /* Filled in by U-Boot */ + max-frame-size = <3800>; + phy-mode = "gmii"; + snps,multicast-filter-bins = <256>; + snps,perfect-filter-entries = <128>; + rx-fifo-depth = <16384>; + tx-fifo-depth = <16384>; + clocks = <&clock>; + clock-names = "stmmaceth"; + snps,axi-config = <&stmmac_axi_setup>; + snps,mtl-rx-config = <&mtl_rx_setup>; + snps,mtl-tx-config = <&mtl_tx_setup>; + mdio0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "snps,dwmac-mdio"; + phy1: ethernet-phy@0 { + reg = <0>; + }; + }; + }; + - | + gmac1: ethernet@f8010000 { + compatible = "snps,dwmac-4.10a", "snps,dwmac"; + reg = <0xf8010000 0x4000>; + interrupts = <0 98 4>; + interrupt-names = "macirq"; + clock-names = "stmmaceth", "ptp_ref"; + clocks = <&clock 4>, <&clock 5>; + phy-mode = "rgmii"; + snps,txpbl = <8>; + snps,rxpbl = <2>; + snps,aal; + snps,tso; + + snps,axi-config { + snps,wr_osr_lmt = <0xf>; + snps,rd_osr_lmt = <0xf>; + snps,blen = <256 128 64 32 0 0 0>; + }; + + snps,mtl-rx-config { + snps,rx-queues-to-use = <1>; + snps,rx-sched-sp; + queue0 { + snps,dcb-algorithm; + snps,map-to-dma-channel = <0x0>; + snps,priority = <0x0>; + }; + }; + + snps,mtl-tx-config { + snps,tx-queues-to-use = <2>; + snps,tx-sched-wrr; + + queue0 { + snps,weight = <0x10>; + snps,dcb-algorithm; + snps,priority = <0x0>; + }; + + queue1 { + snps,avb-algorithm; + snps,send_slope = <0x1000>; + snps,idle_slope = <0x1000>; + snps,high_credit = <0x3E800>; + snps,low_credit = <0x1FC18000>; + snps,priority = <0x1>; + }; + }; + }; +... diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml index 74820f491346..72b58f86bc41 100644 --- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml +++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml @@ -11,31 +11,7 @@ maintainers: - Giuseppe Cavallaro - Jose Abreu -# Select every compatible, including the deprecated ones. This way, we -# will be able to report a warning when we have that compatible, since -# we will validate the node thanks to the select, but won't report it -# as a valid value in the compatible property description -select: - properties: - compatible: - contains: - enum: - - snps,dwmac - - snps,dwmac-3.50a - - snps,dwmac-3.610 - - snps,dwmac-3.70a - - snps,dwmac-3.710 - - snps,dwmac-4.00 - - snps,dwmac-4.10a - - snps,dwmac-4.20a - - snps,dwxgmac - - snps,dwxgmac-2.10 - - # Deprecated - - st,spear600-gmac - - required: - - compatible +select: false allOf: - $ref: "ethernet-controller.yaml#" @@ -62,35 +38,6 @@ allOf: MAC HW capability register. properties: - - # We need to include all the compatibles from schemas that will - # include that schemas, otherwise compatible won't validate for - # those. - 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 - - amlogic,meson6-dwmac - - amlogic,meson8b-dwmac - - amlogic,meson8m2-dwmac - - amlogic,meson-gxbb-dwmac - - amlogic,meson-axg-dwmac - - snps,dwmac - - snps,dwmac-3.50a - - snps,dwmac-3.610 - - snps,dwmac-3.70a - - snps,dwmac-3.710 - - snps,dwmac-4.00 - - snps,dwmac-4.10a - - snps,dwmac-4.20a - - snps,dwxgmac - - snps,dwxgmac-2.10 - reg: minItems: 1 maxItems: 2 @@ -543,88 +490,4 @@ dependencies: snps,reset-delay-us: ["snps,reset-gpio"] additionalProperties: true - -examples: - - | - gmac0: ethernet@e0800000 { - compatible = "snps,dwxgmac-2.10", "snps,dwxgmac"; - reg = <0xe0800000 0x8000>; - interrupt-parent = <&vic1>; - interrupts = <24 23 22>; - interrupt-names = "macirq", "eth_wake_irq", "eth_lpi"; - mac-address = [000000000000]; /* Filled in by U-Boot */ - max-frame-size = <3800>; - phy-mode = "gmii"; - snps,multicast-filter-bins = <256>; - snps,perfect-filter-entries = <128>; - rx-fifo-depth = <16384>; - tx-fifo-depth = <16384>; - clocks = <&clock>; - clock-names = "stmmaceth"; - snps,axi-config = <&stmmac_axi_setup>; - snps,mtl-rx-config = <&mtl_rx_setup>; - snps,mtl-tx-config = <&mtl_tx_setup>; - mdio0 { - #address-cells = <1>; - #size-cells = <0>; - compatible = "snps,dwmac-mdio"; - phy1: ethernet-phy@0 { - reg = <0>; - }; - }; - }; - - | - gmac1: ethernet@f8010000 { - compatible = "snps,dwmac-4.10a", "snps,dwmac"; - reg = <0xf8010000 0x4000>; - interrupts = <0 98 4>; - interrupt-names = "macirq"; - clock-names = "stmmaceth", "ptp_ref"; - clocks = <&clock 4>, <&clock 5>; - phy-mode = "rgmii"; - snps,txpbl = <8>; - snps,rxpbl = <2>; - snps,aal; - snps,tso; - - snps,axi-config { - snps,wr_osr_lmt = <0xf>; - snps,rd_osr_lmt = <0xf>; - snps,blen = <256 128 64 32 0 0 0>; - }; - - snps,mtl-rx-config { - snps,rx-queues-to-use = <1>; - snps,rx-sched-sp; - queue0 { - snps,dcb-algorithm; - snps,map-to-dma-channel = <0x0>; - snps,priority = <0x0>; - }; - }; - - snps,mtl-tx-config { - snps,tx-queues-to-use = <2>; - snps,tx-sched-wrr; - queue0 { - snps,weight = <0x10>; - snps,dcb-algorithm; - snps,priority = <0x0>; - }; - - queue1 { - snps,avb-algorithm; - snps,send_slope = <0x1000>; - snps,idle_slope = <0x1000>; - snps,high_credit = <0x3E800>; - snps,low_credit = <0xFFC18000>; - snps,priority = <0x1>; - }; - }; - }; - -# FIXME: We should set it, but it would report all the generic -# properties as additional properties. -# additionalProperties: false - ... From patchwork Mon Dec 14 09:15:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 343870 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=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 D6E62C1B0E3 for ; Mon, 14 Dec 2020 09:22:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9657122B3B for ; Mon, 14 Dec 2020 09:22:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392438AbgLNJWb (ORCPT ); Mon, 14 Dec 2020 04:22:31 -0500 Received: from mx.baikalchip.com ([94.125.187.42]:46516 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2439650AbgLNJRx (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 , Maxime Coquelin CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , , , , , Subject: [PATCH 08/25] net: stmmac: Add snps,*-config sub-nodes support Date: Mon, 14 Dec 2020 12:15:58 +0300 Message-ID: <20201214091616.13545-9-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: netdev@vger.kernel.org Currently the "snps,axi-config", "snps,mtl-rx-config" and "snps,mtl-tx-config" DT node properties are marked as deprecated when being defined as a phandle reference to a node with parameters. The new way of defining the DW MAC interfaces config is to add an eponymous sub-nodes to the DW MAC device DT node. Make sure the STMMAC driver supports it. Signed-off-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index af34a4cadbb0..b4720e477d90 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -95,7 +95,8 @@ static struct stmmac_axi *stmmac_axi_setup(struct platform_device *pdev) struct device_node *np; struct stmmac_axi *axi; - np = of_parse_phandle(pdev->dev.of_node, "snps,axi-config", 0); + np = of_parse_phandle(pdev->dev.of_node, "snps,axi-config", 0) ?: + of_get_child_by_name(pdev->dev.of_node, "snps,axi-config"); if (!np) return NULL; @@ -150,11 +151,13 @@ static int stmmac_mtl_setup(struct platform_device *pdev, plat->rx_queues_cfg[0].mode_to_use = MTL_QUEUE_DCB; plat->tx_queues_cfg[0].mode_to_use = MTL_QUEUE_DCB; - rx_node = of_parse_phandle(pdev->dev.of_node, "snps,mtl-rx-config", 0); + rx_node = of_parse_phandle(pdev->dev.of_node, "snps,mtl-rx-config", 0) ?: + of_get_child_by_name(pdev->dev.of_node, "snps,mtl-rx-config"); if (!rx_node) return ret; - tx_node = of_parse_phandle(pdev->dev.of_node, "snps,mtl-tx-config", 0); + tx_node = of_parse_phandle(pdev->dev.of_node, "snps,mtl-tx-config", 0) ?: + of_get_child_by_name(pdev->dev.of_node, "snps,mtl-tx-config"); if (!tx_node) { of_node_put(rx_node); return ret; From patchwork Mon Dec 14 09:15:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 343878 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=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 75D85C4361B for ; Mon, 14 Dec 2020 09:18:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 325C6207B0 for ; Mon, 14 Dec 2020 09:18:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439723AbgLNJSJ (ORCPT ); Mon, 14 Dec 2020 04:18:09 -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 S2439652AbgLNJRz (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 09/25] net: stmmac: dwmac-rk: Cleanup STMMAC DT-config in remove cb Date: Mon, 14 Dec 2020 12:15:59 +0300 Message-ID: <20201214091616.13545-10-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: netdev@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-rk.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c index 6ef30252bfe0..01c10ca80f1a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c @@ -1433,11 +1433,14 @@ static int rk_gmac_probe(struct platform_device *pdev) static int rk_gmac_remove(struct platform_device *pdev) { + struct stmmac_priv *priv = netdev_priv(platform_get_drvdata(pdev)); struct rk_priv_data *bsp_priv = get_stmmac_bsp_priv(&pdev->dev); int ret = stmmac_dvr_remove(&pdev->dev); rk_gmac_powerdown(bsp_priv); + 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: 343872 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 B3A2CC2BB48 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 7657E207A2 for ; Mon, 14 Dec 2020 09:22:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439746AbgLNJSN (ORCPT ); Mon, 14 Dec 2020 04:18:13 -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: netdev@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: 343873 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 0A483C2BB48 for ; Mon, 14 Dec 2020 09:21:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B695C207A2 for ; Mon, 14 Dec 2020 09:21:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439791AbgLNJS3 (ORCPT ); Mon, 14 Dec 2020 04:18:29 -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: netdev@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:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 343867 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 DC53BC1B0D8 for ; Mon, 14 Dec 2020 09:28:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 996A122AB0 for ; Mon, 14 Dec 2020 09:28:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389338AbgLNJW5 (ORCPT ); Mon, 14 Dec 2020 04:22:57 -0500 Received: from mx.baikalchip.com ([94.125.187.42]:46516 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2439715AbgLNJSL (ORCPT ); Mon, 14 Dec 2020 04:18:11 -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 15/25] net: stmmac: Use optional clock request method to get pclk Date: Mon, 14 Dec 2020 12:16:05 +0300 Message-ID: <20201214091616.13545-16-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: netdev@vger.kernel.org Let's replace the manual implementation of the optional "pclk" functionality with using devm_clk_get_optional(). By doing so we'll improve the code maintainability, and fix a hidden bug which will cause problems if the "pclk" clock has been actually passed to the device, but the clock framework failed to request it. Signed-off-by: Serge Semin --- .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index e79b3e3351a9..3809b00d3077 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -579,15 +579,13 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) clk_prepare_enable(plat->stmmac_clk); - plat->pclk = devm_clk_get(&pdev->dev, "pclk"); + plat->pclk = devm_clk_get_optional(&pdev->dev, "pclk"); if (IS_ERR(plat->pclk)) { - if (PTR_ERR(plat->pclk) == -EPROBE_DEFER) { - rc = PTR_ERR(plat->pclk); - goto error_pclk_get; - } - - plat->pclk = NULL; + rc = PTR_ERR(plat->pclk); + dev_err_probe(&pdev->dev, rc, "Cannot get CSR clock\n"); + goto error_pclk_get; } + clk_prepare_enable(plat->pclk); /* Fall-back to main clock in case of no PTP ref is passed */ 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: 343875 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 4BA86C1B0E3 for ; Mon, 14 Dec 2020 09:20:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 05156207B0 for ; Mon, 14 Dec 2020 09:20:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439840AbgLNJSn (ORCPT ); Mon, 14 Dec 2020 04:18:43 -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: netdev@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:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 343876 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 32425C1B0D8 for ; Mon, 14 Dec 2020 09:19:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D9CE1207A2 for ; Mon, 14 Dec 2020 09:19:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439868AbgLNJSz (ORCPT ); Mon, 14 Dec 2020 04:18:55 -0500 Received: from ns2.baikalchip.ru ([94.125.187.42]:46534 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S2439819AbgLNJSn (ORCPT ); Mon, 14 Dec 2020 04:18:43 -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 18/25] net: stmmac: dwc-qos: Cleanup STMMAC platform data clock pointers Date: Mon, 14 Dec 2020 12:16:08 +0300 Message-ID: <20201214091616.13545-19-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: netdev@vger.kernel.org The pointers need to be nullified otherwise the stmmac_remove_config_dt() method called after them being initialized will disable the clocks. That then will cause a WARN() backtrace being printed since the clocks would be also disabled in the locally defined remove method. Signed-off-by: Serge Semin --- .../stmicro/stmmac/dwmac-dwc-qos-eth.c | 42 ++++++++++++++----- 1 file changed, 32 insertions(+), 10 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 2342d497348e..31ca299a1cfd 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c @@ -123,39 +123,46 @@ static void *dwc_qos_probe(struct platform_device *pdev, struct plat_stmmacenet_data *plat_dat, struct stmmac_resources *stmmac_res) { + struct clk *clk; int err; - plat_dat->stmmac_clk = devm_clk_get(&pdev->dev, "apb_pclk"); - if (IS_ERR(plat_dat->stmmac_clk)) { + clk = devm_clk_get(&pdev->dev, "apb_pclk"); + if (IS_ERR(clk)) { dev_err(&pdev->dev, "apb_pclk clock not found.\n"); - return ERR_CAST(plat_dat->stmmac_clk); + return ERR_CAST(clk); } - err = clk_prepare_enable(plat_dat->stmmac_clk); + err = clk_prepare_enable(clk); if (err < 0) { dev_err(&pdev->dev, "failed to enable apb_pclk clock: %d\n", err); return ERR_PTR(err); } - plat_dat->pclk = devm_clk_get(&pdev->dev, "phy_ref_clk"); - if (IS_ERR(plat_dat->pclk)) { + plat_dat->stmmac_clk = clk; + + clk = devm_clk_get(&pdev->dev, "phy_ref_clk"); + if (IS_ERR(clk)) { dev_err(&pdev->dev, "phy_ref_clk clock not found.\n"); - err = PTR_ERR(plat_dat->pclk); + err = PTR_ERR(clk); goto disable; } - err = clk_prepare_enable(plat_dat->pclk); + err = clk_prepare_enable(clk); if (err < 0) { dev_err(&pdev->dev, "failed to enable phy_ref clock: %d\n", err); goto disable; } + plat_dat->pclk = clk; + return NULL; disable: clk_disable_unprepare(plat_dat->stmmac_clk); + plat_dat->stmmac_clk = NULL; + return ERR_PTR(err); } @@ -164,8 +171,15 @@ static int dwc_qos_remove(struct platform_device *pdev) struct net_device *ndev = platform_get_drvdata(pdev); struct stmmac_priv *priv = netdev_priv(ndev); + /* Cleanup the pointers to the clock handlers hidden in the platform + * data so the stmmac_remove_config_dt() method wouldn't have disabled + * the clocks too. + */ clk_disable_unprepare(priv->plat->pclk); + priv->plat->pclk = NULL; + clk_disable_unprepare(priv->plat->stmmac_clk); + priv->plat->stmmac_clk = NULL; return 0; } @@ -303,12 +317,12 @@ static void *tegra_eqos_probe(struct platform_device *pdev, goto disable_master; } - data->stmmac_clk = eqos->clk_slave; - err = clk_prepare_enable(eqos->clk_slave); if (err < 0) goto disable_master; + data->stmmac_clk = eqos->clk_slave; + eqos->clk_rx = devm_clk_get(&pdev->dev, "rx"); if (IS_ERR(eqos->clk_rx)) { err = PTR_ERR(eqos->clk_rx); @@ -381,6 +395,7 @@ static void *tegra_eqos_probe(struct platform_device *pdev, clk_disable_unprepare(eqos->clk_rx); disable_slave: clk_disable_unprepare(eqos->clk_slave); + data->stmmac_clk = NULL; disable_master: clk_disable_unprepare(eqos->clk_master); error: @@ -390,6 +405,7 @@ static void *tegra_eqos_probe(struct platform_device *pdev, static int tegra_eqos_remove(struct platform_device *pdev) { + struct stmmac_priv *priv = netdev_priv(platform_get_drvdata(pdev)); struct tegra_eqos *eqos = get_stmmac_bsp_priv(&pdev->dev); reset_control_assert(eqos->rst); @@ -399,6 +415,12 @@ static int tegra_eqos_remove(struct platform_device *pdev) clk_disable_unprepare(eqos->clk_slave); clk_disable_unprepare(eqos->clk_master); + /* Cleanup the pointers to the clock handlers hidden in the platform + * data so the stmmac_remove_config_dt() method wouldn't have disabled + * the clocks too. + */ + priv->plat->stmmac_clk = NULL; + return 0; } 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: 343874 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 58527C4361B 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 2211F20771 for ; Mon, 14 Dec 2020 09:21:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730746AbgLNJU7 (ORCPT ); Mon, 14 Dec 2020 04:20:59 -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: netdev@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:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 343869 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 BE321C4361B for ; Mon, 14 Dec 2020 09:23:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6AF1120771 for ; Mon, 14 Dec 2020 09:23:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394817AbgLNJXc (ORCPT ); Mon, 14 Dec 2020 04:23:32 -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 S2439739AbgLNJSP (ORCPT ); Mon, 14 Dec 2020 04:18:15 -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 21/25] net: stmmac: dwc-qos: Discard Tx/Rx clocks request Date: Mon, 14 Dec 2020 12:16:11 +0300 Message-ID: <20201214091616.13545-22-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: netdev@vger.kernel.org Since the Tx/Rx clocks with the same names are now requested and enabled/disabled in the STMMAC DT-based platform config method, there is no need in duplicating the same procedures in the DWC QoS Eth sub-driver. Discard it then, but make sure the denoted clocks have been specified for the platform. Note also the deprecated clock "phy_ref_clk" have been defined as the Tx clock in the DWC QoS Eth bindings. Let's use a pointer to the Tx clock defined in the platform data then instead of the unrelated pclk pointer. Signed-off-by: Serge Semin --- .../stmicro/stmmac/dwmac-dwc-qos-eth.c | 44 +++++-------------- 1 file changed, 11 insertions(+), 33 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 57f957898b60..f53a78448988 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c @@ -31,8 +31,6 @@ struct tegra_eqos { struct reset_control *rst; struct clk *clk_master; struct clk *clk_slave; - struct clk *clk_tx; - struct clk *clk_rx; struct gpio_desc *reset; }; @@ -155,7 +153,7 @@ static void *dwc_qos_probe(struct platform_device *pdev, goto disable; } - plat_dat->pclk = clk; + plat_dat->tx_clk = clk; return NULL; @@ -175,8 +173,8 @@ static int dwc_qos_remove(struct platform_device *pdev) * data so the stmmac_remove_config_dt() method wouldn't have disabled * the clocks too. */ - clk_disable_unprepare(priv->plat->pclk); - priv->plat->pclk = NULL; + clk_disable_unprepare(priv->plat->tx_clk); + priv->plat->tx_clk = NULL; clk_disable_unprepare(priv->plat->stmmac_clk); priv->plat->stmmac_clk = NULL; @@ -197,6 +195,7 @@ static int dwc_qos_remove(struct platform_device *pdev) static void tegra_eqos_fix_speed(void *priv, unsigned int speed) { struct tegra_eqos *eqos = priv; + struct stmmac_priv *sp = netdev_priv(dev_get_drvdata(eqos->dev)); unsigned long rate = 125000000; bool needs_calibration = false; u32 value; @@ -262,7 +261,7 @@ static void tegra_eqos_fix_speed(void *priv, unsigned int speed) writel(value, eqos->regs + AUTO_CAL_CONFIG); } - err = clk_set_rate(eqos->clk_tx, rate); + err = clk_set_rate(sp->plat->tx_clk, rate); if (err < 0) dev_err(eqos->dev, "failed to set TX rate: %d\n", err); } @@ -301,6 +300,11 @@ static void *tegra_eqos_probe(struct platform_device *pdev, if (!is_of_node(dev->fwnode)) goto bypass_clk_reset_gpio; + if (!data->tx_clk || !data->rx_clk) { + err = -EINVAL; + goto error; + } + eqos->clk_master = devm_clk_get(&pdev->dev, "master_bus"); if (IS_ERR(eqos->clk_master)) { err = PTR_ERR(eqos->clk_master); @@ -323,30 +327,10 @@ static void *tegra_eqos_probe(struct platform_device *pdev, data->stmmac_clk = eqos->clk_slave; - eqos->clk_rx = devm_clk_get(&pdev->dev, "rx"); - if (IS_ERR(eqos->clk_rx)) { - err = PTR_ERR(eqos->clk_rx); - goto disable_slave; - } - - err = clk_prepare_enable(eqos->clk_rx); - if (err < 0) - goto disable_slave; - - eqos->clk_tx = devm_clk_get(&pdev->dev, "tx"); - if (IS_ERR(eqos->clk_tx)) { - err = PTR_ERR(eqos->clk_tx); - goto disable_rx; - } - - err = clk_prepare_enable(eqos->clk_tx); - if (err < 0) - goto disable_rx; - eqos->reset = devm_gpiod_get(&pdev->dev, "phy-reset", GPIOD_OUT_HIGH); if (IS_ERR(eqos->reset)) { err = PTR_ERR(eqos->reset); - goto disable_tx; + goto disable_slave; } usleep_range(2000, 4000); @@ -389,10 +373,6 @@ static void *tegra_eqos_probe(struct platform_device *pdev, reset_control_assert(eqos->rst); reset_phy: gpiod_set_value(eqos->reset, 1); -disable_tx: - clk_disable_unprepare(eqos->clk_tx); -disable_rx: - clk_disable_unprepare(eqos->clk_rx); disable_slave: clk_disable_unprepare(eqos->clk_slave); data->stmmac_clk = NULL; @@ -410,8 +390,6 @@ static int tegra_eqos_remove(struct platform_device *pdev) reset_control_assert(eqos->rst); gpiod_set_value(eqos->reset, 1); - clk_disable_unprepare(eqos->clk_tx); - clk_disable_unprepare(eqos->clk_rx); clk_disable_unprepare(eqos->clk_slave); clk_disable_unprepare(eqos->clk_master); 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: 343868 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 EFB11C1B0E3 for ; Mon, 14 Dec 2020 09:26:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B5A2A22AB0 for ; Mon, 14 Dec 2020 09:26:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439643AbgLNJXd (ORCPT ); Mon, 14 Dec 2020 04:23: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: netdev@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)