From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>,
Ohad Ben-Cohen <ohad@wizery.com>,
linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com
Subject: Re: [RFC 02/18] remoteproc: Introduce virtio device add/remove functions in core.
Date: Wed, 22 Apr 2020 10:57:23 -0600 [thread overview]
Message-ID: <20200422165723.GA9283@xps15> (raw)
In-Reply-To: <20200416161331.7606-3-arnaud.pouliquen@st.com>
This morning I'm attempting to take a fresh look at this set...
On Thu, Apr 16, 2020 at 06:13:15PM +0200, Arnaud Pouliquen wrote:
> In preparation of the migration of the management of rvdev in
> rproc_virtio, this patch spins off new functions to manage the
> virtio device.
>
> Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
> ---
> drivers/remoteproc/remoteproc_core.c | 149 +++++++++++++++------------
> 1 file changed, 83 insertions(+), 66 deletions(-)
>
> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> index 2a0425ab82a7..5c90d569c0f7 100644
> --- a/drivers/remoteproc/remoteproc_core.c
> +++ b/drivers/remoteproc/remoteproc_core.c
> @@ -441,6 +441,86 @@ static void rproc_rvdev_release(struct device *dev)
> kfree(rvdev);
> }
>
> +static int rproc_rvdev_add_device(struct rproc_vdev *rvdev)
> +{
> + struct rproc *rproc = rvdev->rproc;
> + struct fw_rsc_vdev *rsc = rvdev->rsc;
> + char name[16];
> + int ret, i;
> +
> + /* Initialise vdev subdevice */
> + snprintf(name, sizeof(name), "vdev%dbuffer", rvdev->index);
> + rvdev->dev.parent = &rproc->dev;
> + rvdev->dev.dma_pfn_offset = rproc->dev.parent->dma_pfn_offset;
> + rvdev->dev.release = rproc_rvdev_release;
> + dev_set_name(&rvdev->dev, "%s#%s", dev_name(rvdev->dev.parent), name);
> + dev_set_drvdata(&rvdev->dev, rvdev);
> +
> + ret = device_register(&rvdev->dev);
> + if (ret) {
> + put_device(&rvdev->dev);
> + return ret;
> + }
> + /* Make device dma capable by inheriting from parent's capabilities */
> + set_dma_ops(&rvdev->dev, get_dma_ops(rproc->dev.parent));
> +
> + ret = dma_coerce_mask_and_coherent(&rvdev->dev,
> + dma_get_mask(rproc->dev.parent));
> + if (ret) {
> + dev_warn(&rvdev->dev,
> + "Failed to set DMA mask %llx. Trying to continue... %x\n",
> + dma_get_mask(rproc->dev.parent), ret);
> + }
> +
> + /* parse the vrings */
> + for (i = 0; i < rsc->num_of_vrings; i++) {
> + ret = rproc_parse_vring(rvdev, rsc, i);
> + if (ret)
> + goto free_rvdev;
> + }
> +
> + /* allocate the vring resources */
> + for (i = 0; i < rsc->num_of_vrings; i++) {
> + ret = rproc_alloc_vring(rvdev, i);
> + if (ret)
> + goto free_vg;
> + }
> +
> + rvdev->subdev.start = rproc_vdev_do_start;
> + rvdev->subdev.stop = rproc_vdev_do_stop;
> +
> + rproc_add_subdev(rproc, &rvdev->subdev);
> +
> + return 0;
> +
> +free_vg:
> + for (i--; i >= 0; i--) {
> + struct rproc_vring *rvring = &rvdev->vring[i];
> +
> + rproc_free_vring(rvring);
> + }
> +
> +free_rvdev:
> + device_unregister(&rvdev->dev);
> +
> + return ret;
> +}
> +
> +static void rproc_rvdev_remove_device(struct rproc_vdev *rvdev)
> +{
> + struct rproc *rproc = rvdev->rproc;
> + struct rproc_vring *rvring;
> + int id;
> +
> + for (id = 0; id < ARRAY_SIZE(rvdev->vring); id++) {
> + rvring = &rvdev->vring[id];
> + rproc_free_vring(rvring);
> + }
> +
> + rproc_remove_subdev(rproc, &rvdev->subdev);
> + device_unregister(&rvdev->dev);
> +}
> +
> /**
> * rproc_handle_vdev() - handle a vdev fw resource
> * @rproc: the remote processor
> @@ -473,8 +553,6 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc,
> {
> struct device *dev = &rproc->dev;
> struct rproc_vdev *rvdev;
> - int i, ret;
> - char name[16];
>
> /* make sure resource isn't truncated */
> if (struct_size(rsc, vring, rsc->num_of_vrings) + rsc->config_len >
> @@ -505,83 +583,22 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc,
> kref_init(&rvdev->refcount);
>
> rvdev->rsc = rsc;
> + rvdev->rsc_offset = offset;
> rvdev->id = rsc->id;
> rvdev->rproc = rproc;
> rvdev->index = rproc->nb_vdev++;
>
> - /* Initialise vdev subdevice */
> - snprintf(name, sizeof(name), "vdev%dbuffer", rvdev->index);
> - rvdev->dev.parent = rproc->dev.parent;
> - rvdev->dev.dma_pfn_offset = rproc->dev.parent->dma_pfn_offset;
> - rvdev->dev.release = rproc_rvdev_release;
> - dev_set_name(&rvdev->dev, "%s#%s", dev_name(rvdev->dev.parent), name);
> - dev_set_drvdata(&rvdev->dev, rvdev);
> -
> - ret = device_register(&rvdev->dev);
> - if (ret) {
> - put_device(&rvdev->dev);
> - return ret;
> - }
> - /* Make device dma capable by inheriting from parent's capabilities */
> - set_dma_ops(&rvdev->dev, get_dma_ops(rproc->dev.parent));
> -
> - ret = dma_coerce_mask_and_coherent(&rvdev->dev,
> - dma_get_mask(rproc->dev.parent));
> - if (ret) {
> - dev_warn(dev,
> - "Failed to set DMA mask %llx. Trying to continue... %x\n",
> - dma_get_mask(rproc->dev.parent), ret);
> - }
> -
> - /* parse the vrings */
> - for (i = 0; i < rsc->num_of_vrings; i++) {
> - ret = rproc_parse_vring(rvdev, rsc, i);
> - if (ret)
> - goto free_rvdev;
> - }
> -
> - /* remember the resource offset*/
> - rvdev->rsc_offset = offset;
> -
> - /* allocate the vring resources */
> - for (i = 0; i < rsc->num_of_vrings; i++) {
> - ret = rproc_alloc_vring(rvdev, i);
> - if (ret)
> - goto unwind_vring_allocations;
> - }
> -
> list_add_tail(&rvdev->node, &rproc->rvdevs);
This should go in rproc_rvdev_add_device()
>
> - rvdev->subdev.start = rproc_vdev_do_start;
> - rvdev->subdev.stop = rproc_vdev_do_stop;
> -
> - rproc_add_subdev(rproc, &rvdev->subdev);
> -
> - return 0;
> -
> -unwind_vring_allocations:
> - for (i--; i >= 0; i--)
> - rproc_free_vring(&rvdev->vring[i]);
> -free_rvdev:
> - device_unregister(&rvdev->dev);
> - return ret;
> + return rproc_rvdev_add_device(rvdev);
> }
>
> void rproc_vdev_release(struct kref *ref)
> {
> struct rproc_vdev *rvdev = container_of(ref, struct rproc_vdev, refcount);
> - struct rproc_vring *rvring;
> - struct rproc *rproc = rvdev->rproc;
> - int id;
> -
> - for (id = 0; id < ARRAY_SIZE(rvdev->vring); id++) {
> - rvring = &rvdev->vring[id];
> - rproc_free_vring(rvring);
> - }
>
> - rproc_remove_subdev(rproc, &rvdev->subdev);
> + rproc_rvdev_remove_device(rvdev);
> list_del(&rvdev->node);
> - device_unregister(&rvdev->dev);
Keep this function intact, rename it rproc_rvdev_remove_device() to balance out
rproc_rvdev_add_device() and modify rproc_resource_cleanup() to reflect the
change. I suppose we have nothing to loose since rproc_handle_vdev() and
rproc_vdev_release(), from a syntactic point of view, didn't balance each other
out.
> }
>
> /**
> --
> 2.17.1
>
next prev parent reply other threads:[~2020-04-22 16:57 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-16 16:13 [RFC 00/18] remoteproc: Decorelate virtio from core Arnaud Pouliquen
2020-04-16 16:13 ` Arnaud Pouliquen
2020-04-16 16:13 ` [RFC 01/18] remoteproc: Store resource table address in rvdev Arnaud Pouliquen
2020-04-16 16:13 ` Arnaud Pouliquen
2020-04-16 16:13 ` [RFC 02/18] remoteproc: Introduce virtio device add/remove functions in core Arnaud Pouliquen
2020-04-16 16:13 ` Arnaud Pouliquen
2020-04-21 20:41 ` Mathieu Poirier
2020-04-22 12:30 ` Arnaud POULIQUEN
2020-04-22 12:30 ` Arnaud POULIQUEN
2020-04-22 16:57 ` Mathieu Poirier [this message]
2020-04-16 16:13 ` [RFC 03/18] remoteproc: Move rvdev management in rproc_virtio Arnaud Pouliquen
2020-04-16 16:13 ` Arnaud Pouliquen
2020-04-21 22:18 ` Mathieu Poirier
2020-04-22 17:26 ` Mathieu Poirier
2020-04-16 16:13 ` [RFC 04/18] remoteproc: Add rproc_get_by_node helper Arnaud Pouliquen
2020-04-16 16:13 ` Arnaud Pouliquen
2020-04-16 16:13 ` [RFC 05/18] remoteproc: Create platform device for vdev Arnaud Pouliquen
2020-04-16 16:13 ` Arnaud Pouliquen
2020-04-16 16:13 ` [RFC 06/18] remoteproc: Add component in core for child devices synchronization Arnaud Pouliquen
2020-04-16 16:13 ` Arnaud Pouliquen
2020-04-16 16:13 ` [RFC 07/18] remoteproc: Add component bind/unbind for virtio platform Arnaud Pouliquen
2020-04-16 16:13 ` Arnaud Pouliquen
2020-04-16 16:13 ` [RFC 08/18] remoteproc: Externalize carveout functions Arnaud Pouliquen
2020-04-16 16:13 ` Arnaud Pouliquen
2020-04-16 16:13 ` [RFC 09/18] remoteproc: Move vring management from core to virtio Arnaud Pouliquen
2020-04-16 16:13 ` Arnaud Pouliquen
2020-04-16 16:13 ` [RFC 10/18] remoteproc: Add capability to populate rproc subnode devices Arnaud Pouliquen
2020-04-16 16:13 ` Arnaud Pouliquen
2020-04-16 16:13 ` [RFC 11/18] remoteproc: Add child node component in rproc match list Arnaud Pouliquen
2020-04-16 16:13 ` Arnaud Pouliquen
2020-04-16 16:13 ` [RFC 12/18] remoteproc: Support of pre-registered virtio device Arnaud Pouliquen
2020-04-16 16:13 ` Arnaud Pouliquen
2020-04-16 16:13 ` [RFC 13/18] remoteproc: Add memory default allocator helper Arnaud Pouliquen
2020-04-16 16:13 ` Arnaud Pouliquen
2020-04-16 16:13 ` [RFC 14/18] remoteproc: Add pa to da translation API Arnaud Pouliquen
2020-04-16 16:13 ` Arnaud Pouliquen
2020-04-16 16:13 ` [RFC 15/18] remoteproc: associate memory entry to a device Arnaud Pouliquen
2020-04-16 16:13 ` Arnaud Pouliquen
2020-04-16 16:13 ` [RFC 16/18] remoteproc: Parse virtio node for memory region Arnaud Pouliquen
2020-04-16 16:13 ` Arnaud Pouliquen
2020-04-16 16:13 ` [RFC 17/18] remoteproc: stm32: Add the pa to da ops Arnaud Pouliquen
2020-04-16 16:13 ` Arnaud Pouliquen
2020-04-16 16:13 ` [RFC 18/18] ARM: dts: stm32: Declare a virtio device Arnaud Pouliquen
2020-04-16 16:13 ` Arnaud Pouliquen
2020-04-23 17:26 ` [RFC 00/18] remoteproc: Decorelate virtio from core Mathieu Poirier
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=20200422165723.GA9283@xps15 \
--to=mathieu.poirier@linaro.org \
--cc=arnaud.pouliquen@st.com \
--cc=bjorn.andersson@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=ohad@wizery.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.