Skip to contentSkip to conversation

dma/ti: enable udma and psil to be built as modules

PATCH Superseded Kevin Hilman 4 participants 8 messages Sep 27, 2022 – Sep 29, 2022

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover dma/ti: enable udma and psil to be built as modules

Enable the UDMA driver & glue and PSIL lib to be built & loaded as modules.

The defauilt Kconfig settings are not changed, so default upstream is still to be built in. This series just enables the option to build as modules.

v1->v2:
- rework PSIL lib into a single .ko

Kevin Hilman (3):
of/irq: export of_msi_get_domain
dma/ti: convert k3-udma to module
dma/ti: convert PSIL to be buildable as module

 drivers/dma/ti/Kconfig        |  7 +++---
 drivers/dma/ti/Makefile       | 15 +++++++------
 drivers/dma/ti/k3-psil.c      |  2 ++
 drivers/dma/ti/k3-udma-glue.c |  5 ++++-
 drivers/dma/ti/k3-udma.c      | 40 +++++------------------------------
 drivers/of/irq.c              |  1 +
 6 files changed, 24 insertions(+), 46 deletions(-)

base-commit: 568035b01cfb107af8d2e4bd2fb9aea22cf5b868

Signature · 1 line
2.34.0
#1 lore raw

PATCH v2 1/3 of/irq: export of_msi_get_domain

Export of_mis_get_domain to enable it for users from outside.

---
 drivers/of/irq.c | 1 +
 1 file changed, 1 insertion(+)
drivers/of/irq.c +1 -0
index d22f605fa7ee..c9308baa32c5 100644
@@ -727,6 +727,7 @@ struct irq_domain *of_msi_get_domain(struct device *dev,
 
 	return NULL;
 }
+EXPORT_SYMBOL_GPL(of_msi_get_domain);
 
 /**
  * of_msi_configure - Set the msi_domain field of a device
Signature · 1 line
2.34.0
#2 lore raw

PATCH v2 2/3 dma/ti: convert k3-udma to module

In reply to Kevin Hilman

Currently k3-udma driver is built as separate platform drivers with a shared probe and identical code path, just differnet platform data.

To enable to build as module, convert the separate platform driver into a single module_platform_driver with the data selection done via compatible string and of_match. The separate of_match tables are also combined into a single table to avoid the multiple calls to of_match_node()

Since all modern TI platforms using this are DT enabled, the removal of separate platform_drivers shoul should nave no functional change.

---
 drivers/dma/ti/Kconfig        |  4 ++--
 drivers/dma/ti/k3-udma-glue.c |  5 ++++-
 drivers/dma/ti/k3-udma.c      | 40 +++++------------------------------
 3 files changed, 11 insertions(+), 38 deletions(-)
drivers/dma/ti/Kconfig +2 -2
index 79618fac119a..f196be3b222f 100644
@@ -35,7 +35,7 @@ config DMA_OMAP
 	  DMA engine is found on OMAP and DRA7xx parts.
 
 config TI_K3_UDMA
-	bool "Texas Instruments UDMA support"
+	tristate "Texas Instruments UDMA support"
 	depends on ARCH_K3
 	depends on TI_SCI_PROTOCOL
 	depends on TI_SCI_INTA_IRQCHIP
@@ -48,7 +48,7 @@ config TI_K3_UDMA
 	  DMA engine is used in AM65x and j721e.
 
 config TI_K3_UDMA_GLUE_LAYER
-	bool "Texas Instruments UDMA Glue layer for non DMAengine users"
+	tristate "Texas Instruments UDMA Glue layer for non DMAengine users"
 	depends on ARCH_K3
 	depends on TI_K3_UDMA
 	help
drivers/dma/ti/k3-udma-glue.c +4 -1
index 4fdd9f06b723..c29de4695ae7 100644
@@ -6,6 +6,7 @@
  *
  */
 
