Skip to contentSkip to conversation

Add support for Loongson1 DMA

PATCH Superseded Keguang Zhang 3 participants 18 messages Mar 16, 2024 – Mar 20, 2024

Subsystems (4)

v6 of 12 Superseded Latest is v12 →

lore
Share & tools
lore

Keguang Zhang

author maintainer
#0 lore raw

v6 cover Add support for Loongson1 DMA

Add the driver and dt-binding document for Loongson1 DMA.

Changelog
V5 -> V6:
Change the compatible to the fallback
Implement .device_prep_dma_cyclic for Loongson1 sound driver, as well as .device_pause and .device_resume.
Set the limitation LS1X_DMA_MAX_DESC and put all descriptors into one page to save memory
Move dma_pool_zalloc() into ls1x_dma_alloc_desc() Drop dma_slave_config structure
Use .remove_new instead of .remove
Use KBUILD_MODNAME for the driver name
Improve the debug information
Some minor fixes
V4 -> V5:
Add the dt-binding document
Add DT support
Use DT information instead of platform data
Use chan_id of struct dma_chan instead of own id
Use of_dma_xlate_by_chan_id() instead of ls1x_dma_filter() Update the author information to my official name
V3 -> V4:
Use dma_slave_map to find the proper channel. Explicitly call devm_request_irq() and tasklet_kill(). Fix namespace issue.
Some minor fixes and cleanups.
V2 -> V3:
Rename ls1x_dma_filter_fn to ls1x_dma_filter.
V1 -> V2:
Change the config from 'DMA_LOONGSON1' to 'LOONGSON1_DMA', and rearrange it in alphabetical order in Kconfig and Makefile. Fix comment style.

Keguang Zhang (2):
dt-bindings: dma: Add Loongson-1 DMA
dmaengine: Loongson1: Add Loongson1 dmaengine driver

 .../bindings/dma/loongson,ls1x-dma.yaml       |  64 +++
 drivers/dma/Kconfig                           |   9 +
 drivers/dma/Makefile                          |   1 +
 drivers/dma/loongson1-dma.c                   | 492 ++++++++++++++++++
 4 files changed, 566 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml
 create mode 100644 drivers/dma/loongson1-dma.c

--
2.39.2

base-commit: 719136e5c24768ebdf80b9daa53facebbdd377c3
---
Keguang Zhang (2):
dt-bindings: dma: Add Loongson-1 DMA
dmaengine: Loongson1: Add Loongson1 dmaengine driver

 .../devicetree/bindings/dma/loongson,ls1x-dma.yaml |  66 ++
 drivers/dma/Kconfig                                |   9 +
 drivers/dma/Makefile                               |   1 +
 drivers/dma/loongson1-dma.c                        | 665 +++++++++++++++++++++
 4 files changed, 741 insertions(+)

---
base-commit: a1e7655b77e3391b58ac28256789ea45b1685abb
change-id: 20231120-loongson1-dma-163afe5708b9

Best regards,

Signature · 1 line
Keguang Zhang <[email protected]>
author maintainer
#1 lore raw

PATCH v6 1/2 dt-bindings: dma: Add Loongson-1 DMA

Add devicetree binding document for Loongson-1 DMA.

---
V5 -> V6:
Change the compatible to the fallback
Some minor fixes
V4 -> V5:
A newly added patch

---
 .../devicetree/bindings/dma/loongson,ls1x-dma.yaml | 66 ++++++++++++++++++++++
 1 file changed, 66 insertions(+)
Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml new file +66 -0
new file mode 100644
index 000000000000..06358df725c6
@@ -0,0 +1,66 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/dma/loongson,ls1x-dma.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Loongson-1 DMA Controller
+
+maintainers:
+  - Keguang Zhang <[email protected]>
+
+description:
+  Loongson-1 DMA controller provides 3 independent channels for
+  peripherals such as NAND and AC97.
+
+properties:
+  compatible:
+    oneOf:
+      - const: loongson,ls1b-dma
+      - items:
+          - enum:
+              - loongson,ls1c-dma
+          - const: loongson,ls1b-dma
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    description: Each channel has a dedicated interrupt line.
+    minItems: 1
+    maxItems: 3
+
+  interrupt-names:
+    minItems: 1
+    items:
+      - pattern: ch0
+      - pattern: ch1
+      - pattern: ch2
+
+  '#dma-cells':
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - interrupt-names
+  - '#dma-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    dma-controller@1fd01160 {
+        compatible = "loongson,ls1b-dma";
+        reg = <0x1fd01160 0x4>;
+
+        interrupt-parent = <&intc0>;
+        interrupts = <13 IRQ_TYPE_EDGE_RISING>,
+                     <14 IRQ_TYPE_EDGE_RISING>,
+                     <15 IRQ_TYPE_EDGE_RISING>;
+        interrupt-names = "ch0", "ch1", "ch2";
+
+        #dma-cells = <1>;
+    };
Signature · 1 line
2.40.1
#2 lore raw

