This set provides functionality allowing the remoteproc core to attach to
a remote processor that was started by another entity.
New in V5:
1) Added Bjorn's reviewed-by.
2) Removed PM runtime call from patch 04.
3) Used a 'case' statement in patch 05.
Patches that need to be reviewed: 4, 5 and 9.
Applies cleanly on rproc-next (49cff1256879)
Thanks,
Mathieu
Mathieu Poirier (9):
remoteproc: Add new RPROC_DETACHED state
remoteproc: Add new attach() remoteproc operation
remoteproc: Introducing function rproc_attach()
remoteproc: Introducing function rproc_actuate()
remoteproc: Introducing function rproc_validate()
remoteproc: Refactor function rproc_boot()
remoteproc: Refactor function rproc_trigger_auto_boot()
remoteproc: Refactor function rproc_free_vring()
remoteproc: Properly handle firmware name when attaching
drivers/remoteproc/remoteproc_core.c | 213 +++++++++++++++++++++--
drivers/remoteproc/remoteproc_internal.h | 8 +
drivers/remoteproc/remoteproc_sysfs.c | 17 +-
include/linux/remoteproc.h | 9 +-
4 files changed, 230 insertions(+), 17 deletions(-)
--
2.25.1
Add a new function to assert the general health of the remote
processor before handing it to the remoteproc core.
Signed-off-by: Mathieu Poirier <[email protected]>
---
drivers/remoteproc/remoteproc_core.c | 41 ++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index fd424662801f..ad500c291d5f 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -2040,6 +2040,43 @@ struct rproc *rproc_get_by_phandle(phandle phandle)
#endif
EXPORT_SYMBOL(rproc_get_by_phandle);
+static int rproc_validate(struct rproc *rproc)
+{
+ switch (rproc->state) {
+ case RPROC_OFFLINE:
+ /*
+ * An offline processor without a start()
+ * function makes no sense.
+ */
+ if (!rproc->ops->start)
+ return -EINVAL;
+ break;
+ case RPROC_DETACHED:
+ /*
+ * A remote processor in a detached state without an
+ * attach() function makes not sense.
+ */
+ if (!rproc->ops->attach)
+ return -EINVAL;
+ /*
+ * When attaching to a remote processor the device memory
+ * is already available and as such there is no need to have a
+ * cached table.
+ */
+ if (rproc->cached_table)
+ return -EINVAL;
+ break;
+ default:
+ /*
+ * When adding a remote processor, the state of the device
+ * can be offline or detached, nothing else.
+ */
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
/**
* rproc_add() - register a remote processor
* @rproc: the remote processor handle to register
@@ -2069,6 +2106,10 @@ int rproc_add(struct rproc *rproc)
if (ret < 0)
return ret;
+ ret = rproc_validate(rproc);
+ if (ret < 0)
+ return ret;
+
dev_info(dev, "%s is available\n", rproc->name);
/* create debugfs entries */
--
2.25.1
On 7/7/20 11:00 PM, Mathieu Poirier wrote:
> Add a new function to assert the general health of the remote
> processor before handing it to the remoteproc core.
>
> Signed-off-by: Mathieu Poirier <[email protected]>
Reviewed-by: Arnaud Pouliquen <[email protected]>
Thanks,
Arnaud
> ---
> drivers/remoteproc/remoteproc_core.c | 41 ++++++++++++++++++++++++++++
> 1 file changed, 41 insertions(+)
>
> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> index fd424662801f..ad500c291d5f 100644
> --- a/drivers/remoteproc/remoteproc_core.c
> +++ b/drivers/remoteproc/remoteproc_core.c
> @@ -2040,6 +2040,43 @@ struct rproc *rproc_get_by_phandle(phandle phandle)
> #endif
> EXPORT_SYMBOL(rproc_get_by_phandle);
>
> +static int rproc_validate(struct rproc *rproc)
> +{
> + switch (rproc->state) {
> + case RPROC_OFFLINE:
> + /*
> + * An offline processor without a start()
> + * function makes no sense.
> + */
> + if (!rproc->ops->start)
> + return -EINVAL;
> + break;
> + case RPROC_DETACHED:
> + /*
> + * A remote processor in a detached state without an
> + * attach() function makes not sense.
> + */
> + if (!rproc->ops->attach)
> + return -EINVAL;
> + /*
> + * When attaching to a remote processor the device memory
> + * is already available and as such there is no need to have a
> + * cached table.
> + */
> + if (rproc->cached_table)
> + return -EINVAL;
> + break;
> + default:
> + /*
> + * When adding a remote processor, the state of the device
> + * can be offline or detached, nothing else.
> + */
> + return -EINVAL;
> + }
> +
> + return 0;
> +}
> +
> /**
> * rproc_add() - register a remote processor
> * @rproc: the remote processor handle to register
> @@ -2069,6 +2106,10 @@ int rproc_add(struct rproc *rproc)
> if (ret < 0)
> return ret;
>
> + ret = rproc_validate(rproc);
> + if (ret < 0)
> + return ret;
> +
> dev_info(dev, "%s is available\n", rproc->name);
>
> /* create debugfs entries */
>
Hi Mathieu
On 7/7/20 11:00 PM, Mathieu Poirier wrote:
> This set provides functionality allowing the remoteproc core to attach to
> a remote processor that was started by another entity.
>
> New in V5:
> 1) Added Bjorn's reviewed-by.
> 2) Removed PM runtime call from patch 04.
> 3) Used a 'case' statement in patch 05.
>
> Patches that need to be reviewed: 4, 5 and 9.
>
> Applies cleanly on rproc-next (49cff1256879)
I tested the series in different modes, no issue observed.
Tested-by: Arnaud Pouliquen <[email protected]>
Thanks for your work!
Arnaud
>
> Thanks,
> Mathieu
>
> Mathieu Poirier (9):
> remoteproc: Add new RPROC_DETACHED state
> remoteproc: Add new attach() remoteproc operation
> remoteproc: Introducing function rproc_attach()
> remoteproc: Introducing function rproc_actuate()
> remoteproc: Introducing function rproc_validate()
> remoteproc: Refactor function rproc_boot()
> remoteproc: Refactor function rproc_trigger_auto_boot()
> remoteproc: Refactor function rproc_free_vring()
> remoteproc: Properly handle firmware name when attaching
>
> drivers/remoteproc/remoteproc_core.c | 213 +++++++++++++++++++++--
> drivers/remoteproc/remoteproc_internal.h | 8 +
> drivers/remoteproc/remoteproc_sysfs.c | 17 +-
> include/linux/remoteproc.h | 9 +-
> 4 files changed, 230 insertions(+), 17 deletions(-)
>