2022-01-17 11:08:39

by Zong Li

[permalink] [raw]
Subject: [PATCH v4 0/3] Determine the number of DMA channels by 'dma-channels' property

The PDMA driver currently assumes there are four channels by default, it
might cause the error if there is actually less than four channels.
Change that by getting number of channel dynamically from device tree.
For backwards-compatible, it uses the default value (i.e. 4) when there
is no 'dma-channels' information in dts.

This patch set contains the dts and dt-bindings change.

Changed in v4:
- Remove cflags of debug use reported-by: kernel test robot <[email protected]>

Changed in v3:
- Fix allocating wrong size
- Return error if 'dma-channels' is larger than maximum

Changed in v2:
- Rebase on tag v5.16
- Use 4 as default value of dma-channels

Zong Li (3):
riscv: dts: Add dma-channels property in dma node
dt-bindings: Add dma-channels for pdma device node
dmaengine: sf-pdma: Get number of channel by device tree

.../bindings/dma/sifive,fu540-c000-pdma.yaml | 7 +++++++
.../boot/dts/microchip/microchip-mpfs.dtsi | 1 +
arch/riscv/boot/dts/sifive/fu540-c000.dtsi | 1 +
drivers/dma/sf-pdma/sf-pdma.c | 20 ++++++++++++-------
drivers/dma/sf-pdma/sf-pdma.h | 8 ++------
5 files changed, 24 insertions(+), 13 deletions(-)

--
2.31.1


2022-01-17 11:08:42

by Zong Li

[permalink] [raw]
Subject: [PATCH v4 1/3] riscv: dts: Add dma-channels property in dma node

Add dma-channels property, then we can determine how many channels there
by device tree.

Signed-off-by: Zong Li <[email protected]>
---
arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi | 1 +
arch/riscv/boot/dts/sifive/fu540-c000.dtsi | 1 +
2 files changed, 2 insertions(+)

diff --git a/arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi b/arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi
index c9f6d205d2ba..3c48f2d7a4a4 100644
--- a/arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi
+++ b/arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi
@@ -188,6 +188,7 @@ dma@3000000 {
reg = <0x0 0x3000000 0x0 0x8000>;
interrupt-parent = <&plic>;
interrupts = <23 24 25 26 27 28 29 30>;
+ dma-channels = <4>;
#dma-cells = <1>;
};