Re: [PATCH v6 1/2] dt-bindings: dma: Add Loongson-1 DMA

Quoted 34 lines · On Sat, Mar 16, 2024 at 07:33:53PM +0800, Keguang Zhang via B4 Relay wrote:

From: Keguang Zhang <[email protected]>

Add devicetree binding document for Loongson-1 DMA.

---
V5 -> V6:
Change the compatible to the fallback
Some minor fixes
V4 -> V5:
A newly added patch

---
 .../devicetree/bindings/dma/loongson,ls1x-dma.yaml | 66 ++++++++++++++++++++++
 1 file changed, 66 insertions(+)
Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml new file +13 -0
new file mode 100644
index 000000000000..06358df725c6
@@ -0,0 +1,66 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/dma/loongson,ls1x-dma.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Loongson-1 DMA Controller
+
+maintainers:
+  - Keguang Zhang <[email protected]>
+
+description:
+  Loongson-1 DMA controller provides 3 independent channels for

Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml line 23

Quoted 10 lines
Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml new file +10 -0
+  peripherals such as NAND and AC97.
+
+properties:
+  compatible:
+    oneOf:
+      - const: loongson,ls1b-dma
+      - items:
+          - enum:
+              - loongson,ls1c-dma
+          - const: loongson,ls1b-dma

Aren't there several more devices in this family? Do they not have DMA controllers?

Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml line 31

Quoted 8 lines
Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml new file +8 -0
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    description: Each channel has a dedicated interrupt line.
+    minItems: 1
+    maxItems: 3

Is this number not fixed for each SoC?

Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml line 38

Quoted 6 lines
Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml new file +6 -0
+  interrupt-names:
+    minItems: 1
+    items:
+      - pattern: ch0
+      - pattern: ch1
+      - pattern: ch2

Why have you made these a pattern? There's no regex being used here at all.

Cheers,
Cono4.

author maintainer
#3 lore raw

Re: [PATCH v6 1/2] dt-bindings: dma: Add Loongson-1 DMA

Quoted 41 lines · Conor Dooley
Quoted 39 lines · On Sat, Mar 16, 2024 at 07:33:53PM +0800, Keguang Zhang via B4 Relay wrote:

From: Keguang Zhang <[email protected]>

Add devicetree binding document for Loongson-1 DMA.

---
V5 -> V6:
Change the compatible to the fallback
Some minor fixes
V4 -> V5:
A newly added patch

---
 .../devicetree/bindings/dma/loongson,ls1x-dma.yaml | 66 ++++++++++++++++++++++
 1 file changed, 66 insertions(+)
Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml new file +18 -0
new file mode 100644
index 000000000000..06358df725c6
@@ -0,0 +1,66 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/dma/loongson,ls1x-dma.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Loongson-1 DMA Controller
+
+maintainers:
+  - Keguang Zhang <[email protected]>
+
+description:
+  Loongson-1 DMA controller provides 3 independent channels for
+  peripherals such as NAND and AC97.
+
+properties:
+  compatible:
+    oneOf:
Quoted 9 lines

Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml line 23

Quoted 5 lines
Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml new file +5 -0
+      - const: loongson,ls1b-dma
+      - items:
+          - enum:
+              - loongson,ls1c-dma
+          - const: loongson,ls1b-dma

Aren't there several more devices in this family? Do they not have DMA controllers?

You are right. Loongson1 is a SoC family.
However, only 1A/1B/1C have DMA controller.

Quoted 11 lines

Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml line 31

Quoted 8 lines
Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml new file +8 -0
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    description: Each channel has a dedicated interrupt line.
+    minItems: 1
+    maxItems: 3

Is this number not fixed for each SoC?

Yes. Actually, it's fixed for the whole family.

Quoted 10 lines

Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml line 38

Quoted 6 lines
Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml new file +6 -0
+  interrupt-names:
+    minItems: 1
+    items:
+      - pattern: ch0
+      - pattern: ch1
+      - pattern: ch2

Why have you made these a pattern? There's no regex being used here at all.

Will change items to the following regex.
interrupt-names:
minItems: 1
items:
- pattern: "^ch[0-2]$"

Thanks!

Quoted 2 lines

Cheers,
Cono4.

Signature · 3 lines
Best regards,

Keguang Zhang
#4 lore raw

Re: [PATCH v6 1/2] dt-bindings: dma: Add Loongson-1 DMA

Quoted 51 lines · Keguang Zhang
Quoted 41 lines · Conor Dooley
Quoted 39 lines · On Sat, Mar 16, 2024 at 07:33:53PM +0800, Keguang Zhang via B4 Relay wrote:

