From c1a632fc83e364aa8fd82e949b47b36db64523c5 Mon Sep 17 00:00:00 2001 From: Suman Anna Date: Mon, 8 Oct 2018 17:55:32 -0500 Subject: [PATCH] remoteproc: add infrastructure support to allow pre-loaded remoteprocs The remoteproc infrastructure is enhanced to allow remoteproc drivers to be able to connect to already loaded and/or booted remote processors. The added infrastructure is designed to allow multiple different scenarios: - Support userspace driven loading, with the actual boot triggered through the kernel. - Support remote processors loaded and booted by bootloaders, with resource table either directly provided by the remoteproc driver or by remoteproc core by requesting the firmware and processing only the resource table. Support for these features are provided through two new fields in the rproc structure - 'skip_firmware_request' and 'skip_load'. These fields are expected to be set to true as per the mode/need required by the remoteproc drivers before a rproc_add() call. The remoteproc core skips looking for firmware and/or loading any firmware segments using these two state flags. The default behavior is unchanged. The interface and implementation details for either of the above scenarios is left to the individual remoteproc drivers. This design will be used to achieve the following different usecases on TI SoCs: - Allow the TI Keystone remoteproc driver to support a userspace based loader. The remoteproc driver is expected to invoke rproc_boot() and rproc_shutdown() for triggering the boot and shutdown of the remote processor after the loading is completed and the resource table information is published to the remoteproc driver. The resource table is processed in-line during the rproc_boot() invocation. - Allow the K3 R5F remoteproc driver to be invoked in an IPC-only mode (No load, boot or error recovery functionality, but only establish IPC mechanism). The driver relies on still using the regular state machine flow for creating the virtio devices. The rproc .start() and .stop() ops are not bypassed, and the actual boot bypass is implemented within the driver. Signed-off-by: Suman Anna --- drivers/remoteproc/remoteproc_core.c | 34 ++++++++++++++++++---------- include/linux/remoteproc.h | 4 ++++ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index ce59f5b765cd..b7e97b51977a 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1357,11 +1357,14 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw) struct device *dev = &rproc->dev; int ret; - /* load the ELF segments to memory */ - ret = rproc_load_segments(rproc, fw); - if (ret) { - dev_err(dev, "Failed to load program segments: %d\n", ret); - return ret; + if (!rproc->skip_load) { + /* load the ELF segments to memory */ + ret = rproc_load_segments(rproc, fw); + if (ret) { + dev_err(dev, "Failed to load program segments: %d\n", + ret); + return ret; + } } /* @@ -1429,7 +1432,11 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) if (ret) return ret; - dev_info(dev, "Booting fw image %s, size %zd\n", name, fw->size); + if (!rproc->skip_firmware_request) + dev_info(dev, "Booting fw image %s, size %zd\n", + name, fw->size); + else + dev_info(dev, "Booting unspecified pre-loaded fw image\n"); /* * if enabling an IOMMU isn't relevant for this rproc, this is @@ -1860,16 +1867,19 @@ int rproc_boot(struct rproc *rproc) dev_info(dev, "powering up %s\n", rproc->name); - /* load firmware */ - ret = request_firmware(&firmware_p, rproc->firmware, dev); - if (ret < 0) { - dev_err(dev, "request_firmware failed: %d\n", ret); - goto downref_rproc; + if (!rproc->skip_firmware_request) { + /* load firmware */ + ret = request_firmware(&firmware_p, rproc->firmware, dev); + if (ret < 0) { + dev_err(dev, "request_firmware failed: %d\n", ret); + goto downref_rproc; + } } ret = rproc_fw_boot(rproc, firmware_p); - release_firmware(firmware_p); + if (!rproc->skip_firmware_request) + release_firmware(firmware_p); downref_rproc: if (ret) diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index eab814c01458..c1ce8ee4411f 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -483,6 +483,8 @@ struct rproc_dump_segment { * @table_sz: size of @cached_table * @has_iommu: flag to indicate if remote processor is behind an MMU * @auto_boot: flag to indicate if remote processor should be auto-started + * @skip_firmware_request: flag to skip requesting the firmware + * @skip_load: flag to skip the loading of firmware segments * @dump_segments: list of segments in the firmware * @nb_vdev: number of vdev currently handled by rproc */ @@ -516,6 +518,8 @@ struct rproc { size_t table_sz; bool has_iommu; bool auto_boot; + unsigned int skip_firmware_request : 1; + unsigned int skip_load : 1; struct list_head dump_segments; int nb_vdev; }; -- 2.26.2