Skip to content

Commit

Permalink
remoteproc: Further extend the vdev life cycle
Browse files Browse the repository at this point in the history
Tie the vdev (and hence vring) life cycle to the resource parsing and
resource cleanup operations, allowing us to safely register and
unregister virtio devices on the go.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
  • Loading branch information
Bjorn Andersson committed Nov 15, 2016
1 parent a863af5 commit 2b45cef
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/remoteproc/remoteproc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc,
goto unwind_vring_allocations;
}

/* track the rvdevs list reference */
kref_get(&rvdev->refcount);

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

/* it is now safe to add the virtio device */
Expand Down Expand Up @@ -839,8 +842,10 @@ static void rproc_resource_cleanup(struct rproc *rproc)
}

/* clean up remote vdev entries */
list_for_each_entry_safe(rvdev, rvtmp, &rproc->rvdevs, node)
list_for_each_entry_safe(rvdev, rvtmp, &rproc->rvdevs, node) {
rproc_remove_virtio_dev(rvdev);
kref_put(&rvdev->refcount, rproc_vdev_release);
}
}

/*
Expand Down

0 comments on commit 2b45cef

Please sign in to comment.