From: Keguang Zhang <[email protected]>

Add devicetree binding document for Loongson-1 DMA.

---
V5 -> V6:
Change the compatible to the fallback
Some minor fixes
V4 -> V5:
A newly added patch

---
 .../devicetree/bindings/dma/loongson,ls1x-dma.yaml | 66 ++++++++++++++++++++++
 1 file changed, 66 insertions(+)
Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml new file +18 -0
new file mode 100644
index 000000000000..06358df725c6
@@ -0,0 +1,66 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/dma/loongson,ls1x-dma.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Loongson-1 DMA Controller
+
+maintainers:
+  - Keguang Zhang <[email protected]>
+
+description:
+  Loongson-1 DMA controller provides 3 independent channels for
+  peripherals such as NAND and AC97.
+
+properties:
+  compatible:
+    oneOf:
Quoted 9 lines

Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml line 23

Quoted 5 lines
Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml new file +5 -0
+      - const: loongson,ls1b-dma
+      - items:
+          - enum:
+              - loongson,ls1c-dma
+          - const: loongson,ls1b-dma

Aren't there several more devices in this family? Do they not have DMA controllers?

Quoted 2 lines

You are right. Loongson1 is a SoC family.
However, only 1A/1B/1C have DMA controller.

You're missing the 1A then.

Quoted 12 lines
Quoted 12 lines

Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml line 31

Quoted 9 lines
Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml new file +8 -0
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    description: Each channel has a dedicated interrupt line.
+    minItems: 1
+    maxItems: 3

Is this number not fixed for each SoC?

Quoted 1 line

Yes. Actually, it's fixed for the whole family.

Then why do you have minItems: 1? Are there multiple DMA controllers on each SoC that only make use of a subset of the possible channels?

Quoted 15 lines
Quoted 10 lines

Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml line 38

Quoted 6 lines
Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml new file +6 -0
+  interrupt-names:
+    minItems: 1
+    items:
+      - pattern: ch0
+      - pattern: ch1
+      - pattern: ch2

Why have you made these a pattern? There's no regex being used here at all.

Will change items to the following regex.
interrupt-names:
minItems: 1
items:
- pattern: "^ch[0-2]$"

author maintainer
#5 lore raw

Re: [PATCH v6 1/2] dt-bindings: dma: Add Loongson-1 DMA

Quoted 53 lines · Conor Dooley
Quoted 51 lines · Keguang Zhang
Quoted 50 lines · Conor Dooley
Quoted 34 lines · On Sat, Mar 16, 2024 at 07:33:53PM +0800, Keguang Zhang via B4 Relay wrote:

From: Keguang Zhang <[email protected]>

Add devicetree binding document for Loongson-1 DMA.

---
V5 -> V6:
Change the compatible to the fallback
Some minor fixes
V4 -> V5:
A newly added patch

---
 .../devicetree/bindings/dma/loongson,ls1x-dma.yaml | 66 ++++++++++++++++++++++
 1 file changed, 66 insertions(+)
Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml new file +13 -0
new file mode 100644
index 000000000000..06358df725c6
@@ -0,0 +1,66 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/dma/loongson,ls1x-dma.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Loongson-1 DMA Controller
+
+maintainers:
+  - Keguang Zhang <[email protected]>
+
+description:
+  Loongson-1 DMA controller provides 3 independent channels for

Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml line 23

Quoted 10 lines
Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml new file +10 -0
+  peripherals such as NAND and AC97.
+
+properties:
+  compatible:
+    oneOf:
+      - const: loongson,ls1b-dma
+      - items:
+          - enum:
+              - loongson,ls1c-dma
+          - const: loongson,ls1b-dma

Aren't there several more devices in this family? Do they not have DMA controllers?

Quoted 5 lines
Quoted 2 lines

You are right. Loongson1 is a SoC family.
However, only 1A/1B/1C have DMA controller.

You're missing the 1A then.

Will add 1A.

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml line 31

Quoted 9 lines
Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml new file +8 -0
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    description: Each channel has a dedicated interrupt line.
+    minItems: 1
+    maxItems: 3

Is this number not fixed for each SoC?

Quoted 5 lines
Quoted 1 line

Yes. Actually, it's fixed for the whole family.

Then why do you have minItems: 1? Are there multiple DMA controllers on each SoC that only make use of a subset of the possible channels?

All channels are available on each SoC.
Sorry, I will remove the minItems.

Thanks for your review!

Quoted 16 lines
Quoted 15 lines
Quoted 10 lines

Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml line 38

Quoted 6 lines
Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml new file +6 -0
+  interrupt-names:
+    minItems: 1
+    items:
+      - pattern: ch0
+      - pattern: ch1
+      - pattern: ch2

