From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Lee Jones <lee.jones@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, kernel@stlinux.com,
maxime.coquelin@st.com, ohad@wizery.com,
linux-remoteproc@vger.kernel.org,
Ludovic Barre <ludovic.barre@st.com>
Subject: Re: [PATCH 3/5] remoteproc: core: Add ability to select a firmware from the client
Date: Fri, 6 May 2016 11:59:14 -0700 [thread overview]
Message-ID: <20160506185914.GF1256@tuxbot> (raw)
In-Reply-To: <1462454983-13168-4-git-send-email-lee.jones@linaro.org>
On Thu 05 May 06:29 PDT 2016, Lee Jones wrote:
> ST Co-Processors can be loaded with different firmwares to execute
> specific tasks without the need for unloading the rproc module.
>
I'm very much interested in ideas related to this and who "owns" the
life cycle of remoteprocs, do you have any code I can take a look at
that's using this interface?
> This patch provides a function which can update the firmware name.
>
> NB: This can only happen if the rproc is offline.
>
How is this working in the case when the remoteproc provides vdevs that
is holding references towards the rproc?
Do you unload rpmsg et al before doing this?
> Signed-off-by: Ludovic Barre <ludovic.barre@st.com>
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> ---
> drivers/remoteproc/remoteproc_core.c | 63 ++++++++++++++++++++++++++++++++++++
> include/linux/remoteproc.h | 13 ++++++++
> 2 files changed, 76 insertions(+)
>
> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> index 85e5fd8..03720c0 100644
> --- a/drivers/remoteproc/remoteproc_core.c
> +++ b/drivers/remoteproc/remoteproc_core.c
> @@ -1004,6 +1004,7 @@ int rproc_trigger_recovery(struct rproc *rproc)
>
> /* Free the copy of the resource table */
> kfree(rproc->cached_table);
> + rproc->cached_table = NULL;
>
Somewhat unrelated, but should be fixed, so let's go with it.
> return rproc_add_virtio_devices(rproc);
> }
> @@ -1329,6 +1330,66 @@ struct rproc *rproc_get_by_phandle(phandle phandle)
> EXPORT_SYMBOL(rproc_get_by_phandle);
>
> /**
> + * rproc_set_fw_name() - change rproc fw name
> + * @rproc: rproc handle
> + * @firmware: name of firmware file to load
> + *
> + * set a new firmware name for rproc handle
> + * firmware name can be updated only if the rproc is offline
> + * if firmware name is NULL the fw name is set on default name
> + *
> + * this function can wait, if the old fw config virtio is not yet finish
> + * (fw config request is asynchronous)
> + *
> + * Returns 0 on success and an appropriate error code otherwise.
> + */
> +int rproc_set_fw_name(struct rproc *rproc, const char *firmware)
> +{
> + struct rproc_vdev *rvdev, *rvtmp;
> +
> + if (!rproc)
> + return -EINVAL;
> +
> + /* if rproc is just being registered, wait */
> + wait_for_completion(&rproc->firmware_loading_complete);
> +
> + mutex_lock(&rproc->lock);
> +
> + if (rproc->state != RPROC_OFFLINE) {
> + mutex_unlock(&rproc->lock);
> + return -EBUSY;
> + }
> +
> + if (rproc->firmware && rproc->firmware != rproc->orig_firmware)
> + kfree(rproc->firmware);
kfree(NULL) is fine, so you can drop the first part of the expression.
> +
> + /* restore original fw name */
> + if (!firmware) {
> + rproc->firmware = rproc->orig_firmware;
> + } else {
> + rproc->firmware = kstrdup(firmware, GFP_KERNEL);
> + if (!rproc->firmware)
> + rproc->firmware = rproc->orig_firmware;
In the unlikely event that kstrdup fails I we should leave
rproc->firmware unchanged and return an error here.
As this is written we will silently (with a blarg in the log if anyone
checks) switch back to the default firmware and boot that.
> + }
> +
> + dev_info(&rproc->dev, "%s, fw name updated with:%s\n",
> + rproc->name, rproc->firmware);
> +
> + mutex_unlock(&rproc->lock);
> +
> + /* clean up remote vdev entries */
> + list_for_each_entry_safe(rvdev, rvtmp, &rproc->rvdevs, node)
> + rproc_remove_virtio_dev(rvdev);
> +
> + /* Free the copy of the resource table */
> + kfree(rproc->cached_table);
> + rproc->cached_table = NULL;
> +
> + return rproc_add_virtio_devices(rproc);
> +}
> +EXPORT_SYMBOL(rproc_set_fw_name);
[..]
>
> +struct rproc_subdev {
> + struct device dev;
> + struct rproc *rproc;
> + struct resource *res;
> +};
> +
> +#define to_subdevice(d) container_of(d, struct rproc_subdev, dev)
> +struct rproc_subdev *rproc_subdev_add(struct rproc *rproc,
> + struct resource *res);
> +void rproc_subdev_del(struct rproc_subdev *subdev);
> +struct device *rproc_subdev_lookup(struct rproc *rproc, const char *name);
> +int rproc_set_fw_name(struct rproc *rproc, const char *firmware);
These belongs to the next patch.
Regards,
Bjorn
WARNING: multiple messages have this Message-ID (diff)
From: bjorn.andersson@linaro.org (Bjorn Andersson)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/5] remoteproc: core: Add ability to select a firmware from the client
Date: Fri, 6 May 2016 11:59:14 -0700 [thread overview]
Message-ID: <20160506185914.GF1256@tuxbot> (raw)
In-Reply-To: <1462454983-13168-4-git-send-email-lee.jones@linaro.org>
On Thu 05 May 06:29 PDT 2016, Lee Jones wrote:
> ST Co-Processors can be loaded with different firmwares to execute
> specific tasks without the need for unloading the rproc module.
>
I'm very much interested in ideas related to this and who "owns" the
life cycle of remoteprocs, do you have any code I can take a look at
that's using this interface?
> This patch provides a function which can update the firmware name.
>
> NB: This can only happen if the rproc is offline.
>
How is this working in the case when the remoteproc provides vdevs that
is holding references towards the rproc?
Do you unload rpmsg et al before doing this?
> Signed-off-by: Ludovic Barre <ludovic.barre@st.com>
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> ---
> drivers/remoteproc/remoteproc_core.c | 63 ++++++++++++++++++++++++++++++++++++
> include/linux/remoteproc.h | 13 ++++++++
> 2 files changed, 76 insertions(+)
>
> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> index 85e5fd8..03720c0 100644
> --- a/drivers/remoteproc/remoteproc_core.c
> +++ b/drivers/remoteproc/remoteproc_core.c
> @@ -1004,6 +1004,7 @@ int rproc_trigger_recovery(struct rproc *rproc)
>
> /* Free the copy of the resource table */
> kfree(rproc->cached_table);
> + rproc->cached_table = NULL;
>
Somewhat unrelated, but should be fixed, so let's go with it.
> return rproc_add_virtio_devices(rproc);
> }
> @@ -1329,6 +1330,66 @@ struct rproc *rproc_get_by_phandle(phandle phandle)
> EXPORT_SYMBOL(rproc_get_by_phandle);
>
> /**
> + * rproc_set_fw_name() - change rproc fw name
> + * @rproc: rproc handle
> + * @firmware: name of firmware file to load
> + *
> + * set a new firmware name for rproc handle
> + * firmware name can be updated only if the rproc is offline
> + * if firmware name is NULL the fw name is set on default name
> + *
> + * this function can wait, if the old fw config virtio is not yet finish
> + * (fw config request is asynchronous)
> + *
> + * Returns 0 on success and an appropriate error code otherwise.
> + */
> +int rproc_set_fw_name(struct rproc *rproc, const char *firmware)
> +{
> + struct rproc_vdev *rvdev, *rvtmp;
> +
> + if (!rproc)
> + return -EINVAL;
> +
> + /* if rproc is just being registered, wait */
> + wait_for_completion(&rproc->firmware_loading_complete);
> +
> + mutex_lock(&rproc->lock);
> +
> + if (rproc->state != RPROC_OFFLINE) {
> + mutex_unlock(&rproc->lock);
> + return -EBUSY;
> + }
> +
> + if (rproc->firmware && rproc->firmware != rproc->orig_firmware)
> + kfree(rproc->firmware);
kfree(NULL) is fine, so you can drop the first part of the expression.
> +
> + /* restore original fw name */
> + if (!firmware) {
> + rproc->firmware = rproc->orig_firmware;
> + } else {
> + rproc->firmware = kstrdup(firmware, GFP_KERNEL);
> + if (!rproc->firmware)
> + rproc->firmware = rproc->orig_firmware;
In the unlikely event that kstrdup fails I we should leave
rproc->firmware unchanged and return an error here.
As this is written we will silently (with a blarg in the log if anyone
checks) switch back to the default firmware and boot that.
> + }
> +
> + dev_info(&rproc->dev, "%s, fw name updated with:%s\n",
> + rproc->name, rproc->firmware);
> +
> + mutex_unlock(&rproc->lock);
> +
> + /* clean up remote vdev entries */
> + list_for_each_entry_safe(rvdev, rvtmp, &rproc->rvdevs, node)
> + rproc_remove_virtio_dev(rvdev);
> +
> + /* Free the copy of the resource table */
> + kfree(rproc->cached_table);
> + rproc->cached_table = NULL;
> +
> + return rproc_add_virtio_devices(rproc);
> +}
> +EXPORT_SYMBOL(rproc_set_fw_name);
[..]
>
> +struct rproc_subdev {
> + struct device dev;
> + struct rproc *rproc;
> + struct resource *res;
> +};
> +
> +#define to_subdevice(d) container_of(d, struct rproc_subdev, dev)
> +struct rproc_subdev *rproc_subdev_add(struct rproc *rproc,
> + struct resource *res);
> +void rproc_subdev_del(struct rproc_subdev *subdev);
> +struct device *rproc_subdev_lookup(struct rproc *rproc, const char *name);
> +int rproc_set_fw_name(struct rproc *rproc, const char *firmware);
These belongs to the next patch.
Regards,
Bjorn
next prev parent reply other threads:[~2016-05-06 18:59 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-05 13:29 [PATCH 0/5] remoteproc: A few important improvements Lee Jones
2016-05-05 13:29 ` Lee Jones
2016-05-05 13:29 ` [PATCH 1/5] remoteproc: core: Task sync during rproc_fw_boot() Lee Jones
2016-05-05 13:29 ` Lee Jones
2016-05-06 18:44 ` Bjorn Andersson
2016-05-06 18:44 ` Bjorn Andersson
2016-05-05 13:29 ` [PATCH 2/5] remoteproc: core: Add rproc OF look-up functions Lee Jones
2016-05-05 13:29 ` Lee Jones
2016-05-06 18:48 ` Bjorn Andersson
2016-05-06 18:48 ` Bjorn Andersson
2016-05-10 14:16 ` Lee Jones
2016-05-10 14:16 ` Lee Jones
2016-05-10 18:48 ` Bjorn Andersson
2016-05-10 18:48 ` Bjorn Andersson
2016-07-13 19:11 ` Bjorn Andersson
2016-07-13 19:11 ` Bjorn Andersson
2016-07-14 6:53 ` Lee Jones
2016-07-14 6:53 ` Lee Jones
2016-05-05 13:29 ` [PATCH 3/5] remoteproc: core: Add ability to select a firmware from the client Lee Jones
2016-05-05 13:29 ` Lee Jones
2016-05-06 18:59 ` Bjorn Andersson [this message]
2016-05-06 18:59 ` Bjorn Andersson
2016-05-10 13:02 ` Lee Jones
2016-05-10 13:02 ` Lee Jones
2016-05-05 13:29 ` [PATCH 4/5] remoteproc: core: Supply framework to request, declare and fetch shared memory Lee Jones
2016-05-05 13:29 ` Lee Jones
2016-05-11 22:30 ` Bjorn Andersson
2016-05-11 22:30 ` Bjorn Andersson
2016-06-15 22:06 ` Bjorn Andersson
2016-06-15 22:06 ` Bjorn Andersson
2016-06-21 7:33 ` [STLinux Kernel] " loic pallardy
2016-06-21 7:33 ` loic pallardy
2016-06-21 7:33 ` loic pallardy
2016-06-22 16:21 ` Bjorn Andersson
2016-06-22 16:21 ` Bjorn Andersson
2016-05-05 13:29 ` [PATCH 5/5] remoteproc: core: Clip carveout if it's too big Lee Jones
2016-05-05 13:29 ` Lee Jones
2016-05-10 19:21 ` Bjorn Andersson
2016-05-10 19:21 ` Bjorn Andersson
2016-06-17 19:53 ` [STLinux Kernel] " loic pallardy
2016-06-17 19:53 ` loic pallardy
2016-06-17 19:53 ` loic pallardy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160506185914.GF1256@tuxbot \
--to=bjorn.andersson@linaro.org \
--cc=kernel@stlinux.com \
--cc=lee.jones@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=ludovic.barre@st.com \
--cc=maxime.coquelin@st.com \
--cc=ohad@wizery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.