lkml.org 
[lkml]   [2020]   [Apr]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v3 11/14] remoteproc: Deal with synchronisation when changing FW image
Date
This patch prevents the firmware image from being displayed or changed
when the remoteproc core is synchronising with a remote processor. This
is needed since there is no guarantee about the nature of the firmware
image that is loaded by the external entity.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
drivers/remoteproc/remoteproc_sysfs.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c
index 7f8536b73295..cdd322a6ecfa 100644
--- a/drivers/remoteproc/remoteproc_sysfs.c
+++ b/drivers/remoteproc/remoteproc_sysfs.c
@@ -13,9 +13,20 @@
static ssize_t firmware_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
+ ssize_t ret;
struct rproc *rproc = to_rproc(dev);

- return sprintf(buf, "%s\n", rproc->firmware);
+ /*
+ * In most instances there is no guarantee about the firmware
+ * that was loaded by the external entity. As such simply don't
+ * print anything.
+ */
+ if (rproc_needs_syncing(rproc))
+ ret = sprintf(buf, "\n");
+ else
+ ret = sprintf(buf, "%s\n", rproc->firmware);
+
+ return ret;
}

/* Change firmware name via sysfs */
@@ -39,6 +50,17 @@ static ssize_t firmware_store(struct device *dev,
goto out;
}

+ /*
+ * There is no point in trying to change the firmware if loading the
+ * image of the remote processor is done by another entity.
+ */
+ if (rproc_needs_syncing(rproc)) {
+ dev_err(dev,
+ "can't change firmware while synchronising with MCU\n");
+ err = -EBUSY;
+ goto out;
+ }
+
len = strcspn(buf, "\n");
if (!len) {
dev_err(dev, "can't provide a NULL firmware\n");
--
2.20.1
\
 
 \ /
  Last update: 2020-04-24 22:02    [W:5.059 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site