Why have you made these a pattern? There's no regex being used here at all.

Will change items to the following regex.
interrupt-names:
minItems: 1
items:
- pattern: "^ch[0-2]$"

Signature · 3 lines
Best regards,

Keguang Zhang
author maintainer
#6 lore raw

Re: [PATCH v6 1/2] dt-bindings: dma: Add Loongson-1 DMA

In reply to Keguang Zhang
Quoted 75 lines · Keguang Zhang
Quoted 41 lines · Conor Dooley
Quoted 39 lines · On Sat, Mar 16, 2024 at 07:33:53PM +0800, Keguang Zhang via B4 Relay wrote:

From: Keguang Zhang <[email protected]>

Add devicetree binding document for Loongson-1 DMA.

---
V5 -> V6:
Change the compatible to the fallback
Some minor fixes
V4 -> V5:
A newly added patch

---
 .../devicetree/bindings/dma/loongson,ls1x-dma.yaml | 66 ++++++++++++++++++++++
 1 file changed, 66 insertions(+)
Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml new file +18 -0
new file mode 100644
index 000000000000..06358df725c6
@@ -0,0 +1,66 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/dma/loongson,ls1x-dma.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Loongson-1 DMA Controller
+
+maintainers:
+  - Keguang Zhang <[email protected]>
+
+description:
+  Loongson-1 DMA controller provides 3 independent channels for
+  peripherals such as NAND and AC97.
+
+properties:
+  compatible:
+    oneOf:
Quoted 9 lines

Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml line 23

Quoted 5 lines
Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml new file +5 -0
+      - const: loongson,ls1b-dma
+      - items:
+          - enum:
+              - loongson,ls1c-dma
+          - const: loongson,ls1b-dma

Aren't there several more devices in this family? Do they not have DMA controllers?

You are right. Loongson1 is a SoC family.
However, only 1A/1B/1C have DMA controller.

Quoted 11 lines

Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml line 31

Quoted 8 lines
Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml new file +8 -0
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    description: Each channel has a dedicated interrupt line.
+    minItems: 1
+    maxItems: 3

Is this number not fixed for each SoC?

Yes. Actually, it's fixed for the whole family.

Quoted 7 lines
Quoted 6 lines
Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml new file +6 -0
+  interrupt-names:
+    minItems: 1
+    items:
+      - pattern: ch0
+      - pattern: ch1
+      - pattern: ch2
Quoted 9 lines
Quoted 3 lines

Why have you made these a pattern? There's no regex being used here at all.

Will change items to the following regex.
interrupt-names:
minItems: 1
items:
- pattern: "^ch[0-2]$"

Sorry. This pattern fails in dt_binding_check.
Will use const instead of pattern.
interrupt-names:
items:
- const: ch0
- const: ch1
- const: ch2

Quoted 11 lines

Thanks!

Quoted 2 lines

Cheers,
Cono4.

--
Best regards,

Keguang Zhang

--
Best regards,

Keguang Zhang

author maintainer
#7 lore raw

PATCH v6 2/2 dmaengine: Loongson1: Add Loongson1 dmaengine driver

In reply to Keguang Zhang

This patch adds DMA Engine driver for Loongson1 SoCs.

---
V5 -> V6:
Implement .device_prep_dma_cyclic for Loongson1 sound driver, as well as .device_pause and .device_resume.
Set the limitation LS1X_DMA_MAX_DESC and put all descriptors into one page to save memory
Move dma_pool_zalloc() into ls1x_dma_alloc_desc() Drop dma_slave_config structure
Use .remove_new instead of .remove
Use KBUILD_MODNAME for the driver name
Improve the debug information
V4 -> V5:
Add DT support
Use DT data instead of platform data
Use chan_id of struct dma_chan instead of own id
Use of_dma_xlate_by_chan_id() instead of ls1x_dma_filter() Update the author information to my official name
V3 -> V4:
Use dma_slave_map to find the proper channel. Explicitly call devm_request_irq() and tasklet_kill(). Fix namespace issue.
Some minor fixes and cleanups.
V2 -> V3:
Rename ls1x_dma_filter_fn to ls1x_dma_filter.
V1 -> V2:
Change the config from 'DMA_LOONGSON1' to 'LOONGSON1_DMA', and rearrange it in alphabetical order in Kconfig and Makefile. Fix comment style.

---
 drivers/dma/Kconfig         |   9 +
 drivers/dma/Makefile        |   1 +
 drivers/dma/loongson1-dma.c | 665 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 675 insertions(+)
drivers/dma/Kconfig +9 -0
index 002a5ec80620..837163b05c94 100644
@@ -369,6 +369,15 @@ config K3_DMA
 	  Support the DMA engine for Hisilicon K3 platform
 	  devices.
 
