2022-01-26 22:17:11

by Arnaud Pouliquen

[permalink] [raw]
Subject: [RFC PATCH v3 2/4] remoteproc: core: Introduce rproc_register_rvdev function

The rproc structure contains a list of registered rproc_vdev structure.
To be able to move the management of the rproc_vdev structure in
remoteproc_virtio.c (i.e rproc_rvdev_add_device and
rproc_rvdev_remove_device functions), introduce the rproc_register_rvdev
and rproc_unregister_rvdev functions.
These functions will be exported by the remoteproc_core.c.

Signed-off-by: Arnaud Pouliquen <[email protected]>
---
drivers/remoteproc/remoteproc_core.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 83ff44a6a4db..7a091f860c82 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -491,6 +491,18 @@ static int copy_dma_range_map(struct device *to, struct device *from)
return 0;
}

+static void rproc_register_rvdev(struct rproc *rproc, struct rproc_vdev *rvdev)
+{
+ if (rvdev && rproc)
+ list_add_tail(&rvdev->node, &rproc->rvdevs);
+}
+
+static void rproc_unregister_rvdev(struct rproc_vdev *rvdev)
+{
+ if (rvdev)
+ list_del(&rvdev->node);
+}
+
static struct rproc_vdev *
rproc_rvdev_add_device(struct rproc *rproc, struct rproc_vdev_data *rvdev_data)
{
@@ -554,7 +566,7 @@ rproc_rvdev_add_device(struct rproc *rproc, struct rproc_vdev_data *rvdev_data)
goto unwind_vring_allocations;
}

- list_add_tail(&rvdev->node, &rproc->rvdevs);
+ rproc_register_rvdev(rproc, rvdev);

rvdev->subdev.start = rproc_vdev_do_start;
rvdev->subdev.stop = rproc_vdev_do_stop;
@@ -583,7 +595,7 @@ static void rproc_rvdev_remove_device(struct rproc_vdev *rvdev)
}

rproc_remove_subdev(rproc, &rvdev->subdev);
- list_del(&rvdev->node);
+ rproc_unregister_rvdev(rvdev);
device_unregister(&rvdev->dev);
}

--
2.25.1


2022-03-04 20:42:21

by Mathieu Poirier

[permalink] [raw]
Subject: Re: [RFC PATCH v3 2/4] remoteproc: core: Introduce rproc_register_rvdev function

On Wed, Jan 26, 2022 at 05:24:03PM +0100, Arnaud Pouliquen wrote:
> The rproc structure contains a list of registered rproc_vdev structure.
> To be able to move the management of the rproc_vdev structure in
> remoteproc_virtio.c (i.e rproc_rvdev_add_device and
> rproc_rvdev_remove_device functions), introduce the rproc_register_rvdev
> and rproc_unregister_rvdev functions.
> These functions will be exported by the remoteproc_core.c.

This last sentence is very confusing... I kept an eye out for the EXPORT_SYMBOL()
tag but never found it. Please remove.

>
> Signed-off-by: Arnaud Pouliquen <[email protected]>
> ---
> drivers/remoteproc/remoteproc_core.c | 16 ++++++++++++++--
> 1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> index 83ff44a6a4db..7a091f860c82 100644
> --- a/drivers/remoteproc/remoteproc_core.c
> +++ b/drivers/remoteproc/remoteproc_core.c
> @@ -491,6 +491,18 @@ static int copy_dma_range_map(struct device *to, struct device *from)
> return 0;
> }
>
> +static void rproc_register_rvdev(struct rproc *rproc, struct rproc_vdev *rvdev)
> +{
> + if (rvdev && rproc)
> + list_add_tail(&rvdev->node, &rproc->rvdevs);
> +}

I would call those rproc_add_rvdev() and rproc_remove_rvdev() to follow in the
footsteps of rproc_add_subdev() and rproc_remove_subdev().

> +
> +static void rproc_unregister_rvdev(struct rproc_vdev *rvdev)
> +{
> + if (rvdev)
> + list_del(&rvdev->node);
> +}
> +
> static struct rproc_vdev *
> rproc_rvdev_add_device(struct rproc *rproc, struct rproc_vdev_data *rvdev_data)
> {
> @@ -554,7 +566,7 @@ rproc_rvdev_add_device(struct rproc *rproc, struct rproc_vdev_data *rvdev_data)
> goto unwind_vring_allocations;
> }
>
> - list_add_tail(&rvdev->node, &rproc->rvdevs);
> + rproc_register_rvdev(rproc, rvdev);
>
> rvdev->subdev.start = rproc_vdev_do_start;
> rvdev->subdev.stop = rproc_vdev_do_stop;
> @@ -583,7 +595,7 @@ static void rproc_rvdev_remove_device(struct rproc_vdev *rvdev)
> }
>
> rproc_remove_subdev(rproc, &rvdev->subdev);
> - list_del(&rvdev->node);
> + rproc_unregister_rvdev(rvdev);
> device_unregister(&rvdev->dev);
> }
>
> --
> 2.25.1
>