Skip to contentSkip to conversation

dmaengine: Loongson1: Add Loongson1 dmaengine driver

PATCH Applied Keguang Zhang 3 participants 13 messages Jul 4, 2021 – Aug 29, 2021

Subsystems (2)
lore
Share & tools
lore

Keguang Zhang

author maintainer
#0 lore raw

PATCH v5 1/1 dmaengine: Loongson1: Add Loongson1 dmaengine driver

From: Kelvin Cheung <[email protected]>

This patch adds DMA Engine driver for Loongson1B.

---
V4 -> V5:
Drop superfluous log.
Fix coding style.
Submitting next txn as fast as possible.
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 | 505 ++++++++++++++++++++++++++++++++++++
 3 files changed, 515 insertions(+)
 create mode 100644 drivers/dma/loongson1-dma.c
drivers/dma/Kconfig +9 -0
index 6ab9d9a488a6..b3ceeae61483 100644
@@ -343,6 +343,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,
+	  and is required by Loongson1 NAND controller and AC97 support.
+
 config LPC18XX_DMAMUX
 	bool "NXP LPC18xx/43xx DMA MUX for PL080"
 	depends on ARCH_LPC18XX || COMPILE_TEST
drivers/dma/Makefile +1 -0
index aa69094e3547..6d54e485036e 100644
@@ -44,6 +44,7 @@ obj-$(CONFIG_INTEL_IOATDMA) += ioat/
 obj-$(CONFIG_INTEL_IDXD) += idxd/
 obj-$(CONFIG_INTEL_IOP_ADMA) += iop-adma.o
 obj-$(CONFIG_K3_DMA) += k3dma.o
+obj-$(CONFIG_LOONGSON1_DMA) += loongson1-dma.o
 obj-$(CONFIG_LPC18XX_DMAMUX) += lpc18xx-dmamux.o
 obj-$(CONFIG_MILBEAUT_HDMAC) += milbeaut-hdmac.o
 obj-$(CONFIG_MILBEAUT_XDMAC) += milbeaut-xdmac.o
drivers/dma/loongson1-dma.c new file +505 -0

505 lines not on this page · raw message

base-commit: 8d11cfb0c37547bd6b1cdc7c2653c1e6b5ec5abb

Signature · 1 line
2.30.2
maintainer
#1 lore raw

drivers/dma/loongson1-dma.c line 490

Quoted 9 lines · Keguang Zhang
drivers/dma/loongson1-dma.c new file +9 -0
+static struct platform_driver ls1x_dma_driver = {
+	.probe	= ls1x_dma_probe,
+	.remove	= ls1x_dma_remove,
+	.driver	= {
+		.name	= "ls1x-dma",
+	},
+};
+
+module_platform_driver(ls1x_dma_driver);

so my comment was left unanswered, who creates this device!

Signature · 1 line
~Vinod
author maintainer
#2 lore raw
Quoted 14 lines · Vinod Koul <[email protected]> 于2021年7月14日周三 下午1:14写道:

drivers/dma/loongson1-dma.c line 490

Quoted 9 lines · Keguang Zhang
drivers/dma/loongson1-dma.c new file +9 -0
+static struct platform_driver ls1x_dma_driver = {
+     .probe  = ls1x_dma_probe,
+     .remove = ls1x_dma_remove,
+     .driver = {
+             .name   = "ls1x-dma",
+     },
+};
+
+module_platform_driver(ls1x_dma_driver);

so my comment was left unanswered, who creates this device!

Sorry!
This patch will create the device: https://patchwork.kernel.org/patch/12357539

Quoted 3 lines

--
~Vinod

Signature · 3 lines
Best regards,

Kelvin Cheung
author maintainer
#3 lore raw
In reply to Vinod Koul
Quoted 14 lines · Vinod Koul <[email protected]> 于2021年7月14日周三 下午1:14写道:

drivers/dma/loongson1-dma.c line 490