+config LOONGSON1_DMA
+	tristate "Loongson1 DMA support"
+	depends on MACH_LOONGSON32
+	select DMA_ENGINE
+	select DMA_VIRTUAL_CHANNELS
+	help
+	  This selects support for the DMA controller in Loongson1 SoCs,
+	  which is required by Loongson1 NAND and sound support.
+
 config LPC18XX_DMAMUX
 	bool "NXP LPC18xx/43xx DMA MUX for PL080"
 	depends on ARCH_LPC18XX || COMPILE_TEST
drivers/dma/Makefile +1 -0
index dfd40d14e408..5e3604f09b89 100644
@@ -47,6 +47,7 @@ obj-$(CONFIG_INTEL_IDMA64) += idma64.o
 obj-$(CONFIG_INTEL_IOATDMA) += ioat/
 obj-y += idxd/
 obj-$(CONFIG_K3_DMA) += k3dma.o
+obj-$(CONFIG_LOONGSON1_DMA) += loongson1-dma.o
 obj-$(CONFIG_LPC18XX_DMAMUX) += lpc18xx-dmamux.o
 obj-$(CONFIG_LS2X_APB_DMA) += ls2x-apb-dma.o
 obj-$(CONFIG_MILBEAUT_HDMAC) += milbeaut-hdmac.o
drivers/dma/loongson1-dma.c new file +665 -0

665 lines not on this page · raw message

Signature · 1 line
2.40.1
#8 lore raw
In reply to Keguang Zhang

Hi, Keguang,

Sorry for the late reply, there is already a ls2x-apb-dma driver, I'm not sure but can they share the same code base? If not, can rename this driver to ls1x-apb-dma for consistency?

Huacai

Quoted 70 lines · On Sat, Mar 16, 2024 at 7:34 PM Keguang Zhang via B4 Relay…

Add the driver and dt-binding document for Loongson1 DMA.

Changelog
V5 -> V6:
Change the compatible to the fallback
Implement .device_prep_dma_cyclic for Loongson1 sound driver, as well as .device_pause and .device_resume.
Set the limitation LS1X_DMA_MAX_DESC and put all descriptors into one page to save memory
Move dma_pool_zalloc() into ls1x_dma_alloc_desc() Drop dma_slave_config structure
Use .remove_new instead of .remove
Use KBUILD_MODNAME for the driver name
Improve the debug information
Some minor fixes
V4 -> V5:
Add the dt-binding document
Add DT support
Use DT information instead of platform data
Use chan_id of struct dma_chan instead of own id
Use of_dma_xlate_by_chan_id() instead of ls1x_dma_filter() Update the author information to my official name
V3 -> V4:
Use dma_slave_map to find the proper channel. Explicitly call devm_request_irq() and tasklet_kill(). Fix namespace issue.
Some minor fixes and cleanups.
V2 -> V3:
Rename ls1x_dma_filter_fn to ls1x_dma_filter.
V1 -> V2:
Change the config from 'DMA_LOONGSON1' to 'LOONGSON1_DMA', and rearrange it in alphabetical order in Kconfig and Makefile. Fix comment style.

Keguang Zhang (2):
dt-bindings: dma: Add Loongson-1 DMA
dmaengine: Loongson1: Add Loongson1 dmaengine driver

 .../bindings/dma/loongson,ls1x-dma.yaml       |  64 +++
 drivers/dma/Kconfig                           |   9 +
 drivers/dma/Makefile                          |   1 +
 drivers/dma/loongson1-dma.c                   | 492 ++++++++++++++++++
 4 files changed, 566 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml
 create mode 100644 drivers/dma/loongson1-dma.c

--
2.39.2

base-commit: 719136e5c24768ebdf80b9daa53facebbdd377c3
---
Keguang Zhang (2):
dt-bindings: dma: Add Loongson-1 DMA
dmaengine: Loongson1: Add Loongson1 dmaengine driver

 .../devicetree/bindings/dma/loongson,ls1x-dma.yaml |  66 ++
 drivers/dma/Kconfig                                |   9 +
 drivers/dma/Makefile                               |   1 +
 drivers/dma/loongson1-dma.c                        | 665 +++++++++++++++++++++
 4 files changed, 741 insertions(+)

---
base-commit: a1e7655b77e3391b58ac28256789ea45b1685abb
change-id: 20231120-loongson1-dma-163afe5708b9

Best regards,
--
Keguang Zhang <[email protected]>

author maintainer
#9 lore raw

Hi Huacai,

Quoted 5 lines

Hi, Keguang,

Sorry for the late reply, there is already a ls2x-apb-dma driver, I'm not sure but can they share the same code base? If not, can rename this driver to ls1x-apb-dma for consistency?

There are some differences between ls1x DMA and ls2x DMA, such as registers and DMA descriptors.
I will rename it to ls1x-apb-dma.
Thanks!

