summaryrefslogtreecommitdiff
path: root/drivers/remoteproc/remoteproc_core.c
diff options
context:
space:
mode:
authorBjorn Andersson <bjorn.andersson@linaro.org>2016-10-19 19:40:07 -0700
committerBjorn Andersson <bjorn.andersson@linaro.org>2016-11-14 21:52:16 -0800
commita863af5d419361d3e657d4880dd3d7c490a8c4ba (patch)
tree26f3c715c9ec1875d68b7999de047979a72a4104 /drivers/remoteproc/remoteproc_core.c
parentaab8d8022304b646fbf6eed5f6ac9bc21d54d2fd (diff)
remoteproc: virtio: Anchor vring life cycle in vdev
Instead of having the vrings being allocated and freed as they are requested by the virtio device tie their life cycle to the vdev resource. This allows us to decouple the vdev resource management from the virtio device management. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Diffstat (limited to 'drivers/remoteproc/remoteproc_core.c')
-rw-r--r--drivers/remoteproc/remoteproc_core.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 67f581d0c488..bb78316f8120 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -370,6 +370,13 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc,
/* 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);
/* it is now safe to add the virtio device */
@@ -379,6 +386,9 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc,
return 0;
+unwind_vring_allocations:
+ for (i--; i >= 0; i--)
+ rproc_free_vring(&rvdev->vring[i]);
remove_rvdev:
list_del(&rvdev->node);
free_rvdev:
@@ -389,6 +399,16 @@ free_rvdev:
void rproc_vdev_release(struct kref *ref)
{
struct rproc_vdev *rvdev = container_of(ref, struct rproc_vdev, refcount);
+ struct rproc_vring *rvring;
+ int id;
+
+ for (id = 0; id < ARRAY_SIZE(rvdev->vring); id++) {
+ rvring = &rvdev->vring[id];
+ if (!rvring->va)
+ continue;
+
+ rproc_free_vring(rvring);
+ }
list_del(&rvdev->node);
kfree(rvdev);