+#include <linux/module.h>
 #include <linux/atomic.h>
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
@@ -1433,4 +1434,6 @@ static int __init k3_udma_glue_class_init(void)
 {
 	return class_register(&k3_udma_glue_devclass);
 }
-arch_initcall(k3_udma_glue_class_init);
+
+module_init(k3_udma_glue_class_init);
+MODULE_LICENSE("GPL v2");
drivers/dma/ti/k3-udma.c +5 -35
index 2f0d2c68c93c..7239ff31c8c5 100644
@@ -5,6 +5,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/module.h>
 #include <linux/delay.h>
 #include <linux/dmaengine.h>
 #include <linux/dma-mapping.h>
@@ -4318,18 +4319,10 @@ static const struct of_device_id udma_of_match[] = {
 		.compatible = "ti,j721e-navss-mcu-udmap",
 		.data = &j721e_mcu_data,
 	},
-	{ /* Sentinel */ },
-};
-
-static const struct of_device_id bcdma_of_match[] = {
 	{
 		.compatible = "ti,am64-dmss-bcdma",
 		.data = &am64_bcdma_data,
 	},
-	{ /* Sentinel */ },
-};
-
-static const struct of_device_id pktdma_of_match[] = {
 	{
 		.compatible = "ti,am64-dmss-pktdma",
 		.data = &am64_pktdma_data,
@@ -5254,14 +5247,9 @@ static int udma_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	match = of_match_node(udma_of_match, dev->of_node);
-	if (!match)
-		match = of_match_node(bcdma_of_match, dev->of_node);
 	if (!match) {
-		match = of_match_node(pktdma_of_match, dev->of_node);
-		if (!match) {
-			dev_err(dev, "No compatible match found\n");
-			return -ENODEV;
-		}
+		dev_err(dev, "No compatible match found\n");
+		return -ENODEV;
 	}
 	ud->match_data = match->data;
 
@@ -5494,27 +5482,9 @@ static struct platform_driver udma_driver = {
 	},
 	.probe		= udma_probe,
 };
-builtin_platform_driver(udma_driver);
 
-static struct platform_driver bcdma_driver = {
-	.driver = {
-		.name	= "ti-bcdma",
-		.of_match_table = bcdma_of_match,
-		.suppress_bind_attrs = true,
-	},
-	.probe		= udma_probe,
-};
-builtin_platform_driver(bcdma_driver);
-
-static struct platform_driver pktdma_driver = {
-	.driver = {
-		.name	= "ti-pktdma",
-		.of_match_table = pktdma_of_match,
-		.suppress_bind_attrs = true,
-	},
-	.probe		= udma_probe,
-};
-builtin_platform_driver(pktdma_driver);
+module_platform_driver(udma_driver);
+MODULE_LICENSE("GPL v2");
 
 /* Private interfaces to UDMA */
 #include "k3-udma-private.c"
Signature · 1 line
2.34.0
#3 lore raw

Re: [PATCH v2 2/3] dma/ti: convert k3-udma to module

Quoted 12 lines · Kevin Hilman

Currently k3-udma driver is built as separate platform drivers with a shared probe and identical code path, just differnet platform data.

To enable to build as module, convert the separate platform driver into a single module_platform_driver with the data selection done via compatible string and of_match. The separate of_match tables are also combined into a single table to avoid the multiple calls to of_match_node()

Since all modern TI platforms using this are DT enabled, the removal of separate platform_drivers shoul should nave no functional change.

Hello

You have some typo in last sentence. (extra shoul, nave->have)

Regards

maintainer
#4 lore raw

Re: [PATCH v2 2/3] dma/ti: convert k3-udma to module

In reply to Kevin Hilman
Quoted 11 lines · Kevin Hilman

Currently k3-udma driver is built as separate platform drivers with a shared probe and identical code path, just differnet platform data.

To enable to build as module, convert the separate platform driver into a single module_platform_driver with the data selection done via compatible string and of_match. The separate of_match tables are also combined into a single table to avoid the multiple calls to of_match_node()

Since all modern TI platforms using this are DT enabled, the removal of separate platform_drivers shoul should nave no functional change.

drop extra shoul

Please change subsystem tag to dmaengine: ti: xxxx for this and next patch

Quoted 3 lines

this has trailing whitespaces, maybe copy paste error

Quoted 128 lines
---
 drivers/dma/ti/Kconfig        |  4 ++--
 drivers/dma/ti/k3-udma-glue.c |  5 ++++-
 drivers/dma/ti/k3-udma.c      | 40 +++++------------------------------
 3 files changed, 11 insertions(+), 38 deletions(-)
drivers/dma/ti/Kconfig +2 -2
index 79618fac119a..f196be3b222f 100644
@@ -35,7 +35,7 @@ config DMA_OMAP
 	  DMA engine is found on OMAP and DRA7xx parts.
 
 config TI_K3_UDMA
-	bool "Texas Instruments UDMA support"
+	tristate "Texas Instruments UDMA support"
 	depends on ARCH_K3
 	depends on TI_SCI_PROTOCOL
 	depends on TI_SCI_INTA_IRQCHIP
@@ -48,7 +48,7 @@ config TI_K3_UDMA
 	  DMA engine is used in AM65x and j721e.
 
 config TI_K3_UDMA_GLUE_LAYER
-	bool "Texas Instruments UDMA Glue layer for non DMAengine users"
+	tristate "Texas Instruments UDMA Glue layer for non DMAengine users"
 	depends on ARCH_K3
 	depends on TI_K3_UDMA
 	help
drivers/dma/ti/k3-udma-glue.c +4 -1
index 4fdd9f06b723..c29de4695ae7 100644
@@ -6,6 +6,7 @@
  *
  */
 
+#include <linux/module.h>
 #include <linux/atomic.h>
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
@@ -1433,4 +1434,6 @@ static int __init k3_udma_glue_class_init(void)
 {
 	return class_register(&k3_udma_glue_devclass);
 }
-arch_initcall(k3_udma_glue_class_init);
+
+module_init(k3_udma_glue_class_init);
+MODULE_LICENSE("GPL v2");
drivers/dma/ti/k3-udma.c +5 -35
index 2f0d2c68c93c..7239ff31c8c5 100644
@@ -5,6 +5,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/module.h>
 #include <linux/delay.h>
 #include <linux/dmaengine.h>
 #include <linux/dma-mapping.h>
@@ -4318,18 +4319,10 @@ static const struct of_device_id udma_of_match[] = {
 		.compatible = "ti,j721e-navss-mcu-udmap",
 		.data = &j721e_mcu_data,
 	},
-	{ /* Sentinel */ },
-};
-
-static const struct of_device_id bcdma_of_match[] = {
 	{
 		.compatible = "ti,am64-dmss-bcdma",
 		.data = &am64_bcdma_data,
 	},
-	{ /* Sentinel */ },
-};
-
-static const struct of_device_id pktdma_of_match[] = {
 	{
 		.compatible = "ti,am64-dmss-pktdma",
 		.data = &am64_pktdma_data,
@@ -5254,14 +5247,9 @@ static int udma_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	match = of_match_node(udma_of_match, dev->of_node);
-	if (!match)
-		match = of_match_node(bcdma_of_match, dev->of_node);
 	if (!match) {
-		match = of_match_node(pktdma_of_match, dev->of_node);
-		if (!match) {
-			dev_err(dev, "No compatible match found\n");
-			return -ENODEV;
-		}
+		dev_err(dev, "No compatible match found\n");
+		return -ENODEV;
 	}
 	ud->match_data = match->data;
 
@@ -5494,27 +5482,9 @@ static struct platform_driver udma_driver = {
 	},
 	.probe		= udma_probe,
 };
-builtin_platform_driver(udma_driver);
 
-static struct platform_driver bcdma_driver = {
-	.driver = {
-		.name	= "ti-bcdma",
-		.of_match_table = bcdma_of_match,
-		.suppress_bind_attrs = true,
-	},
-	.probe		= udma_probe,
-};
-builtin_platform_driver(bcdma_driver);
-
-static struct platform_driver pktdma_driver = {
-	.driver = {
-		.name	= "ti-pktdma",
-		.of_match_table = pktdma_of_match,
-		.suppress_bind_attrs = true,
-	},
-	.probe		= udma_probe,
-};
-builtin_platform_driver(pktdma_driver);
+module_platform_driver(udma_driver);
+MODULE_LICENSE("GPL v2");
 
 /* Private interfaces to UDMA */
 #include "k3-udma-private.c"
Signature · 1 line
2.34.0
Signature · 1 line
~Vinod
#5 lore raw

Re: [PATCH v2 2/3] dma/ti: convert k3-udma to module

Hi Vinod,

Quoted 10 lines · Vinod Koul
Quoted 9 lines · Kevin Hilman

Currently k3-udma driver is built as separate platform drivers with a shared probe and identical code path, just differnet platform data.

To enable to build as module, convert the separate platform driver into a single module_platform_driver with the data selection done via compatible string and of_match. The separate of_match tables are also combined into a single table to avoid the multiple calls to of_match_node()

Quoted 7 lines
Quoted 2 lines

Since all modern TI platforms using this are DT enabled, the removal of separate platform_drivers shoul should nave no functional change.

drop extra shoul

Please change subsystem tag to dmaengine: ti: xxxx for this and next patch

OK.

Quoted 5 lines
Quoted 3 lines

this has trailing whitespaces, maybe copy paste error

Yup. Thanks for the review. Will respin.

Kevin

#6 lore raw

PATCH v2 3/3 dma/ti: convert PSIL to be buildable as module

In reply to Kevin Hilman

Combine all the SoC specific files into a single lib that can be built-in or built as a module.

---
 drivers/dma/ti/Kconfig   |  3 ++-
 drivers/dma/ti/Makefile  | 15 ++++++++-------
 drivers/dma/ti/k3-psil.c |  2 ++
 3 files changed, 12 insertions(+), 8 deletions(-)
drivers/dma/ti/Kconfig +2 -1
index f196be3b222f..2adc2cca10e9 100644
@@ -56,7 +56,8 @@ config TI_K3_UDMA_GLUE_LAYER
 	  If unsure, say N.
 
 config TI_K3_PSIL
-	bool
+       tristate
+       default TI_K3_UDMA
 
 config TI_DMA_CROSSBAR
 	bool
drivers/dma/ti/Makefile +8 -7
index d3a303f0d7c6..383bbd6d12b9 100644
@@ -4,11 +4,12 @@ obj-$(CONFIG_TI_EDMA) += edma.o
 obj-$(CONFIG_DMA_OMAP) += omap-dma.o
 obj-$(CONFIG_TI_K3_UDMA) += k3-udma.o
 obj-$(CONFIG_TI_K3_UDMA_GLUE_LAYER) += k3-udma-glue.o
-obj-$(CONFIG_TI_K3_PSIL) += k3-psil.o \
-			    k3-psil-am654.o \
-			    k3-psil-j721e.o \
-			    k3-psil-j7200.o \
-			    k3-psil-am64.o \
-			    k3-psil-j721s2.o \
-			    k3-psil-am62.o
+obj-$(CONFIG_TI_K3_PSIL) += k3-psil-lib.o
+k3-psil-lib-objs := k3-psil.o \
+		    k3-psil-am654.o \
+		    k3-psil-j721e.o \
+		    k3-psil-j7200.o \
+		    k3-psil-am64.o \
+		    k3-psil-j721s2.o \
+		    k3-psil-am62.o
 obj-$(CONFIG_TI_DMA_CROSSBAR) += dma-crossbar.o
drivers/dma/ti/k3-psil.c +2 -0
index 761a384093d2..8b6533a1eeeb 100644
@@ -5,6 +5,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/module.h>
 #include <linux/device.h>
 #include <linux/init.h>
 #include <linux/mutex.h>
@@ -101,3 +102,4 @@ int psil_set_new_ep_config(struct device *dev, const char *name,
 	return 0;
 }
 EXPORT_SYMBOL_GPL(psil_set_new_ep_config);
+MODULE_LICENSE("GPL v2");
Signature · 1 line
2.34.0
Acked-by on v2 3/3
#7 lore raw

Re: [PATCH v2 3/3] dma/ti: convert PSIL to be buildable as module

Hi Kevin,

Quoted 37 lines · Kevin Hilman

Combine all the SoC specific files into a single lib that can be built-in or built as a module.

---
  drivers/dma/ti/Kconfig   |  3 ++-
  drivers/dma/ti/Makefile  | 15 ++++++++-------
  drivers/dma/ti/k3-psil.c |  2 ++
  3 files changed, 12 insertions(+), 8 deletions(-)
drivers/dma/ti/Kconfig +2 -1
index f196be3b222f..2adc2cca10e9 100644
@@ -56,7 +56,8 @@ config TI_K3_UDMA_GLUE_LAYER
  	  If unsure, say N.
 
  config TI_K3_PSIL
-	bool
+       tristate
+       default TI_K3_UDMA
 
  config TI_DMA_CROSSBAR
  	bool
drivers/dma/ti/Makefile +0 -5
index d3a303f0d7c6..383bbd6d12b9 100644
@@ -4,11 +4,12 @@ obj-$(CONFIG_TI_EDMA) += edma.o
  obj-$(CONFIG_DMA_OMAP) += omap-dma.o
  obj-$(CONFIG_TI_K3_UDMA) += k3-udma.o
  obj-$(CONFIG_TI_K3_UDMA_GLUE_LAYER) += k3-udma-glue.o
-obj-$(CONFIG_TI_K3_PSIL) += k3-psil.o \
-			    k3-psil-am654.o \
-			    k3-psil-j721e.o \
-			    k3-psil-j7200.o \
-			    k3-psil-am64.o \

drivers/dma/ti/Makefile obj-$(CONFIG_TI_EDMA) += edma.o · line 14

Quoted 10 lines
drivers/dma/ti/Makefile +8 -2
-			    k3-psil-j721s2.o \
-			    k3-psil-am62.o
+obj-$(CONFIG_TI_K3_PSIL) += k3-psil-lib.o
+k3-psil-lib-objs := k3-psil.o \
+		    k3-psil-am654.o \
+		    k3-psil-j721e.o \
+		    k3-psil-j7200.o \
+		    k3-psil-am64.o \
+		    k3-psil-j721s2.o \
+		    k3-psil-am62.o

Can you reverse the order? First declare the objects needed for k3-psil-lib. It is more natural and easier to read.

With that change you can add my:

Quoted 18 lines
drivers/dma/ti/Makefile +0 -0
  obj-$(CONFIG_TI_DMA_CROSSBAR) += dma-crossbar.o
drivers/dma/ti/k3-psil.c +2 -0
index 761a384093d2..8b6533a1eeeb 100644
@@ -5,6 +5,7 @@
   */
 
  #include <linux/kernel.h>
+#include <linux/module.h>
  #include <linux/device.h>
  #include <linux/init.h>
  #include <linux/mutex.h>
@@ -101,3 +102,4 @@ int psil_set_new_ep_config(struct device *dev, const char *name,
  	return 0;
  }
  EXPORT_SYMBOL_GPL(psil_set_new_ep_config);
+MODULE_LICENSE("GPL v2");
Signature · 1 line
Péter