Quoted 75 lines

Huacai

Quoted 70 lines · On Sat, Mar 16, 2024 at 7:34 PM Keguang Zhang via B4 Relay…

Add the driver and dt-binding document for Loongson1 DMA.

Changelog
V5 -> V6:
Change the compatible to the fallback
Implement .device_prep_dma_cyclic for Loongson1 sound driver, as well as .device_pause and .device_resume.
Set the limitation LS1X_DMA_MAX_DESC and put all descriptors into one page to save memory
Move dma_pool_zalloc() into ls1x_dma_alloc_desc() Drop dma_slave_config structure
Use .remove_new instead of .remove
Use KBUILD_MODNAME for the driver name
Improve the debug information
Some minor fixes
V4 -> V5:
Add the dt-binding document
Add DT support
Use DT information instead of platform data
Use chan_id of struct dma_chan instead of own id
Use of_dma_xlate_by_chan_id() instead of ls1x_dma_filter() Update the author information to my official name
V3 -> V4:
Use dma_slave_map to find the proper channel. Explicitly call devm_request_irq() and tasklet_kill(). Fix namespace issue.
Some minor fixes and cleanups.
V2 -> V3:
Rename ls1x_dma_filter_fn to ls1x_dma_filter.
V1 -> V2:
Change the config from 'DMA_LOONGSON1' to 'LOONGSON1_DMA', and rearrange it in alphabetical order in Kconfig and Makefile. Fix comment style.

Keguang Zhang (2):
dt-bindings: dma: Add Loongson-1 DMA
dmaengine: Loongson1: Add Loongson1 dmaengine driver

 .../bindings/dma/loongson,ls1x-dma.yaml       |  64 +++
 drivers/dma/Kconfig                           |   9 +
 drivers/dma/Makefile                          |   1 +
 drivers/dma/loongson1-dma.c                   | 492 ++++++++++++++++++
 4 files changed, 566 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml
 create mode 100644 drivers/dma/loongson1-dma.c

--
2.39.2

base-commit: 719136e5c24768ebdf80b9daa53facebbdd377c3
---
Keguang Zhang (2):
dt-bindings: dma: Add Loongson-1 DMA
dmaengine: Loongson1: Add Loongson1 dmaengine driver

 .../devicetree/bindings/dma/loongson,ls1x-dma.yaml |  66 ++
 drivers/dma/Kconfig                                |   9 +
 drivers/dma/Makefile                               |   1 +
 drivers/dma/loongson1-dma.c                        | 665 +++++++++++++++++++++
 4 files changed, 741 insertions(+)

---
base-commit: a1e7655b77e3391b58ac28256789ea45b1685abb
change-id: 20231120-loongson1-dma-163afe5708b9

Best regards,
--
Keguang Zhang <[email protected]>

Signature · 3 lines
Best regards,

Keguang Zhang
#10 lore raw
Quoted 5 lines · Keguang Zhang

Hi Huacai,

Quoted 2 lines

Hi, Keguang,

Quoted 7 lines
Quoted 3 lines

Sorry for the late reply, there is already a ls2x-apb-dma driver, I'm not sure but can they share the same code base? If not, can rename this driver to ls1x-apb-dma for consistency?

There are some differences between ls1x DMA and ls2x DMA, such as registers and DMA descriptors.
I will rename it to ls1x-apb-dma.

OK, please also rename the yaml file to keep consistency.

Huacai

Quoted 84 lines

Thanks!

Quoted 75 lines

Huacai

Quoted 70 lines · On Sat, Mar 16, 2024 at 7:34 PM Keguang Zhang via B4 Relay…

Add the driver and dt-binding document for Loongson1 DMA.

Changelog
V5 -> V6:
Change the compatible to the fallback
Implement .device_prep_dma_cyclic for Loongson1 sound driver, as well as .device_pause and .device_resume.
Set the limitation LS1X_DMA_MAX_DESC and put all descriptors into one page to save memory
Move dma_pool_zalloc() into ls1x_dma_alloc_desc() Drop dma_slave_config structure
Use .remove_new instead of .remove
Use KBUILD_MODNAME for the driver name
Improve the debug information
Some minor fixes
V4 -> V5:
Add the dt-binding document
Add DT support
Use DT information instead of platform data
Use chan_id of struct dma_chan instead of own id
Use of_dma_xlate_by_chan_id() instead of ls1x_dma_filter() Update the author information to my official name
V3 -> V4:
Use dma_slave_map to find the proper channel. Explicitly call devm_request_irq() and tasklet_kill(). Fix namespace issue.
Some minor fixes and cleanups.
V2 -> V3:
Rename ls1x_dma_filter_fn to ls1x_dma_filter.
V1 -> V2:
Change the config from 'DMA_LOONGSON1' to 'LOONGSON1_DMA', and rearrange it in alphabetical order in Kconfig and Makefile. Fix comment style.