Quoted 9 lines · Keguang Zhang
drivers/dma/loongson1-dma.c new file +9 -0
+static struct platform_driver ls1x_dma_driver = {
+     .probe  = ls1x_dma_probe,
+     .remove = ls1x_dma_remove,
+     .driver = {
+             .name   = "ls1x-dma",
+     },
+};
+
+module_platform_driver(ls1x_dma_driver);

so my comment was left unanswered, who creates this device!

Sorry!
This patch will create the device: https://patchwork.kernel.org/patch/12281691

Quoted 3 lines

--
~Vinod

--
Best regards,

Kelvin Cheung

maintainer
#4 lore raw
Quoted 16 lines · Kelvin Cheung
Quoted 14 lines · Vinod Koul <[email protected]> 于2021年7月14日周三 下午1:14写道:

drivers/dma/loongson1-dma.c line 490

Quoted 9 lines · Keguang Zhang
drivers/dma/loongson1-dma.c new file +9 -0
+static struct platform_driver ls1x_dma_driver = {
+     .probe  = ls1x_dma_probe,
+     .remove = ls1x_dma_remove,
+     .driver = {
+             .name   = "ls1x-dma",
+     },
+};
+
+module_platform_driver(ls1x_dma_driver);

so my comment was left unanswered, who creates this device!

Quoted 2 lines

Sorry!
This patch will create the device: https://patchwork.kernel.org/patch/12281691

Greg, looks like the above patch creates platform devices in mips, is that the right way..?

Signature · 1 line
~Vinod
#5 lore raw
Quoted 17 lines · Vinod Koul
Quoted 16 lines · Kelvin Cheung
Quoted 14 lines · Vinod Koul <[email protected]> 于2021年7月14日周三 下午1:14写道:

drivers/dma/loongson1-dma.c line 490

Quoted 9 lines · Keguang Zhang
drivers/dma/loongson1-dma.c new file +9 -0
+static struct platform_driver ls1x_dma_driver = {
+     .probe  = ls1x_dma_probe,
+     .remove = ls1x_dma_remove,
+     .driver = {
+             .name   = "ls1x-dma",
+     },
+};
+
+module_platform_driver(ls1x_dma_driver);

so my comment was left unanswered, who creates this device!

Quoted 5 lines
Quoted 2 lines

Sorry!
This patch will create the device: https://patchwork.kernel.org/patch/12281691

Greg, looks like the above patch creates platform devices in mips, is that the right way..?

I do not understand, what exactly is the question?

thanks,

greg k-h

maintainer
#6 lore raw
Quoted 18 lines · Greg KH
Quoted 17 lines · Vinod Koul
Quoted 16 lines · Kelvin Cheung
Quoted 14 lines · Vinod Koul <[email protected]> 于2021年7月14日周三 下午1:14写道:

drivers/dma/loongson1-dma.c line 490

Quoted 9 lines · Keguang Zhang
drivers/dma/loongson1-dma.c new file +9 -0
+static struct platform_driver ls1x_dma_driver = {
+     .probe  = ls1x_dma_probe,
+     .remove = ls1x_dma_remove,
+     .driver = {
+             .name   = "ls1x-dma",
+     },
+};
+
+module_platform_driver(ls1x_dma_driver);

so my comment was left unanswered, who creates this device!

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Sorry!
This patch will create the device: https://patchwork.kernel.org/patch/12281691

Greg, looks like the above patch creates platform devices in mips, is that the right way..?

I do not understand, what exactly is the question?

So this patch was adding Loongson1 dmaengine driver which is a platform device. I asked about the platform device and was told that [1] creates the platform device. I am not sure if that is the recommended way given that you have been asking people to not use platform devices.

[1]: https://patchwork.kernel.org/patch/12281691

So is [1] the correct approach or should this be fixed?

Signature · 1 line
~Vinod
#7 lore raw
Quoted 25 lines · Vinod Koul
Quoted 24 lines · Greg KH
Quoted 22 lines · Vinod Koul
Quoted 16 lines · Kelvin Cheung
Quoted 14 lines · Vinod Koul <[email protected]> 于2021年7月14日周三 下午1:14写道:

