2022-10-29 07:49:33

by Péter Ujfalusi

[permalink] [raw]
Subject: [PATCH v2] soc: ti: k3-ringacc: Allow the driver to be built as module

The ring accelerator driver can be built as module since all depending
functions are exported.

Signed-off-by: Peter Ujfalusi <[email protected]>
---
Hi,

Changes since v1:
- Fix MODULE_LICENSE line to GPL
- Use goto label in k3_ringacc_request_ring() for try_module_get error
- keep suppress_bind_attrs = true

Nicolas, I have not added your reviewed and tested by tag due to these changes.
I would appreciate if you would spare some time to re-check the patch.

Regards,
Peter

drivers/soc/ti/Kconfig | 2 +-
drivers/soc/ti/k3-ringacc.c | 28 ++++++++++++++++++++++++++--
2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/drivers/soc/ti/Kconfig b/drivers/soc/ti/Kconfig
index 7e2fb1c16af1..e009d9589af4 100644
--- a/drivers/soc/ti/Kconfig
+++ b/drivers/soc/ti/Kconfig
@@ -63,7 +63,7 @@ config TI_SCI_PM_DOMAINS
rootfs may be available.

config TI_K3_RINGACC
- bool "K3 Ring accelerator Sub System"
+ tristate "K3 Ring accelerator Sub System"
depends on ARCH_K3 || COMPILE_TEST
depends on TI_SCI_INTA_IRQCHIP
help
diff --git a/drivers/soc/ti/k3-ringacc.c b/drivers/soc/ti/k3-ringacc.c
index f7bf18b8229a..e01e4d815230 100644
--- a/drivers/soc/ti/k3-ringacc.c
+++ b/drivers/soc/ti/k3-ringacc.c
@@ -7,7 +7,7 @@