Keguang Zhang (2):
dt-bindings: dma: Add Loongson-1 DMA
dmaengine: Loongson1: Add Loongson1 dmaengine driver

 .../bindings/dma/loongson,ls1x-dma.yaml       |  64 +++
 drivers/dma/Kconfig                           |   9 +
 drivers/dma/Makefile                          |   1 +
 drivers/dma/loongson1-dma.c                   | 492 ++++++++++++++++++
 4 files changed, 566 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/loongson,ls1x-dma.yaml
 create mode 100644 drivers/dma/loongson1-dma.c

--
2.39.2

base-commit: 719136e5c24768ebdf80b9daa53facebbdd377c3
---
Keguang Zhang (2):
dt-bindings: dma: Add Loongson-1 DMA
dmaengine: Loongson1: Add Loongson1 dmaengine driver

 .../devicetree/bindings/dma/loongson,ls1x-dma.yaml |  66 ++
 drivers/dma/Kconfig                                |   9 +
 drivers/dma/Makefile                               |   1 +
 drivers/dma/loongson1-dma.c                        | 665 +++++++++++++++++++++
 4 files changed, 741 insertions(+)

---
base-commit: a1e7655b77e3391b58ac28256789ea45b1685abb
change-id: 20231120-loongson1-dma-163afe5708b9

Best regards,
--
Keguang Zhang <[email protected]>

--
Best regards,

Keguang Zhang

#11 lore raw
Quoted 6 lines · Huacai Chen
Quoted 5 lines · Keguang Zhang

Hi Huacai,

Quoted 2 lines

Hi, Keguang,

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

Sorry for the late reply, there is already a ls2x-apb-dma driver, I'm not sure but can they share the same code base? If not, can rename this driver to ls1x-apb-dma for consistency?

There are some differences between ls1x DMA and ls2x DMA, such as registers and DMA descriptors.
I will rename it to ls1x-apb-dma.

OK, please also rename the yaml file to keep consistency.

No, the yaml file needs to match the (one of the) compatible strings.

#12 lore raw

Hi, Conor,

Quoted 12 lines · Conor Dooley
Quoted 10 lines · Huacai Chen
Quoted 9 lines · Keguang Zhang

Hi Huacai,

Quoted 5 lines

Hi, Keguang,

Sorry for the late reply, there is already a ls2x-apb-dma driver, I'm not sure but can they share the same code base? If not, can rename this driver to ls1x-apb-dma for consistency?

Quoted 6 lines
Quoted 4 lines
Quoted 3 lines

There are some differences between ls1x DMA and ls2x DMA, such as registers and DMA descriptors.
I will rename it to ls1x-apb-dma.

OK, please also rename the yaml file to keep consistency.

No, the yaml file needs to match the (one of the) compatible strings.

OK, then I think we can also rename the compatible strings, if possible.

Huacai

#13 lore raw
Quoted 15 lines · Huacai Chen

Hi, Conor,

Quoted 12 lines · Conor Dooley
Quoted 10 lines · Huacai Chen
Quoted 9 lines · Keguang Zhang

Hi Huacai,

Quoted 5 lines

Hi, Keguang,

Sorry for the late reply, there is already a ls2x-apb-dma driver, I'm not sure but can they share the same code base? If not, can rename this driver to ls1x-apb-dma for consistency?

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines

There are some differences between ls1x DMA and ls2x DMA, such as registers and DMA descriptors.
I will rename it to ls1x-apb-dma.

OK, please also rename the yaml file to keep consistency.

No, the yaml file needs to match the (one of the) compatible strings.

OK, then I think we can also rename the compatible strings, if possible.

If there are no other types of dma controller on this device, I do not see why would we add "apb" into the compatible as there is nothing to differentiate this controller from.

author maintainer
#14 lore raw
Quoted 20 lines · Conor Dooley
Quoted 18 lines · Huacai Chen

Hi, Conor,

Quoted 15 lines · Conor Dooley
Quoted 13 lines · Huacai Chen
Quoted 12 lines · Keguang Zhang

Hi Huacai,

Quoted 5 lines

Hi, Keguang,

Sorry for the late reply, there is already a ls2x-apb-dma driver, I'm not sure but can they share the same code base? If not, can rename this driver to ls1x-apb-dma for consistency?

There are some differences between ls1x DMA and ls2x DMA, such as registers and DMA descriptors.
I will rename it to ls1x-apb-dma.

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line

OK, please also rename the yaml file to keep consistency.

No, the yaml file needs to match the (one of the) compatible strings.

OK, then I think we can also rename the compatible strings, if possible.