drivers/dma/loongson1-dma.c line 490

Quoted 9 lines · Keguang Zhang
drivers/dma/loongson1-dma.c new file +9 -0
+static struct platform_driver ls1x_dma_driver = {
+     .probe  = ls1x_dma_probe,
+     .remove = ls1x_dma_remove,
+     .driver = {
+             .name   = "ls1x-dma",
+     },
+};
+
+module_platform_driver(ls1x_dma_driver);

so my comment was left unanswered, who creates this device!

Quoted 2 lines

Sorry!
This patch will create the device: https://patchwork.kernel.org/patch/12281691

Greg, looks like the above patch creates platform devices in mips, is that the right way..?

Quoted 6 lines
Quoted 1 line

I do not understand, what exactly is the question?

So this patch was adding Loongson1 dmaengine driver which is a platform device. I asked about the platform device and was told that [1] creates the platform device. I am not sure if that is the recommended way given that you have been asking people to not use platform devices.

Yes, but this link:

Quoted 1 line

[1]: https://patchwork.kernel.org/patch/12281691

Does look like a "real" platform device in that you have fixed resources for the device and no way to discover it on your own.

But why are you not using DT for this? That looks like the old platform data files.

thanks,

greg k-h

maintainer
#8 lore raw
Quoted 35 lines · Greg KH
Quoted 25 lines · Vinod Koul
Quoted 24 lines · Greg KH
Quoted 22 lines · Vinod Koul
Quoted 16 lines · Kelvin Cheung
Quoted 14 lines · Vinod Koul <[email protected]> 于2021年7月14日周三 下午1:14写道:

Review

Quoted 9 lines · Keguang Zhang
(quoted diff) +9 -0
+static struct platform_driver ls1x_dma_driver = {
+     .probe  = ls1x_dma_probe,
+     .remove = ls1x_dma_remove,
+     .driver = {
+             .name   = "ls1x-dma",
+     },
+};
+
+module_platform_driver(ls1x_dma_driver);

so my comment was left unanswered, who creates this device!

Quoted 2 lines

Sorry!
This patch will create the device: https://patchwork.kernel.org/patch/12281691

Greg, looks like the above patch creates platform devices in mips, is that the right way..?

Quoted 6 lines
Quoted 1 line

I do not understand, what exactly is the question?

So this patch was adding Loongson1 dmaengine driver which is a platform device. I asked about the platform device and was told that [1] creates the platform device. I am not sure if that is the recommended way given that you have been asking people to not use platform devices.

Yes, but this link:

Quoted 7 lines
Quoted 1 line

[1]: https://patchwork.kernel.org/patch/12281691

Does look like a "real" platform device in that you have fixed resources for the device and no way to discover it on your own.

But why are you not using DT for this? That looks like the old platform data files.

