]> git.ipfire.org Git - people/arne_f/kernel.git/commitdiff
remoteproc: Further extend the vdev life cycle
authorBjorn Andersson <bjorn.andersson@linaro.org>
Thu, 20 Oct 2016 02:40:08 +0000 (19:40 -0700)
committerBjorn Andersson <bjorn.andersson@linaro.org>
Tue, 15 Nov 2016 05:52:16 +0000 (21:52 -0800)
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>
drivers/remoteproc/remoteproc_core.c

index bb78316f8120002d8e2222fb4cc0d737203aaeaa..62de765a9498476e771a86a5bc6836809bf998e7 100644 (file)
@@ -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 */
@@ -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);
+       }
 }
 
 /*