#include <linux/dma-mapping.h>
#include <linux/io.h>
-#include <linux/init.h>
+#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
@@ -336,6 +336,9 @@ struct k3_ring *k3_ringacc_request_ring(struct k3_ringacc *ringacc,

mutex_lock(&ringacc->req_lock);

+ if (!try_module_get(ringacc->dev->driver->owner))
+ goto err_module_get;
+
if (id == K3_RINGACC_RING_ID_ANY) {
/* Request for any general purpose ring */
struct ti_sci_resource_desc *gp_rings =
@@ -380,6 +383,9 @@ struct k3_ring *k3_ringacc_request_ring(struct k3_ringacc *ringacc,
return &ringacc->rings[id];

error:
+ module_put(ringacc->dev->driver->owner);
+
+err_module_get:
mutex_unlock(&ringacc->req_lock);
return NULL;
}
@@ -616,6 +622,8 @@ int k3_ringacc_ring_free(struct k3_ring *ring)
no_init:
clear_bit(ring->ring_id, ringacc->rings_inuse);

+ module_put(ringacc->dev->driver->owner);
+
out:
mutex_unlock(&ringacc->req_lock);
return 0;
@@ -1450,6 +1458,7 @@ static const struct of_device_id k3_ringacc_of_match[] = {
{ .compatible = "ti,am654-navss-ringacc", .data = &k3_ringacc_data, },
{},
};
+MODULE_DEVICE_TABLE(of, k3_ringacc_of_match);

struct k3_ringacc *k3_ringacc_dmarings_init(struct platform_device *pdev,
struct k3_ringacc_init_data *data)
@@ -1544,12 +1553,27 @@ static int k3_ringacc_probe(struct platform_device *pdev)
return 0;
}

+static int k3_ringacc_remove(struct platform_device *pdev)
+{
+ struct k3_ringacc *ringacc = dev_get_drvdata(&pdev->dev);
+
+ mutex_lock(&k3_ringacc_list_lock);
+ list_del(&ringacc->list);
+ mutex_unlock(&k3_ringacc_list_lock);
+ return 0;
+}
+
static struct platform_driver k3_ringacc_driver = {
.probe = k3_ringacc_probe,
+ .remove = k3_ringacc_remove,
.driver = {
.name = "k3-ringacc",
.of_match_table = k3_ringacc_of_match,
.suppress_bind_attrs = true,
},
};
-builtin_platform_driver(k3_ringacc_driver);
+module_platform_driver(k3_ringacc_driver);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("TI Ringacc driver for K3 SOCs");
+MODULE_AUTHOR("Grygorii Strashko <[email protected]>");
--
2.38.1



2022-10-31 10:30:33

by Nicolas Frayer

[permalink] [raw]
Subject: Re: [PATCH v2] soc: ti: k3-ringacc: Allow the driver to be built as module

Le sam. 29 oct. 2022 à 09:44, Peter Ujfalusi
<[email protected]> a écrit :
>
> The ring accelerator driver can be built as module since all depending
> functions are exported.
>
> Signed-off-by: Peter Ujfalusi <[email protected]>
> ---
> Hi,
>
> Changes since v1:
> - Fix MODULE_LICENSE line to GPL
> - Use goto label in k3_ringacc_request_ring() for try_module_get error
> - keep suppress_bind_attrs = true
>
> Nicolas, I have not added your reviewed and tested by tag due to these changes.
> I would appreciate if you would spare some time to re-check the patch.
>

Hi Peter,

I've re-checked/re-tested the patch.

Reviewed-by: Nicolas Frayer <[email protected]>
Tested-by: Nicolas Frayer <[email protected]>

> Regards,
> Peter
>
> drivers/soc/ti/Kconfig | 2 +-
> drivers/soc/ti/k3-ringacc.c | 28 ++++++++++++++++++++++++++--
> 2 files changed, 27 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/soc/ti/Kconfig b/drivers/soc/ti/Kconfig
> index 7e2fb1c16af1..e009d9589af4 100644
> --- a/drivers/soc/ti/Kconfig
> +++ b/drivers/soc/ti/Kconfig
> @@ -63,7 +63,7 @@ config TI_SCI_PM_DOMAINS
> rootfs may be available.
>
> config TI_K3_RINGACC
> - bool "K3 Ring accelerator Sub System"
> + tristate "K3 Ring accelerator Sub System"
> depends on ARCH_K3 || COMPILE_TEST
> depends on TI_SCI_INTA_IRQCHIP
> help
> diff --git a/drivers/soc/ti/k3-ringacc.c b/drivers/soc/ti/k3-ringacc.c
> index f7bf18b8229a..e01e4d815230 100644
> --- a/drivers/soc/ti/k3-ringacc.c
> +++ b/drivers/soc/ti/k3-ringacc.c
> @@ -7,7 +7,7 @@
>
> #include <linux/dma-mapping.h>
> #include <linux/io.h>
> -#include <linux/init.h>
> +#include <linux/module.h>
> #include <linux/of.h>
> #include <linux/of_device.h>
> #include <linux/platform_device.h>
> @@ -336,6 +336,9 @@ struct k3_ring *k3_ringacc_request_ring(struct k3_ringacc *ringacc,
>
> mutex_lock(&ringacc->req_lock);
>
> + if (!try_module_get(ringacc->dev->driver->owner))
> + goto err_module_get;
> +
> if (id == K3_RINGACC_RING_ID_ANY) {
> /* Request for any general purpose ring */
> struct ti_sci_resource_desc *gp_rings =
> @@ -380,6 +383,9 @@ struct k3_ring *k3_ringacc_request_ring(struct k3_ringacc *ringacc,
> return &ringacc->rings[id];
>
> error:
> + module_put(ringacc->dev->driver->owner);
> +
> +err_module_get:
> mutex_unlock(&ringacc->req_lock);
> return NULL;
> }
> @@ -616,6 +622,8 @@ int k3_ringacc_ring_free(struct k3_ring *ring)
> no_init:
> clear_bit(ring->ring_id, ringacc->rings_inuse);
>
> + module_put(ringacc->dev->driver->owner);
> +
> out:
> mutex_unlock(&ringacc->req_lock);
> return 0;
> @@ -1450,6 +1458,7 @@ static const struct of_device_id k3_ringacc_of_match[] = {
> { .compatible = "ti,am654-navss-ringacc", .data = &k3_ringacc_data, },
> {},
> };
> +MODULE_DEVICE_TABLE(of, k3_ringacc_of_match);
>
> struct k3_ringacc *k3_ringacc_dmarings_init(struct platform_device *pdev,
> struct k3_ringacc_init_data *data)
> @@ -1544,12 +1553,27 @@ static int k3_ringacc_probe(struct platform_device *pdev)
> return 0;
> }
>
> +static int k3_ringacc_remove(struct platform_device *pdev)
> +{
> + struct k3_ringacc *ringacc = dev_get_drvdata(&pdev->dev);
> +
> + mutex_lock(&k3_ringacc_list_lock);
> + list_del(&ringacc->list);
> + mutex_unlock(&k3_ringacc_list_lock);
> + return 0;
> +}
> +
> static struct platform_driver k3_ringacc_driver = {
> .probe = k3_ringacc_probe,
> + .remove = k3_ringacc_remove,
> .driver = {
> .name = "k3-ringacc",
> .of_match_table = k3_ringacc_of_match,
> .suppress_bind_attrs = true,
> },
> };
> -builtin_platform_driver(k3_ringacc_driver);
> +module_platform_driver(k3_ringacc_driver);
> +
> +MODULE_LICENSE("GPL");
> +MODULE_DESCRIPTION("TI Ringacc driver for K3 SOCs");
> +MODULE_AUTHOR("Grygorii Strashko <[email protected]>");
> --
> 2.38.1
>

2022-11-03 07:35:49

by Nishanth Menon

[permalink] [raw]
Subject: Re: [PATCH v2] soc: ti: k3-ringacc: Allow the driver to be built as module

Hi Peter Ujfalusi,

On Sat, 29 Oct 2022 10:53:56 +0300, Peter Ujfalusi wrote:
> The ring accelerator driver can be built as module since all depending
> functions are exported.
>
>

I have applied the following to branch ti-drivers-soc-next on [1].
Thank you!

[1/1] soc: ti: k3-ringacc: Allow the driver to be built as module
commit: c07f216a8b72bac0c6e921793ad656a3b77f3545

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent up the chain during
the next merge window (or sooner if it is a relevant bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

[1] git://git.kernel.org/pub/scm/linux/kernel/git/ti/linux.git
--
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D