diff --git a/arch/riscv/boot/dts/sifive/fu540-c000.dtsi b/arch/riscv/boot/dts/sifive/fu540-c000.dtsi
index 0655b5c4201d..2bdfe7f06e4b 100644
--- a/arch/riscv/boot/dts/sifive/fu540-c000.dtsi
+++ b/arch/riscv/boot/dts/sifive/fu540-c000.dtsi
@@ -171,6 +171,7 @@ dma: dma@3000000 {
reg = <0x0 0x3000000 0x0 0x8000>;
interrupt-parent = <&plic0>;
interrupts = <23 24 25 26 27 28 29 30>;
+ dma-channels = <4>;
#dma-cells = <1>;
};
uart1: serial@10011000 {
--
2.31.1

2022-01-20 13:46:05

by Conor Dooley

[permalink] [raw]
Subject: Re: [PATCH v4 1/3] riscv: dts: Add dma-channels property in dma node

On 17/01/2022 01:35, Zong Li wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> Add dma-channels property, then we can determine how many channels there
> by device tree.
>
> Signed-off-by: Zong Li <[email protected]>
> ---
> arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi | 1 +
> arch/riscv/boot/dts/sifive/fu540-c000.dtsi | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi b/arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi
> index c9f6d205d2ba..3c48f2d7a4a4 100644
> --- a/arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi
> +++ b/arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi
> @@ -188,6 +188,7 @@ dma@3000000 {
> reg = <0x0 0x3000000 0x0 0x8000>;
> interrupt-parent = <&plic>;
> interrupts = <23 24 25 26 27 28 29 30>;
> + dma-channels = <4>;
> #dma-cells = <1>;
> };
For mpfs: Acked-by: Conor Dooley <[email protected]>

>
> diff --git a/arch/riscv/boot/dts/sifive/fu540-c000.dtsi b/arch/riscv/boot/dts/sifive/fu540-c000.dtsi
> index 0655b5c4201d..2bdfe7f06e4b 100644
> --- a/arch/riscv/boot/dts/sifive/fu540-c000.dtsi
> +++ b/arch/riscv/boot/dts/sifive/fu540-c000.dtsi
> @@ -171,6 +171,7 @@ dma: dma@3000000 {
> reg = <0x0 0x3000000 0x0 0x8000>;
> interrupt-parent = <&plic0>;
> interrupts = <23 24 25 26 27 28 29 30>;
> + dma-channels = <4>;
> #dma-cells = <1>;
> };
> uart1: serial@10011000 {
> --
> 2.31.1
>

2022-01-21 22:32:07

by Palmer Dabbelt

[permalink] [raw]
Subject: Re: [PATCH v4 1/3] riscv: dts: Add dma-channels property in dma node

On Sun, 16 Jan 2022 17:35:26 PST (-0800), [email protected] wrote:
> Add dma-channels property, then we can determine how many channels there
> by device tree.
>
> Signed-off-by: Zong Li <[email protected]>
> ---
> arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi | 1 +
> arch/riscv/boot/dts/sifive/fu540-c000.dtsi | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi b/arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi
> index c9f6d205d2ba..3c48f2d7a4a4 100644
> --- a/arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi
> +++ b/arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi
> @@ -188,6 +188,7 @@ dma@3000000 {
> reg = <0x0 0x3000000 0x0 0x8000>;
> interrupt-parent = <&plic>;
> interrupts = <23 24 25 26 27 28 29 30>;
> + dma-channels = <4>;
> #dma-cells = <1>;
> };
>
> diff --git a/arch/riscv/boot/dts/sifive/fu540-c000.dtsi b/arch/riscv/boot/dts/sifive/fu540-c000.dtsi
> index 0655b5c4201d..2bdfe7f06e4b 100644
> --- a/arch/riscv/boot/dts/sifive/fu540-c000.dtsi
> +++ b/arch/riscv/boot/dts/sifive/fu540-c000.dtsi
> @@ -171,6 +171,7 @@ dma: dma@3000000 {
> reg = <0x0 0x3000000 0x0 0x8000>;
> interrupt-parent = <&plic0>;
> interrupts = <23 24 25 26 27 28 29 30>;
> + dma-channels = <4>;
> #dma-cells = <1>;
> };
> uart1: serial@10011000 {

I've got some comments in on the bindings, but I'm assuming it's easier
to keep these all together. Happy to take this through the RISC-V tree,
but I'm guessing it'll be easier to take these via dmaengine as there's
a lot more diff there so

Reviewed-by: Palmer Dabbelt <[email protected]>
Acked-by: Palmer Dabbelt <[email protected]>

Thanks!

2022-01-27 13:24:16

by Vinod Koul

[permalink] [raw]
Subject: Re: [PATCH v4 1/3] riscv: dts: Add dma-channels property in dma node

On 17-01-22, 09:35, Zong Li wrote:
> Add dma-channels property, then we can determine how many channels there
> by device tree.
>
> Signed-off-by: Zong Li <[email protected]>
> ---
> arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi | 1 +
> arch/riscv/boot/dts/sifive/fu540-c000.dtsi | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi b/arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi
> index c9f6d205d2ba..3c48f2d7a4a4 100644
> --- a/arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi
> +++ b/arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi
> @@ -188,6 +188,7 @@ dma@3000000 {

Unrelated but the node name should be dma-controller@...

> reg = <0x0 0x3000000 0x0 0x8000>;
> interrupt-parent = <&plic>;
> interrupts = <23 24 25 26 27 28 29 30>;
> + dma-channels = <4>;
> #dma-cells = <1>;
> };
>
> diff --git a/arch/riscv/boot/dts/sifive/fu540-c000.dtsi b/arch/riscv/boot/dts/sifive/fu540-c000.dtsi
> index 0655b5c4201d..2bdfe7f06e4b 100644
> --- a/arch/riscv/boot/dts/sifive/fu540-c000.dtsi
> +++ b/arch/riscv/boot/dts/sifive/fu540-c000.dtsi
> @@ -171,6 +171,7 @@ dma: dma@3000000 {
> reg = <0x0 0x3000000 0x0 0x8000>;
> interrupt-parent = <&plic0>;
> interrupts = <23 24 25 26 27 28 29 30>;
> + dma-channels = <4>;
> #dma-cells = <1>;
> };
> uart1: serial@10011000 {
> --
> 2.31.1

--
~Vinod

2022-01-27 14:04:07

by Zong Li

[permalink] [raw]
Subject: Re: [PATCH v4 1/3] riscv: dts: Add dma-channels property in dma node

On Thu, Jan 27, 2022 at 3:03 PM Vinod Koul <[email protected]> wrote:
>
> On 17-01-22, 09:35, Zong Li wrote:
> > Add dma-channels property, then we can determine how many channels there
> > by device tree.
> >
> > Signed-off-by: Zong Li <[email protected]>
> > ---
> > arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi | 1 +
> > arch/riscv/boot/dts/sifive/fu540-c000.dtsi | 1 +
> > 2 files changed, 2 insertions(+)
> >
> > diff --git a/arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi b/arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi
> > index c9f6d205d2ba..3c48f2d7a4a4 100644
> > --- a/arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi
> > +++ b/arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi
> > @@ -188,6 +188,7 @@ dma@3000000 {
>
> Unrelated but the node name should be dma-controller@...
>

Thanks for the correction, I guess we could give another patch for
changing the node name.

> > reg = <0x0 0x3000000 0x0 0x8000>;
> > interrupt-parent = <&plic>;
> > interrupts = <23 24 25 26 27 28 29 30>;
> > + dma-channels = <4>;
> > #dma-cells = <1>;
> > };
> >
> > diff --git a/arch/riscv/boot/dts/sifive/fu540-c000.dtsi b/arch/riscv/boot/dts/sifive/fu540-c000.dtsi
> > index 0655b5c4201d..2bdfe7f06e4b 100644
> > --- a/arch/riscv/boot/dts/sifive/fu540-c000.dtsi
> > +++ b/arch/riscv/boot/dts/sifive/fu540-c000.dtsi
> > @@ -171,6 +171,7 @@ dma: dma@3000000 {
> > reg = <0x0 0x3000000 0x0 0x8000>;
> > interrupt-parent = <&plic0>;
> > interrupts = <23 24 25 26 27 28 29 30>;
> > + dma-channels = <4>;
> > #dma-cells = <1>;
> > };
> > uart1: serial@10011000 {
> > --
> > 2.31.1
>
> --
> ~Vinod