linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Péter Ujfalusi" <peter.ujfalusi@gmail.com>
To: Kevin Hilman <khilman@baylibre.com>, dmaengine@vger.kernel.org
Cc: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	Nicolas Frayer <nfrayer@baylibre.com>
Subject: Re: [PATCH 2/3] dma/ti: convert k3-udma to module
Date: Mon, 26 Sep 2022 21:52:46 +0300	[thread overview]
Message-ID: <11cf284c-d0d6-0687-b70b-2245ff8d6fcd@gmail.com> (raw)
In-Reply-To: <20220926181848.2917639-3-khilman@baylibre.com>



On 9/26/22 21:18, Kevin Hilman wrote:
> 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.
> 
> Signed-off-by: Kevin Hilman <khilman@baylibre.com>
> ---
>  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(-)
> 
> diff --git a/drivers/dma/ti/Kconfig b/drivers/dma/ti/Kconfig
> index 79618fac119a..f196be3b222f 100644
> --- a/drivers/dma/ti/Kconfig
> +++ b/drivers/dma/ti/Kconfig
> @@ -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
> diff --git a/drivers/dma/ti/k3-udma-glue.c b/drivers/dma/ti/k3-udma-glue.c
> index 4fdd9f06b723..c29de4695ae7 100644
> --- a/drivers/dma/ti/k3-udma-glue.c
> +++ b/drivers/dma/ti/k3-udma-glue.c
> @@ -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");
> diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
> index 2f0d2c68c93c..7239ff31c8c5 100644
> --- a/drivers/dma/ti/k3-udma.c
> +++ b/drivers/dma/ti/k3-udma.c
> @@ -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);

I did liked the 'hack' that the dev_* prints contained the actual type
of the DMA (udma/bcdma/pktdma), but it is not working via modules,
unless the driver init parts are split out and the bulk is kept as a
library.
I had this half way implemented in my wip, but never got the chance to
finalize it.

But, one can get the info via the address, so...

> +MODULE_LICENSE("GPL v2");
>  
>  /* Private interfaces to UDMA */
>  #include "k3-udma-private.c"

-- 
Péter

  reply	other threads:[~2022-09-26 18:45 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-26 18:18 [PATCH 0/3] dma/ti: enable udma and psil to be built as modules Kevin Hilman
2022-09-26 18:18 ` [PATCH 1/3] of/irq: export of_msi_get_domain Kevin Hilman
2022-09-26 18:18 ` [PATCH 2/3] dma/ti: convert k3-udma to module Kevin Hilman
2022-09-26 18:52   ` Péter Ujfalusi [this message]
2022-09-26 21:17     ` Kevin Hilman
2022-09-27 17:07       ` Péter Ujfalusi
2022-09-26 18:18 ` [PATCH 3/3] dma/ti: convert PSIL to be buildable as module Kevin Hilman
2022-09-26 18:47   ` Péter Ujfalusi
2022-09-26 18:50     ` Kevin Hilman
2022-09-27 17:19       ` Péter Ujfalusi
2022-09-27 22:56         ` Kevin Hilman
2022-09-26 19:02 ` [PATCH 0/3] dma/ti: enable udma and psil to be built as modules Péter Ujfalusi
2022-09-26 21:21   ` Kevin Hilman
2022-09-27 17:21     ` Péter Ujfalusi
2022-09-27 23:10       ` Kevin Hilman
2022-09-28 13:54         ` Péter Ujfalusi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11cf284c-d0d6-0687-b70b-2245ff8d6fcd@gmail.com \
    --to=peter.ujfalusi@gmail.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=khilman@baylibre.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=nfrayer@baylibre.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).