Apparently I was told that this platform does not use DT :( Looking at it it should.. Maybe Kelvin can explain why..

Signature · 1 line
~Vinod
author maintainer
#9 lore raw

Hi Vinod, Greg,

Quoted 39 lines · Vinod Koul <[email protected]> 于2021年7月20日周二 下午8:18写道:
Quoted 37 lines · Greg KH
Quoted 25 lines · Vinod Koul
Quoted 24 lines · Greg KH
Quoted 22 lines · Vinod Koul
Quoted 16 lines · Kelvin Cheung
Quoted 14 lines · Vinod Koul <[email protected]> 于2021年7月14日周三 下午1:14写道:

Review

Quoted 9 lines · Keguang Zhang
(quoted diff) +9 -0
+static struct platform_driver ls1x_dma_driver = {
+     .probe  = ls1x_dma_probe,
+     .remove = ls1x_dma_remove,
+     .driver = {
+             .name   = "ls1x-dma",
+     },
+};
+
+module_platform_driver(ls1x_dma_driver);

so my comment was left unanswered, who creates this device!

Quoted 2 lines

Sorry!
This patch will create the device: https://patchwork.kernel.org/patch/12281691

Greg, looks like the above patch creates platform devices in mips, is that the right way..?

Quoted 6 lines
Quoted 1 line

I do not understand, what exactly is the question?

So this patch was adding Loongson1 dmaengine driver which is a platform device. I asked about the platform device and was told that [1] creates the platform device. I am not sure if that is the recommended way given that you have been asking people to not use platform devices.

Yes, but this link:

Quoted 1 line

[1]: https://patchwork.kernel.org/patch/12281691

Quoted 8 lines
Quoted 5 lines

Does look like a "real" platform device in that you have fixed resources for the device and no way to discover it on your own.

But why are you not using DT for this? That looks like the old platform data files.

Apparently I was told that this platform does not use DT :( Looking at it it should.. Maybe Kelvin can explain why..

Yes, the DT support of Loongson32 is still on the way. Therefore, I have to use the old way to let the driver work. I will update this driver once this platform supports DT.

Quoted 3 lines

--
~Vinod

Signature · 3 lines
Best regards,

Kelvin Cheung
author maintainer
#10 lore raw
Quoted 49 lines · Kelvin Cheung <[email protected]> 于2021年7月21日周三 下午8:22写道:

Hi Vinod, Greg,

Quoted 45 lines · Vinod Koul <[email protected]> 于2021年7月20日周二 下午8:18写道:
Quoted 42 lines · Greg KH
Quoted 25 lines · Vinod Koul
Quoted 24 lines · Greg KH
Quoted 22 lines · Vinod Koul
Quoted 16 lines · Kelvin Cheung
Quoted 14 lines · Vinod Koul <[email protected]> 于2021年7月14日周三 下午1:14写道:

Review

Quoted 9 lines · Keguang Zhang
(quoted diff) +9 -0
+static struct platform_driver ls1x_dma_driver = {
+     .probe  = ls1x_dma_probe,
+     .remove = ls1x_dma_remove,
+     .driver = {
+             .name   = "ls1x-dma",
+     },
+};
+
+module_platform_driver(ls1x_dma_driver);

so my comment was left unanswered, who creates this device!

Quoted 2 lines

Sorry!
This patch will create the device: https://patchwork.kernel.org/patch/12281691

Greg, looks like the above patch creates platform devices in mips, is that the right way..?

Quoted 6 lines
Quoted 1 line

I do not understand, what exactly is the question?

So this patch was adding Loongson1 dmaengine driver which is a platform device. I asked about the platform device and was told that [1] creates the platform device. I am not sure if that is the recommended way given that you have been asking people to not use platform devices.

Yes, but this link:

Quoted 1 line

[1]: https://patchwork.kernel.org/patch/12281691

Does look like a "real" platform device in that you have fixed resources for the device and no way to discover it on your own.

But why are you not using DT for this? That looks like the old platform data files.

Quoted 7 lines
Quoted 2 lines

Apparently I was told that this platform does not use DT :( Looking at it it should.. Maybe Kelvin can explain why..

Yes, the DT support of Loongson32 is still on the way. Therefore, I have to use the old way to let the driver work. I will update this driver once this platform supports DT.

Hi Vinod,
Is there anything to be improved?
Perhaps this patch is acceptable now?

Thanks!

Quoted 10 lines
Quoted 3 lines

--
~Vinod

--
Best regards,

Kelvin Cheung

Signature · 3 lines
Best regards,

Kelvin Cheung
maintainer
#12 lore raw
Quoted 6 lines · Vinod Koul
Quoted 3 lines · Keguang Zhang

From: Kelvin Cheung <[email protected]>

This patch adds DMA Engine driver for Loongson1B.

Applied, thanks

Dropped now, there have been build failures and no follow up fixes posted.

Pls fix and repost the driver after next merge window

Signature · 1 line
~Vinod