If there are no other types of dma controller on this device, I do not see why would we add "apb" into the compatible as there is nothing to differentiate this controller from.

That's true. 1A/1B/1C only have one APB DMA. Should I keep the compatible "ls1b-dma" and "ls1c-dma"?

Signature · 3 lines
Best regards,

Keguang Zhang
#15 lore raw
Quoted 25 lines · Keguang Zhang
Quoted 23 lines · Conor Dooley
Quoted 21 lines · Huacai Chen

Hi, Conor,

Quoted 18 lines · Conor Dooley
Quoted 6 lines · Huacai Chen
Quoted 5 lines · Keguang Zhang

Hi Huacai,

Quoted 2 lines

Hi, Keguang,

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

Sorry for the late reply, there is already a ls2x-apb-dma driver, I'm not sure but can they share the same code base? If not, can rename this driver to ls1x-apb-dma for consistency?

There are some differences between ls1x DMA and ls2x DMA, such as registers and DMA descriptors.
I will rename it to ls1x-apb-dma.

OK, please also rename the yaml file to keep consistency.

No, the yaml file needs to match the (one of the) compatible strings.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

OK, then I think we can also rename the compatible strings, if possible.

If there are no other types of dma controller on this device, I do not see why would we add "apb" into the compatible as there is nothing to differentiate this controller from.

That's true. 1A/1B/1C only have one APB DMA. Should I keep the compatible "ls1b-dma" and "ls1c-dma"?

The name "apbdma" comes from the user manual, "exchange data between memory and apb devices", at present there are two drivers using this
naming: tegra20-apb-dma.c and ls2x-apb-dma.c.

Huacai

Quoted 5 lines

--
Best regards,

Keguang Zhang

#16 lore raw
Quoted 32 lines · Huacai Chen
Quoted 31 lines · Keguang Zhang
Quoted 28 lines · Conor Dooley
Quoted 15 lines · Huacai Chen

Hi, Conor,

Quoted 12 lines · Conor Dooley
Quoted 10 lines · Huacai Chen
Quoted 9 lines · Keguang Zhang

Hi Huacai,

Quoted 5 lines

Hi, Keguang,

Sorry for the late reply, there is already a ls2x-apb-dma driver, I'm not sure but can they share the same code base? If not, can rename this driver to ls1x-apb-dma for consistency?

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines

There are some differences between ls1x DMA and ls2x DMA, such as registers and DMA descriptors.
I will rename it to ls1x-apb-dma.

OK, please also rename the yaml file to keep consistency.

No, the yaml file needs to match the (one of the) compatible strings.

OK, then I think we can also rename the compatible strings, if possible.

If there are no other types of dma controller on this device, I do not see why would we add "apb" into the compatible as there is nothing to differentiate this controller from.

Quoted 5 lines
Quoted 2 lines

That's true. 1A/1B/1C only have one APB DMA. Should I keep the compatible "ls1b-dma" and "ls1c-dma"?

The name "apbdma" comes from the user manual, "exchange data between memory and apb devices", at present there are two drivers using this
naming: tegra20-apb-dma.c and ls2x-apb-dma.c.

I think it's unnessesary but I won't stand in your way.

author maintainer
#17 lore raw
Quoted 34 lines · Conor Dooley
Quoted 32 lines · Huacai Chen
Quoted 31 lines · Keguang Zhang
Quoted 28 lines · Conor Dooley
Quoted 15 lines · Huacai Chen

Hi, Conor,

Quoted 12 lines · Conor Dooley
Quoted 10 lines · Huacai Chen
Quoted 9 lines · Keguang Zhang

Hi Huacai,

Quoted 5 lines

Hi, Keguang,

Sorry for the late reply, there is already a ls2x-apb-dma driver, I'm not sure but can they share the same code base? If not, can rename this driver to ls1x-apb-dma for consistency?

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines

There are some differences between ls1x DMA and ls2x DMA, such as registers and DMA descriptors.
I will rename it to ls1x-apb-dma.

OK, please also rename the yaml file to keep consistency.

No, the yaml file needs to match the (one of the) compatible strings.

OK, then I think we can also rename the compatible strings, if possible.

If there are no other types of dma controller on this device, I do not see why would we add "apb" into the compatible as there is nothing to differentiate this controller from.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

That's true. 1A/1B/1C only have one APB DMA. Should I keep the compatible "ls1b-dma" and "ls1c-dma"?

The name "apbdma" comes from the user manual, "exchange data between memory and apb devices", at present there are two drivers using this
naming: tegra20-apb-dma.c and ls2x-apb-dma.c.

I think it's unnessesary but I won't stand in your way.

Then I will follow Huacai's suggestion.
Thanks for your review, Conor and Huacai.

Signature · 3 lines
Best regards,

Keguang Zhang