spi: dw: Add generic DW DMA controller support
Subsystems (3)
cover spi: dw: Add generic DW DMA controller support
Baikal-T1 SoC provides DW DMA controller to perform low-speed peripherals Mem-to-Dev and Dev-to-Mem transaction. This is also applicable to the DW APB SSI devices embedded into the SoC. Currently this type DMA device is supported by the DW APB SPI driver only as a middle layer code for Intel MID PCI devices. Seeing the same code can be used for normal platform DW DMAC device we introduced a set of patches to fix it within this patchset.
First of all traditionally we replaced the legacy plain text-based dt-binding file with yaml-based one. Then we unpinned the Intel MID specific code from the generic DMA one and placed it into the spi-dw-pci.c driver, which was a better place for it anyway. Then we introduced a set of naming cleanups since the code was going to be used for generic DW DMAC device and DMAC usage alterations to handle the controller functionality in a generic way by the DW APB SSI MMIO driver as well. See the individual patches commit messages for details.
In addition we fixed a problem in the native chip-select method, which despite of multiple attempts to be fixed doesn't correctly perceive the SPI_CS_HIGH flag and the enable-argument.
Finally as a cherry on a cake we replaced the manually written DebugFS registers read method with a ready-to-use for the same purpose regset32 DebugFS interface usage.
This patchset is rebased and tested on the mainline Linux kernel 5.7-rc4:0e698dfa2822 ("Linux 5.7-rc4")
tag: v5.7-rc4
Serge Semin (17):
dt-bindings: spi: Convert DW SPI binding to DT schema
dt-bindings: spi: dw: Add DMA properties bindings
spi: dw: Split up the generic DMA code and Intel MID driver
spi: dw: Cleanup generic DW DMA code namings
spi: dw: Discard static DW DMA slave structures
spi: dw: Add DW SPI DMA/PCI/MMIO dependency on DW SPI core
spi: dw: Add Tx/Rx finish wait methods to DMA
spi: dw: Clear DMAC register when done or stopped
spi: dw: Enable interrupts in accordance with DMA xfer mode
spi: dw: Parameterize the DMA Rx/Tx burst length
spi: dw: Fix native CS being unset
spi: dw: Fix dma_slave_config used partly uninitialized
spi: dw: Initialize paddr in DW SPI MMIO private data
spi: dw: Add DMA support to the DW SPI MMIO driver
spi: dw: Use DMA max burst to set the request thresholds
spi: dw: Fix Rx-only DMA transfers
spi: dw: Use regset32 DebugFS method to create a registers file
.../bindings/spi/snps,dw-apb-ssi.txt | 41 ---
.../bindings/spi/snps,dw-apb-ssi.yaml | 123 +++++++++
.../devicetree/bindings/spi/spi-dw.txt | 24 --
drivers/spi/Kconfig | 16 +-
drivers/spi/Makefile | 4 +-
drivers/spi/{spi-dw-mid.c => spi-dw-dma.c} | 237 ++++++++++++------
drivers/spi/spi-dw-mmio.c | 15 +-
drivers/spi/spi-dw-pci.c | 38 ++-
drivers/spi/spi-dw.c | 89 +++----
drivers/spi/spi-dw.h | 27 +-
10 files changed, 402 insertions(+), 212 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt
create mode 100644 Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml
delete mode 100644 Documentation/devicetree/bindings/spi/spi-dw.txt
rename drivers/spi/{spi-dw-mid.c => spi-dw-dma.c} (53%)Signature · 1 line
2.25.1
PATCH 1/17 dt-bindings: spi: Convert DW SPI binding to DT schema
Modern device tree bindings are supposed to be created as YAML-files in accordance with dt-schema. This commit replaces two DW SPI legacy bare text bindings with YAML file. As before the bindings file states that the corresponding dts node is supposed to be compatible either with generic DW APB SSI controller or with Microsemi/Amazon/Renesas vendors-specific controllers, to have registers, interrupts and clocks properties. Though in case of Microsemi version of the controller there must be two registers resources specified. Properties like clock-names, reg-io-width, cs-gpio, num-cs and SPI-specific sub-nodes are optional.
--- .../bindings/spi/snps,dw-apb-ssi.txt | 41 ------- .../bindings/spi/snps,dw-apb-ssi.yaml | 113 ++++++++++++++++++ .../devicetree/bindings/spi/spi-dw.txt | 24 ---- 3 files changed, 113 insertions(+), 65 deletions(-) delete mode 100644 Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt create mode 100644 Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml delete mode 100644 Documentation/devicetree/bindings/spi/spi-dw.txt
Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt deleted +0 -41
@@ -1,41 +0,0 @@ -Synopsys DesignWare AMBA 2.0 Synchronous Serial Interface. - -Required properties: -- compatible : "snps,dw-apb-ssi" or "mscc,<soc>-spi", where soc is "ocelot" or - "jaguar2", or "amazon,alpine-dw-apb-ssi" -- reg : The register base for the controller. For "mscc,<soc>-spi", a second - register set is required (named ICPU_CFG:SPI_MST) -- interrupts : One interrupt, used by the controller. -- #address-cells : <1>, as required by generic SPI binding. -- #size-cells : <0>, also as required by generic SPI binding. -- clocks : phandles for the clocks, see the description of clock-names below. - The phandle for the "ssi_clk" is required. The phandle for the "pclk" clock - is optional. If a single clock is specified but no clock-name, it is the - "ssi_clk" clock. If both clocks are listed, the "ssi_clk" must be first. - -Optional properties: -- clock-names : Contains the names of the clocks: - "ssi_clk", for the core clock used to generate the external SPI clock. - "pclk", the interface clock, required for register access. If a clock domain - used to enable this clock then it should be named "pclk_clkdomain". -- cs-gpios : Specifies the gpio pins to be used for chipselects. -- num-cs : The number of chipselects. If omitted, this will default to 4. -- reg-io-width : The I/O register width (in bytes) implemented by this - device. Supported values are 2 or 4 (the default). - -Child nodes as per the generic SPI binding. - -Example: - - spi@fff00000 { - compatible = "snps,dw-apb-ssi"; - reg = <0xfff00000 0x1000>; - interrupts = <0 154 4>; - #address-cells = <1>; - #size-cells = <0>; - clocks = <&spi_m_clk>; - num-cs = <2>; - cs-gpios = <&gpio0 13 0>, - <&gpio0 14 0>; - }; -
Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml new file +113 -0
113 lines not on this page · raw message
Documentation/devicetree/bindings/spi/spi-dw.txt deleted +0 -24
@@ -1,24 +0,0 @@ -Synopsys DesignWare SPI master - -Required properties: -- compatible: should be "snps,designware-spi" -- #address-cells: see spi-bus.txt -- #size-cells: see spi-bus.txt -- reg: address and length of the spi master registers -- interrupts: should contain one interrupt -- clocks: spi clock phandle -- num-cs: see spi-bus.txt - -Optional properties: -- cs-gpios: see spi-bus.txt - -Example: - -spi: spi@4020a000 { - compatible = "snps,designware-spi"; - interrupts = <11 1>; - reg = <0x4020a000 0x1000>; - clocks = <&pclk>; - num-cs = <2>; - cs-gpios = <&banka 0 0>; -};
Signature · 1 line
2.25.1
Re: [PATCH 01/17] dt-bindings: spi: Convert DW SPI binding to DT schema
Quoted 10 lines · Serge Semin
Modern device tree bindings are supposed to be created as YAML-files in accordance with dt-schema. This commit replaces two DW SPI legacy bare text bindings with YAML file. As before the bindings file states that the corresponding dts node is supposed to be compatible either with generic DW APB SSI controller or with Microsemi/Amazon/Renesas vendors-specific controllers, to have registers, interrupts and clocks properties. Though in case of Microsemi version of the controller there must be two registers resources specified. Properties like clock-names, reg-io-width, cs-gpio, num-cs and SPI-specific sub-nodes are optional.
Can you incorporate work done here or agree with Wan how to proceed?
Quoted 221 lines
Signed-off-by Serge Semin <[email protected]>Cc Georgy Vlasov <[email protected]>Cc Ramil Zaripov <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Allison Randal <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Gareth Williams <[email protected]>--- .../bindings/spi/snps,dw-apb-ssi.txt | 41 ------- .../bindings/spi/snps,dw-apb-ssi.yaml | 113 ++++++++++++++++++ .../devicetree/bindings/spi/spi-dw.txt | 24 ---- 3 files changed, 113 insertions(+), 65 deletions(-) delete mode 100644 Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt create mode 100644 Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml delete mode 100644 Documentation/devicetree/bindings/spi/spi-dw.txtDocumentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt deleted +0
-41@@ -1,41 +0,0 @@ -Synopsys DesignWare AMBA 2.0 Synchronous Serial Interface. - -Required properties: -- compatible : "snps,dw-apb-ssi" or "mscc,<soc>-spi", where soc is "ocelot" or - "jaguar2", or "amazon,alpine-dw-apb-ssi" -- reg : The register base for the controller. For "mscc,<soc>-spi", a second - register set is required (named ICPU_CFG:SPI_MST) -- interrupts : One interrupt, used by the controller. -- #address-cells : <1>, as required by generic SPI binding. -- #size-cells : <0>, also as required by generic SPI binding. -- clocks : phandles for the clocks, see the description of clock-names below. - The phandle for the "ssi_clk" is required. The phandle for the "pclk" clock - is optional. If a single clock is specified but no clock-name, it is the - "ssi_clk" clock. If both clocks are listed, the "ssi_clk" must be first. - -Optional properties: -- clock-names : Contains the names of the clocks: - "ssi_clk", for the core clock used to generate the external SPI clock. - "pclk", the interface clock, required for register access. If a clock domain - used to enable this clock then it should be named "pclk_clkdomain". -- cs-gpios : Specifies the gpio pins to be used for chipselects. -- num-cs : The number of chipselects. If omitted, this will default to 4. -- reg-io-width : The I/O register width (in bytes) implemented by this - device. Supported values are 2 or 4 (the default). - -Child nodes as per the generic SPI binding. - -Example: - - spi@fff00000 { - compatible = "snps,dw-apb-ssi"; - reg = <0xfff00000 0x1000>; - interrupts = <0 154 4>; - #address-cells = <1>; - #size-cells = <0>; - clocks = <&spi_m_clk>; - num-cs = <2>; - cs-gpios = <&gpio0 13 0>, - <&gpio0 14 0>; - }; -Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml new file +113
-0@@ -0,0 +1,113 @@ +# SPDX-License-Identifier: GPL-2.0-only +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/spi/snps,dw-apb-ssi.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Synopsys DesignWare AMBA 2.0 Synchronous Serial Interface + +maintainers: + - Mark Brown <[email protected]> + +allOf: + - $ref: "spi-controller.yaml#" + - if: + properties: + compatible: + contains: + enum: + - mscc,ocelot-spi + - mscc,jaguar2-spi + then: + properties: + reg: + minItems: 2 + +properties: + compatible: + oneOf: + - description: Generic DW SPI controller + const: snps,dw-apb-ssi + - description: Microsemi Ocelot/Jaguar2 SoC SPI controller + items: + - enum: + - mscc,ocelot-spi + - mscc,jaguar2-spi + - const: snps,dw-apb-ssi + - description: Amazon Alpine SPI controller + const: amazon,alpine-dw-apb-ssi + - description: Renesas RZ/N1 SPI controlle. + items: + - const: renesas,rzn1-spi + - const: snps,dw-apb-ssi + + reg: + minItems: 1 + items: + - description: DW APB SSI controller memory mapped registers + - description: SPI MST region map + + interrupts: + maxItems: 1 + + clocks: + minItems: 1 + items: + - description: SPI Controller reference clock source + - description: APB interface clock source + + clock-names: + minItems: 1 + items: + - const: ssi_clk + - const: pclk + + reg-io-width: + $ref: /schemas/types.yaml#/definitions/uint32 + description: I/O register width (in bytes) implemented by this device + default: 4 + enum: [ 2, 4 ] + + num-cs: + default: 4 + minimum: 1 + maximum: 4 + +patternProperties: + "^.*@[0-9a-f]+$": + type: object + properties: + reg: + minimum: 0 + maximum: 3 + + spi-rx-bus-width: + const: 1 + + spi-tx-bus-width: + const: 1 + +unevaluatedProperties: false + +required: + - compatible + - reg + - "#address-cells" + - "#size-cells" + - interrupts + - clocks + +examples: + - | + spi@fff00000 { + compatible = "snps,dw-apb-ssi"; + reg = <0xfff00000 0x1000>; + #address-cells = <1>; + #size-cells = <0>; + interrupts = <0 154 4>; + clocks = <&spi_m_clk>; + num-cs = <2>; + cs-gpios = <&gpio0 13 0>, + <&gpio0 14 0>; + }; +...Documentation/devicetree/bindings/spi/spi-dw.txt deleted +0
-24@@ -1,24 +0,0 @@ -Synopsys DesignWare SPI master - -Required properties: -- compatible: should be "snps,designware-spi" -- #address-cells: see spi-bus.txt -- #size-cells: see spi-bus.txt -- reg: address and length of the spi master registers -- interrupts: should contain one interrupt -- clocks: spi clock phandle -- num-cs: see spi-bus.txt - -Optional properties: -- cs-gpios: see spi-bus.txt - -Example: - -spi: spi@4020a000 { - compatible = "snps,designware-spi"; - interrupts = <11 1>; - reg = <0x4020a000 0x1000>; - clocks = <&pclk>; - num-cs = <2>; - cs-gpios = <&banka 0 0>; -};Signature · 1 line
2.25.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 01/17] dt-bindings: spi: Convert DW SPI binding to DT schema
+Cc: Wan Ahmad Zainie <[email protected]>
Quoted 12 lines · Andy Shevchenko
Quoted 10 lines · Serge Semin
Modern device tree bindings are supposed to be created as YAML-files in accordance with dt-schema. This commit replaces two DW SPI legacy bare text bindings with YAML file. As before the bindings file states that the corresponding dts node is supposed to be compatible either with generic DW APB SSI controller or with Microsemi/Amazon/Renesas vendors-specific controllers, to have registers, interrupts and clocks properties. Though in case of Microsemi version of the controller there must be two registers resources specified. Properties like clock-names, reg-io-width, cs-gpio, num-cs and SPI-specific sub-nodes are optional.
Quoted 3 lines
Can you incorporate work done here or agree with Wan how to proceed?
Don't worry. I'll make sure the updates provided by Wan including the new IP support are preserved after rebasing this series on top of the spi/for-next.
-Sergey
Quoted 228 lines
Quoted 222 lines
Signed-off-by Serge Semin <[email protected]>Cc Georgy Vlasov <[email protected]>Cc Ramil Zaripov <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Allison Randal <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Gareth Williams <[email protected]>--- .../bindings/spi/snps,dw-apb-ssi.txt | 41 ------- .../bindings/spi/snps,dw-apb-ssi.yaml | 113 ++++++++++++++++++ .../devicetree/bindings/spi/spi-dw.txt | 24 ---- 3 files changed, 113 insertions(+), 65 deletions(-) delete mode 100644 Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt create mode 100644 Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml delete mode 100644 Documentation/devicetree/bindings/spi/spi-dw.txtDocumentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt deleted +0
-41@@ -1,41 +0,0 @@ -Synopsys DesignWare AMBA 2.0 Synchronous Serial Interface. - -Required properties: -- compatible : "snps,dw-apb-ssi" or "mscc,<soc>-spi", where soc is "ocelot" or - "jaguar2", or "amazon,alpine-dw-apb-ssi" -- reg : The register base for the controller. For "mscc,<soc>-spi", a second - register set is required (named ICPU_CFG:SPI_MST) -- interrupts : One interrupt, used by the controller. -- #address-cells : <1>, as required by generic SPI binding. -- #size-cells : <0>, also as required by generic SPI binding. -- clocks : phandles for the clocks, see the description of clock-names below. - The phandle for the "ssi_clk" is required. The phandle for the "pclk" clock - is optional. If a single clock is specified but no clock-name, it is the - "ssi_clk" clock. If both clocks are listed, the "ssi_clk" must be first. - -Optional properties: -- clock-names : Contains the names of the clocks: - "ssi_clk", for the core clock used to generate the external SPI clock. - "pclk", the interface clock, required for register access. If a clock domain - used to enable this clock then it should be named "pclk_clkdomain". -- cs-gpios : Specifies the gpio pins to be used for chipselects. -- num-cs : The number of chipselects. If omitted, this will default to 4. -- reg-io-width : The I/O register width (in bytes) implemented by this - device. Supported values are 2 or 4 (the default). - -Child nodes as per the generic SPI binding. - -Example: - - spi@fff00000 { - compatible = "snps,dw-apb-ssi"; - reg = <0xfff00000 0x1000>; - interrupts = <0 154 4>; - #address-cells = <1>; - #size-cells = <0>; - clocks = <&spi_m_clk>; - num-cs = <2>; - cs-gpios = <&gpio0 13 0>, - <&gpio0 14 0>; - }; -Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml new file +113
-0@@ -0,0 +1,113 @@ +# SPDX-License-Identifier: GPL-2.0-only +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/spi/snps,dw-apb-ssi.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Synopsys DesignWare AMBA 2.0 Synchronous Serial Interface + +maintainers: + - Mark Brown <[email protected]> + +allOf: + - $ref: "spi-controller.yaml#" + - if: + properties: + compatible: + contains: + enum: + - mscc,ocelot-spi + - mscc,jaguar2-spi + then: + properties: + reg: + minItems: 2 + +properties: + compatible: + oneOf: + - description: Generic DW SPI controller + const: snps,dw-apb-ssi + - description: Microsemi Ocelot/Jaguar2 SoC SPI controller + items: + - enum: + - mscc,ocelot-spi + - mscc,jaguar2-spi + - const: snps,dw-apb-ssi + - description: Amazon Alpine SPI controller + const: amazon,alpine-dw-apb-ssi + - description: Renesas RZ/N1 SPI controlle. + items: + - const: renesas,rzn1-spi + - const: snps,dw-apb-ssi + + reg: + minItems: 1 + items: + - description: DW APB SSI controller memory mapped registers + - description: SPI MST region map + + interrupts: + maxItems: 1 + + clocks: + minItems: 1 + items: + - description: SPI Controller reference clock source + - description: APB interface clock source + + clock-names: + minItems: 1 + items: + - const: ssi_clk + - const: pclk + + reg-io-width: + $ref: /schemas/types.yaml#/definitions/uint32 + description: I/O register width (in bytes) implemented by this device + default: 4 + enum: [ 2, 4 ] + + num-cs: + default: 4 + minimum: 1 + maximum: 4 + +patternProperties: + "^.*@[0-9a-f]+$": + type: object + properties: + reg: + minimum: 0 + maximum: 3 + + spi-rx-bus-width: + const: 1 + + spi-tx-bus-width: + const: 1 + +unevaluatedProperties: false + +required: + - compatible + - reg + - "#address-cells" + - "#size-cells" + - interrupts + - clocks + +examples: + - | + spi@fff00000 { + compatible = "snps,dw-apb-ssi"; + reg = <0xfff00000 0x1000>; + #address-cells = <1>; + #size-cells = <0>; + interrupts = <0 154 4>; + clocks = <&spi_m_clk>; + num-cs = <2>; + cs-gpios = <&gpio0 13 0>, + <&gpio0 14 0>; + }; +...Documentation/devicetree/bindings/spi/spi-dw.txt deleted +0
-24@@ -1,24 +0,0 @@ -Synopsys DesignWare SPI master - -Required properties: -- compatible: should be "snps,designware-spi" -- #address-cells: see spi-bus.txt -- #size-cells: see spi-bus.txt -- reg: address and length of the spi master registers -- interrupts: should contain one interrupt -- clocks: spi clock phandle -- num-cs: see spi-bus.txt - -Optional properties: -- cs-gpios: see spi-bus.txt - -Example: - -spi: spi@4020a000 { - compatible = "snps,designware-spi"; - interrupts = <11 1>; - reg = <0x4020a000 0x1000>; - clocks = <&pclk>; - num-cs = <2>; - cs-gpios = <&banka 0 0>; -};Signature · 1 line
2.25.1Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 01/17] dt-bindings: spi: Convert DW SPI binding to DT schema
Quoted 16 lines · Serge Semin
+Cc: Wan Ahmad Zainie <[email protected]>
Quoted 12 lines · Andy Shevchenko
Quoted 10 lines · Serge Semin
Modern device tree bindings are supposed to be created as YAML-files in accordance with dt-schema. This commit replaces two DW SPI legacy bare text bindings with YAML file. As before the bindings file states that the corresponding dts node is supposed to be compatible either with generic DW APB SSI controller or with Microsemi/Amazon/Renesas vendors-specific controllers, to have registers, interrupts and clocks properties. Though in case of Microsemi version of the controller there must be two registers resources specified. Properties like clock-names, reg-io-width, cs-gpio, num-cs and SPI-specific sub-nodes are optional.
Quoted 6 lines
Quoted 3 lines
Can you incorporate work done here or agree with Wan how to proceed?
Don't worry. I'll make sure the updates provided by Wan including the new IP support are preserved after rebasing this series on top of the spi/for-next.
Thanks!
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH 2/17 dt-bindings: spi: dw: Add DMA properties bindings
In reply to Serge SeminSince DW SPI controller may use DW DMA engine to perform the CPU-less Tx/Rx SPI transfers and the DW SPI driver now supports it, lets alter the DW SPI bindings file to accept the Rx and Tx DMA line specifiers.
--- .../devicetree/bindings/spi/snps,dw-apb-ssi.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+)
Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml +10 -0
@@ -73,6 +73,16 @@ properties: minimum: 1 maximum: 4 + dmas: + items: + - description: TX DMA Channel + - description: RX DMA Channel + + dma-names: + items: + - const: tx + - const: rx + patternProperties: "^.*@[0-9a-f]+$": type: object
Signature · 1 line
2.25.1
PATCH 4/17 spi: dw: Cleanup generic DW DMA code namings
In reply to Serge SeminSince from now the former Intel MID platform layer will be used as a generic DW SPI DMA module, lets alter the internal methods naming to be DMA-related instead of having the "mid_" prefix. In addition the DW PCI-DMA specific methods and structures should be named with pci-suffexes, since we'll implement the DW MMIO DMA specific functions and objects soon.
--- drivers/spi/spi-dw-dma.c | 42 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-)
drivers/spi/spi-dw-dma.c +21 -21
@@ -20,10 +20,10 @@#define RX_BUSY 0#define TX_BUSY 1 -static struct dw_dma_slave mid_dma_tx = { .dst_id =1 }; -static struct dw_dma_slave mid_dma_rx = { .src_id =0 }; +static struct dw_dma_slave pci_dma_tx = { .dst_id =1 }; +static struct dw_dma_slave pci_dma_rx = { .src_id =0 }; -static bool mid_spi_dma_chan_filter (struct dma_chan *chan,void *param) +static bool dw_spi_dma_chan_filter (struct dma_chan *chan,void *param) {struct dw_dma_slave *s = param;
@@ -34,7 +34,7 @@ static bool mid_spi_dma_chan_filter(struct dma_chan *chan, void *param)return true; } -static int mid_spi_dma_init (struct dw_spi *dws) +static int dw_spi_pci_dma_init (struct dw_spi *dws) {struct pci_dev *dma_dev;struct dw_dma_slave *tx = dws->dma_tx;
@@ -54,14 +54,14 @@ static int mid_spi_dma_init(struct dw_spi *dws)/* 1. Init rx channel */ rx->dma_dev = &dma_dev->dev; - dws->rxchan =dma_request_channel (mask, mid_spi_dma_chan_filter, rx); + dws->rxchan =dma_request_channel (mask, dw_spi_dma_chan_filter, rx);if (!dws->rxchan) goto err_exit; dws->master->dma_rx = dws->rxchan;/* 2. Init tx channel */ tx->dma_dev = &dma_dev->dev; - dws->txchan =dma_request_channel (mask, mid_spi_dma_chan_filter, tx); + dws->txchan =dma_request_channel (mask, dw_spi_dma_chan_filter, tx);if (!dws->txchan) goto free_rxchan; dws->master->dma_tx = dws->txchan;
@@ -75,7 +75,7 @@ static int mid_spi_dma_init(struct dw_spi *dws)return -EBUSY ; } -static void mid_spi_dma_exit (struct dw_spi *dws) +static void dw_spi_dma_exit (struct dw_spi *dws) {if (!dws->dma_inited)return ;
@@ -103,7 +103,7 @@ static irqreturn_t dma_transfer(struct dw_spi *dws)return IRQ_HANDLED ; } -static bool mid_spi_can_dma (struct spi_controller *master, +static bool dw_spi_can_dma (struct spi_controller *master,struct spi_device *spi,struct spi_transfer *xfer) {struct dw_spi *dws =spi_controller_get_devdata (master);
@@ -215,7 +215,7 @@ static struct dma_async_tx_descriptor *dw_spi_dma_prepare_rx(struct dw_spi *dws,return rxdesc; } -static int mid_spi_dma_setup (struct dw_spi *dws,struct spi_transfer *xfer) +static int dw_spi_dma_setup (struct dw_spi *dws,struct spi_transfer *xfer) {u16 dma_ctrl =0 ;
@@ -236,7 +236,7 @@ static int mid_spi_dma_setup(struct dw_spi *dws, struct spi_transfer *xfer)return 0 ; } -static int mid_spi_dma_transfer (struct dw_spi *dws,struct spi_transfer *xfer) +static int dw_spi_dma_transfer (struct dw_spi *dws,struct spi_transfer *xfer) {struct dma_async_tx_descriptor *txdesc, *rxdesc;
@@ -262,7 +262,7 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, struct spi_transfer *xfer)return 0 ; } -static void mid_spi_dma_stop (struct dw_spi *dws) +static void dw_spi_dma_stop (struct dw_spi *dws) {if (test_bit (TX_BUSY , &dws->dma_chan_busy)) {dmaengine_terminate_sync (dws->txchan);
@@ -274,19 +274,19 @@ static void mid_spi_dma_stop(struct dw_spi *dws) } } -static const struct dw_spi_dma_ops mid_dma_ops = { - .dma_init = mid_spi_dma_init, - .dma_exit = mid_spi_dma_exit, - .dma_setup = mid_spi_dma_setup, - .can_dma = mid_spi_can_dma, - .dma_transfer = mid_spi_dma_transfer, - .dma_stop = mid_spi_dma_stop, +static const struct dw_spi_dma_ops dw_spi_pci_dma_ops = { + .dma_init = dw_spi_pci_dma_init, + .dma_exit = dw_spi_dma_exit, + .dma_setup = dw_spi_dma_setup, + .can_dma = dw_spi_can_dma, + .dma_transfer = dw_spi_dma_transfer, + .dma_stop = dw_spi_dma_stop, };void dw_spi_pci_dma_setup (struct dw_spi *dws) { - dws->dma_tx = &mid_dma_tx; - dws->dma_rx = &mid_dma_rx; - dws->dma_ops = &mid_dma_ops; + dws->dma_tx = &pci_dma_tx; + dws->dma_rx = &pci_dma_rx; + dws->dma_ops = &dw_spi_pci_dma_ops; }EXPORT_SYMBOL_GPL (dw_spi_pci_dma_setup);
Signature · 1 line
2.25.1
Re: [PATCH 04/17] spi: dw: Cleanup generic DW DMA code namings
Quoted 6 lines · Serge Semin
Since from now the former Intel MID platform layer will be used as a generic DW SPI DMA module, lets alter the internal methods naming to be DMA-related instead of having the "
mid_" prefix. In addition the DW PCI-DMA specific methods and structures should be named with pci-suffexes, since we'll implement the DW MMIO DMA specific functions and objects soon.
I think we rather leave Intel Medfield things alone. And I think I did this already in spi/for-next in less invasive way.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 04/17] spi: dw: Cleanup generic DW DMA code namings
Quoted 9 lines · Andy Shevchenko
Quoted 6 lines · Serge Semin
Since from now the former Intel MID platform layer will be used as a generic DW SPI DMA module, lets alter the internal methods naming to be DMA-related instead of having the "
mid_" prefix. In addition the DW PCI-DMA specific methods and structures should be named with pci-suffexes, since we'll implement the DW MMIO DMA specific functions and objects soon.I think we rather leave Intel Medfield things alone. And I think I did this already in spi/for-next in less invasive way.
The naming is horrible in that module. Since it's going to be a generic DMA driver the prefixes should be correspondingly fixed. Currently they are a bit random.
-Sergey
Quoted 6 lines
Signature · 3 lines
-- With Best Regards, Andy Shevchenko
Re: [PATCH 04/17] spi: dw: Cleanup generic DW DMA code namings
Quoted 10 lines · Serge Semin
Quoted 8 lines · Andy Shevchenko
Quoted 6 lines · Serge Semin
Since from now the former Intel MID platform layer will be used as a generic DW SPI DMA module, lets alter the internal methods naming to be DMA-related instead of having the "
mid_" prefix. In addition the DW PCI-DMA specific methods and structures should be named with pci-suffexes, since we'll implement the DW MMIO DMA specific functions and objects soon.
Quoted 3 lines
Quoted 1 line
I think we rather leave Intel Medfield things alone. And I think I did this already in spi/for-next in less invasive way.
The naming is horrible in that module.
I agree!
Quoted 3 lines
Since it's going to be a generic DMA
driver the prefixes should be correspondingly fixed. Currently they are a bit random.
Unfortunately, proposed '_pci' not anyhow better. There is Medfield stuff and non-Medfield.
Luckily Elkhart Lake uses generic approach. That's why better to have suffix based on platform, rather than on bus.
I think what should be done here are (in a patch per item):
1) moving to new named module (w/o mid)
2) removing mid_ prefix
3) something else I forgot?
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH 6/17 spi: dw: Add DW SPI DMA/PCI/MMIO dependency on DW SPI core
In reply to Serge SeminSeeing all of the DW SPI driver components like DW SPI DMA/PCI/MMIO depend on the DW SPI core code it's better to use the if-endif conditional kernel config statement to signify that common dependency.
--- drivers/spi/Kconfig | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/spi/Kconfig +7 -3
@@ -226,17 +226,21 @@ config SPI_DESIGNWARE help general driver for SPI controller core from DesignWare +if SPI_DESIGNWARE + config SPI_DW_DMA tristate "DMA support for DW SPI controller" - depends on SPI_DESIGNWARE && DW_DMAC_PCI + depends on DW_DMAC_PCI config SPI_DW_PCI tristate "PCI interface driver for DW SPI core" - depends on SPI_DESIGNWARE && PCI + depends on PCI config SPI_DW_MMIO tristate "Memory-mapped io interface driver for DW SPI core" - depends on SPI_DESIGNWARE + depends on HAS_IOMEM + +endif config SPI_DLN2 tristate "Diolan DLN-2 USB SPI adapter"
Signature · 1 line
2.25.1
PATCH 8/17 spi: dw: Clear DMAC register when done or stopped
In reply to Serge SeminIf DMAC register is left uncleared any further DMAless transfers may cause the DMAC hardware handshaking interface getting activated. So the next DMA-based Rx/Tx transaction will be started right after the dma_async_issue_pending() method is invoked even if no DMATDLR/DMARDLR conditions are met. This at the same time may cause the Tx/Rx FIFO buffers underrun/overrun. In order to fix this we must clear DMAC register after a current DMA-based transaction is finished.
--- drivers/spi/spi-dw-dma.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/spi/spi-dw-dma.c +6 -0
@@ -156,6 +156,8 @@ static void dw_spi_dma_tx_done(void *arg)clear_bit (TX_BUSY , &dws->dma_chan_busy);if (test_bit (RX_BUSY , &dws->dma_chan_busy))return ; + +dw_writel (dws,DW_SPI_DMACR ,0 );spi_finalize_current_transfer (dws->master); }
@@ -226,6 +228,8 @@ static void dw_spi_dma_rx_done(void *arg)clear_bit (RX_BUSY , &dws->dma_chan_busy);if (test_bit (TX_BUSY , &dws->dma_chan_busy))return ; + +dw_writel (dws,DW_SPI_DMACR ,0 );spi_finalize_current_transfer (dws->master); }
@@ -318,6 +322,8 @@ static void dw_spi_dma_stop(struct dw_spi *dws)dmaengine_terminate_sync (dws->rxchan);clear_bit (RX_BUSY , &dws->dma_chan_busy); } + +dw_writel (dws,DW_SPI_DMACR ,0 ); }static const struct dw_spi_dma_ops dw_spi_pci_dma_ops = {
Signature · 1 line
2.25.1
Mark Brown
maintainerRe: [PATCH 08/17] spi: dw: Clear DMAC register when done or stopped
Quoted 8 lines · Serge Semin
If DMAC register is left uncleared any further DMAless transfers may cause the DMAC hardware handshaking interface getting activated. So the next DMA-based Rx/Tx transaction will be started right after the
dma_async_issue_pending()method is invoked even if no DMATDLR/DMARDLR conditions are met. This at the same time may cause the Tx/Rx FIFO buffers underrun/overrun. In order to fix this we must clear DMAC register after a current DMA-based transaction is finished.
This also looks like a bugfix so should be pulled forwards to the start of the series if possible.
Re: [PATCH 08/17] spi: dw: Clear DMAC register when done or stopped
Quoted 10 lines · Mark Brown
Quoted 8 lines · Serge Semin
If DMAC register is left uncleared any further DMAless transfers may cause the DMAC hardware handshaking interface getting activated. So the next DMA-based Rx/Tx transaction will be started right after the
dma_async_issue_pending()method is invoked even if no DMATDLR/DMARDLR conditions are met. This at the same time may cause the Tx/Rx FIFO buffers underrun/overrun. In order to fix this we must clear DMAC register after a current DMA-based transaction is finished.
Quoted 2 lines
This also looks like a bugfix so should be pulled forwards to the start of the series if possible.
Ok.
-Sergey
PATCH 9/17 spi: dw: Enable interrupts in accordance with DMA xfer mode
In reply to Serge SeminIt's pointless to track the Tx overrun interrupts if Rx-only SPI transfer is issued. Similarly there is no need in handling the Rx overrun/underrun interrupts if Tx-only SPI transfer is executed. So lets unmask the interrupts only if corresponding SPI transactions are implied.
--- drivers/spi/spi-dw-dma.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/spi/spi-dw-dma.c +8 -4
@@ -267,19 +267,23 @@ static struct dma_async_tx_descriptor *dw_spi_dma_prepare_rx(struct dw_spi *dws,static int dw_spi_dma_setup (struct dw_spi *dws,struct spi_transfer *xfer) { -u16 dma_ctrl =0 ; +u16 imr =0 , dma_ctrl =0 ;dw_writel (dws,DW_SPI_DMARDLR ,0xf );dw_writel (dws,DW_SPI_DMATDLR ,0x10 ); -if (xfer->tx_buf) +if (xfer->tx_buf) { dma_ctrl |=SPI_DMA_TDMAE ; -if (xfer->rx_buf) + imr |=SPI_INT_TXOI ; + } +if (xfer->rx_buf) { dma_ctrl |=SPI_DMA_RDMAE ; + imr |=SPI_INT_RXUI |SPI_INT_RXOI ; + }dw_writel (dws,DW_SPI_DMACR , dma_ctrl);/* Set the interrupt mask */ -spi_umask_intr (dws,SPI_INT_TXOI |SPI_INT_RXUI |SPI_INT_RXOI ); +spi_umask_intr (dws, imr); dws->transfer_handler = dma_transfer;
Signature · 1 line
2.25.1
PATCH 10/17 spi: dw: Parameterize the DMA Rx/Tx burst length
In reply to Serge SeminIt isn't good to have numeric literals in the code especially if there are multiple of them and they are related. Moreover in current implementation the Tx DMA transfer activation level isn't optimal, since it's hardwired to be at 16-32 bytes level, while it's better to keep the SPI FIFO buffer as full as possible until all available data is submitted. So lets introduce the DMA burst level parametrization macros with optimal values - issue Rx transfer if at least 16 bytes are available in the buffer and execute Tx transaction if at least 16 bytes room is opened in SPI Tx FIFO.
--- drivers/spi/spi-dw-dma.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/spi/spi-dw-dma.c +6 -4
@@ -20,7 +20,9 @@#define WAIT_RETRIES 5#define RX_BUSY 0 +#define RX_BURST_LEVEL 16#define TX_BUSY 1 +#define TX_BURST_LEVEL 16static bool dw_spi_dma_chan_filter (struct dma_chan *chan,void *param) {
@@ -172,7 +174,7 @@ static struct dma_async_tx_descriptor *dw_spi_dma_prepare_tx(struct dw_spi *dws, txconf.direction =DMA_MEM_TO_DEV ; txconf.dst_addr = dws->dma_addr; - txconf.dst_maxburst =16 ; + txconf.dst_maxburst =TX_BURST_LEVEL ; txconf.src_addr_width =DMA_SLAVE_BUSWIDTH_4_BYTES ; txconf.dst_addr_width =convert_dma_width (dws->dma_width); txconf.device_fc = false;
@@ -244,7 +246,7 @@ static struct dma_async_tx_descriptor *dw_spi_dma_prepare_rx(struct dw_spi *dws, rxconf.direction =DMA_DEV_TO_MEM ; rxconf.src_addr = dws->dma_addr; - rxconf.src_maxburst =16 ; + rxconf.src_maxburst =RX_BURST_LEVEL ; rxconf.dst_addr_width =DMA_SLAVE_BUSWIDTH_4_BYTES ; rxconf.src_addr_width =convert_dma_width (dws->dma_width); rxconf.device_fc = false;
@@ -269,8 +271,8 @@ static int dw_spi_dma_setup(struct dw_spi *dws, struct spi_transfer *xfer) {u16 imr =0 , dma_ctrl =0 ; -dw_writel (dws,DW_SPI_DMARDLR ,0xf ); -dw_writel (dws,DW_SPI_DMATDLR ,0x10 ); +dw_writel (dws,DW_SPI_DMARDLR ,RX_BURST_LEVEL -1 ); +dw_writel (dws,DW_SPI_DMATDLR , dws->fifo_len -TX_BURST_LEVEL );if (xfer->tx_buf) { dma_ctrl |=SPI_DMA_TDMAE ;
Signature · 1 line
2.25.1
PATCH 12/17 spi: dw: Fix dma_slave_config used partly uninitialized
In reply to Serge SeminSince the TX and RX DMA-slave config structures are declared on the stack and only a part of their fields is initialized further in the prepare Tx/Rx methods, the next dmaengine_slave_config() calls may randomly perform an incorrect DMA channels setup depending on the stack initial values. Lets fix this by zeroing the config-structures before using them.
--- drivers/spi/spi-dw-dma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/spi-dw-dma.c +2 -2
@@ -166,7 +166,7 @@ static void dw_spi_dma_tx_done(void *arg)static struct dma_async_tx_descriptor *dw_spi_dma_prepare_tx (struct dw_spi *dws,struct spi_transfer *xfer) { -struct dma_slave_config txconf; +struct dma_slave_config txconf = {0 };struct dma_async_tx_descriptor *txdesc;if (!xfer->tx_buf)
@@ -238,7 +238,7 @@ static void dw_spi_dma_rx_done(void *arg)static struct dma_async_tx_descriptor *dw_spi_dma_prepare_rx (struct dw_spi *dws,struct spi_transfer *xfer) { -struct dma_slave_config rxconf; +struct dma_slave_config rxconf = {0 };struct dma_async_tx_descriptor *rxdesc;if (!xfer->rx_buf)
Signature · 1 line
2.25.1
Re: [PATCH 12/17] spi: dw: Fix dma_slave_config used partly uninitialized
Quoted 6 lines · Serge Semin
Since the TX and RX DMA-slave config structures are declared on the stack and only a part of their fields is initialized further in the prepare Tx/Rx methods, the next
dmaengine_slave_config()calls may randomly perform an incorrect DMA channels setup depending on the stack initial values. Lets fix this by zeroing the config-structures before using them.
Already in spi/for-next.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH 13/17 spi: dw: Initialize paddr in DW SPI MMIO private data
In reply to Serge SeminThis field is used only for the DW SPI DMA code initialization, that's why there were no problems with it being uninitialized in Dw SPI MMIO driver. Since in a further patch we are going to introduce the DW SPI DMA support in the MMIO version of the driver, lets set the field with the physical address of the DW SPI controller registers region.
--- drivers/spi/spi-dw-mmio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/spi/spi-dw-mmio.c +4 -1
@@ -136,6 +136,7 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)int (*init_func)(struct platform_device *pdev,struct dw_spi_mmio *dwsmmio);struct dw_spi_mmio *dwsmmio; +struct resource *mem;struct dw_spi *dws;int ret;int num_cs;
@@ -148,11 +149,13 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) dws = &dwsmmio->dws;/* Get basic io resource and map it */ - dws->regs =devm_platform_ioremap_resource (pdev,0 ); + mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + dws->regs =devm_ioremap_resource (&pdev->dev, mem);if (IS_ERR (dws->regs)) {dev_err (&pdev->dev,"SPI region map failed\n" );return PTR_ERR (dws->regs); } + dws->paddr = mem->start; dws->irq =platform_get_irq (pdev,0 );if (dws->irq <0 )
Signature · 1 line
2.25.1
Re: [PATCH 13/17] spi: dw: Initialize paddr in DW SPI MMIO private data
Quoted 5 lines · Serge Semin
This field is used only for the DW SPI DMA code initialization, that's why there were no problems with it being uninitialized in Dw SPI MMIO driver. Since in a further patch we are going to introduce the DW SPI DMA support in the MMIO version of the driver, lets set the field with the physical address of the DW SPI controller registers region.
...
drivers/spi/spi-dw-mmio.c static int dw_spi_mmio_probe(struct platform_device *pdev) · line 153
Quoted 3 lines
drivers/spi/spi-dw-mmio.c +2
-1- dws->regs =devm_platform_ioremap_resource (pdev,0 ); + mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + dws->regs =devm_ioremap_resource (&pdev->dev, mem);
There is a helper
dws->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &mem);
Quoted 11 lines
drivers/spi/spi-dw-mmio.c +1
-0if (IS_ERR (dws->regs)) {dev_err (&pdev->dev,"SPI region map failed\n" );return PTR_ERR (dws->regs); } + dws->paddr = mem->start; dws->irq =platform_get_irq (pdev,0 );if (dws->irq <0 )Signature · 1 line
2.25.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 13/17] spi: dw: Initialize paddr in DW SPI MMIO private data
Quoted 9 lines · Andy Shevchenko
Quoted 5 lines · Serge Semin
This field is used only for the DW SPI DMA code initialization, that's why there were no problems with it being uninitialized in Dw SPI MMIO driver. Since in a further patch we are going to introduce the DW SPI DMA support in the MMIO version of the driver, lets set the field with the physical address of the DW SPI controller registers region.
...
Quoted 7 lines
drivers/spi/spi-dw-mmio.c static int dw_spi_mmio_probe(struct platform_device *pdev) · line 153
Quoted 3 lines
drivers/spi/spi-dw-mmio.c +2
-1- dws->regs =devm_platform_ioremap_resource (pdev,0 ); + mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + dws->regs =devm_ioremap_resource (&pdev->dev, mem);There is a helper
dws->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &mem);
Oh, good point. It has been just added, in kernel v5.7. v5.6 didn't provide such a convenient helper. Thanks for the suggestion.
-Sergey
Quoted 19 lines
Quoted 13 lines
drivers/spi/spi-dw-mmio.c +1
-0if (IS_ERR (dws->regs)) {dev_err (&pdev->dev,"SPI region map failed\n" );return PTR_ERR (dws->regs); } + dws->paddr = mem->start; dws->irq =platform_get_irq (pdev,0 );if (dws->irq <0 )Signature · 1 line
2.25.1Signature · 2 lines
With Best Regards, Andy Shevchenko
Mark Brown
maintainerQuoted 2 lines · Serge Semin
Serge Semin (17):
dt-bindings: spi: Convert DW SPI binding to DT schema
Please don't make new feature development dependent on conversion to the new schema format, there's quite a backlog of reviews of schema conversions so it can slow things down. It's good to do the conversions but please do them after adding any new stuff to the binding rather than before.
Quoted 10 lines · Mark Brown
Quoted 2 lines · Serge Semin
Serge Semin (17):
dt-bindings: spi: Convert DW SPI binding to DT schemaPlease don't make new feature development dependent on conversion to the new schema format, there's quite a backlog of reviews of schema conversions so it can slow things down. It's good to do the conversions but please do them after adding any new stuff to the binding rather than before.
So by saying this do you want me to revert an order of the first two patches in the series, right? So the series would first add the DMA properties support to the binding, then would convert the binding file to DT schema.
-Sergey
Mark Brown
maintainerQuoted 11 lines · Serge Semin
Quoted 5 lines · Mark Brown
Please don't make new feature development dependent on conversion to the new schema format, there's quite a backlog of reviews of schema conversions so it can slow things down. It's good to do the conversions but please do them after adding any new stuff to the binding rather than before.
So by saying this do you want me to revert an order of the first two patches in the series, right? So the series would first add the DMA properties support to the binding, then would convert the binding file to DT schema.
The conversion to YAML format should be the very last thing in the patch series, and as Andy says there's another patch in flight also doing this conversion which you should coordinate with.
Quoted 9 lines · Mark Brown
Quoted 7 lines · Serge Semin
Quoted 5 lines · Mark Brown
Please don't make new feature development dependent on conversion to the new schema format, there's quite a backlog of reviews of schema conversions so it can slow things down. It's good to do the conversions but please do them after adding any new stuff to the binding rather than before.
Quoted 6 lines
Quoted 3 lines
So by saying this do you want me to revert an order of the first two patches in the series, right? So the series would first add the DMA properties support to the binding, then would convert the binding file to DT schema.
The conversion to YAML format should be the very last thing in the patch series,
Hm, haven't heard about this requirement. Could you point me out to a doc or some discussion concerning this for future reference? It's not a first DT conversion patch I've submitted and non of them were addressed with such request. I do understand that the order of DT concerning patches can be important and agree to fix it by updating the original legacy binding first, then perform a conversion. But placing the conversion in a tail of the series just seems unnecessary. The patch can be dropped from any place of the series if for some reason Rob would be late with review.
Personally I prefer placing all DT changes in the head of the series, so Rob wouldn't need to search through the whole patchset looking for the DT-related patches.
-Sergey
Quoted 2 lines
and as Andy says there's another patch in flight also doing this conversion which you should coordinate with.
Mark Brown
maintainerQuoted 5 lines · Serge Semin
Quoted 2 lines · Mark Brown
The conversion to YAML format should be the very last thing in the patch series,
Quoted 8 lines
Hm, haven't heard about this requirement. Could you point me out to a doc or some discussion concerning this for future reference? It's not a first DT conversion patch I've submitted and non of them were addressed with such request. I do understand that the order of DT concerning patches can be important and agree to fix it by updating the original legacy binding first, then perform a conversion. But placing the conversion in a tail of the series just seems unnecessary. The patch can be dropped from any place of the series if for some reason Rob would be late with review.
This is a practical observation based on the fact that there is a huge backlog of reviews of DT binding conversions and that those conversions typically go through several review cycles and that not everyone who's sending patches to the kernel is fully up to speed on processes or has strong English. By telling people (including other people who find instructions on the list) to put the conversion right at the end of the series I am avoiding any ambiguity or confusion about ordering with regard to any other patches to the DT, including any new patches that get added to the series.
Quoted 3 lines
Personally I prefer placing all DT changes in the head of the series, so Rob wouldn't need to search through the whole patchset looking for the DT-related patches.
Ideally the YAML conversions would be done entirely separately to other development rather than as part of a bigger series, they're pretty much orthogonal anyway. Sadly there's obvious content collisions with any new development that adds DT stuff so that's not always the most practical thing.
Quoted 29 lines · Mark Brown
Quoted 5 lines · Serge Semin
Quoted 2 lines · Mark Brown
The conversion to YAML format should be the very last thing in the patch series,
Quoted 8 lines
Hm, haven't heard about this requirement. Could you point me out to a doc or some discussion concerning this for future reference? It's not a first DT conversion patch I've submitted and non of them were addressed with such request. I do understand that the order of DT concerning patches can be important and agree to fix it by updating the original legacy binding first, then perform a conversion. But placing the conversion in a tail of the series just seems unnecessary. The patch can be dropped from any place of the series if for some reason Rob would be late with review.
This is a practical observation based on the fact that there is a huge backlog of reviews of DT binding conversions and that those conversions typically go through several review cycles and that not everyone who's sending patches to the kernel is fully up to speed on processes or has strong English. By telling people (including other people who find instructions on the list) to put the conversion right at the end of the series I am avoiding any ambiguity or confusion about ordering with regard to any other patches to the DT, including any new patches that get added to the series.
Quoted 3 lines
Personally I prefer placing all DT changes in the head of the series, so Rob wouldn't need to search through the whole patchset looking for the DT-related patches.
Quoted 5 lines
Ideally the YAML conversions would be done entirely separately to other development rather than as part of a bigger series, they're pretty much orthogonal anyway. Sadly there's obvious content collisions with any new development that adds DT stuff so that's not always the most practical thing.
Ok. I see your point. I'll move the conversion patch to the tail of the series after rebasing the patchset on top of the spi/for-next branch. Thanks for clarification.
-Sergey
A message that is not in the archive (sent off-list or not yet received): [email protected]
Mark Brown
maintainerRe: [PATCH 07/17] spi: dw: Add Tx/Rx finish wait methods to DMA
Quoted 3 lines · Serge Semin
Since DMA transfers are performed asynchronously with actual SPI transaction, then even if DMA transfers are finished it doesn't mean all data is actually pushed to the SPI bus. Some data might still be
This looks like a bug fix so it should really have gone at the start of the series so it can be sent to Linus as a bug fix rather than waiting for the merge window. This makes sense to me, a couple of nits below:
Review
Quoted 10 lines
(quoted diff) +10
-0+static void dw_spi_dma_wait_tx_done(struct dw_spi *dws) +{ + int retry = WAIT_RETRIES; + unsigned long ns; + + ns = (NSEC_PER_SEC / spi_get_clk(dws)) * dws->n_bytes * BITS_PER_BYTE; + ns *= dw_readl(dws, DW_SPI_TXFLR); + + while (dw_spi_dma_tx_busy(dws) && retry--) + ndelay(ns);
How deep can the FIFO be with this IP - could we end up ndelay()ing for non-trivial amounts of time?
Review
Quoted 5 lines
(quoted diff) +5
-0+static inline u32 spi_get_clk(struct dw_spi *dws) +{ + u32 div = dw_readl(dws, DW_SPI_BAUDR); + + return div ? dws->max_freq / div : 0;
Please write normal conditional statements rather than using the ternery operator - it helps with legibility.
A message that is not in the archive (sent off-list or not yet received): 20200513113555.mjivjk374giopnea@mobilestation
Mark Brown
maintainerRe: [PATCH 07/17] spi: dw: Add Tx/Rx finish wait methods to DMA
Quoted 10 lines · Serge Semin
Quoted 5 lines · Mark Brown
Review
Quoted 2 lines
(quoted diff) +2
-0+ while (dw_spi_dma_tx_busy(dws) && retry--) + ndelay(ns);How deep can the FIFO be with this IP - could we end up ndelay()ing for non-trivial amounts of time?
According to the DW APB SSI db it can be up to 256 transfer words. So the delay should be trivial.
Yes, that should be fine.
Mark Brown
maintainerQuoted 3 lines · Serge Semin
Baikal-T1 SoC provides DW DMA controller to perform low-speed peripherals Mem-to-Dev and Dev-to-Mem transaction. This is also applicable to the DW APB SSI devices embedded into the SoC. Currently this type DMA device is
This basically all looks good to me (without any hardware specific knowledge), I had a few comments but they were mostly procedural ones - mainly getting these bug fixes you've done merged as such. Nice work.
Quoted 8 lines · Mark Brown
Quoted 3 lines · Serge Semin
Baikal-T1 SoC provides DW DMA controller to perform low-speed peripherals Mem-to-Dev and Dev-to-Mem transaction. This is also applicable to the DW APB SSI devices embedded into the SoC. Currently this type DMA device is
This basically all looks good to me (without any hardware specific knowledge), I had a few comments but they were mostly procedural ones - mainly getting these bug fixes you've done merged as such. Nice work.
Agree that is nice work!
Though, can you please give us chance to review next version of the series and test on our hardware?
Serge, I think you should base it on spi/for-next rather than vanilla.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 6 lines · Andy Shevchenko
Quoted 5 lines · Mark Brown
Quoted 3 lines · Serge Semin
Baikal-T1 SoC provides DW DMA controller to perform low-speed peripherals Mem-to-Dev and Dev-to-Mem transaction. This is also applicable to the DW APB SSI devices embedded into the SoC. Currently this type DMA device is
Quoted 8 lines
Quoted 3 lines
This basically all looks good to me (without any hardware specific knowledge), I had a few comments but they were mostly procedural ones - mainly getting these bug fixes you've done merged as such. Nice work.
Agree that is nice work!
Though, can you please give us chance to review next version of the series and test on our hardware?Serge, I think you should base it on spi/for-next rather than vanilla.
Yeah, seeing there are potentially merge-conflict changes in the for-next branch I have to do the rebase. Will be done in v2.
-Sergey
Quoted 6 lines
Signature · 3 lines
-- With Best Regards, Andy Shevchenko
Quoted 8 lines · Mark Brown
Quoted 3 lines · Serge Semin
Baikal-T1 SoC provides DW DMA controller to perform low-speed peripherals Mem-to-Dev and Dev-to-Mem transaction. This is also applicable to the DW APB SSI devices embedded into the SoC. Currently this type DMA device is
This basically all looks good to me (without any hardware specific knowledge), I had a few comments but they were mostly procedural ones - mainly getting these bug fixes you've done merged as such. Nice work.
Thanks. I'll address the Andy's comments and send v2 after that.
-Sergey
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 14/17] spi: dw: Add DMA support to the DW SPI MMIO driver
Quoted 12 lines · Serge Semin
Since the common code in the
spi-dw-dma.cdriver is ready to be used by the MMIO driver, we just need to initialize the DW SPI private data fields with Tx/Rx DMA channel handlers and setup the DW SPI DMA callbacks. This commit introduces such alterations to the DW SPI DMA/MMIO code. A dedicated DW SPI MMIO DMA initializer performs the DMA channels request from the parental device (which is supposed to be a DW SPI platform device). Then it checks whether the retrieved DW DMA channels support LLP. If they don't currently we print a warning, that further DMA usage may be finished with DW SPI inbound FIFO overflow (nothing else we can do about it at the moment). Finally the DW SPI MMIO DMA initializer sets the DMA-inited flag.
Quoted 3 lines
Currently the DMA will be initialized only for a generic DW SPI MMIO device declared with "snps,dw-apb-ssi" compatible string if
SPI_DW_DMAkernel config is enabled.
Already in spi/for-next (see for generic suffix in spi-dw-mid.c).
Signature · 2 lines
With Best Regards, Andy Shevchenko
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 16/17] spi: dw: Fix Rx-only DMA transfers
Quoted 10 lines · Serge Semin
Tx-only DMA transfers are working perfectly fine since in this case the code just ignores the Rx FIFO overflow interrupts. But it turns out the SPI Rx-only transfers are broken since nothing pushing any data to the shift registers, so the Rx FIFO is left empty and the SPI core subsystems just returns a timeout error. Since DW DMAC driver doesn't support something like cyclic write operations of a single byte to a device register, the only way to support the Rx-only SPI transfers is to fake it by using a dummy Tx-buffer. This is what we intend to fix in this commit by setting the
SPI_CONTROLLER_MUST_TXflag for DMA-capable platform.
Hmm... If Mark consider this a right thing to do, then it's fine. I didn't investigate what this flag may produce as a side effect.
Quoted 13 lines
drivers/spi/spi-dw.c +1
-0@@ -524,6 +524,7 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws) dws->dma_inited =0 ; }else { master->can_dma = dws->dma_ops->can_dma; + master->flags |=SPI_CONTROLLER_MUST_TX ; } }Signature · 1 line
2.25.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 17/17] spi: dw: Use regset32 DebugFS method to create a registers file
Quoted 3 lines · Serge Semin
DebugFS kernel interface provides a dedicated method to create the registers dump file. Use it instead of creating a generic DebugFS file with manually written read callback function.
Of course ideal would be use something like regmap API which delivers this as a side effect. But this also good clean up!
Comments below.
Quoted 75 lines
Signed-off-by Serge Semin <[email protected]>Cc Georgy Vlasov <[email protected]>Cc Ramil Zaripov <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Allison Randal <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Gareth Williams <[email protected]>Cc Rob Herring <[email protected]>--- drivers/spi/spi-dw.c | 85 +++++++++++++------------------------------- drivers/spi/spi-dw.h | 2 ++ 2 files changed, 27 insertions(+), 60 deletions(-)drivers/spi/spi-dw.c +0
-47@@ -32,66 +32,28 @@ struct chip_data { };#ifdef CONFIG_DEBUG_FS -#define SPI_REGS_BUFSIZE 1024 -static ssize_t dw_spi_show_regs (struct file *file,char __user *user_buf, -size_t count,loff_t *ppos) -{ -struct dw_spi *dws = file->private_data; -char *buf; -u32 len =0 ; -ssize_t ret; - - buf =kzalloc (SPI_REGS_BUFSIZE ,GFP_KERNEL ); -if (!buf) -return 0 ; - - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"%s registers:\n" ,dev_name (&dws->master->dev)); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"=================================\n" ); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"CTRL0: \t\t0x%08x\n" ,dw_readl (dws,DW_SPI_CTRL0 )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"CTRL1: \t\t0x%08x\n" ,dw_readl (dws,DW_SPI_CTRL1 )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"SSIENR: \t0x%08x\n" ,dw_readl (dws,DW_SPI_SSIENR )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"SER: \t\t0x%08x\n" ,dw_readl (dws,DW_SPI_SER )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"BAUDR: \t\t0x%08x\n" ,dw_readl (dws,DW_SPI_BAUDR )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"TXFTLR: \t0x%08x\n" ,dw_readl (dws,DW_SPI_TXFLTR )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"RXFTLR: \t0x%08x\n" ,dw_readl (dws,DW_SPI_RXFLTR )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"TXFLR: \t\t0x%08x\n" ,dw_readl (dws,DW_SPI_TXFLR )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"RXFLR: \t\t0x%08x\n" ,dw_readl (dws,DW_SPI_RXFLR )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"SR: \t\t0x%08x\n" ,dw_readl (dws,DW_SPI_SR )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"IMR: \t\t0x%08x\n" ,dw_readl (dws,DW_SPI_IMR )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"ISR: \t\t0x%08x\n" ,dw_readl (dws,DW_SPI_ISR )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"DMACR: \t\t0x%08x\n" ,dw_readl (dws,DW_SPI_DMACR )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"DMATDLR: \t0x%08x\n" ,dw_readl (dws,DW_SPI_DMATDLR )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"DMARDLR: \t0x%08x\n" ,dw_readl (dws,DW_SPI_DMARDLR ));
drivers/spi/spi-dw.c struct chip_data { · line 38
Quoted 10 lines
drivers/spi/spi-dw.c +4
-6- len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"=================================\n" ); - - ret =simple_read_from_buffer (user_buf, count, ppos, buf, len); -kfree (buf); -return ret; +#define DW_SPI_DBGFS_REG (_name, _off) \ +{ \ + .name = _name, \ + .offset = _off \
Leave comma here.
Quoted 45 lines
drivers/spi/spi-dw.c +21
-7} -static const struct file_operations dw_spi_regs_ops = { - .owner =THIS_MODULE , - .open = simple_open, - .read = dw_spi_show_regs, - .llseek = default_llseek, +static const struct debugfs_reg32 dw_spi_dbgfs_regs[] = { +DW_SPI_DBGFS_REG ("CTRL0" ,DW_SPI_CTRL0 ), +DW_SPI_DBGFS_REG ("CTRL1" ,DW_SPI_CTRL1 ), +DW_SPI_DBGFS_REG ("SSIENR" ,DW_SPI_SSIENR ), +DW_SPI_DBGFS_REG ("SER" ,DW_SPI_SER ), +DW_SPI_DBGFS_REG ("BAUDR" ,DW_SPI_BAUDR ), +DW_SPI_DBGFS_REG ("TXFTLR" ,DW_SPI_TXFLTR ), +DW_SPI_DBGFS_REG ("RXFTLR" ,DW_SPI_RXFLTR ), +DW_SPI_DBGFS_REG ("TXFLR" ,DW_SPI_TXFLR ), +DW_SPI_DBGFS_REG ("RXFLR" ,DW_SPI_RXFLR ), +DW_SPI_DBGFS_REG ("SR" ,DW_SPI_SR ), +DW_SPI_DBGFS_REG ("IMR" ,DW_SPI_IMR ), +DW_SPI_DBGFS_REG ("ISR" ,DW_SPI_ISR ), +DW_SPI_DBGFS_REG ("DMACR" ,DW_SPI_DMACR ), +DW_SPI_DBGFS_REG ("DMATDLR" ,DW_SPI_DMATDLR ), +DW_SPI_DBGFS_REG ("DMARDLR" ,DW_SPI_DMARDLR ) };static int dw_spi_debugfs_init (struct dw_spi *dws)@@ -103,8 +65,11 @@ static int dw_spi_debugfs_init(struct dw_spi *dws)if (!dws->debugfs)return -ENOMEM ; -debugfs_create_file ("registers" ,S_IFREG |S_IRUGO , - dws->debugfs, (void *)dws, &dw_spi_regs_ops); + dws->regset.regs = dw_spi_dbgfs_regs; + dws->regset.nregs =ARRAY_SIZE (dw_spi_dbgfs_regs); + dws->regset.base = dws->regs; +debugfs_create_regset32 ("registers" ,0400 , dws->debugfs, &dws->regset); +return 0 ; }drivers/spi/spi-dw.h +0
-0
drivers/spi/spi-dw.h line 7
Quoted 4 lines
drivers/spi/spi-dw.h +1
-0@@ -4,6 +4,7 @@#include <linux/io.h> #include <linux/scatterlist.h> +#include <linux/debugfs.h>
Perhaps keep ordered?
drivers/spi/spi-dw.h struct dw_spi { · line 147
Quoted 9 lines
drivers/spi/spi-dw.h +1
-0/* Register offsets */ #define DW_SPI_CTRL0 0x00@@ -142,6 +143,7 @@ struct dw_spi {void *priv;#ifdef CONFIG_DEBUG_FS struct dentry *debugfs; +struct debugfs_regset32 regset;
I'm wondering why we need it here and not simple on the stack?
Quoted 6 lines
drivers/spi/spi-dw.h +0
-0#endif };Signature · 2 lines
-- 2.25.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
A message that is not in the archive (sent off-list or not yet received): 20200513124422.z6ctlmvipwer45q4@mobilestation
Re: [PATCH 17/17] spi: dw: Use regset32 DebugFS method to create a registers file
Quoted 6 lines · Serge Semin
Quoted 4 lines · Andy Shevchenko
Quoted 3 lines · Serge Semin
DebugFS kernel interface provides a dedicated method to create the registers dump file. Use it instead of creating a generic DebugFS file with manually written read callback function.
Quoted 8 lines
Quoted 6 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+#define DW_SPI_DBGFS_REG(_name, _off) \ +{ \ + .name = _name, \ + .offset = _off \Leave comma here.
don't see a point.
It will help in case if this getting extended. Also slightly better to distinguish between terminator type of members vs. data structures.
Quoted 8 lines
Quoted 5 lines
Review
Quoted 3 lines
}
(quoted diff) +1
-0+ struct debugfs_regset32 regset;I'm wondering why we need it here and not simple on the stack?
Please see the way the DebugFS regset work. A prompt: how does the DebugFS core get to know what is a base address of the registers? =)
If they have a member in the struct which passed thru private pointer of inode. But I see your point.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 17 lines · Serge Semin
Baikal-T1 SoC provides DW DMA controller to perform low-speed peripherals Mem-to-Dev and Dev-to-Mem transaction. This is also applicable to the DW APB SSI devices embedded into the SoC. Currently this type DMA device is supported by the DW APB SPI driver only as a middle layer code for Intel MID PCI devices. Seeing the same code can be used for normal platform DW DMAC device we introduced a set of patches to fix it within this patchset.
First of all traditionally we replaced the legacy plain text-based dt-binding file with yaml-based one. Then we unpinned the Intel MID specific code from the generic DMA one and placed it into the
spi-dw-pci.cdriver, which was a better place for it anyway. Then we introduced a set of naming cleanups since the code was going to be used for generic DW DMAC device and DMAC usage alterations to handle the controller functionality in a generic way by the DW APB SSI MMIO driver as well. See the individual patches commit messages for details.
Quoted 7 lines
In addition we fixed a problem in the native chip-select method, which despite of multiple attempts to be fixed doesn't correctly perceive the
SPI_CS_HIGHflag and the enable-argument.Finally as a cherry on a cake we replaced the manually written DebugFS registers read method with a ready-to-use for the same purpose regset32 DebugFS interface usage.
Thanks! Appreciate the series (some of the things I would like to have done myself, but lack of time and no specific request from our hardware).
Though, I will wait for v2 rebased on top of spi/for-next and I will review the rest of the patches (mostly those I haven't commented out).
Quoted 3 lines
This patchset is rebased and tested on the mainline Linux kernel 5.7-rc4:
0e698dfa2822("Linux 5.7-rc4")
tag: v5.7-rc4
Perhaps --base will do the trick?
Quoted 63 lines
Co-developed-by Georgy Vlasov <[email protected]>Signed-off-by Georgy Vlasov <[email protected]>Co-developed-by Ramil Zaripov <[email protected]>Signed-off-by Ramil Zaripov <[email protected]>Signed-off-by Serge Semin <[email protected]>Cc Alexey Malahov <[email protected]>Cc Maxim Kaurkin <[email protected]>Cc Pavel Parkhomenko <[email protected]>Cc Ekaterina Skachko <[email protected]>Cc Vadim Vlasov <[email protected]>Cc Alexey Kolotnikov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Allison Randal <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Gareth Williams <[email protected]>Cc Rob Herring <[email protected]>Serge Semin (17):
dt-bindings: spi: Convert DW SPI binding to DT schema
dt-bindings: spi: dw: Add DMA properties bindings
spi: dw: Split up the generic DMA code and Intel MID driver
spi: dw: Cleanup generic DW DMA code namings
spi: dw: Discard static DW DMA slave structures
spi: dw: Add DW SPI DMA/PCI/MMIO dependency on DW SPI core
spi: dw: Add Tx/Rx finish wait methods to DMA
spi: dw: Clear DMAC register when done or stopped
spi: dw: Enable interrupts in accordance with DMA xfer mode
spi: dw: Parameterize the DMA Rx/Tx burst length
spi: dw: Fix native CS being unset
spi: dw: Fixdma_slave_configused partly uninitialized
spi: dw: Initialize paddr in DW SPI MMIO private data
spi: dw: Add DMA support to the DW SPI MMIO driver
spi: dw: Use DMA max burst to set the request thresholds
spi: dw: Fix Rx-only DMA transfers
spi: dw: Use regset32 DebugFS method to create a registers file.../bindings/spi/snps,dw-apb-ssi.txt | 41 --- .../bindings/spi/snps,dw-apb-ssi.yaml | 123 +++++++++ .../devicetree/bindings/spi/spi-dw.txt | 24 -- drivers/spi/Kconfig | 16 +- drivers/spi/Makefile | 4 +- drivers/spi/{spi-dw-mid.c => spi-dw-dma.c} | 237 ++++++++++++------ drivers/spi/spi-dw-mmio.c | 15 +- drivers/spi/spi-dw-pci.c | 38 ++- drivers/spi/spi-dw.c | 89 +++---- drivers/spi/spi-dw.h | 27 +- 10 files changed, 402 insertions(+), 212 deletions(-) delete mode 100644 Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt create mode 100644 Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml delete mode 100644 Documentation/devicetree/bindings/spi/spi-dw.txt rename drivers/spi/{spi-dw-mid.c => spi-dw-dma.c} (53%)Signature · 1 line
2.25.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 11/17] spi: dw: Fix native CS being unset
Quoted 9 lines · Serge Semin
Commit
6e0a32d6f376("spi: dw: Fix default polarity of native chipselect") attempted to fix the problem when GPIO active-high chip-select is utilized to communicate with some SPI slave. It fixed the problem, but broke the normal native CS support. At the same time the reversion commitada9e3fcc175("spi: dw: Correct handling of native chipselect") didn't solve the problem either, since it just inverted theset_cs()polarity perception without taking into account that CS-high might be applicable. Here is what is done to finally fix the problem.
I'm not sure this is the whole story.
I think Charles' fix made it work, and then commit 3e5ec1db8bfee845d9f8560d1c64aeaccd586398
"spi: Fix SPI_CS_HIGH setting when using native and GPIO CS" fixed it broken again.
This commit will make sure only set SPI_CS_HIGH on a spi_device if it is using a GPIO as CS. Before this change, the core would set that on everything, and expect the .set_cs() callback to cope.
I think we fixed that and that fix should have been undone when applying commit 3e5ec1db8bfe.
So possibly Fixes: should be set only to this commit, so that the fix is not backported to kernels without it.
Quoted 4 lines
DW SPI controller demands any native CS being set in order to proceed with data transfer. So in order to activate the SPI communications we must set any bit in the Slave Select DW SPI controller register no matter whether the platform requests the GPIO- or native CS.
Ah-ha! Maybe we should even add a comment explaining that. And that is why SPI_MASTER_GPIO_SS is set.
I suppose my naive understanding was:
"bit set to 1" = CS asserted (driven low)
"bit set to 0" = CS de-asserted (driven high)
So that is not how this register works at all.
Quoted 3 lines
This commit fixes the problem for all described cases. So no matter whether an SPI slave needs GPIO- or native-based CS with active-high or low signal the corresponding bit will be set in SER.
Makes sense.
Review
Quoted 11 lines
struct dw_spi *dws = spi_controller_get_devdata(spi->controller); struct chip_data *chip = spi_get_ctldata(spi);(quoted diff) +2
-1+ bool cs_high = !!(spi->mode & SPI_CS_HIGH); /* Chip select logic is inverted from spi_set_cs() */ if (chip && chip->cs_control) chip->cs_control(!enable); - if (!enable) + if (cs_high == enable) dw_writel(dws, DW_SPI_SER, BIT(spi->chip_select));
This is the correct fix now but I an afraid not correct before commit 3e5ec1db8bfe.
What I can't help but asking is: can the native chip select even handle active high chip select if not backed by a GPIO? Which register would set that polarity?
Yours,
Linus Walleij
A message that is not in the archive (sent off-list or not yet received): 20200513001347.dyt357erev7vzy3l@mobilestation
Linus Walleij
Acked-byRe: [PATCH 11/17] spi: dw: Fix native CS being unset
Quoted 10 lines · Serge Semin
Quoted 2 lines
This is the correct fix now but I an afraid not correct before commit
3e5ec1db8bfe.Sorry, but that's "enable" flag propagation from basic
spi_set_cs()to the HW CS setting callback is a nightmare. In Russia there is a common saying for such cases, which can be translated as "you can't figure it out without a bottle of vodka".)Actually the fix is correct no matter whether commit
3e5ec1db8bfeis applied or not. At least I don't see a connection between them.
OK that seems to hold given the resoning below so:
Quoted 5 lines
Quoted 3 lines
What I can't help but asking is: can the native chip select even handle active high chip select if not backed by a GPIO? Which register would set that polarity?
No. DW APB SSI doesn't support active-high mode of the native CS's.
We had some related discussion what to do with this case when a controller can support active high CS if and only if it is using a GPIO instead of the native CS. We didn't really figure it out, I suppose ideally we should use two flags in the master but that exercise is for another day.
Yours.
Linus Walleij
A message that is not in the archive (sent off-list or not yet received): 20200514115558.e6cqnuxqyqkysfn7@mobilestation
Re: [PATCH 11/17] spi: dw: Fix native CS being unset
Quoted 9 lines · Serge Semin
Quoted 2 lines · Linus Walleij
On Wed, May 13, 2020 at 2:13 AM Serge Semin
<[email protected]> wrote:BTW I experience a problem with vger.kernel.org. For some reason a few days ago it started bouncing my emails back sent to the GPIO/MIPS/SPI/kernel mailing lists. I've sent multiple backward messages to the postmaster (postmaster (dog) vger.kernel.org) with the bounce text, but still with no response. Could you tell me who should I bother with this problem to get a help with its solution?
Perhaps, [email protected] ?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Mark Brown
maintainerRe: [PATCH 11/17] spi: dw: Fix native CS being unset
Quoted 9 lines · Andy Shevchenko
Quoted 5 lines · Serge Semin
BTW I experience a problem with vger.kernel.org. For some reason a few days ago it started bouncing my emails back sent to the GPIO/MIPS/SPI/kernel mailing lists. I've sent multiple backward messages to the postmaster (postmaster (dog) vger.kernel.org) with the bounce text, but still with no response. Could you tell me who should I bother with this problem to get a help with its solution?
Perhaps, [email protected] ?
vger is completely separate to kernel.org in terms of admin. Usually the bounce messages from vger say why things are being bounced, there's a good chance that either mail to you is bouncing and Dave got annoyed with you and is trying to get your attention or something you're doing is looking like spam.
Mark Brown
maintainerRe: [PATCH 11/17] spi: dw: Fix native CS being unset
In reply to a message not in the archiveQuoted 8 lines · Serge Semin
Quoted 5 lines · Linus Walleij
We had some related discussion what to do with this case when a controller can support active high CS if and only if it is using a GPIO instead of the native CS. We didn't really figure it out, I suppose ideally we should use two flags in the master but that exercise is for another day.
Quoted 7 lines
Even though it might be painful, but as I see it the best way to generically fix this problem would be to change the
controller->set_cs()callback semantics. SPI core should pass a CS activation flag to theset_cs()callback instead of the CS pin logical level (just propagate the enable argument passed to thespi_set_cs()SPI core method). So if an SPI controller supports the Active-high native CS, during theset_cs()callback invocation it would analyze thespi_deviceflags state to figure out whether the slave needs the
The idea with set_cs() is to support controllers that allow the chip select to be directly managed. If the controller is interpreting or automatically managing chip select at all then set_cs() is not likely to be a good fit, if the controller does support unfiltered management then anything else is going to result in there being a bunch of duplicate code between drivers.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 03/17] spi: dw: Split up the generic DMA code and Intel MID driver
Quoted 6 lines · Serge Semin
This is an initial preparation patch before adding the DW DMA support into the DW SPI MMIO driver. We need to unpin the DMA-specific code from the code intended to be used for Intel MID. This isn't that hard, since most part of the
spi-dw-mid.cdriver in fact implements a generic DW DMA interface for the DW SPI controller driver. The only Intel MID specifics concern getting the max frequency from the MRST Clock
Quoted 8 lines
Control Unit and fetching the DMA controller channels from corresponding PCIe DMA controller. Since first one is related with the SPI interface configuration we moved it' implementation into the DW PCIe-SPI driver object. While seeing there is no other than Medfield board with DW DMA controller currently supported we left the DMA channels search procedure in the DW SPI DMA module. After being cleaned up of the Intel MID specifics former
spi-dw-mid.cmodule can be just renamed to be the DW SPI DMA driver.
And I guess this already been done in spi/for-next in less invasive way.
Quoted 223 lines
Co-developed-by Georgy Vlasov <[email protected]>Signed-off-by Georgy Vlasov <[email protected]>Co-developed-by Ramil Zaripov <[email protected]>Signed-off-by Ramil Zaripov <[email protected]>Signed-off-by Serge Semin <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Rob Herring <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Allison Randal <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Gareth Williams <[email protected]>--- drivers/spi/Kconfig | 8 ++--- drivers/spi/Makefile | 4 +-- drivers/spi/{spi-dw-mid.c => spi-dw-dma.c} | 36 ++------------------ drivers/spi/spi-dw-pci.c | 38 ++++++++++++++++++++-- drivers/spi/spi-dw.h | 12 +++++-- 5 files changed, 55 insertions(+), 43 deletions(-) rename drivers/spi/{spi-dw-mid.c => spi-dw-dma.c} (88%)drivers/spi/Kconfig +4
-4@@ -226,14 +226,14 @@ config SPI_DESIGNWARE help general driver for SPI controller core from DesignWare +config SPI_DW_DMA + tristate "DMA support for DW SPI controller" + depends on SPI_DESIGNWARE && DW_DMAC_PCI + config SPI_DW_PCI tristate "PCI interface driver for DW SPI core" depends on SPI_DESIGNWARE && PCI -config SPI_DW_MID_DMA - bool "DMA support for DW SPI controller on Intel MID platform" - depends on SPI_DW_PCI && DW_DMAC_PCI - config SPI_DW_MMIO tristate "Memory-mapped io interface driver for DW SPI core" depends on SPI_DESIGNWAREdrivers/spi/Makefile +2
-2@@ -36,9 +36,9 @@ obj-$(CONFIG_SPI_COLDFIRE_QSPI) += spi-coldfire-qspi.o obj-$(CONFIG_SPI_DAVINCI) += spi-davinci.o obj-$(CONFIG_SPI_DLN2) += spi-dln2.o obj-$(CONFIG_SPI_DESIGNWARE) += spi-dw.o +obj-$(CONFIG_SPI_DW_DMA) += spi-dw-dma.o obj-$(CONFIG_SPI_DW_MMIO) += spi-dw-mmio.o -obj-$(CONFIG_SPI_DW_PCI) += spi-dw-midpci.o -spi-dw-midpci-objs := spi-dw-pci.o spi-dw-mid.o +obj-$(CONFIG_SPI_DW_PCI) += spi-dw-pci.o obj-$(CONFIG_SPI_EFM32) += spi-efm32.o obj-$(CONFIG_SPI_EP93XX) += spi-ep93xx.o obj-$(CONFIG_SPI_FALCON) += spi-falcon.odrivers/spi/spi-dw-dma.c renamed from drivers/spi/spi-dw-mid.c +3
-33@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* -* Special handling for DW core on Intel MID platform +* Special handling for DW DMA core * * Copyright (c) 2009, 2014 Intel Corporation. */ @@ -14,7 +14,6 @@#include "spi-dw.h" -#ifdef CONFIG_SPI_DW_MID_DMA #include <linux/pci.h> #include <linux/platform_data/dma-dw.h> @@ -283,40 +282,11 @@ static const struct dw_spi_dma_ops mid_dma_ops = { .dma_transfer = mid_spi_dma_transfer, .dma_stop = mid_spi_dma_stop, }; -#endif -/* Some specific info for SPI0 controller on Intel MID */ - -/* HW info for MRST Clk Control Unit, 32b reg per controller */ -#define MRST_SPI_CLK_BASE 100000000/* 100m */ -#define MRST_CLK_SPI_REG 0xff11d86c -#define CLK_SPI_BDIV_OFFSET 0 -#define CLK_SPI_BDIV_MASK 0x00000007 -#define CLK_SPI_CDIV_OFFSET 9 -#define CLK_SPI_CDIV_MASK 0x00000e00 -#define CLK_SPI_DISABLE_OFFSET 8 - -int dw_spi_mid_init (struct dw_spi *dws) +void dw_spi_pci_dma_setup (struct dw_spi *dws) { -void __iomem *clk_reg; -u32 clk_cdiv; - - clk_reg =ioremap (MRST_CLK_SPI_REG ,16 ); -if (!clk_reg) -return -ENOMEM ; - -/* Get SPI controller operating freq info */ - clk_cdiv =readl (clk_reg + dws->bus_num *sizeof (u32)); - clk_cdiv &=CLK_SPI_CDIV_MASK ; - clk_cdiv >>=CLK_SPI_CDIV_OFFSET ; - dws->max_freq =MRST_SPI_CLK_BASE / (clk_cdiv +1 ); - -iounmap (clk_reg); - -#ifdef CONFIG_SPI_DW_MID_DMA dws->dma_tx = &mid_dma_tx; dws->dma_rx = &mid_dma_rx; dws->dma_ops = &mid_dma_ops; -#endif -return 0 ; } +EXPORT_SYMBOL_GPL (dw_spi_pci_dma_setup);drivers/spi/spi-dw-pci.c +36
-2@@ -16,6 +16,17 @@#define DRIVER_NAME "dw_spi_pci" +/* HW info for MRST Clk Control Unit, 32b reg per controller */ +#define MRST_SPI_CLK_BASE 100000000/* 100m */ +#define MRST_CLK_SPI_REG 0xff11d86c +#define CLK_SPI_BDIV_OFFSET 0 +#define CLK_SPI_BDIV_MASK 0x00000007 +#define CLK_SPI_CDIV_OFFSET 9 +#define CLK_SPI_CDIV_MASK 0x00000e00 +#define CLK_SPI_DISABLE_OFFSET 8 + +static int spi_mid_init (struct dw_spi *dws); +struct spi_pci_desc {int (*setup)(struct dw_spi *);u16 num_cs;@@ -24,13 +35,13 @@ struct spi_pci_desc { };static struct spi_pci_desc spi_pci_mid_desc_1 = { - .setup = dw_spi_mid_init, + .setup = spi_mid_init, .num_cs =5 , .bus_num =0 , };static struct spi_pci_desc spi_pci_mid_desc_2 = { - .setup = dw_spi_mid_init, + .setup = spi_mid_init, .num_cs =2 , .bus_num =1 , };@@ -41,6 +52,29 @@ static struct spi_pci_desc spi_pci_ehl_desc = { .max_freq = 100000000, }; +/* Some specific info for SPI0 controller on Intel MID */ +static int spi_mid_init (struct dw_spi *dws) +{ +void __iomem *clk_reg; +u32 clk_cdiv; + + clk_reg =ioremap (MRST_CLK_SPI_REG ,16 ); +if (!clk_reg) +return -ENOMEM ; + +/* Get SPI controller operating freq info */ + clk_cdiv =readl (clk_reg + dws->bus_num *sizeof (u32)); + clk_cdiv &=CLK_SPI_CDIV_MASK ; + clk_cdiv >>=CLK_SPI_CDIV_OFFSET ; + dws->max_freq =MRST_SPI_CLK_BASE / (clk_cdiv +1 ); + +iounmap (clk_reg); + +dw_spi_pci_dma_setup (dws); + +return 0 ; +} +static int spi_pci_probe (struct pci_dev *pdev,const struct pci_device_id *ent) {struct dw_spi *dws;drivers/spi/spi-dw.h +10
-2@@ -253,6 +253,14 @@ extern void dw_spi_remove_host(struct dw_spi *dws);extern int dw_spi_suspend_host (struct dw_spi *dws);extern int dw_spi_resume_host (struct dw_spi *dws); -/* platform related setup */ -extern int dw_spi_mid_init (struct dw_spi *dws);/* Intel MID platforms */ +#ifdef CONFIG_SPI_DW_DMA + +extern void dw_spi_pci_dma_setup (struct dw_spi *dws); + +#else /* !CONFIG_SPI_DW_DMA */ + +static inline void dw_spi_pci_dma_setup (struct dw_spi *dws) {} + +#endif /* !CONFIG_SPI_DW_DMA */ +#endif /* DW_SPI_HEADER_H */ Signature · 1 line
2.25.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 05/17] spi: dw: Discard static DW DMA slave structures
Quoted 10 lines · Serge Semin
Having them declared is redundant since each struct
dw_dma_chanhas the same structure embedded and the structure from the passeddma_chanprivate pointer will be copied there as a result of the next calls chain:dma_request_channel()->find_candidate()->dma_chan_get()->device_alloc_chan_resources()=dwc_alloc_chan_resources()->dw_dma_filter().
So just remove the staticdw_dma_chanstructures and use a locally declared data instance with dst_id/src_id set to the same values as the static copies used to have.
I'm not against it, but you may leave if for the future (see spi/for-next).
Signature · 2 lines
With Best Regards, Andy Shevchenko
v2 cover spi: dw: Add generic DW DMA controller support
In reply to Serge SeminBaikal-T1 SoC provides a DW DMA controller to perform low-speed peripherals Mem-to-Dev and Dev-to-Mem transaction. This is also applicable to the DW APB SSI devices embedded into the SoC. Currently the DMA-based transfers are supported by the DW APB SPI driver only as a middle layer code for Intel MID/Elkhart PCI devices. Seeing the same code can be used for normal platform DMAC device we introduced a set of patches to fix it within this series.
First of all we need to add the Tx and Rx DMA channels support into the DW APB SSI binding. Then there are several fixes and cleanups provided as a initial preparation for the Generic DMA support integration: add Tx/Rx finish wait methods, clear DMAC register when done or stopped, Fix native CS being unset, enable interrupts in accordance with DMA xfer mode, discard static DW DMA slave structures, discard unused void priv pointer and dma_width member of the dw_spi structure, provide the DMA Tx/Rx burst length parametrisation and make sure it's optionally set in accordance with the DMA max-burst capability.
In order to have the DW APB SSI MMIO driver working with DMA we need to initialize the paddr field with the physical base address of the DW APB SSI registers space. Then we unpin the Intel MID specific code from the generic DMA one and placed it into the spi-dw-pci.c driver, which is a better place for it anyway. After that the naming cleanups are performed since the code is going to be used for a generic DMAC device. Finally the Generic DMA initialization can be added to the generic version of the DW APB SSI IP.
Last but not least we traditionally convert the legacy plain text-based dt-binding file with yaml-based one and as a cherry on a cake replace the manually written DebugFS registers read method with a ready-to-use for the same purpose regset32 DebugFS interface usage.
This patchset is rebased and tested on the spi/for-next (5.7-rc5):
base-commit: fe9fce6b2cf3 ("Merge remote-tracking branch 'spi/for-5.8' into spi-next")
---
Changelog v2:
- Rebase on top of the spi repository for-next branch.
- Move bindings conversion patch to the tail of the series.
- Move fixes to the head of the series.
- Apply as many changes as possible to be applied the Generic DMA functionality support is added and the spi-dw-mid is moved to the spi-dw-dma driver.
- Discard patch "spi: dw: Fix dma_slave_config used partly uninitialized" since the problem has already been fixed.
- Add new patch "spi: dw: Discard unused void priv pointer".
- Add new patch "spi: dw: Discard dma_width member of the dw_spi structure". n_bytes member of the DW SPI data can be used instead.
- Build the DMA functionality into the DW APB SSI core if required instead of creating a separate kernel module.
- Use conditional statement instead of the ternary operator in the ref clock getter.
Serge Semin (19):
dt-bindings: spi: dw: Add Tx/Rx DMA properties
spi: dw: Add Tx/Rx finish wait methods to the MID DMA
spi: dw: Clear DMAC register when done or stopped
spi: dw: Fix native CS being unset
spi: dw: Enable interrupts in accordance with DMA xfer mode
spi: dw: Discard static DW DMA slave structures
spi: dw: Discard unused void priv pointer
spi: dw: Discard dma_width member of the dw_spi structure
spi: dw: Parameterize the DMA Rx/Tx burst length
spi: dw: Use DMA max burst to set the request thresholds
spi: dw: Initialize paddr in DW SPI MMIO private data
spi: dw: Fix Rx-only DMA transfers
spi: dw: Move Non-DMA code to the DW PCIe-SPI driver
spi: dw: Remove DW DMA code dependency from DW_DMAC_PCI
spi: dw: Add DW SPI DMA/PCI/MMIO dependency on the DW SPI core
spi: dw: Cleanup generic DW DMA code namings
spi: dw: Add DMA support to the DW SPI MMIO driver
spi: dw: Use regset32 DebugFS method to create regdump file
dt-bindings: spi: Convert DW SPI binding to DT schema
.../bindings/spi/snps,dw-apb-ssi.txt | 42 ---
.../bindings/spi/snps,dw-apb-ssi.yaml | 127 +++++++++
.../devicetree/bindings/spi/spi-dw.txt | 24 --
drivers/spi/Kconfig | 15 +-
drivers/spi/Makefile | 7 +-
drivers/spi/{spi-dw-mid.c => spi-dw-dma.c} | 257 ++++++++++--------
drivers/spi/spi-dw-mmio.c | 9 +-
drivers/spi/spi-dw-pci.c | 50 +++-
drivers/spi/spi-dw.c | 98 +++----
drivers/spi/spi-dw.h | 33 ++-
10 files changed, 405 insertions(+), 257 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt
create mode 100644 Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml
delete mode 100644 Documentation/devicetree/bindings/spi/spi-dw.txt
rename drivers/spi/{spi-dw-mid.c => spi-dw-dma.c} (53%)Signature · 1 line
2.25.1
PATCH v2 1/19 dt-bindings: spi: dw: Add Tx/Rx DMA properties
Since commit 22d48ad7bfac ("spi: dw: Add Elkhart Lake PSE DMA support") the spi-dw-mid.c module supports a platform DMA engine handling the DW APB SSI controller requests. Lets alter the DW SPI bindings file to accept the Rx and Tx DMA line specifiers.
---
Changelog v2:
- Revert the order of the DT changes: first add the DMA channels support, then perform the binding file conversion.
--- Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt +2 -0
@@ -23,6 +23,8 @@ Optional properties: - num-cs : The number of chipselects. If omitted, this will default to 4. - reg-io-width : The I/O register width (in bytes) implemented by this device. Supported values are 2 or 4 (the default). +- dmas : Phandle + identifiers of Tx and Rx DMA channels. +- dma-names : Contains the names of the DMA channels. Must be "tx" and "rx". Child nodes as per the generic SPI binding.
Signature · 1 line
2.25.1
Re: [PATCH v2 01/19] dt-bindings: spi: dw: Add Tx/Rx DMA properties
Quoted 4 lines · Serge Semin
Since commit
22d48ad7bfac("spi: dw: Add Elkhart Lake PSE DMA support") thespi-dw-mid.cmodule supports a platform DMA engine handling the DW APB SSI controller requests. Lets alter the DW SPI bindings file to accept the Rx and Tx DMA line specifiers.
I'm wondering if these properties are implied by the SPI generic one? (forgive me if I'm not understanding all DT schema relations)
Per se looks good.
Quoted 38 lines
Signed-off-by Serge Semin <[email protected]>Cc Georgy Vlasov <[email protected]>Cc Ramil Zaripov <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Allison Randal <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Gareth Williams <[email protected]>---
Changelog v2:
- Revert the order of the DT changes: first add the DMA channels support, then perform the binding file conversion.--- Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt | 2 ++ 1 file changed, 2 insertions(+)Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt +2
-0@@ -23,6 +23,8 @@ Optional properties: - num-cs : The number of chipselects. If omitted, this will default to 4. - reg-io-width : The I/O register width (in bytes) implemented by this device. Supported values are 2 or 4 (the default). +- dmas : Phandle + identifiers of Tx and Rx DMA channels. +- dma-names : Contains the names of the DMA channels. Must be "tx" and "rx". Child nodes as per the generic SPI binding.Signature · 1 line
2.25.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
Mark Brown
maintainerRe: [PATCH v2 01/19] dt-bindings: spi: dw: Add Tx/Rx DMA properties
Quoted 9 lines · Andy Shevchenko
Quoted 4 lines · Serge Semin
Since commit
22d48ad7bfac("spi: dw: Add Elkhart Lake PSE DMA support") thespi-dw-mid.cmodule supports a platform DMA engine handling the DW APB SSI controller requests. Lets alter the DW SPI bindings file to accept the Rx and Tx DMA line specifiers.I'm wondering if these properties are implied by the SPI generic one? (forgive me if I'm not understanding all DT schema relations)
Which SPI generic DMA bindings are you thinking of here? There aren't any in spi-controller.yaml.
Re: [PATCH v2 01/19] dt-bindings: spi: dw: Add Tx/Rx DMA properties
Quoted 8 lines · Mark Brown
Quoted 6 lines · Andy Shevchenko
Quoted 4 lines · Serge Semin
Since commit
22d48ad7bfac("spi: dw: Add Elkhart Lake PSE DMA support") thespi-dw-mid.cmodule supports a platform DMA engine handling the DW APB SSI controller requests. Lets alter the DW SPI bindings file to accept the Rx and Tx DMA line specifiers.
Quoted 5 lines
Quoted 2 lines
I'm wondering if these properties are implied by the SPI generic one? (forgive me if I'm not understanding all DT schema relations)
Which SPI generic DMA bindings are you thinking of here? There aren't any in
spi-controller.yaml.
There are default schemas in the dt-core, which defines the dmas and dma-names type, but the exact naming and number of phandler+identifiers are implementation specific. So it's either supposed to be implemented on the generic SPI controller basis (like in someplace of spi-controller.yaml) or in individual controllers DT schema. As Mark said we don't have any DMA properties definition in the generic SPI controller schema (spi-controller.yaml), so the particular SPI controllers DT schemas have got their own DMA properties declared. Most of them BTW use the same naming as we do here: "rx" and "tx", but some alas don't.
-Sergey
PATCH v2 3/19 spi: dw: Clear DMAC register when done or stopped
In reply to Serge SeminIf DMAC register is left uncleared any further DMAless transfers may cause the DMAC hardware handshaking interface getting activated. So the next DMA-based Rx/Tx transaction will be started right after the dma_async_issue_pending() method is invoked even if no DMATDLR/DMARDLR conditions are met. This at the same time may cause the Tx/Rx FIFO buffers underrun/overrun. In order to fix this we must clear DMAC register after a current DMA-based transaction is finished.
---
Changelog v2:
- Move the patch to the head of the series so one could be picked up to the stable kernels as a fix.
- Clear the DMACR in the DMA exit callback too.
--- drivers/spi/spi-dw-mid.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/spi/spi-dw-mid.c +8 -0
@@ -108,6 +108,8 @@ static void mid_spi_dma_exit(struct dw_spi *dws)dmaengine_terminate_sync (dws->rxchan);dma_release_channel (dws->rxchan); } + +dw_writel (dws,DW_SPI_DMACR ,0 ); }static irqreturn_t dma_transfer (struct dw_spi *dws)
@@ -178,6 +180,8 @@ static void dw_spi_dma_tx_done(void *arg)clear_bit (TX_BUSY , &dws->dma_chan_busy);if (test_bit (RX_BUSY , &dws->dma_chan_busy))return ; + +dw_writel (dws,DW_SPI_DMACR ,0 );spi_finalize_current_transfer (dws->master); }
@@ -249,6 +253,8 @@ static void dw_spi_dma_rx_done(void *arg)clear_bit (RX_BUSY , &dws->dma_chan_busy);if (test_bit (TX_BUSY , &dws->dma_chan_busy))return ; + +dw_writel (dws,DW_SPI_DMACR ,0 );spi_finalize_current_transfer (dws->master); }
@@ -342,6 +348,8 @@ static void mid_spi_dma_stop(struct dw_spi *dws)dmaengine_terminate_sync (dws->rxchan);clear_bit (RX_BUSY , &dws->dma_chan_busy); } + +dw_writel (dws,DW_SPI_DMACR ,0 ); }static const struct dw_spi_dma_ops mfld_dma_ops = {
Signature · 1 line
2.25.1
Re: [PATCH v2 03/19] spi: dw: Clear DMAC register when done or stopped
Quoted 8 lines · Serge Semin
If DMAC register is left uncleared any further DMAless transfers may cause the DMAC hardware handshaking interface getting activated. So the next DMA-based Rx/Tx transaction will be started right after the
dma_async_issue_pending()method is invoked even if no DMATDLR/DMARDLR conditions are met. This at the same time may cause the Tx/Rx FIFO buffers underrun/overrun. In order to fix this we must clear DMAC register after a current DMA-based transaction is finished.
After adding a Fixes tag,
Quoted 70 lines
Co-developed-by Georgy Vlasov <[email protected]>Signed-off-by Georgy Vlasov <[email protected]>Signed-off-by Serge Semin <[email protected]>Cc Ramil Zaripov <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Allison Randal <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Gareth Williams <[email protected]>Cc Rob Herring <[email protected]>---
Changelog v2:
- Move the patch to the head of the series so one could be picked up to the stable kernels as a fix.
- Clear the DMACR in the DMA exit callback too.--- drivers/spi/spi-dw-mid.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/spi/spi-dw-mid.c +8
-0@@ -108,6 +108,8 @@ static void mid_spi_dma_exit(struct dw_spi *dws)dmaengine_terminate_sync (dws->rxchan);dma_release_channel (dws->rxchan); } + +dw_writel (dws,DW_SPI_DMACR ,0 ); }static irqreturn_t dma_transfer (struct dw_spi *dws)@@ -178,6 +180,8 @@ static void dw_spi_dma_tx_done(void *arg)clear_bit (TX_BUSY , &dws->dma_chan_busy);if (test_bit (RX_BUSY , &dws->dma_chan_busy))return ; + +dw_writel (dws,DW_SPI_DMACR ,0 );spi_finalize_current_transfer (dws->master); }@@ -249,6 +253,8 @@ static void dw_spi_dma_rx_done(void *arg)clear_bit (RX_BUSY , &dws->dma_chan_busy);if (test_bit (TX_BUSY , &dws->dma_chan_busy))return ; + +dw_writel (dws,DW_SPI_DMACR ,0 );spi_finalize_current_transfer (dws->master); }@@ -342,6 +348,8 @@ static void mid_spi_dma_stop(struct dw_spi *dws)dmaengine_terminate_sync (dws->rxchan);clear_bit (RX_BUSY , &dws->dma_chan_busy); } + +dw_writel (dws,DW_SPI_DMACR ,0 ); }static const struct dw_spi_dma_ops mfld_dma_ops = {Signature · 1 line
2.25.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
Mark Brown
maintainerRe: [PATCH v2 03/19] spi: dw: Clear DMAC register when done or stopped
In reply to Serge SeminQuoted 2 lines · Serge Semin
If DMAC register is left uncleared any further DMAless transfers may cause the DMAC hardware handshaking interface getting activated.
This and patch 4 look good as is but they don't apply against for-5.7 due to context changes in -next, unfortunately everyone seems to have decided that now is the time to start working on this driver which makes combinations of new work and fixes awkward. I'm going to apply these for 5.8 but it'd be good if you could send versions based on for-5.7 as well so I can apply there - I can sort out the conflicts with 5.8.
Re: [PATCH v2 03/19] spi: dw: Clear DMAC register when done or stopped
Quoted 11 lines · Mark Brown
Quoted 2 lines · Serge Semin
If DMAC register is left uncleared any further DMAless transfers may cause the DMAC hardware handshaking interface getting activated.
This and patch 4 look good as is but they don't apply against for-5.7 due to context changes in -next, unfortunately everyone seems to have decided that now is the time to start working on this driver which makes combinations of new work and fixes awkward. I'm going to apply these for 5.8 but it'd be good if you could send versions based on for-5.7 as well so I can apply there - I can sort out the conflicts with 5.8.
Thanks. I'll send these two patches:
spi: dw: Clear DMAC register when done or stopped
spi: dw: Fix native CS being unset
rebased on top of the for-5.7.
-Sergey
PATCH v2 5/19 spi: dw: Enable interrupts in accordance with DMA xfer mode
In reply to Serge SeminIt's pointless to track the Tx overrun interrupts if Rx-only SPI transfer is issued. Similarly there is no need in handling the Rx overrun/underrun interrupts if Tx-only SPI transfer is executed. So lets unmask the interrupts only if corresponding SPI transactions are implied.
--- drivers/spi/spi-dw-mid.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/spi/spi-dw-mid.c +8 -4
@@ -293,19 +293,23 @@ static struct dma_async_tx_descriptor *dw_spi_dma_prepare_rx(struct dw_spi *dws,static int mid_spi_dma_setup (struct dw_spi *dws,struct spi_transfer *xfer) { -u16 dma_ctrl =0 ; +u16 imr =0 , dma_ctrl =0 ;dw_writel (dws,DW_SPI_DMARDLR ,0xf );dw_writel (dws,DW_SPI_DMATDLR ,0x10 ); -if (xfer->tx_buf) +if (xfer->tx_buf) { dma_ctrl |=SPI_DMA_TDMAE ; -if (xfer->rx_buf) + imr |=SPI_INT_TXOI ; + } +if (xfer->rx_buf) { dma_ctrl |=SPI_DMA_RDMAE ; + imr |=SPI_INT_RXUI |SPI_INT_RXOI ; + }dw_writel (dws,DW_SPI_DMACR , dma_ctrl);/* Set the interrupt mask */ -spi_umask_intr (dws,SPI_INT_TXOI |SPI_INT_RXUI |SPI_INT_RXOI ); +spi_umask_intr (dws, imr); dws->transfer_handler = dma_transfer;
Signature · 1 line
2.25.1
Re: [PATCH v2 05/19] spi: dw: Enable interrupts in accordance with DMA xfer mode
Quoted 5 lines · Serge Semin
It's pointless to track the Tx overrun interrupts if Rx-only SPI transfer is issued. Similarly there is no need in handling the Rx overrun/underrun interrupts if Tx-only SPI transfer is executed. So lets unmask the interrupts only if corresponding SPI transactions are implied.
My comments below.
Quoted 7 lines
Co-developed-by Georgy Vlasov <[email protected]>Signed-off-by Georgy Vlasov <[email protected]>Signed-off-by Serge Semin <[email protected]>Cc Ramil Zaripov <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>
Quoted 8 lines
Cc Ralf Baechle <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Allison Randal <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Gareth Williams <[email protected]>Cc Rob Herring <[email protected]>
I think you really need to revisit Cc list in all patches (DT people hardly interested in this one, though ones where properties are being used might be point of interest).
...
drivers/spi/spi-dw-mid.c static struct dma_async_tx_descriptor *dw_spi_dma_prepare_rx(struct dw_spi *dws, · line 312
Quoted 3 lines
drivers/spi/spi-dw-mid.c +1
-1/* Set the interrupt mask */ -spi_umask_intr (dws,SPI_INT_TXOI |SPI_INT_RXUI |SPI_INT_RXOI ); +spi_umask_intr (dws, imr);
Can we rather do like this
/* Set the interrupt mask */ if (xfer->tx_buf) imr |= SPI_INT_TXOI; if (xfer->rx_buf) imr |= SPI_INT_RXUI | SPI_INT_RXOI; spi_umask_intr(dws, imr);
?
(First block sets DMA, second one IRQ)
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 05/19] spi: dw: Enable interrupts in accordance with DMA xfer mode
Quoted 45 lines · Andy Shevchenko
Quoted 5 lines · Serge Semin
It's pointless to track the Tx overrun interrupts if Rx-only SPI transfer is issued. Similarly there is no need in handling the Rx overrun/underrun interrupts if Tx-only SPI transfer is executed. So lets unmask the interrupts only if corresponding SPI transactions are implied.
My comments below.
Quoted 7 lines
Co-developed-by Georgy Vlasov <[email protected]>Signed-off-by Georgy Vlasov <[email protected]>Signed-off-by Serge Semin <[email protected]>Cc Ramil Zaripov <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Quoted 8 lines
Cc Ralf Baechle <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Allison Randal <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Gareth Williams <[email protected]>Cc Rob Herring <[email protected]>I think you really need to revisit Cc list in all patches (DT people hardly interested in this one, though ones where properties are being used might be point of interest).
...
drivers/spi/spi-dw-mid.c static struct dma_async_tx_descriptor *dw_spi_dma_prepare_rx(struct dw_spi *dws, · line 312
Quoted 3 lines
drivers/spi/spi-dw-mid.c +1
-1/* Set the interrupt mask */ -spi_umask_intr (dws,SPI_INT_TXOI |SPI_INT_RXUI |SPI_INT_RXOI ); +spi_umask_intr (dws, imr);Can we rather do like this
/* Set the interrupt mask */ if (xfer->tx_buf) imr |= SPI_INT_TXOI; if (xfer->rx_buf) imr |= SPI_INT_RXUI | SPI_INT_RXOI; spi_umask_intr(dws, imr);
Quoted 3 lines
?
(First block sets DMA, second one IRQ)
I'd rather leave it as is.
-Sergey
Quoted 6 lines
Signature · 3 lines
-- With Best Regards, Andy Shevchenko
PATCH v2 9/19 spi: dw: Parameterize the DMA Rx/Tx burst length
In reply to Serge SeminIt isn't good to have numeric literals in the code especially if there are multiple of them and they are related. Moreover in current implementation the Tx DMA transfer activation level isn't optimal, since it's hardwired to be at 16-32 bytes level, while it's better to keep the SPI FIFO buffer as full as possible until all available data is submitted. So lets introduce the DMA burst level parametrization macros with optimal values - issue Rx transfer if at least 16 bytes are available in the buffer and execute Tx transaction if at least 16 bytes room is opened in SPI Tx FIFO.
--- drivers/spi/spi-dw-mid.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/spi/spi-dw-mid.c +6 -4
@@ -20,7 +20,9 @@#define WAIT_RETRIES 5#define RX_BUSY 0 +#define RX_BURST_LEVEL 16#define TX_BUSY 1 +#define TX_BURST_LEVEL 16static bool mid_spi_dma_chan_filter (struct dma_chan *chan,void *param) {
@@ -193,7 +195,7 @@ static struct dma_async_tx_descriptor *dw_spi_dma_prepare_tx(struct dw_spi *dws,memset (&txconf,0 ,sizeof (txconf)); txconf.direction =DMA_MEM_TO_DEV ; txconf.dst_addr = dws->dma_addr; - txconf.dst_maxburst =16 ; + txconf.dst_maxburst =TX_BURST_LEVEL ; txconf.src_addr_width =DMA_SLAVE_BUSWIDTH_4_BYTES ; txconf.dst_addr_width =convert_dma_width (dws->n_bytes); txconf.device_fc = false;
@@ -266,7 +268,7 @@ static struct dma_async_tx_descriptor *dw_spi_dma_prepare_rx(struct dw_spi *dws,memset (&rxconf,0 ,sizeof (rxconf)); rxconf.direction =DMA_DEV_TO_MEM ; rxconf.src_addr = dws->dma_addr; - rxconf.src_maxburst =16 ; + rxconf.src_maxburst =RX_BURST_LEVEL ; rxconf.dst_addr_width =DMA_SLAVE_BUSWIDTH_4_BYTES ; rxconf.src_addr_width =convert_dma_width (dws->n_bytes); rxconf.device_fc = false;
@@ -291,8 +293,8 @@ static int mid_spi_dma_setup(struct dw_spi *dws, struct spi_transfer *xfer) {u16 imr =0 , dma_ctrl =0 ; -dw_writel (dws,DW_SPI_DMARDLR ,0xf ); -dw_writel (dws,DW_SPI_DMATDLR ,0x10 ); +dw_writel (dws,DW_SPI_DMARDLR ,RX_BURST_LEVEL -1 ); +dw_writel (dws,DW_SPI_DMATDLR , dws->fifo_len -TX_BURST_LEVEL );if (xfer->tx_buf) { dma_ctrl |=SPI_DMA_TDMAE ;
Signature · 1 line
2.25.1
Re: [PATCH v2 09/19] spi: dw: Parameterize the DMA Rx/Tx burst length
Quoted 10 lines · Serge Semin
It isn't good to have numeric literals in the code especially if there are multiple of them and they are related. Moreover in current implementation the Tx DMA transfer activation level isn't optimal, since it's hardwired to be at 16-32 bytes level, while it's better to keep the SPI FIFO buffer as full as possible until all available data is submitted. So lets introduce the DMA burst level parametrization macros with optimal values - issue Rx transfer if at least 16 bytes are available in the buffer and execute Tx transaction if at least 16 bytes room is opened in SPI Tx FIFO.
drivers/spi/spi-dw-mid.c static int mid_spi_dma_setup(struct dw_spi *dws, struct spi_transfer *xfer) · line 297
Quoted 4 lines
drivers/spi/spi-dw-mid.c +2
-2-dw_writel (dws,DW_SPI_DMARDLR ,0xf ); -dw_writel (dws,DW_SPI_DMATDLR ,0x10 ); +dw_writel (dws,DW_SPI_DMARDLR ,RX_BURST_LEVEL -1 ); +dw_writel (dws,DW_SPI_DMATDLR , dws->fifo_len -TX_BURST_LEVEL );
...and if FIFO length is less than TX_BURST_LEVEL?
For the patch that introduces definitions, i.e. keeping the last line here as
dw_writel(dws, DW_SPI_DMATDLR, TX_BURST_LEVEL);
I'm good. You may put your tag in that case. For fifo_len case we need to discuss in separate patch, perhaps.
Signature · 2 lines
With Best Regards, Andy Shevchenko
A message that is not in the archive (sent off-list or not yet received): 20200516143353.hw6nny5hbwgiyxfw@mobilestation
Re: [PATCH v2 09/19] spi: dw: Parameterize the DMA Rx/Tx burst length
Quoted 21 lines · Serge Semin
Quoted 20 lines · Andy Shevchenko
Quoted 10 lines · Serge Semin
It isn't good to have numeric literals in the code especially if there are multiple of them and they are related. Moreover in current implementation the Tx DMA transfer activation level isn't optimal, since it's hardwired to be at 16-32 bytes level, while it's better to keep the SPI FIFO buffer as full as possible until all available data is submitted. So lets introduce the DMA burst level parametrization macros with optimal values - issue Rx transfer if at least 16 bytes are available in the buffer and execute Tx transaction if at least 16 bytes room is opened in SPI Tx FIFO.
drivers/spi/spi-dw-mid.c static int mid_spi_dma_setup(struct dw_spi *dws, struct spi_transfer *xfer) · line 297
Quoted 4 lines
drivers/spi/spi-dw-mid.c +2
-2-dw_writel (dws,DW_SPI_DMARDLR ,0xf ); -dw_writel (dws,DW_SPI_DMATDLR ,0x10 ); +dw_writel (dws,DW_SPI_DMARDLR ,RX_BURST_LEVEL -1 ); +dw_writel (dws,DW_SPI_DMATDLR , dws->fifo_len -TX_BURST_LEVEL );...and if FIFO length is less than
TX_BURST_LEVEL?For the patch that introduces definitions, i.e. keeping the last line here as
Quoted 7 lines
Quoted 4 lines
dw_writel(dws, DW_SPI_DMATDLR, TX_BURST_LEVEL);I'm good. You may put your tag in that case. For
fifo_lencase we need to discuss in separate patch, perhaps.It's fixed in a consequent patch anyway. Though if v3 is required I'll remove this change from here.
I consider that here you might have introduced a regression and actually doing two things in one patch. Why not to split?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 09/19] spi: dw: Parameterize the DMA Rx/Tx burst length
Quoted 24 lines · Andy Shevchenko
Quoted 23 lines · Serge Semin
Quoted 22 lines · Andy Shevchenko
Quoted 10 lines · Serge Semin
It isn't good to have numeric literals in the code especially if there are multiple of them and they are related. Moreover in current implementation the Tx DMA transfer activation level isn't optimal, since it's hardwired to be at 16-32 bytes level, while it's better to keep the SPI FIFO buffer as full as possible until all available data is submitted. So lets introduce the DMA burst level parametrization macros with optimal values - issue Rx transfer if at least 16 bytes are available in the buffer and execute Tx transaction if at least 16 bytes room is opened in SPI Tx FIFO.
drivers/spi/spi-dw-mid.c static int mid_spi_dma_setup(struct dw_spi *dws, struct spi_transfer *xfer) · line 297
Quoted 4 lines
drivers/spi/spi-dw-mid.c +2
-2-dw_writel (dws,DW_SPI_DMARDLR ,0xf ); -dw_writel (dws,DW_SPI_DMATDLR ,0x10 ); +dw_writel (dws,DW_SPI_DMARDLR ,RX_BURST_LEVEL -1 ); +dw_writel (dws,DW_SPI_DMATDLR , dws->fifo_len -TX_BURST_LEVEL );...and if FIFO length is less than
TX_BURST_LEVEL?For the patch that introduces definitions, i.e. keeping the last line here as
dw_writel(dws, DW_SPI_DMATDLR, TX_BURST_LEVEL);
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
I'm good. You may put your tag in that case. For
fifo_lencase we need to discuss in separate patch, perhaps.It's fixed in a consequent patch anyway. Though if v3 is required I'll remove this change from here.
I consider that here you might have introduced a regression and actually doing two things in one patch. Why not to split?
Theoretically I could, but only for a hardware with FIFO smaller than 16 bytes. So did I, seeing this module has been dedicated for the Intel Medfield/Elkhart chips only?
Anyway as I said this change is mostly redundant, since further in this patchset I'll replace the constants used here with burst length properly calculated based on the fifo-length and max-burst-length specific to the DMA.
-Sergey
Quoted 6 lines
Signature · 3 lines
-- With Best Regards, Andy Shevchenko
PATCH v2 10/19 spi: dw: Use DMA max burst to set the request thresholds
In reply to Serge SeminEach channel of DMA controller may have a limited length of burst transaction (number of IO operations performed at ones in a single DMA client request). This parameter can be used to setup the most optimal DMA Tx/Rx data level values. In order to avoid the Tx buffer overrun we can set the DMA Tx level to be of FIFO depth minus the maximum burst transactions length. To prevent the Rx buffer underflow the DMA Rx level should be set to the maximum burst transactions length. This commit setups the DMA channels and the DW SPI DMA Tx/Rx levels in accordance with these rules.
--- drivers/spi/spi-dw-mid.c | 37 +++++++++++++++++++++++++++++++++---- drivers/spi/spi-dw.h | 2 ++ 2 files changed, 35 insertions(+), 4 deletions(-)
drivers/spi/spi-dw-mid.c +33 -4
@@ -35,6 +35,31 @@ static bool mid_spi_dma_chan_filter(struct dma_chan *chan, void *param)return true; } +static void mid_spi_maxburst_init (struct dw_spi *dws) +{ +struct dma_slave_caps caps; +u32 max_burst, def_burst; +int ret; + + def_burst = dws->fifo_len /2 ; + + ret =dma_get_slave_caps (dws->rxchan, &caps); +if (!ret && caps.max_burst) + max_burst = caps.max_burst; +else + max_burst =RX_BURST_LEVEL ; + + dws->rxburst = (def_burst > max_burst) ? max_burst : def_burst; + + ret =dma_get_slave_caps (dws->txchan, &caps); +if (!ret && caps.max_burst) + max_burst = caps.max_burst; +else + max_burst =TX_BURST_LEVEL ; + + dws->txburst = (def_burst > max_burst) ? max_burst : def_burst; +} +static int mid_spi_dma_init_mfld (struct device *dev,struct dw_spi *dws) {struct dw_dma_slave slave = {0 };
@@ -67,6 +92,8 @@ static int mid_spi_dma_init_mfld(struct device *dev, struct dw_spi *dws) dws->master->dma_rx = dws->rxchan; dws->master->dma_tx = dws->txchan; +mid_spi_maxburst_init (dws); +return 0 ; free_rxchan:
@@ -92,6 +119,8 @@ static int mid_spi_dma_init_generic(struct device *dev, struct dw_spi *dws) dws->master->dma_rx = dws->rxchan; dws->master->dma_tx = dws->txchan; +mid_spi_maxburst_init (dws); +return 0 ; }
@@ -195,7 +224,7 @@ static struct dma_async_tx_descriptor *dw_spi_dma_prepare_tx(struct dw_spi *dws,memset (&txconf,0 ,sizeof (txconf)); txconf.direction =DMA_MEM_TO_DEV ; txconf.dst_addr = dws->dma_addr; - txconf.dst_maxburst =TX_BURST_LEVEL ; + txconf.dst_maxburst = dws->txburst; txconf.src_addr_width =DMA_SLAVE_BUSWIDTH_4_BYTES ; txconf.dst_addr_width =convert_dma_width (dws->n_bytes); txconf.device_fc = false;
@@ -268,7 +297,7 @@ static struct dma_async_tx_descriptor *dw_spi_dma_prepare_rx(struct dw_spi *dws,memset (&rxconf,0 ,sizeof (rxconf)); rxconf.direction =DMA_DEV_TO_MEM ; rxconf.src_addr = dws->dma_addr; - rxconf.src_maxburst =RX_BURST_LEVEL ; + rxconf.src_maxburst = dws->rxburst; rxconf.dst_addr_width =DMA_SLAVE_BUSWIDTH_4_BYTES ; rxconf.src_addr_width =convert_dma_width (dws->n_bytes); rxconf.device_fc = false;
@@ -293,8 +322,8 @@ static int mid_spi_dma_setup(struct dw_spi *dws, struct spi_transfer *xfer) {u16 imr =0 , dma_ctrl =0 ; -dw_writel (dws,DW_SPI_DMARDLR ,RX_BURST_LEVEL -1 ); -dw_writel (dws,DW_SPI_DMATDLR , dws->fifo_len -TX_BURST_LEVEL ); +dw_writel (dws,DW_SPI_DMARDLR , dws->rxburst -1 ); +dw_writel (dws,DW_SPI_DMATDLR , dws->fifo_len - dws->txburst);if (xfer->tx_buf) { dma_ctrl |=SPI_DMA_TDMAE ;
drivers/spi/spi-dw.h +2 -0
@@ -141,7 +141,9 @@ struct dw_spi {/* DMA info */ struct dma_chan *txchan; +u32 txburst;struct dma_chan *rxchan; +u32 rxburst;unsigned long dma_chan_busy;dma_addr_t dma_addr;/* phy address of the Data register */ const struct dw_spi_dma_ops *dma_ops;
Signature · 1 line
2.25.1
Re: [PATCH v2 10/19] spi: dw: Use DMA max burst to set the request thresholds
Quoted 9 lines · Serge Semin
Each channel of DMA controller may have a limited length of burst transaction (number of IO operations performed at ones in a single DMA client request). This parameter can be used to setup the most optimal DMA Tx/Rx data level values. In order to avoid the Tx buffer overrun we can set the DMA Tx level to be of FIFO depth minus the maximum burst transactions length. To prevent the Rx buffer underflow the DMA Rx level should be set to the maximum burst transactions length. This commit setups the DMA channels and the DW SPI DMA Tx/Rx levels in accordance with these rules.
It's good one, but see my comments.
I think this patch should go before previous one.
(and without changes regarding FIFO length)
Quoted 6 lines
drivers/spi/spi-dw-mid.c +6
-0+static void mid_spi_maxburst_init (struct dw_spi *dws) +{ +struct dma_slave_caps caps; +u32 max_burst, def_burst; +int ret; +
drivers/spi/spi-dw-mid.c static bool mid_spi_dma_chan_filter(struct dma_chan *chan, void *param) · line 52
Quoted 10 lines
drivers/spi/spi-dw-mid.c +9
-0+ def_burst = dws->fifo_len /2 ; + + ret =dma_get_slave_caps (dws->rxchan, &caps); +if (!ret && caps.max_burst) + max_burst = caps.max_burst; +else + max_burst =RX_BURST_LEVEL ; + + dws->rxburst = (def_burst > max_burst) ? max_burst : def_burst;
min() ?
drivers/spi/spi-dw-mid.c static bool mid_spi_dma_chan_filter(struct dma_chan *chan, void *param) · line 60
Quoted 9 lines
drivers/spi/spi-dw-mid.c +8
-0+ + ret =dma_get_slave_caps (dws->txchan, &caps); +if (!ret && caps.max_burst) + max_burst = caps.max_burst; +else + max_burst =TX_BURST_LEVEL ; + + dws->txburst = (def_burst > max_burst) ? max_burst : def_burst;
Ditto.
Quoted 52 lines
drivers/spi/spi-dw-mid.c +10
-4+} +static int mid_spi_dma_init_mfld (struct device *dev,struct dw_spi *dws) {struct dw_dma_slave slave = {0 };@@ -67,6 +92,8 @@ static int mid_spi_dma_init_mfld(struct device *dev, struct dw_spi *dws) dws->master->dma_rx = dws->rxchan; dws->master->dma_tx = dws->txchan; +mid_spi_maxburst_init (dws); +return 0 ; free_rxchan:@@ -92,6 +119,8 @@ static int mid_spi_dma_init_generic(struct device *dev, struct dw_spi *dws) dws->master->dma_rx = dws->rxchan; dws->master->dma_tx = dws->txchan; +mid_spi_maxburst_init (dws); +return 0 ; }@@ -195,7 +224,7 @@ static struct dma_async_tx_descriptor *dw_spi_dma_prepare_tx(struct dw_spi *dws,memset (&txconf,0 ,sizeof (txconf)); txconf.direction =DMA_MEM_TO_DEV ; txconf.dst_addr = dws->dma_addr; - txconf.dst_maxburst =TX_BURST_LEVEL ; + txconf.dst_maxburst = dws->txburst; txconf.src_addr_width =DMA_SLAVE_BUSWIDTH_4_BYTES ; txconf.dst_addr_width =convert_dma_width (dws->n_bytes); txconf.device_fc = false;@@ -268,7 +297,7 @@ static struct dma_async_tx_descriptor *dw_spi_dma_prepare_rx(struct dw_spi *dws,memset (&rxconf,0 ,sizeof (rxconf)); rxconf.direction =DMA_DEV_TO_MEM ; rxconf.src_addr = dws->dma_addr; - rxconf.src_maxburst =RX_BURST_LEVEL ; + rxconf.src_maxburst = dws->rxburst; rxconf.dst_addr_width =DMA_SLAVE_BUSWIDTH_4_BYTES ; rxconf.src_addr_width =convert_dma_width (dws->n_bytes); rxconf.device_fc = false;@@ -293,8 +322,8 @@ static int mid_spi_dma_setup(struct dw_spi *dws, struct spi_transfer *xfer) {u16 imr =0 , dma_ctrl =0 ; -dw_writel (dws,DW_SPI_DMARDLR ,RX_BURST_LEVEL -1 ); -dw_writel (dws,DW_SPI_DMATDLR , dws->fifo_len -TX_BURST_LEVEL ); +dw_writel (dws,DW_SPI_DMARDLR , dws->rxburst -1 ); +dw_writel (dws,DW_SPI_DMATDLR , dws->fifo_len - dws->txburst);if (xfer->tx_buf) { dma_ctrl |=SPI_DMA_TDMAE ;
...
drivers/spi/spi-dw.h struct dw_spi { · line 146
Quoted 5 lines
drivers/spi/spi-dw.h +2
-0/* DMA info */ struct dma_chan *txchan; +u32 txburst;struct dma_chan *rxchan; +u32 rxburst;
Leave u32 together, it may be optimal on 64-bit architectures where ABIs require padding.
Signature · 2 lines
With Best Regards, Andy Shevchenko
A message that is not in the archive (sent off-list or not yet received): 20200516200133.wmaqnfjbr7234fzo@mobilestation
Re: [PATCH v2 10/19] spi: dw: Use DMA max burst to set the request thresholds
Quoted 11 lines · Serge Semin
Quoted 10 lines · Andy Shevchenko
Quoted 9 lines · Serge Semin
Each channel of DMA controller may have a limited length of burst transaction (number of IO operations performed at ones in a single DMA client request). This parameter can be used to setup the most optimal DMA Tx/Rx data level values. In order to avoid the Tx buffer overrun we can set the DMA Tx level to be of FIFO depth minus the maximum burst transactions length. To prevent the Rx buffer underflow the DMA Rx level should be set to the maximum burst transactions length. This commit setups the DMA channels and the DW SPI DMA Tx/Rx levels in accordance with these rules.
...
Quoted 9 lines
Quoted 7 lines
drivers/spi/spi-dw.h struct dw_spi { · line 146
Quoted 5 lines
drivers/spi/spi-dw.h +2
-0/* DMA info */ struct dma_chan *txchan; +u32 txburst;struct dma_chan *rxchan; +u32 rxburst;Leave u32 together, it may be optimal on 64-bit architectures where ABIs require padding.
It's not like anyone cared about padding in this structure in the first place)
I think I have been caring (to some extend).
Quoted 1 line
Though if v3 is required I'll group these members together.
From what I see v3 is what Mark and me are waiting for. Mark, are we on the same page here?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Mark Brown
maintainerRe: [PATCH v2 10/19] spi: dw: Use DMA max burst to set the request thresholds
Quoted 6 lines · Andy Shevchenko
Quoted 1 line · Serge Semin
Though if v3 is required I'll group these members together.
From what I see v3 is what Mark and me are waiting for. Mark, are we on the same page here?
I loose track of what's going on with this specific patch, sorry - it's patch 10 in the series so there's a good chance it has dependencies on some of the earlier changes anyway.
Re: [PATCH v2 10/19] spi: dw: Use DMA max burst to set the request thresholds
In reply to Andy ShevchenkoQuoted 23 lines · Andy Shevchenko
Quoted 11 lines · Serge Semin
Quoted 10 lines · Andy Shevchenko
Quoted 9 lines · Serge Semin
Each channel of DMA controller may have a limited length of burst transaction (number of IO operations performed at ones in a single DMA client request). This parameter can be used to setup the most optimal DMA Tx/Rx data level values. In order to avoid the Tx buffer overrun we can set the DMA Tx level to be of FIFO depth minus the maximum burst transactions length. To prevent the Rx buffer underflow the DMA Rx level should be set to the maximum burst transactions length. This commit setups the DMA channels and the DW SPI DMA Tx/Rx levels in accordance with these rules.
...
Quoted 8 lines
Quoted 7 lines
drivers/spi/spi-dw.h struct dw_spi { · line 146
Quoted 5 lines
drivers/spi/spi-dw.h +2
-0/* DMA info */ struct dma_chan *txchan; +u32 txburst;struct dma_chan *rxchan; +u32 rxburst;Leave u32 together, it may be optimal on 64-bit architectures where ABIs require padding.
Quoted 3 lines
Quoted 1 line
It's not like anyone cared about padding in this structure in the first place)
I think I have been caring (to some extend).
Well, If you have then instead of asking to rearrange just two members (which by the way finely grouped by the Tx-Rx affiliation) why not sending a patch, which would refactor the whole structure so to be optimal for the x64 platforms? I don't really see why this gets very important for you seeing Mark is Ok with this. My current commit follows the common driver design including the DW SSI data members grouping. On the second thought I'll leave it as is then.
-Sergey
Quoted 11 lines
Quoted 2 lines
Though if v3 is required I'll group these members together.
From what I see v3 is what Mark and me are waiting for. Mark, are we on the same page here?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 10/19] spi: dw: Use DMA max burst to set the request thresholds
Quoted 4 lines · Serge Semin
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Serge Semin
Quoted 1 line · Andy Shevchenko
On Fri, May 15, 2020 at 01:47:49PM +0300, Serge Semin wrote:
...
Quoted 11 lines
Quoted 10 lines
Quoted 8 lines
Quoted 6 lines
drivers/spi/spi-dw.h struct dw_spi { · line 146
Quoted 4 lines
struct dma_chan *txchan;drivers/spi/spi-dw.h +2
-0+u32 txburst;struct dma_chan *rxchan; +u32 rxburst;Leave u32 together, it may be optimal on 64-bit architectures where ABIs require padding.
It's not like anyone cared about padding in this structure in the first place)
I think I have been caring (to some extend).
Quoted 7 lines
Well, If you have then instead of asking to rearrange just two members (which by the way finely grouped by the Tx-Rx affiliation) why not sending a patch, which would refactor the whole structure so to be optimal for the x64 platforms? I don't really see why this gets very important for you seeing Mark is Ok with this. My current commit follows the common driver design including the DW SSI data members grouping. On the second thought I'll leave it as is then.
Again same issue here. What is really easy to do for you here, will become a burden and additional churn to anybody else. So, why not to minimize it in the first place? Same with comma in another patch. Sorry, I really don't get it.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 10/19] spi: dw: Use DMA max burst to set the request thresholds
Quoted 28 lines · Andy Shevchenko
Quoted 4 lines · Serge Semin
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Serge Semin
Quoted 1 line · Andy Shevchenko
On Fri, May 15, 2020 at 01:47:49PM +0300, Serge Semin wrote:
...
Quoted 11 lines
Quoted 10 lines
Quoted 8 lines
Quoted 6 lines
drivers/spi/spi-dw.h struct dw_spi { · line 146
Quoted 4 lines
struct dma_chan *txchan;drivers/spi/spi-dw.h +2
-0+u32 txburst;struct dma_chan *rxchan; +u32 rxburst;Leave u32 together, it may be optimal on 64-bit architectures where ABIs require padding.
It's not like anyone cared about padding in this structure in the first place)
I think I have been caring (to some extend).
Quoted 7 lines
Well, If you have then instead of asking to rearrange just two members (which by the way finely grouped by the Tx-Rx affiliation) why not sending a patch, which would refactor the whole structure so to be optimal for the x64 platforms? I don't really see why this gets very important for you seeing Mark is Ok with this. My current commit follows the common driver design including the DW SSI data members grouping. On the second thought I'll leave it as is then.
Quoted 4 lines
Again same issue here. What is really easy to do for you here, will become a burden and additional churn to anybody else. So, why not to minimize it in the first place? Same with comma in another patch. Sorry, I really don't get it.
If comma is more or less understandable (though adding it is absolutely redundant there and doesn't worth even a bit of time spending for the discussion), here you consider the patch from padding point of view. The driver developer didn't care about it, but did care about grouping the members in a corresponding way. The padding burden will be there anyway and should be fixed for the whole structure in an additional patch. Until then the way of grouping should be preserved.
-Sergey
Quoted 4 lines
Signature · 3 lines
-- With Best Regards, Andy Shevchenko
Re: [PATCH v2 10/19] spi: dw: Use DMA max burst to set the request thresholds
Quoted 7 lines · Serge Semin
Quoted 6 lines · Andy Shevchenko
Quoted 4 lines · Serge Semin
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Serge Semin
Quoted 1 line · Andy Shevchenko
On Fri, May 15, 2020 at 01:47:49PM +0300, Serge Semin wrote:
...
Quoted 17 lines
Quoted 12 lines
Quoted 11 lines
Quoted 3 lines
Quoted 1 line
It's not like anyone cared about padding in this structure in the first place)
I think I have been caring (to some extend).
Well, If you have then instead of asking to rearrange just two members (which by the way finely grouped by the Tx-Rx affiliation) why not sending a patch, which would refactor the whole structure so to be optimal for the x64 platforms? I don't really see why this gets very important for you seeing Mark is Ok with this. My current commit follows the common driver design including the DW SSI data members grouping. On the second thought I'll leave it as is then.
Quoted 4 lines
Again same issue here. What is really easy to do for you here, will become a burden and additional churn to anybody else. So, why not to minimize it in the first place? Same with comma in another patch. Sorry, I really don't get it.
Quoted 7 lines
If comma is more or less understandable (though adding it is absolutely redundant there and doesn't worth even a bit of time spending for the discussion), here you consider the patch from padding point of view. The driver developer didn't care about it, but did care about grouping the members in a corresponding way. The padding burden will be there anyway and should be fixed for the whole structure in an additional patch. Until then the way of grouping should be preserved.
Like you said, we spent already much more time than that simple change can be satisfied. And like you said, "deleloper ... did care about groupping members in a corresponding way". So, if we look at this in the original code, my suggestion, besides padding benefit, is consistent with existing pattern in that data structure.
Note, I agree on extern keyword change can be postponed (it was in the original code), but here you introduce a new code...
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 10/19] spi: dw: Use DMA max burst to set the request thresholds
Quoted 36 lines · Andy Shevchenko
Quoted 7 lines · Serge Semin
Quoted 6 lines · Andy Shevchenko
Quoted 4 lines · Serge Semin
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Serge Semin
Quoted 1 line · Andy Shevchenko
On Fri, May 15, 2020 at 01:47:49PM +0300, Serge Semin wrote:
...
Quoted 17 lines
Quoted 12 lines
Quoted 11 lines
Quoted 3 lines
Quoted 1 line
It's not like anyone cared about padding in this structure in the first place)
I think I have been caring (to some extend).
Well, If you have then instead of asking to rearrange just two members (which by the way finely grouped by the Tx-Rx affiliation) why not sending a patch, which would refactor the whole structure so to be optimal for the x64 platforms? I don't really see why this gets very important for you seeing Mark is Ok with this. My current commit follows the common driver design including the DW SSI data members grouping. On the second thought I'll leave it as is then.
Quoted 4 lines
Again same issue here. What is really easy to do for you here, will become a burden and additional churn to anybody else. So, why not to minimize it in the first place? Same with comma in another patch. Sorry, I really don't get it.
Quoted 7 lines
If comma is more or less understandable (though adding it is absolutely redundant there and doesn't worth even a bit of time spending for the discussion), here you consider the patch from padding point of view. The driver developer didn't care about it, but did care about grouping the members in a corresponding way. The padding burden will be there anyway and should be fixed for the whole structure in an additional patch. Until then the way of grouping should be preserved.
Quoted 5 lines
Like you said, we spent already much more time than that simple change can be satisfied. And like you said, "deleloper ... did care about groupping members in a corresponding way". So, if we look at this in the original code, my suggestion, besides padding benefit, is consistent with existing pattern in that data structure.
What pattern do you mean? As I see it, my implementation is consistent with current structure structure, while yours is not.
-Sergey
Quoted 9 lines
Note, I agree on extern keyword change can be postponed (it was in the original code), but here you introduce a new code...
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v2 11/19 spi: dw: Initialize paddr in DW SPI MMIO private data
In reply to Serge SeminThis field is used only for the DW SPI DMA code initialization, that's why there were no problems with it being uninitialized in Dw SPI MMIO driver. Since in a further patch we are going to introduce the DW SPI DMA support in the MMIO version of the driver, lets set the field with the physical address of the DW SPI controller registers region.
--- drivers/spi/spi-dw-mmio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/spi/spi-dw-mmio.c +4 -1
@@ -184,6 +184,7 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)int (*init_func)(struct platform_device *pdev,struct dw_spi_mmio *dwsmmio);struct dw_spi_mmio *dwsmmio; +struct resource *mem;struct dw_spi *dws;int ret;int num_cs;
@@ -196,10 +197,12 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) dws = &dwsmmio->dws;/* Get basic io resource and map it */ - dws->regs =devm_platform_ioremap_resource (pdev,0 ); + dws->regs =devm_platform_get_and_ioremap_resource (pdev,0 , &mem);if (IS_ERR (dws->regs))return PTR_ERR (dws->regs); + dws->paddr = mem->start; + dws->irq =platform_get_irq (pdev,0 );if (dws->irq <0 )return dws->irq;/* -ENXIO */
Signature · 1 line
2.25.1
Re: [PATCH v2 11/19] spi: dw: Initialize paddr in DW SPI MMIO private data
Quoted 5 lines · Serge Semin
This field is used only for the DW SPI DMA code initialization, that's why there were no problems with it being uninitialized in Dw SPI MMIO driver. Since in a further patch we are going to introduce the DW SPI DMA support in the MMIO version of the driver, lets set the field with the physical address of the DW SPI controller registers region.
Quoted 50 lines
Co-developed-by Georgy Vlasov <[email protected]>Signed-off-by Georgy Vlasov <[email protected]>Co-developed-by Ramil Zaripov <[email protected]>Signed-off-by Ramil Zaripov <[email protected]>Signed-off-by Serge Semin <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Allison Randal <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Gareth Williams <[email protected]>Cc Rob Herring <[email protected]>--- drivers/spi/spi-dw-mmio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/spi/spi-dw-mmio.c +4
-1@@ -184,6 +184,7 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)int (*init_func)(struct platform_device *pdev,struct dw_spi_mmio *dwsmmio);struct dw_spi_mmio *dwsmmio; +struct resource *mem;struct dw_spi *dws;int ret;int num_cs;@@ -196,10 +197,12 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) dws = &dwsmmio->dws;/* Get basic io resource and map it */ - dws->regs =devm_platform_ioremap_resource (pdev,0 ); + dws->regs =devm_platform_get_and_ioremap_resource (pdev,0 , &mem);if (IS_ERR (dws->regs))return PTR_ERR (dws->regs); + dws->paddr = mem->start; + dws->irq =platform_get_irq (pdev,0 );if (dws->irq <0 )return dws->irq;/* -ENXIO */ Signature · 1 line
2.25.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v2 14/19 spi: dw: Remove DW DMA code dependency from DW_DMAC_PCI
In reply to Serge SeminSince there is a generic method available to initialize the DW SPI DMA interface on any DT and ACPI-based platforms, which in general can be designed with not only DW DMAC but with any DMA engine on board, we can freely remove the CONFIG_DW_DMAC_PCI config from dependency list of CONFIG_SPI_DW_DMA. Especially seeing that we don't use anything DW DMAC specific in the new driver.
--- drivers/spi/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/Kconfig +1 -1
@@ -228,7 +228,7 @@ config SPI_DESIGNWARE config SPI_DW_DMA bool "DMA support for DW SPI controller" - depends on SPI_DESIGNWARE && DW_DMAC_PCI + depends on SPI_DESIGNWARE config SPI_DW_PCI tristate "PCI interface driver for DW SPI core"
Signature · 1 line
2.25.1
Re: [PATCH v2 14/19] spi: dw: Remove DW DMA code dependency from DW_DMAC_PCI
Quoted 6 lines · Serge Semin
Since there is a generic method available to initialize the DW SPI DMA interface on any DT and ACPI-based platforms, which in general can be designed with not only DW DMAC but with any DMA engine on board, we can freely remove the
CONFIG_DW_DMAC_PCIconfig from dependency list ofCONFIG_SPI_DW_DMA. Especially seeing that we don't use anything DW DMAC specific in the new driver.
Right, and used data structures are always available at compile time.
Quoted 36 lines
Co-developed-by Georgy Vlasov <[email protected]>Signed-off-by Georgy Vlasov <[email protected]>Co-developed-by Ramil Zaripov <[email protected]>Signed-off-by Ramil Zaripov <[email protected]>Signed-off-by Serge Semin <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Rob Herring <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Allison Randal <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Gareth Williams <[email protected]>--- drivers/spi/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/spi/Kconfig +1
-1@@ -228,7 +228,7 @@ config SPI_DESIGNWARE config SPI_DW_DMA bool "DMA support for DW SPI controller" - depends on SPI_DESIGNWARE && DW_DMAC_PCI + depends on SPI_DESIGNWARE config SPI_DW_PCI tristate "PCI interface driver for DW SPI core"Signature · 1 line
2.25.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v2 15/19 spi: dw: Add DW SPI DMA/PCI/MMIO dependency on the DW SPI core
In reply to Serge SeminSeeing all of the DW SPI driver components like DW SPI DMA/PCI/MMIO depend on the DW SPI core code it's better to use the if-endif conditional kernel config statement to signify that common dependency.
--- drivers/spi/Kconfig | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/spi/Kconfig +6 -3
@@ -226,17 +226,20 @@ config SPI_DESIGNWARE help general driver for SPI controller core from DesignWare +if SPI_DESIGNWARE + config SPI_DW_DMA bool "DMA support for DW SPI controller" - depends on SPI_DESIGNWARE config SPI_DW_PCI tristate "PCI interface driver for DW SPI core" - depends on SPI_DESIGNWARE && PCI + depends on PCI config SPI_DW_MMIO tristate "Memory-mapped io interface driver for DW SPI core" - depends on SPI_DESIGNWARE + depends on HAS_IOMEM + +endif config SPI_DLN2 tristate "Diolan DLN-2 USB SPI adapter"
Signature · 1 line
2.25.1
Re: [PATCH v2 15/19] spi: dw: Add DW SPI DMA/PCI/MMIO dependency on the DW SPI core
Quoted 3 lines · Serge Semin
Seeing all of the DW SPI driver components like DW SPI DMA/PCI/MMIO depend on the DW SPI core code it's better to use the if-endif conditional kernel config statement to signify that common dependency.
Makes sense!
Quoted 52 lines
Co-developed-by Georgy Vlasov <[email protected]>Signed-off-by Georgy Vlasov <[email protected]>Co-developed-by Ramil Zaripov <[email protected]>Signed-off-by Ramil Zaripov <[email protected]>Signed-off-by Serge Semin <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Allison Randal <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Gareth Williams <[email protected]>Cc Rob Herring <[email protected]>--- drivers/spi/Kconfig | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)drivers/spi/Kconfig +6
-3@@ -226,17 +226,20 @@ config SPI_DESIGNWARE help general driver for SPI controller core from DesignWare +if SPI_DESIGNWARE + config SPI_DW_DMA bool "DMA support for DW SPI controller" - depends on SPI_DESIGNWARE config SPI_DW_PCI tristate "PCI interface driver for DW SPI core" - depends on SPI_DESIGNWARE && PCI + depends on PCI config SPI_DW_MMIO tristate "Memory-mapped io interface driver for DW SPI core" - depends on SPI_DESIGNWARE + depends on HAS_IOMEM + +endif config SPI_DLN2 tristate "Diolan DLN-2 USB SPI adapter"Signature · 1 line
2.25.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v2 17/19 spi: dw: Add DMA support to the DW SPI MMIO driver
In reply to Serge SeminSince the common code in the spi-dw-dma.c driver is ready to be used by the MMIO driver and now provides a method to generically (on any DT or ACPI-based platforms) retrieve the Tx/Rx DMA channel handlers, we can use it and a set of the common DW SPI DMA callbacks to enable DMA at least for generic "snps,dw-apb-ssi" and "snps,dwc-ssi-1.01a" devices.
--- drivers/spi/spi-dw-mmio.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/spi/spi-dw-mmio.c +4 -0
@@ -149,6 +149,8 @@ static int dw_spi_dw_apb_init(struct platform_device *pdev,/* Register hook to configure CTRLR0 */ dwsmmio->dws.update_cr0 = dw_spi_update_cr0; +dw_spi_dma_setup_generic (&dwsmmio->dws); +return 0 ; }
@@ -158,6 +160,8 @@ static int dw_spi_dwc_ssi_init(struct platform_device *pdev,/* Register hook to configure CTRLR0 */ dwsmmio->dws.update_cr0 = dw_spi_update_cr0_v1_01a; +dw_spi_dma_setup_generic (&dwsmmio->dws); +return 0 ; }
Signature · 1 line
2.25.1
Re: [PATCH v2 17/19] spi: dw: Add DMA support to the DW SPI MMIO driver
Quoted 6 lines · Serge Semin
Since the common code in the
spi-dw-dma.cdriver is ready to be used by the MMIO driver and now provides a method to generically (on any DT or ACPI-based platforms) retrieve the Tx/Rx DMA channel handlers, we can use it and a set of the common DW SPI DMA callbacks to enable DMA at least for generic "snps,dw-apb-ssi" and "snps,dwc-ssi-1.01a" devices.
Quoted 46 lines
Co-developed-by Georgy Vlasov <[email protected]>Signed-off-by Georgy Vlasov <[email protected]>Co-developed-by Ramil Zaripov <[email protected]>Signed-off-by Ramil Zaripov <[email protected]>Signed-off-by Serge Semin <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Allison Randal <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Gareth Williams <[email protected]>Cc Rob Herring <[email protected]>--- drivers/spi/spi-dw-mmio.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/spi/spi-dw-mmio.c +4
-0@@ -149,6 +149,8 @@ static int dw_spi_dw_apb_init(struct platform_device *pdev,/* Register hook to configure CTRLR0 */ dwsmmio->dws.update_cr0 = dw_spi_update_cr0; +dw_spi_dma_setup_generic (&dwsmmio->dws); +return 0 ; }@@ -158,6 +160,8 @@ static int dw_spi_dwc_ssi_init(struct platform_device *pdev,/* Register hook to configure CTRLR0 */ dwsmmio->dws.update_cr0 = dw_spi_update_cr0_v1_01a; +dw_spi_dma_setup_generic (&dwsmmio->dws); +return 0 ; }Signature · 1 line
2.25.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v2 19/19 dt-bindings: spi: Convert DW SPI binding to DT schema
In reply to Serge SeminModern device tree bindings are supposed to be created as YAML-files in accordance with dt-schema. This commit replaces two DW SPI legacy bare text bindings with YAML file. As before the bindings file states that the corresponding dts node is supposed to be compatible either with generic DW APB SSI controller or with Microsemi/Amazon/Renesas/Intel vendors-specific controllers, to have registers, interrupts and clocks properties. Though in case of Microsemi version of the controller there must be two registers resources specified. Properties like clock-names, reg-io-width, cs-gpio, num-cs, DMA and slave device sub-nodes are optional.
--- .../bindings/spi/snps,dw-apb-ssi.txt | 44 ------ .../bindings/spi/snps,dw-apb-ssi.yaml | 127 ++++++++++++++++++ .../devicetree/bindings/spi/spi-dw.txt | 24 ---- 3 files changed, 127 insertions(+), 68 deletions(-) delete mode 100644 Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt create mode 100644 Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml delete mode 100644 Documentation/devicetree/bindings/spi/spi-dw.txt
Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt deleted +0 -44
@@ -1,44 +0,0 @@ -Synopsys DesignWare AMBA 2.0 Synchronous Serial Interface. - -Required properties: -- compatible : "snps,dw-apb-ssi" or "mscc,<soc>-spi", where soc is "ocelot" or - "jaguar2", or "amazon,alpine-dw-apb-ssi", or "snps,dwc-ssi-1.01a" or - "intel,keembay-ssi" -- reg : The register base for the controller. For "mscc,<soc>-spi", a second - register set is required (named ICPU_CFG:SPI_MST) -- interrupts : One interrupt, used by the controller. -- #address-cells : <1>, as required by generic SPI binding. -- #size-cells : <0>, also as required by generic SPI binding. -- clocks : phandles for the clocks, see the description of clock-names below. - The phandle for the "ssi_clk" is required. The phandle for the "pclk" clock - is optional. If a single clock is specified but no clock-name, it is the - "ssi_clk" clock. If both clocks are listed, the "ssi_clk" must be first. - -Optional properties: -- clock-names : Contains the names of the clocks: - "ssi_clk", for the core clock used to generate the external SPI clock. - "pclk", the interface clock, required for register access. If a clock domain - used to enable this clock then it should be named "pclk_clkdomain". -- cs-gpios : Specifies the gpio pins to be used for chipselects. -- num-cs : The number of chipselects. If omitted, this will default to 4. -- reg-io-width : The I/O register width (in bytes) implemented by this - device. Supported values are 2 or 4 (the default). -- dmas : Phandle + identifiers of Tx and Rx DMA channels. -- dma-names : Contains the names of the DMA channels. Must be "tx" and "rx". - -Child nodes as per the generic SPI binding. - -Example: - - spi@fff00000 { - compatible = "snps,dw-apb-ssi"; - reg = <0xfff00000 0x1000>; - interrupts = <0 154 4>; - #address-cells = <1>; - #size-cells = <0>; - clocks = <&spi_m_clk>; - num-cs = <2>; - cs-gpios = <&gpio0 13 0>, - <&gpio0 14 0>; - }; -
Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml new file +127 -0
127 lines not on this page · raw message
Documentation/devicetree/bindings/spi/spi-dw.txt deleted +0 -24
@@ -1,24 +0,0 @@ -Synopsys DesignWare SPI master - -Required properties: -- compatible: should be "snps,designware-spi" -- #address-cells: see spi-bus.txt -- #size-cells: see spi-bus.txt -- reg: address and length of the spi master registers -- interrupts: should contain one interrupt -- clocks: spi clock phandle -- num-cs: see spi-bus.txt - -Optional properties: -- cs-gpios: see spi-bus.txt - -Example: - -spi: spi@4020a000 { - compatible = "snps,designware-spi"; - interrupts = <11 1>; - reg = <0x4020a000 0x1000>; - clocks = <&pclk>; - num-cs = <2>; - cs-gpios = <&banka 0 0>; -};
Signature · 1 line
2.25.1
Re: [PATCH v2 19/19] dt-bindings: spi: Convert DW SPI binding to DT schema
Rob,
Could you take a look at this patch? We are getting closer to merging the series into the spi/for-next branch and then to the kernel 5.8. It would be great to have the bindings converted by the next merge window.
-Sergey
Quoted 10 lines · Serge Semin
Modern device tree bindings are supposed to be created as YAML-files in accordance with dt-schema. This commit replaces two DW SPI legacy bare text bindings with YAML file. As before the bindings file states that the corresponding dts node is supposed to be compatible either with generic DW APB SSI controller or with Microsemi/Amazon/Renesas/Intel vendors-specific controllers, to have registers, interrupts and clocks properties. Though in case of Microsemi version of the controller there must be two registers resources specified. Properties like clock-names, reg-io-width, cs-gpio, num-cs, DMA and slave device sub-nodes are optional.
[nip]
Quoted 27 lines · Serge Semin
Baikal-T1 SoC provides a DW DMA controller to perform low-speed peripherals Mem-to-Dev and Dev-to-Mem transaction. This is also applicable to the DW APB SSI devices embedded into the SoC. Currently the DMA-based transfers are supported by the DW APB SPI driver only as a middle layer code for Intel MID/Elkhart PCI devices. Seeing the same code can be used for normal platform DMAC device we introduced a set of patches to fix it within this series.
First of all we need to add the Tx and Rx DMA channels support into the DW APB SSI binding. Then there are several fixes and cleanups provided as a initial preparation for the Generic DMA support integration: add Tx/Rx finish wait methods, clear DMAC register when done or stopped, Fix native CS being unset, enable interrupts in accordance with DMA xfer mode, discard static DW DMA slave structures, discard unused void priv pointer and
dma_widthmember of thedw_spistructure, provide the DMA Tx/Rx burst length parametrisation and make sure it's optionally set in accordance with the DMA max-burst capability.In order to have the DW APB SSI MMIO driver working with DMA we need to initialize the paddr field with the physical base address of the DW APB SSI registers space. Then we unpin the Intel MID specific code from the generic DMA one and placed it into the
spi-dw-pci.cdriver, which is a better place for it anyway. After that the naming cleanups are performed since the code is going to be used for a generic DMAC device. Finally the Generic DMA initialization can be added to the generic version of the DW APB SSI IP.
Quoted 7 lines
Last but not least we traditionally convert the legacy plain text-based dt-binding file with yaml-based one and as a cherry on a cake replace the manually written DebugFS registers read method with a ready-to-use for the same purpose regset32 DebugFS interface usage.
This patchset is rebased and tested on the spi/for-next (5.7-rc5):
base-commit:fe9fce6b2cf3("Merge remote-tracking branch 'spi/for-5.8' into spi-next")
Thanks! I'm going to review it soon.
Hint for the next time, please start always a new thread with new version.
Quoted 83 lines
Co-developed-by Georgy Vlasov <[email protected]>Signed-off-by Georgy Vlasov <[email protected]>Co-developed-by Ramil Zaripov <[email protected]>Signed-off-by Ramil Zaripov <[email protected]>Signed-off-by Serge Semin <[email protected]>Cc Alexey Malahov <[email protected]>Cc Maxim Kaurkin <[email protected]>Cc Pavel Parkhomenko <[email protected]>Cc Ekaterina Skachko <[email protected]>Cc Vadim Vlasov <[email protected]>Cc Alexey Kolotnikov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Allison Randal <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Gareth Williams <[email protected]>Cc Rob Herring <[email protected]>---
Changelog v2:
- Rebase on top of the spi repository for-next branch.
- Move bindings conversion patch to the tail of the series.
- Move fixes to the head of the series.
- Apply as many changes as possible to be applied the Generic DMA functionality support is added and the spi-dw-mid is moved to the spi-dw-dma driver.
- Discard patch "spi: dw: Fixdma_slave_configused partly uninitialized" since the problem has already been fixed.
- Add new patch "spi: dw: Discard unused void priv pointer".
- Add new patch "spi: dw: Discarddma_widthmember of thedw_spistructure".n_bytesmember of the DW SPI data can be used instead.
- Build the DMA functionality into the DW APB SSI core if required instead of creating a separate kernel module.
- Use conditional statement instead of the ternary operator in the ref clock getter.Serge Semin (19):
dt-bindings: spi: dw: Add Tx/Rx DMA properties
spi: dw: Add Tx/Rx finish wait methods to the MID DMA
spi: dw: Clear DMAC register when done or stopped
spi: dw: Fix native CS being unset
spi: dw: Enable interrupts in accordance with DMA xfer mode
spi: dw: Discard static DW DMA slave structures
spi: dw: Discard unused void priv pointer
spi: dw: Discarddma_widthmember of thedw_spistructure
spi: dw: Parameterize the DMA Rx/Tx burst length
spi: dw: Use DMA max burst to set the request thresholds
spi: dw: Initialize paddr in DW SPI MMIO private data
spi: dw: Fix Rx-only DMA transfers
spi: dw: Move Non-DMA code to the DW PCIe-SPI driver
spi: dw: Remove DW DMA code dependency fromDW_DMAC_PCI
spi: dw: Add DW SPI DMA/PCI/MMIO dependency on the DW SPI core
spi: dw: Cleanup generic DW DMA code namings
spi: dw: Add DMA support to the DW SPI MMIO driver
spi: dw: Use regset32 DebugFS method to create regdump file
dt-bindings: spi: Convert DW SPI binding to DT schema.../bindings/spi/snps,dw-apb-ssi.txt | 42 --- .../bindings/spi/snps,dw-apb-ssi.yaml | 127 +++++++++ .../devicetree/bindings/spi/spi-dw.txt | 24 -- drivers/spi/Kconfig | 15 +- drivers/spi/Makefile | 7 +- drivers/spi/{spi-dw-mid.c => spi-dw-dma.c} | 257 ++++++++++-------- drivers/spi/spi-dw-mmio.c | 9 +- drivers/spi/spi-dw-pci.c | 50 +++- drivers/spi/spi-dw.c | 98 +++---- drivers/spi/spi-dw.h | 33 ++- 10 files changed, 405 insertions(+), 257 deletions(-) delete mode 100644 Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt create mode 100644 Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml delete mode 100644 Documentation/devicetree/bindings/spi/spi-dw.txt rename drivers/spi/{spi-dw-mid.c => spi-dw-dma.c} (53%)Signature · 1 line
2.25.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 33 lines · Andy Shevchenko
Quoted 32 lines · Serge Semin
Baikal-T1 SoC provides a DW DMA controller to perform low-speed peripherals Mem-to-Dev and Dev-to-Mem transaction. This is also applicable to the DW APB SSI devices embedded into the SoC. Currently the DMA-based transfers are supported by the DW APB SPI driver only as a middle layer code for Intel MID/Elkhart PCI devices. Seeing the same code can be used for normal platform DMAC device we introduced a set of patches to fix it within this series.
First of all we need to add the Tx and Rx DMA channels support into the DW APB SSI binding. Then there are several fixes and cleanups provided as a initial preparation for the Generic DMA support integration: add Tx/Rx finish wait methods, clear DMAC register when done or stopped, Fix native CS being unset, enable interrupts in accordance with DMA xfer mode, discard static DW DMA slave structures, discard unused void priv pointer and
dma_widthmember of thedw_spistructure, provide the DMA Tx/Rx burst length parametrisation and make sure it's optionally set in accordance with the DMA max-burst capability.In order to have the DW APB SSI MMIO driver working with DMA we need to initialize the paddr field with the physical base address of the DW APB SSI registers space. Then we unpin the Intel MID specific code from the generic DMA one and placed it into the
spi-dw-pci.cdriver, which is a better place for it anyway. After that the naming cleanups are performed since the code is going to be used for a generic DMAC device. Finally the Generic DMA initialization can be added to the generic version of the DW APB SSI IP.Last but not least we traditionally convert the legacy plain text-based dt-binding file with yaml-based one and as a cherry on a cake replace the manually written DebugFS registers read method with a ready-to-use for the same purpose regset32 DebugFS interface usage.
Quoted 6 lines
Quoted 2 lines
This patchset is rebased and tested on the spi/for-next (5.7-rc5):
base-commit:fe9fce6b2cf3("Merge remote-tracking branch 'spi/for-5.8' into spi-next")Thanks! I'm going to review it soon.
Hint for the next time, please start always a new thread with new version.
Thanks for suggestion. Indeed my knowledge of the submission procedure has been incomplete: "However, for a multi-patch series, it is generally best to avoid using In-Reply-To: to link to older versions of the series. This way multiple versions of the patch don't become an unmanageable forest of references in email clients." [1]
[1] Documentation/process/submitting-patches.rst
-Sergey
Quoted 90 lines
Quoted 84 lines
Co-developed-by Georgy Vlasov <[email protected]>Signed-off-by Georgy Vlasov <[email protected]>Co-developed-by Ramil Zaripov <[email protected]>Signed-off-by Ramil Zaripov <[email protected]>Signed-off-by Serge Semin <[email protected]>Cc Alexey Malahov <[email protected]>Cc Maxim Kaurkin <[email protected]>Cc Pavel Parkhomenko <[email protected]>Cc Ekaterina Skachko <[email protected]>Cc Vadim Vlasov <[email protected]>Cc Alexey Kolotnikov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Allison Randal <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Gareth Williams <[email protected]>Cc Rob Herring <[email protected]>---
Changelog v2:
- Rebase on top of the spi repository for-next branch.
- Move bindings conversion patch to the tail of the series.
- Move fixes to the head of the series.
- Apply as many changes as possible to be applied the Generic DMA functionality support is added and the spi-dw-mid is moved to the spi-dw-dma driver.
- Discard patch "spi: dw: Fixdma_slave_configused partly uninitialized" since the problem has already been fixed.
- Add new patch "spi: dw: Discard unused void priv pointer".
- Add new patch "spi: dw: Discarddma_widthmember of thedw_spistructure".n_bytesmember of the DW SPI data can be used instead.
- Build the DMA functionality into the DW APB SSI core if required instead of creating a separate kernel module.
- Use conditional statement instead of the ternary operator in the ref clock getter.Serge Semin (19):
dt-bindings: spi: dw: Add Tx/Rx DMA properties
spi: dw: Add Tx/Rx finish wait methods to the MID DMA
spi: dw: Clear DMAC register when done or stopped
spi: dw: Fix native CS being unset
spi: dw: Enable interrupts in accordance with DMA xfer mode
spi: dw: Discard static DW DMA slave structures
spi: dw: Discard unused void priv pointer
spi: dw: Discarddma_widthmember of thedw_spistructure
spi: dw: Parameterize the DMA Rx/Tx burst length
spi: dw: Use DMA max burst to set the request thresholds
spi: dw: Initialize paddr in DW SPI MMIO private data
spi: dw: Fix Rx-only DMA transfers
spi: dw: Move Non-DMA code to the DW PCIe-SPI driver
spi: dw: Remove DW DMA code dependency fromDW_DMAC_PCI
spi: dw: Add DW SPI DMA/PCI/MMIO dependency on the DW SPI core
spi: dw: Cleanup generic DW DMA code namings
spi: dw: Add DMA support to the DW SPI MMIO driver
spi: dw: Use regset32 DebugFS method to create regdump file
dt-bindings: spi: Convert DW SPI binding to DT schema.../bindings/spi/snps,dw-apb-ssi.txt | 42 --- .../bindings/spi/snps,dw-apb-ssi.yaml | 127 +++++++++ .../devicetree/bindings/spi/spi-dw.txt | 24 -- drivers/spi/Kconfig | 15 +- drivers/spi/Makefile | 7 +- drivers/spi/{spi-dw-mid.c => spi-dw-dma.c} | 257 ++++++++++-------- drivers/spi/spi-dw-mmio.c | 9 +- drivers/spi/spi-dw-pci.c | 50 +++- drivers/spi/spi-dw.c | 98 +++---- drivers/spi/spi-dw.h | 33 ++- 10 files changed, 405 insertions(+), 257 deletions(-) delete mode 100644 Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt create mode 100644 Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml delete mode 100644 Documentation/devicetree/bindings/spi/spi-dw.txt rename drivers/spi/{spi-dw-mid.c => spi-dw-dma.c} (53%)Signature · 1 line
2.25.1Signature · 2 lines
With Best Regards, Andy Shevchenko
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v2 02/19] spi: dw: Add Tx/Rx finish wait methods to the MID DMA
Quoted 9 lines · Serge Semin
Since DMA transfers are performed asynchronously with actual SPI transaction, then even if DMA transfers are finished it doesn't mean all data is actually pushed to the SPI bus. Some data might still be in the controller FIFO. This is specifically true for Tx-only transfers. In this case if the next SPI transfer is recharged while a tail of the previous one is still in FIFO, we'll loose that tail data. In order to fix this lets add the wait procedure of the Tx/Rx SPI transfers completion after the corresponding DMA transactions are finished.
General question, doesn't spi core provides us some helpers like spi_delay_exec()?
Quoted 16 lines
Co-developed-by Georgy Vlasov <[email protected]>Signed-off-by Georgy Vlasov <[email protected]>Signed-off-by Serge Semin <[email protected]>Cc Ramil Zaripov <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Allison Randal <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Gareth Williams <[email protected]>Cc Rob Herring <[email protected]>
Quoted 8 lines
---
Changelog v2:
- Use conditional statement instead of the ternary operator in the ref clock getter.- Move the patch to the head of the series so one could be picked up to the stable kernels as a fix.
You forgot a Fixes tag.
Quoted 10 lines
--- drivers/spi/spi-dw-mid.c | 50 ++++++++++++++++++++++++++++++++++++++++ drivers/spi/spi-dw.h | 10 ++++++++ 2 files changed, 60 insertions(+)drivers/spi/spi-dw-mid.c +0
-0
drivers/spi/spi-dw-mid.c line 20
Quoted 5 lines
drivers/spi/spi-dw-mid.c +1
-0@@ -16,7 +16,9 @@#include <linux/irqreturn.h> #include <linux/pci.h> #include <linux/platform_data/dma-dw.h> +#include <linux/delay.h>
Keep it in order.
Quoted 15 lines
drivers/spi/spi-dw-mid.c +7
-0+#define WAIT_RETRIES 5#define RX_BUSY 0#define TX_BUSY 1@@ -141,6 +143,28 @@ static enum dma_slave_buswidth convert_dma_width(u32 dma_width) {return DMA_SLAVE_BUSWIDTH_UNDEFINED ; } +static inline bool dw_spi_dma_tx_busy (struct dw_spi *dws) +{ +return !(dw_readl (dws,DW_SPI_SR ) &SR_TF_EMPT ); +} + +static void dw_spi_dma_wait_tx_done (struct dw_spi *dws)
drivers/spi/spi-dw-mid.c static enum dma_slave_buswidth convert_dma_width(u32 dma_width) { · line 161
Quoted 10 lines
drivers/spi/spi-dw-mid.c +9
-0+{ +int retry =WAIT_RETRIES ; +unsigned long ns; + + ns = (NSEC_PER_SEC /spi_get_clk (dws)) * dws->n_bytes *BITS_PER_BYTE ; + ns *=dw_readl (dws,DW_SPI_TXFLR ); + +while (dw_spi_dma_tx_busy (dws) && retry--) +ndelay (ns);
This misses power management for CPU and do you really need this to be atomic? At the end why not to use readx_poll_timeout() ?
drivers/spi/spi-dw-mid.c static enum dma_slave_buswidth convert_dma_width(u32 dma_width) { · line 162
Quoted 1 line
drivers/spi/spi-dw-mid.c +1
-0+if (retry <0 ) {
Usually we do
unsigned int retries = NNNN;
do {
...
} while (--retries);
if (!retries)
...But in any case, see above.
drivers/spi/spi-dw-mid.c static enum dma_slave_buswidth convert_dma_width(u32 dma_width) { · line 166
Quoted 4 lines
drivers/spi/spi-dw-mid.c +4
-0+dev_err (&dws->master->dev,"Tx hanged up\n" ); + dws->master->cur_msg->status = -EIO ; + } +}
Same comments to Rx part.
Quoted 75 lines
drivers/spi/spi-dw-mid.c +27
-0+/* * dws->dma_chan_busy is set before the dma transfer starts, callback for tx * channel will clear a corresponding bit. @@ -149,6 +173,8 @@ static void dw_spi_dma_tx_done(void *arg) {struct dw_spi *dws = arg; +dw_spi_dma_wait_tx_done (dws); +clear_bit (TX_BUSY , &dws->dma_chan_busy);if (test_bit (RX_BUSY , &dws->dma_chan_busy))return ;@@ -188,6 +214,28 @@ static struct dma_async_tx_descriptor *dw_spi_dma_prepare_tx(struct dw_spi *dws,return txdesc; } +static inline bool dw_spi_dma_rx_busy (struct dw_spi *dws) +{ +return !!(dw_readl (dws,DW_SPI_SR ) &SR_RF_NOT_EMPT ); +} + +static void dw_spi_dma_wait_rx_done (struct dw_spi *dws) +{ +int retry =WAIT_RETRIES ; +unsigned long ns; + + ns = (NSEC_PER_SEC /spi_get_clk (dws)) * dws->n_bytes *BITS_PER_BYTE ; + ns *=dw_readl (dws,DW_SPI_RXFLR ); + +while (dw_spi_dma_rx_busy (dws) && retry--) +ndelay (ns); + +if (retry <0 ) { +dev_err (&dws->master->dev,"Rx hanged up\n" ); + dws->master->cur_msg->status = -EIO ; + } +} +/* * dws->dma_chan_busy is set before the dma transfer starts, callback for rx * channel will clear a corresponding bit. @@ -196,6 +244,8 @@ static void dw_spi_dma_rx_done(void *arg) {struct dw_spi *dws = arg; +dw_spi_dma_wait_rx_done (dws); +clear_bit (RX_BUSY , &dws->dma_chan_busy);if (test_bit (TX_BUSY , &dws->dma_chan_busy))return ;drivers/spi/spi-dw.h +10
-0@@ -210,6 +210,16 @@ static inline void spi_set_clk(struct dw_spi *dws, u16 div)dw_writel (dws,DW_SPI_BAUDR , div); } +static inline u32 spi_get_clk (struct dw_spi *dws) +{ +u32 div =dw_readl (dws,DW_SPI_BAUDR ); + +if (!div) +return 0 ; + +return dws->max_freq / div; +} +/* Disable IRQ bits */ static inline void spi_mask_intr (struct dw_spi *dws,u32 mask) {Signature · 1 line
2.25.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
Mark Brown
maintainerRe: [PATCH v2 02/19] spi: dw: Add Tx/Rx finish wait methods to the MID DMA
Quoted 2 lines · Andy Shevchenko
General question, doesn't spi core provides us some helpers like
spi_delay_exec()?
Well, nobody wrote one. It's also a bit tricky to handle given that often you're checking some controller specific things while a FIFO in the IP drains/fills, though nothing insurmountable.
Re: [PATCH v2 02/19] spi: dw: Add Tx/Rx finish wait methods to the MID DMA
Quoted 6 lines · Mark Brown
Quoted 2 lines · Andy Shevchenko
General question, doesn't spi core provides us some helpers like
spi_delay_exec()?Well, nobody wrote one.
spi_delay_exec() seems quite good to be used here. Can we use it for delays?
Quoted 3 lines
It's also a bit tricky to handle given that
often you're checking some controller specific things while a FIFO in the IP drains/fills, though nothing insurmountable.
Yes, input can be gathered by reading controller specific data.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Mark Brown
maintainerRe: [PATCH v2 02/19] spi: dw: Add Tx/Rx finish wait methods to the MID DMA
Quoted 6 lines · Andy Shevchenko
Quoted 1 line · Mark Brown
Well, nobody wrote one.
spi_delay_exec()seems quite good to be used here. Can we use it for delays?
I guess we could, though it's really there because for historical reasons we've got a bunch of different ways of specifying delays from client drivers rather than for the executing a delay where you've already got a good idea of the length of the delay.
A message that is not in the archive (sent off-list or not yet received): 20200515200250.zjsv5uaftwqcnwud@mobilestation
Mark Brown
maintainerRe: [PATCH v2 02/19] spi: dw: Add Tx/Rx finish wait methods to the MID DMA
Quoted 11 lines · Serge Semin
Quoted 4 lines · Mark Brown
I guess we could, though it's really there because for historical reasons we've got a bunch of different ways of specifying delays from client drivers rather than for the executing a delay where you've already got a good idea of the length of the delay.
A beauty of
spi_delay_exec()is that it provides a selective delay. I mean it checks the delay value and selects an appropriate delay method like ndelay, udelay and so on. That's the only reason I'd use it here. But It has got a few drawbacks:
Right, usually you'd have a good ideal how long the delay is and therefore just be able to go directly for an appropraite delay function.
Quoted 1 line
- timeout value has type u16. It's too small to keep nanoseconds.
That could be increased, though obviously if you have a bigger delay you can specify it in usecs instead.
Quoted 2 lines
- semantically the xfer argument isn't optional and we can't fetch it that easy in the dmaengine completion callbacks.
Not sure I follow this.
Quoted 5 lines
So if there were an alternative method like
_spi_transfer_delay_ns()I'd use it. Otherwise we'd need to locally implement the selective delay. Unless you know another alternative, which does it. If you don't and there isn't one then in order to not over-complicate a simple delay-loop code I'd simply leave thendelay()here.
Not that I'm aware of.
A message that is not in the archive (sent off-list or not yet received): 20200518110453.w3ko5a5yzwyr73ir@mobilestation
Mark Brown
maintainerRe: [PATCH v2 02/19] spi: dw: Add Tx/Rx finish wait methods to the MID DMA
Quoted 5 lines · Serge Semin
Quoted 2 lines · Mark Brown
Quoted 2 lines
- semantically the xfer argument isn't optional and we can't fetch it that easy in the dmaengine completion callbacks.
Quoted 8 lines
Quoted 1 line
Not sure I follow this.
I mean is it Ok to call the
spi_delay_execlike this:spi_delay_exec(delay, NULL), with null passed instead of xfer pointer? Semantically the pointer is required only if we'd need to calculate theSPI_DELAY_UNIT_SCKdelay, but here we'll need USECS and NSECS delays. So at the first glace there is no problem with passed NULL instead of xfer. But doing so we'd rely on the semantic peculiarity, which may seem a bit hackish.
Yes, that should be fine if you don't specify a SCK delay. There's no reason to be looking at that if the delay isn't specified in SCKs.
A message that is not in the archive (sent off-list or not yet received): 20200515194058.pmpd4wa7lw2dle3g@mobilestation
Re: [PATCH v2 02/19] spi: dw: Add Tx/Rx finish wait methods to the MID DMA
Quoted 11 lines · Serge Semin
Quoted 10 lines · Andy Shevchenko
Quoted 9 lines · Serge Semin
Since DMA transfers are performed asynchronously with actual SPI transaction, then even if DMA transfers are finished it doesn't mean all data is actually pushed to the SPI bus. Some data might still be in the controller FIFO. This is specifically true for Tx-only transfers. In this case if the next SPI transfer is recharged while a tail of the previous one is still in FIFO, we'll loose that tail data. In order to fix this lets add the wait procedure of the Tx/Rx SPI transfers completion after the corresponding DMA transactions are finished.
...
Quoted 3 lines
Quoted 1 line
You forgot a Fixes tag.
If you find a commit this patch fixes I'd be glad to add the tag.)
I believe you can do it, but I will help you here, what about
7063c0d942a1 ("spi/dw_spi: add DMA support")
or may be more closer to the reality
30c8eb52cc4a ("spi: dw-mid: split rx and tx callbacks when DMA")
?
...
Quoted 1 line
I will if v3 is needed.
I guess it will be due to Fixes tag.
Signature · 2 lines
With Best Regards, Andy Shevchenko
A message that is not in the archive (sent off-list or not yet received): [email protected]
Andy Shevchenko
Reviewed-byRe: [PATCH v2 04/19] spi: dw: Fix native CS being unset
Quoted 24 lines · Serge Semin
Commit
6e0a32d6f376("spi: dw: Fix default polarity of native chipselect") attempted to fix the problem when GPIO active-high chip-select is utilized to communicate with some SPI slave. It fixed the problem, but broke the normal native CS support. At the same time the reversion commitada9e3fcc175("spi: dw: Correct handling of native chipselect") didn't solve the problem either, since it just inverted theset_cs()polarity perception without taking into account that CS-high might be applicable. Here is what is done to finally fix the problem.DW SPI controller demands any native CS being set in order to proceed with data transfer. So in order to activate the SPI communications we must set any bit in the Slave Select DW SPI controller register no matter whether the platform requests the GPIO- or native CS. Preferably it should be the bit corresponding to the SPI slave CS number. But currently the
dw_spi_set_cs()method activates the chip-select only if the second argument is false. Since the second argument of theset_cscallback is expected to be a boolean with "is-high" semantics (actual chip-select pin state value), the bit in the DW SPI Slave Select register will be set only if SPI core requests the driver to set the CS in the low state. So this will work for active-low GPIO-based CS case, and won't work for active-high CS setting the bit when SPI core actually needs to deactivate the CS.
Quoted 3 lines
This commit fixes the problem for all described cases. So no matter whether an SPI slave needs GPIO- or native-based CS with active-high or low signal the corresponding bit will be set in SER.
Nice catch!
Quoted 53 lines
Signed-off-by Serge Semin <[email protected]>Fixes ada9e3fcc175 ("spi: dw: Correct handling of native chipselect")Fixes 6e0a32d6f376 ("spi: dw: Fix default polarity of native chipselect")Reviewed-by Charles Keepax <[email protected]>Acked-by Linus Walleij <[email protected]>Cc Georgy Vlasov <[email protected]>Cc Ramil Zaripov <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Allison Randal <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Gareth Williams <[email protected]>Cc Rob Herring <[email protected]>---
Changelog v2:
- Add a comment about SER register, that it must be set to activate the SPI communications.--- drivers/spi/spi-dw.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)drivers/spi/spi-dw.c +9
-1@@ -124,8 +124,16 @@ static inline void dw_spi_debugfs_remove(struct dw_spi *dws)void dw_spi_set_cs (struct spi_device *spi,bool enable) {struct dw_spi *dws =spi_controller_get_devdata (spi->controller); +bool cs_high = !!(spi->mode &SPI_CS_HIGH ); -if (!enable) +/* +* DW SPI controller demands any native CS being set in order to +* proceed with data transfer. So in order to activate the SPI +* communications we must set a corresponding bit in the Slave +* Enable register no matter whether the SPI core is configured to +* support active-high or active-low CS level. +*/ +if (cs_high == enable)dw_writel (dws,DW_SPI_SER ,BIT (spi->chip_select));else if (dws->cs_override)dw_writel (dws,DW_SPI_SER ,0 );Signature · 1 line
2.25.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v2 06/19] spi: dw: Discard static DW DMA slave structures
Quoted 10 lines · Serge Semin
Having them declared is redundant since each struct
dw_dma_chanhas the same structure embedded and the structure from the passeddma_chanprivate pointer will be copied there as a result of the next calls chain:dma_request_channel()->find_candidate()->dma_chan_get()->device_alloc_chan_resources()=dwc_alloc_chan_resources()->dw_dma_filter().
So just remove the staticdw_dma_chanstructures and use a locally declared data instance with dst_id/src_id set to the same values as the static copies used to have.
...
Review
Quoted 4 lines
(quoted diff) +1
-2-static struct dw_dma_slave mid_dma_tx = { .dst_id = 1 }; -static struct dw_dma_slave mid_dma_rx = { .src_id = 0 }; + struct dw_dma_slave slave = {0};
I really would like to leave them separated and as in the original form, i.e.
struct dw_dma_slave tx = { .dst_id = 1 };
struct dw_dma_slave rx = { .src_id = 0 };those src and dst IDs are put in that form on purpose...
Review
Quoted 1 line
(quoted diff) +1
-0+ /* 1. Init rx channel (.src_id = 0, .dst_id = 0) */
...this comment adds a bit of confusion.
(Needs more time to parse and understand what IDs are in use)
Review
Quoted 4 lines
(quoted diff) +3
-0+ slave.dma_dev = &dma_dev->dev; + dws->rxchan = dma_request_channel(mask, mid_spi_dma_chan_filter, &slave); + /* 2. Init tx channel (.src_id = 0, .dst_id = 1) */
Ditto.
P.S. Just a recommendation for the future: in all your patches try to be less invasive where it's possible.
Signature · 2 lines
With Best Regards, Andy Shevchenko
A message that is not in the archive (sent off-list or not yet received): 20200516142030.kburieaxjg4n7c42@mobilestation
Re: [PATCH v2 06/19] spi: dw: Discard static DW DMA slave structures
Quoted 22 lines · Serge Semin
Quoted 21 lines · Andy Shevchenko
Quoted 10 lines · Serge Semin
Having them declared is redundant since each struct
dw_dma_chanhas the same structure embedded and the structure from the passeddma_chanprivate pointer will be copied there as a result of the next calls chain:dma_request_channel()->find_candidate()->dma_chan_get()->device_alloc_chan_resources()=dwc_alloc_chan_resources()->dw_dma_filter().
So just remove the staticdw_dma_chanstructures and use a locally declared data instance with dst_id/src_id set to the same values as the static copies used to have....
Review
Quoted 4 lines
(quoted diff) +1
-2-static struct dw_dma_slave mid_dma_tx = { .dst_id = 1 }; -static struct dw_dma_slave mid_dma_rx = { .src_id = 0 }; + struct dw_dma_slave slave = {0};I really would like to leave them separated and as in the original form, i.e.
Quoted 6 lines
Quoted 4 lines
struct dw_dma_slave tx = { .dst_id = 1 }; struct dw_dma_slave rx = { .src_id = 0 };those src and dst IDs are put in that form on purpose...
As long as you don't tell us what purpose it is, my position won't change.
It's not the way when your changes makes this the older (upstreamed) stuff's issue, it's an opposite. But I will help you here...
Quoted 2 lines
These structures declared here just hold the static memory and nothing else. Allocating them on stack is better.
I'm not talking about stack, it's fine for me, what I'm talking about is *how* they are being initialized. Read my message again carefully, please.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 06/19] spi: dw: Discard static DW DMA slave structures
Quoted 30 lines · Andy Shevchenko
Quoted 20 lines · Serge Semin
Quoted 19 lines · Andy Shevchenko
Quoted 10 lines · Serge Semin
Having them declared is redundant since each struct
dw_dma_chanhas the same structure embedded and the structure from the passeddma_chanprivate pointer will be copied there as a result of the next calls chain:dma_request_channel()->find_candidate()->dma_chan_get()->device_alloc_chan_resources()=dwc_alloc_chan_resources()->dw_dma_filter().
So just remove the staticdw_dma_chanstructures and use a locally declared data instance with dst_id/src_id set to the same values as the static copies used to have....
Quoted 4 lines
(quoted diff) +1
-2-static struct dw_dma_slave mid_dma_tx = { .dst_id = 1 }; -static struct dw_dma_slave mid_dma_rx = { .src_id = 0 }; + struct dw_dma_slave slave = {0};Quoted 8 lines
Quoted 6 lines
I really would like to leave them separated and as in the original form, i.e.
struct dw_dma_slave tx = { .dst_id = 1 }; struct dw_dma_slave rx = { .src_id = 0 };those src and dst IDs are put in that form on purpose...
As long as you don't tell us what purpose it is, my position won't change.
Quoted 8 lines
It's not the way when your changes makes this the older (upstreamed) stuff's issue, it's an opposite. But I will help you here...
Quoted 2 lines
These structures declared here just hold the static memory and nothing else. Allocating them on stack is better.
I'm not talking about stack, it's fine for me, what I'm talking about is *how* they are being initialized. Read my message again carefully, please.
And to avoid additional churn around this, the purpose is to show what Dreq number is in use actually for these transfers (that's why 0 assignment is explicitly there and no counterpart Dreq filled).
Signature · 2 lines
With Best Regards, Andy Shevchenko
A message that is not in the archive (sent off-list or not yet received): 20200518123242.xoosc4pcj7heo4he@mobilestation
Re: [PATCH v2 06/19] spi: dw: Discard static DW DMA slave structures
Quoted 4 lines · Serge Semin
Quoted 3 lines · Andy Shevchenko
Quoted 1 line · Andy Shevchenko
On Sat, May 16, 2020 at 05:20:30PM +0300, Serge Semin wrote:
...
Quoted 10 lines
Quoted 6 lines
Quoted 2 lines
I'm not talking about stack, it's fine for me, what I'm talking about is *how* they are being initialized. Read my message again carefully, please.
And to avoid additional churn around this, the purpose is to show what Dreq number is in use actually for these transfers (that's why 0 assignment is explicitly there and no counterpart Dreq filled).
Sorry, but nothing persuasive so far. We still can remove their static definition and explicitly assign zero or one to the src and dst request IDs on stack. I'll do this in v3, since I have to send one anyway.
Right, I'm completely fine with it, thanks!
Signature · 2 lines
With Best Regards, Andy Shevchenko
A message that is not in the archive (sent off-list or not yet received): [email protected]
Andy Shevchenko
Reviewed-byRe: [PATCH v2 07/19] spi: dw: Discard unused void priv pointer
Quoted 4 lines · Serge Semin
Seeing the "void *priv" member of the
dw_spidata structure is unused let's remove it. The glue-layers can embed the DW APB SSI controller descriptor into their private data object. MMIO driver for instance already utilizes that design pattern.
Quoted 40 lines
Signed-off-by Serge Semin <[email protected]>Cc Georgy Vlasov <[email protected]>Cc Ramil Zaripov <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Allison Randal <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Gareth Williams <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Rob Herring <[email protected]>---
Changelog v2:
- It's a new patch created as a result of more thorough driver study.--- drivers/spi/spi-dw.h | 2 -- 1 file changed, 2 deletions(-)drivers/spi/spi-dw.h +0
-2@@ -147,8 +147,6 @@ struct dw_spi {dma_addr_t dma_addr;/* phy address of the Data register */ const struct dw_spi_dma_ops *dma_ops; -/* Bus interface info */ -void *priv;#ifdef CONFIG_DEBUG_FS struct dentry *debugfs;#endif Signature · 1 line
2.25.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
A message that is not in the archive (sent off-list or not yet received): [email protected]
Andy Shevchenko
Reviewed-byRe: [PATCH v2 08/19] spi: dw: Discard dma_width member of the dw_spi structure
Quoted 8 lines · Serge Semin
This member has exactly the same value as
n_bytesof the DW SPI private data object, it's calculated at the same point of the transfer method,n_bytesisn't changed during the whole transfer, and they even serve for the same purpose - keep number of bytes per transfer word, though thedma_widthis used only to calculate the DMA source/destination addresses width, whichn_bytescould be also utilized for. Taking all of these into account let's replace thedma_widthmember usage withn_bytesone and remove the former.
I've no strong opinion about this.
So, after addressing one issue below,
Quoted 30 lines
Signed-off-by Serge Semin <[email protected]>Cc Georgy Vlasov <[email protected]>Cc Ramil Zaripov <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Allison Randal <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Gareth Williams <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Rob Herring <[email protected]>---
Changelog v2:
- It's a new patch created as a result of more thorough driver study.--- drivers/spi/spi-dw-mid.c | 10 +++++----- drivers/spi/spi-dw.c | 1 - drivers/spi/spi-dw.h | 1 - 3 files changed, 5 insertions(+), 7 deletions(-)drivers/spi/spi-dw-mid.c +0
-0
drivers/spi/spi-dw-mid.c static bool mid_spi_can_dma(struct spi_controller *master, · line 136
Quoted 7 lines
drivers/spi/spi-dw-mid.c +1
-2@@ -132,10 +132,10 @@ static bool mid_spi_can_dma(struct spi_controller *master,return xfer->len > dws->fifo_len; } -static enum dma_slave_buswidth convert_dma_width (u32 dma_width) { -if (dma_width ==1 ) +static enum dma_slave_buswidth convert_dma_width (u8 n_bytes) {
It seems somebody (maybe even me) at some point messed up between enum definition and function that returns an enum.
For what said, { should be on the separate line.
Quoted 52 lines
drivers/spi/spi-dw-mid.c +2
-1+if (n_bytes ==1 )return DMA_SLAVE_BUSWIDTH_1_BYTE ; - else if (dma_width == 2) +else if (n_bytes ==2 )return DMA_SLAVE_BUSWIDTH_2_BYTES ;drivers/spi/spi-dw-mid.c +2
-2return DMA_SLAVE_BUSWIDTH_UNDEFINED ;@@ -195,7 +195,7 @@ static struct dma_async_tx_descriptor *dw_spi_dma_prepare_tx(struct dw_spi *dws, txconf.dst_addr = dws->dma_addr; txconf.dst_maxburst =16 ; txconf.src_addr_width =DMA_SLAVE_BUSWIDTH_4_BYTES ; - txconf.dst_addr_width =convert_dma_width (dws->dma_width); + txconf.dst_addr_width =convert_dma_width (dws->n_bytes); txconf.device_fc = false;dmaengine_slave_config (dws->txchan, &txconf);@@ -268,7 +268,7 @@ static struct dma_async_tx_descriptor *dw_spi_dma_prepare_rx(struct dw_spi *dws, rxconf.src_addr = dws->dma_addr; rxconf.src_maxburst =16 ; rxconf.dst_addr_width =DMA_SLAVE_BUSWIDTH_4_BYTES ; - rxconf.src_addr_width =convert_dma_width (dws->dma_width); + rxconf.src_addr_width =convert_dma_width (dws->n_bytes); rxconf.device_fc = false;dmaengine_slave_config (dws->rxchan, &rxconf);drivers/spi/spi-dw.c +0
-1@@ -353,7 +353,6 @@ static int dw_spi_transfer_one(struct spi_controller *master, } dws->n_bytes =DIV_ROUND_UP (transfer->bits_per_word,BITS_PER_BYTE ); - dws->dma_width =DIV_ROUND_UP (transfer->bits_per_word,BITS_PER_BYTE ); cr0 = dws->update_cr0 (master, spi, transfer);dw_writel (dws,DW_SPI_CTRLR0 , cr0);drivers/spi/spi-dw.h +0
-1@@ -136,7 +136,6 @@ struct dw_spi {void *rx_end;int dma_mapped;u8 n_bytes;/* current is a 1/2 bytes op */ -u32 dma_width;irqreturn_t (*transfer_handler)(struct dw_spi *dws);u32 current_freq;/* frequency in hz */ Signature · 1 line
2.25.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
A message that is not in the archive (sent off-list or not yet received): 20200515130559.psq2zwfhovt6rzhl@mobilestation
Re: [PATCH v2 08/19] spi: dw: Discard dma_width member of the dw_spi structure
Quoted 14 lines · Serge Semin
Quoted 13 lines · Andy Shevchenko
Quoted 8 lines · Serge Semin
This member has exactly the same value as
n_bytesof the DW SPI private data object, it's calculated at the same point of the transfer method,n_bytesisn't changed during the whole transfer, and they even serve for the same purpose - keep number of bytes per transfer word, though thedma_widthis used only to calculate the DMA source/destination addresses width, whichn_bytescould be also utilized for. Taking all of these into account let's replace thedma_widthmember usage withn_bytesone and remove the former.I've no strong opinion about this.
So, after addressing one issue below,Reviewed-by Andy Shevchenko <[email protected]>
...
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
(quoted diff) +1
-2-static enum dma_slave_buswidth convert_dma_width(u32 dma_width) { - if (dma_width == 1) +static enum dma_slave_buswidth convert_dma_width(u8 n_bytes) {
Quoted 7 lines
Quoted 4 lines
It seems somebody (maybe even me) at some point messed up between enum definition and function that returns an enum.
For what said, { should be on the separate line.
See the patch 16/19: "spi: dw: Cleanup generic DW DMA code namings" in this series.
Since you are touching that line here, it makes sense to do it here rather than ping-pong to other patch in very same series.
Signature · 2 lines
With Best Regards, Andy Shevchenko
A message that is not in the archive (sent off-list or not yet received): 20200515141627.pqdaic6wksatusl6@mobilestation
Re: [PATCH v2 08/19] spi: dw: Discard dma_width member of the dw_spi structure
Quoted 29 lines · Serge Semin
Quoted 28 lines · Andy Shevchenko
Quoted 14 lines · Serge Semin
Quoted 13 lines · Andy Shevchenko
Quoted 8 lines · Serge Semin
This member has exactly the same value as
n_bytesof the DW SPI private data object, it's calculated at the same point of the transfer method,n_bytesisn't changed during the whole transfer, and they even serve for the same purpose - keep number of bytes per transfer word, though thedma_widthis used only to calculate the DMA source/destination addresses width, whichn_bytescould be also utilized for. Taking all of these into account let's replace thedma_widthmember usage withn_bytesone and remove the former.I've no strong opinion about this.
So, after addressing one issue below,Reviewed-by Andy Shevchenko <[email protected]>...
Quoted 10 lines
Quoted 9 lines
Review
Quoted 4 lines
(quoted diff) +1
-2-static enum dma_slave_buswidth convert_dma_width(u32 dma_width) { - if (dma_width == 1) +static enum dma_slave_buswidth convert_dma_width(u8 n_bytes) {It seems somebody (maybe even me) at some point messed up between enum definition and function that returns an enum.
For what said, { should be on the separate line.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
See the patch 16/19: "spi: dw: Cleanup generic DW DMA code namings" in this series.
Since you are touching that line here, it makes sense to do it here rather than ping-pong to other patch in very same series.
You didn't open the patch I referred to, did you?
Patches in the series are going on purpose. I look at them in the sequence of the appearance. But okay, I looked at it and I found what I expected. I think that you may reorder patch 16 to be one right after renaming module.
Quoted 3 lines
If you did, you would have
seen that I touched that line there too in the framework of the naming cleanup procedure. So please, stop wasting my time with trivial stuff.
Haven't you missed my tag? It means I spent *my* time on *your* stuff. Please, be respectful to reviewers.
Signature · 2 lines
With Best Regards, Andy Shevchenko
A message that is not in the archive (sent off-list or not yet received): [email protected]
Andy Shevchenko
Reviewed-byRe: [PATCH v2 12/19] spi: dw: Fix Rx-only DMA transfers
Quoted 10 lines · Serge Semin
Tx-only DMA transfers are working perfectly fine since in this case the code just ignores the Rx FIFO overflow interrupts. But it turns out the SPI Rx-only transfers are broken since nothing pushing any data to the shift registers, so the Rx FIFO is left empty and the SPI core subsystems just returns a timeout error. Since DW DMAC driver doesn't support something like cyclic write operations of a single byte to a device register, the only way to support the Rx-only SPI transfers is to fake it by using a dummy Tx-buffer. This is what we intend to fix in this commit by setting the
SPI_CONTROLLER_MUST_TXflag for DMA-capable platform.
I'm fine with this if Mark considers this right thing to do. So, conditionally
Quoted 34 lines
Signed-off-by Serge Semin <[email protected]>Cc Georgy Vlasov <[email protected]>Cc Ramil Zaripov <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Allison Randal <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Gareth Williams <[email protected]>Cc Rob Herring <[email protected]>--- drivers/spi/spi-dw.c | 1 + 1 file changed, 1 insertion(+)drivers/spi/spi-dw.c +1
-0@@ -517,6 +517,7 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)dev_warn (dev,"DMA init failed\n" ); }else { master->can_dma = dws->dma_ops->can_dma; + master->flags |=SPI_CONTROLLER_MUST_TX ; } }Signature · 1 line
2.25.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
Mark Brown
maintainerRe: [PATCH v2 12/19] spi: dw: Fix Rx-only DMA transfers
Quoted 12 lines · Andy Shevchenko
Quoted 10 lines · Serge Semin
Tx-only DMA transfers are working perfectly fine since in this case the code just ignores the Rx FIFO overflow interrupts. But it turns out the SPI Rx-only transfers are broken since nothing pushing any data to the shift registers, so the Rx FIFO is left empty and the SPI core subsystems just returns a timeout error. Since DW DMAC driver doesn't support something like cyclic write operations of a single byte to a device register, the only way to support the Rx-only SPI transfers is to fake it by using a dummy Tx-buffer. This is what we intend to fix in this commit by setting the
SPI_CONTROLLER_MUST_TXflag for DMA-capable platform.
Quoted 3 lines
I'm fine with this if Mark considers this right thing to do. So, conditionally
Reviewed-by Andy Shevchenko <[email protected]>
Yes, this is good - it's quite a common issue that controllers have and the main reason the flag exists is to provide a standard fix for it.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v2 13/19] spi: dw: Move Non-DMA code to the DW PCIe-SPI driver
Quoted 4 lines · Serge Semin
This is a preparation patch before adding the DW DMA support into the DW SPI MMIO driver. We need to unpin the Non-DMA-specific code from the intended to be generic DW APB SSI DMA code. This isn't that hard, since the most part of the
spi-dw-mid.cdriver in fact implements a
Quoted 8 lines
generic DMA interface for the DW SPI controller driver. The only Intel MID specifics concern getting the max frequency from the MRST Clock Control Unit and fetching the DMA controller channels from corresponding PCIe DMA controller. Since first one is related with the SPI interface configuration we moved it' implementation into the DW PCIe-SPI driver module. After that former
spi-dw-mid.cfile can be just renamed to be the DW SPI DMA module optionally compiled in to the DW APB SSI core driver.
Cc list here is huge!
I think this patch should go immediately after bunch of fixes.
...
Review
Quoted 4 lines
(quoted diff) +3
-1-obj-$(CONFIG_SPI_DESIGNWARE) += spi-dw.o +obj-$(CONFIG_SPI_DESIGNWARE) += spi-dw-core.o +spi-dw-core-y := spi-dw.o +spi-dw-core-$(CONFIG_SPI_DW_DMA) += spi-dw-dma.o
We may leave module name the same, right?
obj-$(CONFIG_SPI_DESIGNWARE) += spi-dw.o
spi-dw-y := spi-dw-core.o
spi-dw-$(CONFIG_SPI_DW_DMA) += spi-dw-dma.o
Quoted 134 lines
obj-$(CONFIG_SPI_DW_MMIO) += spi-dw-mmio.o
(quoted diff) +2
-45-obj-$(CONFIG_SPI_DW_PCI) += spi-dw-midpci.o -spi-dw-midpci-objs := spi-dw-pci.o spi-dw-mid.o +obj-$(CONFIG_SPI_DW_PCI) += spi-dw-pci.o -/* Some specific info for SPI0 controller on Intel MID */ - -/* HW info for MRST Clk Control Unit, 32b reg per controller */ -#define MRST_SPI_CLK_BASE 100000000 /* 100m */ -#define MRST_CLK_SPI_REG 0xff11d86c -#define CLK_SPI_BDIV_OFFSET 0 -#define CLK_SPI_BDIV_MASK 0x00000007 -#define CLK_SPI_CDIV_OFFSET 9 -#define CLK_SPI_CDIV_MASK 0x00000e00 -#define CLK_SPI_DISABLE_OFFSET 8 - -int dw_spi_mid_init_mfld(struct dw_spi *dws) -{ - void __iomem *clk_reg; - u32 clk_cdiv; - - clk_reg = ioremap(MRST_CLK_SPI_REG, 16); - if (!clk_reg) - return -ENOMEM; - - /* Get SPI controller operating freq info */ - clk_cdiv = readl(clk_reg + dws->bus_num * sizeof(u32)); - clk_cdiv &= CLK_SPI_CDIV_MASK; - clk_cdiv >>= CLK_SPI_CDIV_OFFSET; - dws->max_freq = MRST_SPI_CLK_BASE / (clk_cdiv + 1); - - iounmap(clk_reg); - - /* Register hook to configure CTRLR0 */ - dws->update_cr0 = dw_spi_update_cr0; - - dw_spi_mid_setup_dma_mfld(dws); - return 0; -} - -int dw_spi_mid_init_generic(struct dw_spi *dws) -{ - /* Register hook to configure CTRLR0 */ - dws->update_cr0 = dw_spi_update_cr0; - - dw_spi_mid_setup_dma_generic(dws); - return 0; -} +EXPORT_SYMBOL_GPL(dw_spi_mid_setup_dma_generic);drivers/spi/spi-dw-pci.c +47
-3@@ -15,6 +15,15 @@#define DRIVER_NAME "dw_spi_pci" +/* HW info for MRST Clk Control Unit, 32b reg per controller */ +#define MRST_SPI_CLK_BASE 100000000/* 100m */ +#define MRST_CLK_SPI_REG 0xff11d86c +#define CLK_SPI_BDIV_OFFSET 0 +#define CLK_SPI_BDIV_MASK 0x00000007 +#define CLK_SPI_CDIV_OFFSET 9 +#define CLK_SPI_CDIV_MASK 0x00000e00 +#define CLK_SPI_DISABLE_OFFSET 8 +struct spi_pci_desc {int (*setup)(struct dw_spi *);u16 num_cs;@@ -22,20 +31,55 @@ struct spi_pci_desc {u32 max_freq; }; +static int spi_mid_init (struct dw_spi *dws) +{ +void __iomem *clk_reg; +u32 clk_cdiv; + + clk_reg =ioremap (MRST_CLK_SPI_REG ,16 ); +if (!clk_reg) +return -ENOMEM ; + +/* Get SPI controller operating freq info */ + clk_cdiv =readl (clk_reg + dws->bus_num *sizeof (u32)); + clk_cdiv &=CLK_SPI_CDIV_MASK ; + clk_cdiv >>=CLK_SPI_CDIV_OFFSET ; + dws->max_freq =MRST_SPI_CLK_BASE / (clk_cdiv +1 ); + +iounmap (clk_reg); + +/* Register hook to configure CTRLR0 */ + dws->update_cr0 = dw_spi_update_cr0; + +dw_spi_mid_setup_dma_mfld (dws); + +return 0 ; +} + +static int spi_generic_init (struct dw_spi *dws) +{ +/* Register hook to configure CTRLR0 */ + dws->update_cr0 = dw_spi_update_cr0; + +dw_spi_mid_setup_dma_generic (dws); + +return 0 ; +} +static struct spi_pci_desc spi_pci_mid_desc_1 = { - .setup = dw_spi_mid_init_mfld, + .setup = spi_mid_init, .num_cs =5 , .bus_num =0 , };static struct spi_pci_desc spi_pci_mid_desc_2 = { - .setup = dw_spi_mid_init_mfld, + .setup = spi_mid_init, .num_cs =2 , .bus_num =1 , };static struct spi_pci_desc spi_pci_ehl_desc = { - .setup = dw_spi_mid_init_generic, + .setup = spi_generic_init, .num_cs =2 , .bus_num =-1 , .max_freq =100000000 ,drivers/spi/spi-dw.h +0
-0@@ -265,8 +265,16 @@ extern u32 dw_spi_update_cr0_v1_01a(struct spi_controller *master, struct spi_device *spi,
drivers/spi/spi-dw.h extern u32 dw_spi_update_cr0_v1_01a(struct spi_controller *master, · line 272
Quoted 10 lines
drivers/spi/spi-dw.h +5
-3struct spi_transfer *transfer); -/* platform related setup */ -extern int dw_spi_mid_init_mfld (struct dw_spi *dws); -extern int dw_spi_mid_init_generic (struct dw_spi *dws); +#ifdef CONFIG_SPI_DW_DMA + +extern void dw_spi_mid_setup_dma_mfld (struct dw_spi *dws); +extern void dw_spi_mid_setup_dma_generic (struct dw_spi *dws); +
I would drop blank lines and extern keywords.
drivers/spi/spi-dw.h extern u32 dw_spi_update_cr0_v1_01a(struct spi_controller *master, · line 278
Quoted 6 lines
drivers/spi/spi-dw.h +5
-0+#else + +static inline void dw_spi_mid_setup_dma_mfld (struct dw_spi *dws) {} +static inline void dw_spi_mid_setup_dma_generic (struct dw_spi *dws) {} +
Ditto for blank lines.
Quoted 6 lines
drivers/spi/spi-dw.h +1
-0+#endif /* !CONFIG_SPI_DW_DMA */ #endif /*
DW_SPI_HEADER_H*/Signature · 1 line
2.25.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
A message that is not in the archive (sent off-list or not yet received): 20200516201724.7q5uhxmzpr6xjooj@mobilestation
A message that is not in the archive (sent off-list or not yet received): 20200518125850.jnhaqlr2ticu3ivs@mobilestation
Mark Brown
maintainerRe: [PATCH v2 13/19] spi: dw: Move Non-DMA code to the DW PCIe-SPI driver
Quoted 6 lines · Serge Semin
Quoted 2 lines · Serge Semin
Only if we rename the
spi-dw.ctospi-dw-core.c. Such modification will break all the pending patches merging. Mark, are you ok with this?Mark, could give me your comment regarding this renaming? Are you ok with this?
Either way is fine for me.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Andy Shevchenko
Reviewed-byRe: [PATCH v2 18/19] spi: dw: Use regset32 DebugFS method to create regdump file
Quoted 3 lines · Serge Semin
DebugFS kernel interface provides a dedicated method to create the registers dump file. Use it instead of creating a generic DebugFS file with manually written read callback function.
With below nit addressed,
Quoted 76 lines
Signed-off-by Serge Semin <[email protected]>Cc Georgy Vlasov <[email protected]>Cc Ramil Zaripov <[email protected]>Cc Alexey Malahov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Paul Burton <[email protected]>Cc Ralf Baechle <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Allison Randal <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Gareth Williams <[email protected]>Cc Rob Herring <[email protected]>--- drivers/spi/spi-dw.c | 86 ++++++++++++++------------------------------ drivers/spi/spi-dw.h | 2 ++ 2 files changed, 28 insertions(+), 60 deletions(-)drivers/spi/spi-dw.c +0
-49@@ -29,66 +29,29 @@ struct chip_data { };#ifdef CONFIG_DEBUG_FS -#define SPI_REGS_BUFSIZE 1024 -static ssize_t dw_spi_show_regs (struct file *file,char __user *user_buf, -size_t count,loff_t *ppos) -{ -struct dw_spi *dws = file->private_data; -char *buf; -u32 len =0 ; -ssize_t ret; - - buf =kzalloc (SPI_REGS_BUFSIZE ,GFP_KERNEL ); -if (!buf) -return 0 ; - - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"%s registers:\n" ,dev_name (&dws->master->dev)); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"=================================\n" ); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"CTRLR0: \t0x%08x\n" ,dw_readl (dws,DW_SPI_CTRLR0 )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"CTRLR1: \t0x%08x\n" ,dw_readl (dws,DW_SPI_CTRLR1 )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"SSIENR: \t0x%08x\n" ,dw_readl (dws,DW_SPI_SSIENR )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"SER: \t\t0x%08x\n" ,dw_readl (dws,DW_SPI_SER )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"BAUDR: \t\t0x%08x\n" ,dw_readl (dws,DW_SPI_BAUDR )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"TXFTLR: \t0x%08x\n" ,dw_readl (dws,DW_SPI_TXFTLR )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"RXFTLR: \t0x%08x\n" ,dw_readl (dws,DW_SPI_RXFTLR )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"TXFLR: \t\t0x%08x\n" ,dw_readl (dws,DW_SPI_TXFLR )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"RXFLR: \t\t0x%08x\n" ,dw_readl (dws,DW_SPI_RXFLR )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"SR: \t\t0x%08x\n" ,dw_readl (dws,DW_SPI_SR )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"IMR: \t\t0x%08x\n" ,dw_readl (dws,DW_SPI_IMR )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"ISR: \t\t0x%08x\n" ,dw_readl (dws,DW_SPI_ISR )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"DMACR: \t\t0x%08x\n" ,dw_readl (dws,DW_SPI_DMACR )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"DMATDLR: \t0x%08x\n" ,dw_readl (dws,DW_SPI_DMATDLR )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"DMARDLR: \t0x%08x\n" ,dw_readl (dws,DW_SPI_DMARDLR )); - len +=scnprintf (buf + len,SPI_REGS_BUFSIZE - len, -"=================================\n" );
drivers/spi/spi-dw.c struct chip_data { · line 37
Quoted 10 lines
drivers/spi/spi-dw.c +5
-4- - ret =simple_read_from_buffer (user_buf, count, ppos, buf, len); -kfree (buf); -return ret; + +#define DW_SPI_DBGFS_REG (_name, _off) \ +{ \ + .name = _name, \ + .offset = _off \
As previously discussed (did I miss your answer?) the comma at the end leaves better pattern for maintenance prospective.
Quoted 63 lines
drivers/spi/spi-dw.c +16
-5} -static const struct file_operations dw_spi_regs_ops = { - .owner =THIS_MODULE , - .open = simple_open, - .read = dw_spi_show_regs, - .llseek = default_llseek, +static const struct debugfs_reg32 dw_spi_dbgfs_regs[] = { +DW_SPI_DBGFS_REG ("CTRLR0" ,DW_SPI_CTRLR0 ), +DW_SPI_DBGFS_REG ("CTRLR1" ,DW_SPI_CTRLR1 ), +DW_SPI_DBGFS_REG ("SSIENR" ,DW_SPI_SSIENR ), +DW_SPI_DBGFS_REG ("SER" ,DW_SPI_SER ), +DW_SPI_DBGFS_REG ("BAUDR" ,DW_SPI_BAUDR ), +DW_SPI_DBGFS_REG ("TXFTLR" ,DW_SPI_TXFTLR ), +DW_SPI_DBGFS_REG ("RXFTLR" ,DW_SPI_RXFTLR ), +DW_SPI_DBGFS_REG ("TXFLR" ,DW_SPI_TXFLR ), +DW_SPI_DBGFS_REG ("RXFLR" ,DW_SPI_RXFLR ), +DW_SPI_DBGFS_REG ("SR" ,DW_SPI_SR ), +DW_SPI_DBGFS_REG ("IMR" ,DW_SPI_IMR ), +DW_SPI_DBGFS_REG ("ISR" ,DW_SPI_ISR ), +DW_SPI_DBGFS_REG ("DMACR" ,DW_SPI_DMACR ), +DW_SPI_DBGFS_REG ("DMATDLR" ,DW_SPI_DMATDLR ), +DW_SPI_DBGFS_REG ("DMARDLR" ,DW_SPI_DMARDLR ) };static int
dw_spi_debugfs_init(struct dw_spi *dws)drivers/spi/spi-dw.c +5
-2@@ -100,8 +63,11 @@ static int dw_spi_debugfs_init(struct dw_spi *dws)if (!dws->debugfs)return -ENOMEM ; -debugfs_create_file ("registers" ,S_IFREG |S_IRUGO , - dws->debugfs, (void *)dws, &dw_spi_regs_ops); + dws->regset.regs = dw_spi_dbgfs_regs; + dws->regset.nregs =ARRAY_SIZE (dw_spi_dbgfs_regs); + dws->regset.base = dws->regs; +debugfs_create_regset32 ("registers" ,0400 , dws->debugfs, &dws->regset); +return 0 ; }drivers/spi/spi-dw.h +2
-0@@ -2,6 +2,7 @@#ifndef DW_SPI_HEADER_H #define DW_SPI_HEADER_H +#include <linux/debugfs.h> #include <linux/irqreturn.h> #include <linux/io.h> #include <linux/scatterlist.h> @@ -150,6 +151,7 @@ struct dw_spi {#ifdef CONFIG_DEBUG_FS struct dentry *debugfs; +struct debugfs_regset32 regset;#endif };Signature · 1 line
2.25.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
A message that is not in the archive (sent off-list or not yet received): 20200516204634.td52orxfnh7iewg6@mobilestation
Re: [PATCH v2 18/19] spi: dw: Use regset32 DebugFS method to create regdump file
Quoted 13 lines · Serge Semin
Quoted 12 lines · Andy Shevchenko
Quoted 3 lines · Serge Semin
DebugFS kernel interface provides a dedicated method to create the registers dump file. Use it instead of creating a generic DebugFS file with manually written read callback function.
With below nit addressed,
Reviewed-by Andy Shevchenko <[email protected]>Quoted 3 lines
(quoted diff) +3
-0+#define DW_SPI_DBGFS_REG(_name, _off) \ +{ \ + .name = _name, \
Quoted 7 lines
Quoted 4 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ .offset = _off \As previously discussed (did I miss your answer?) the comma at the end leaves better pattern for maintenance prospective.
Ah, sorry. Missed that. This comma is hardly needed seeing the structure consists of just two elements. So I'd rather leave it as is.
While it's a really small thing, I consider that it's not good to make someone's else problem what can be done here. So, please, consider to add a comma. Look at the other drivers and code in the kernel. This is at least defacto preferred style.
Signature · 2 lines
With Best Regards, Andy Shevchenko
A message that is not in the archive (sent off-list or not yet received): 20200518140825.jnkfpybxnwq7fx2m@mobilestation
Re: [PATCH v2 18/19] spi: dw: Use regset32 DebugFS method to create regdump file
Quoted 23 lines · Serge Semin
Quoted 22 lines · Andy Shevchenko
Quoted 20 lines · Serge Semin
Quoted 8 lines · Andy Shevchenko
Quoted 3 lines · Serge Semin
DebugFS kernel interface provides a dedicated method to create the registers dump file. Use it instead of creating a generic DebugFS file with manually written read callback function.
With below nit addressed,
Reviewed-by Andy Shevchenko <[email protected]>Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +4
-0+#define DW_SPI_DBGFS_REG(_name, _off) \ +{ \ + .name = _name, \ + .offset = _off \As previously discussed (did I miss your answer?) the comma at the end leaves better pattern for maintenance prospective.
Ah, sorry. Missed that. This comma is hardly needed seeing the structure consists of just two elements. So I'd rather leave it as is.
Quoted 6 lines
Quoted 4 lines
While it's a really small thing, I consider that it's not good to make someone's else problem what can be done here. So, please, consider to add a comma. Look at the other drivers and code in the kernel. This is at least defacto preferred style.
Andy, you never give up, don't you? =)
First of all, I really appreciate work you have done so far (I mean it). Now to the point.
You see, I always try to have a rationale behind any proposed comment. I agree, that some of them can be considered as a bikeshedding for a certain developer, but on big picture with this scale of project even small change (being made or being rejected to be made) can provoke additional churn with a good magnitude, if we consider all possible cases where somebody, e.g., can take into account existing code to copy'n'paste from). So, I would easy give up on something if there will be a stronger (than mine) argument why the proposed thing is not good to be done (at least as a part of the discussed patch set). I also want to and will learn from the developers as a reviewer.
Hope that above will clarify my reviewer's point of view to the code.
Review
Quoted 7 lines
Agreed then. I'll add comma to the
initializer and also after the last member here:DW_SPI_DBGFS_REG("ISR", DW_SPI_ISR), DW_SPI_DBGFS_REG("DMACR", DW_SPI_DMACR), DW_SPI_DBGFS_REG("DMATDLR", DW_SPI_DMATDLR),(quoted diff) +1
-1- DW_SPI_DBGFS_REG("DMARDLR", DW_SPI_DMARDLR) + DW_SPI_DBGFS_REG("DMARDLR", DW_SPI_DMARDLR),
Good catch, thanks for taking it into consideration as well.
Quoted 3 lines
};
static int
dw_spi_debugfs_init(struct dw_spi *dws)
Signature · 2 lines
With Best Regards, Andy Shevchenko
Mark Brown
maintainerOn Fri, May 15, 2020 at 01:47:39PM +0300, Serge Semin wrote:
Appled:
Quoted 4 lines
dt-bindings: spi: dw: Add Tx/Rx DMA properties
spi: dw: Clear DMAC register when done or stopped
spi: dw: Fix native CS being unset
spi: dw: Initialize paddr in DW SPI MMIO private data
Thanks. No issues from me with the other patches.
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.