Commit 4a4dca19 authored by Mathieu Poirier's avatar Mathieu Poirier Committed by Bjorn Andersson

remoteproc: Properly handle firmware name when attaching

This patch prevents the firmware image name from being displayed when
the remoteproc core is attaching to a remote processor. This is needed
needed since there is no guarantee about the nature of the firmware
image that is loaded by the external entity.
Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: default avatarArnaud Pouliquen <arnaud.pouliquen@st.com>
Reviewed-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Tested-by: default avatarArnaud Pouliquen <arnaud.pouliquen@st.com>
Link: https://lore.kernel.org/r/20200714195035.1426873-10-mathieu.poirier@linaro.orgSigned-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
parent 4d3ebb3b
......@@ -1627,6 +1627,14 @@ static int rproc_stop(struct rproc *rproc, bool crashed)
rproc->state = RPROC_OFFLINE;
/*
* The remote processor has been stopped and is now offline, which means
* that the next time it is brought back online the remoteproc core will
* be responsible to load its firmware. As such it is no longer
* autonomous.
*/
rproc->autonomous = false;
dev_info(dev, "stopped remote processor %s\n", rproc->name);
return 0;
......@@ -2145,6 +2153,16 @@ int rproc_add(struct rproc *rproc)
/* create debugfs entries */
rproc_create_debug_dir(rproc);
/*
* Remind ourselves the remote processor has been attached to rather
* than booted by the remoteproc core. This is important because the
* RPROC_DETACHED state will be lost as soon as the remote processor
* has been attached to. Used in firmware_show() and reset in
* rproc_stop().
*/
if (rproc->state == RPROC_DETACHED)
rproc->autonomous = true;
/* if rproc is marked always-on, request it to boot */
if (rproc->auto_boot) {
ret = rproc_trigger_auto_boot(rproc);
......
......@@ -15,8 +15,20 @@ static ssize_t firmware_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct rproc *rproc = to_rproc(dev);
const char *firmware = rproc->firmware;
/*
* If the remote processor has been started by an external
* entity we have no idea of what image it is running. As such
* simply display a generic string rather then rproc->firmware.
*
* Here we rely on the autonomous flag because a remote processor
* may have been attached to and currently in a running state.
*/
if (rproc->autonomous)
firmware = "unknown";
return sprintf(buf, "%s\n", rproc->firmware);
return sprintf(buf, "%s\n", firmware);
}
/* Change firmware name via sysfs */
......
......@@ -491,6 +491,7 @@ 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
* @autonomous: true if an external entity has booted the remote processor
* @dump_segments: list of segments in the firmware
* @nb_vdev: number of vdev currently handled by rproc
*/
......@@ -524,6 +525,7 @@ struct rproc {
size_t table_sz;
bool has_iommu;
bool auto_boot;
bool autonomous;
struct list_head dump_segments;
int nb_vdev;
u8 elf_class;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment