diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 3d7d58a109d8ebb0b602e17b9a6ff4ed211423ef..1210d6db40b1c2036537ea539d0230c2c606318b 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1030,8 +1030,9 @@ static void rproc_crash_handler_work(struct work_struct *work) } /** - * rproc_boot() - boot a remote processor + * __rproc_boot() - boot a remote processor * @rproc: handle of a remote processor + * @wait: wait for rproc registration completion * * Boot a remote processor (i.e. load its firmware, power it on, ...). * @@ -1040,7 +1041,7 @@ static void rproc_crash_handler_work(struct work_struct *work) * * Returns 0 on success, and an appropriate error value otherwise. */ -int rproc_boot(struct rproc *rproc) +static int __rproc_boot(struct rproc *rproc, bool wait) { const struct firmware *firmware_p; struct device *dev; @@ -1088,6 +1089,10 @@ int rproc_boot(struct rproc *rproc) goto downref_rproc; } + /* if rproc virtio is not yet configured, wait */ + if (wait) + wait_for_completion(&rproc->firmware_loading_complete); + ret = rproc_fw_boot(rproc, firmware_p); release_firmware(firmware_p); @@ -1101,8 +1106,28 @@ int rproc_boot(struct rproc *rproc) mutex_unlock(&rproc->lock); return ret; } + +/** + * rproc_boot() - boot a remote processor + * @rproc: handle of a remote processor + */ +int rproc_boot(struct rproc *rproc) +{ + return __rproc_boot(rproc, true); +} EXPORT_SYMBOL(rproc_boot); +/** + * rproc_boot_nowait() - boot a remote processor + * @rproc: handle of a remote processor + * + * Same as rproc_boot() but don't wait for rproc registration completion + */ +int rproc_boot_nowait(struct rproc *rproc) +{ + return __rproc_boot(rproc, false); +} + /** * rproc_shutdown() - power off the remote processor * @rproc: the remote processor diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index 8041b95cb05863c80ec6717bea03fab29c0ec27a..57e1de59bec8df168a258488a309a17b1aaca66e 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -48,6 +48,7 @@ struct rproc_fw_ops { /* from remoteproc_core.c */ void rproc_release(struct kref *kref); irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id); +int rproc_boot_nowait(struct rproc *rproc); /* from remoteproc_virtio.c */ int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id); diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c index e44872fb9e5e23ff2aaf284a675bab940d67b172..cc91556313e1763073a42b47791a77aae6728a60 100644 --- a/drivers/remoteproc/remoteproc_virtio.c +++ b/drivers/remoteproc/remoteproc_virtio.c @@ -161,7 +161,7 @@ static int rproc_virtio_find_vqs(struct virtio_device *vdev, unsigned nvqs, } /* now that the vqs are all set, boot the remote processor */ - ret = rproc_boot(rproc); + ret = rproc_boot_nowait(rproc); if (ret) { dev_err(&rproc->dev, "rproc_boot() failed %d\n", ret); goto error;