[PATCH 2/2] drivers:remoteproc:support always on remote processor

From: Barry Song
Date: Tue Mar 03 2015 - 07:07:42 EST


From: Wei Chen <Wei.Chen@xxxxxxx>

In current rproc use scenarios, the Linux side controls
the lifecycle of the remote processors, just like boot,
start, shutdown.

But in some scenarios, we require the remote processors
to be powered and booted before Linux bring up. In
additional, we might have require the remote processors
could not be shutdown, if it would be shutdown, the Linux
should be shutdown too.

In above scenarios, we have make remoteproc to support
always on remote processor. This kind of remote processor
control its lifecycle by itself.

Signed-off-by: Wei Chen <Wei.Chen@xxxxxxx>
Signed-off-by: Barry Song <Baohua.Song@xxxxxxx>
---
drivers/remoteproc/remoteproc_core.c | 5 +++++
drivers/remoteproc/remoteproc_virtio.c | 8 ++++++++
include/linux/remoteproc.h | 4 +++-
3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index f9709b6..5a5356a 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -914,6 +914,10 @@ static void rproc_fw_config_virtio(const struct firmware *fw, void *context)

rproc->table_csum = crc32(0, table, tablesz);

+ if (rproc->state == RPROC_ALWAYS_ON) {
+ rproc->table_ptr = table;
+ goto handl_res;
+ }
/*
* Create a copy of the resource table. When a virtio device starts
* and calls vring_new_virtqueue() the address of the allocated vring
@@ -926,6 +930,7 @@ static void rproc_fw_config_virtio(const struct firmware *fw, void *context)

rproc->table_ptr = rproc->cached_table;

+handl_res:
/* count the number of notify-ids */
rproc->max_notifyid = -1;
ret = rproc_handle_resources(rproc, tablesz, rproc_count_vrings_handler);
diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c
index e1a1023..2eba600 100644
--- a/drivers/remoteproc/remoteproc_virtio.c
+++ b/drivers/remoteproc/remoteproc_virtio.c
@@ -138,9 +138,13 @@ static void rproc_virtio_del_vqs(struct virtio_device *vdev)
{
struct rproc *rproc = vdev_to_rproc(vdev);

+ if (rproc->state == RPROC_ALWAYS_ON)
+ goto del_vqs;
+
/* power down the remote processor before deleting vqs */
rproc_shutdown(rproc);

+del_vqs:
__rproc_virtio_del_vqs(vdev);
}

@@ -160,6 +164,10 @@ static int rproc_virtio_find_vqs(struct virtio_device *vdev, unsigned nvqs,
}
}

+ /* always on rproc */
+ if (rproc->state == RPROC_ALWAYS_ON)
+ return 0;
+
/* now that the vqs are all set, boot the remote processor */
ret = rproc_boot(rproc);
if (ret) {
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index 9e7e745..e23cd45 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -344,6 +344,7 @@ struct rproc_ops {
* a message.
* @RPROC_RUNNING: device is up and running
* @RPROC_CRASHED: device has crashed; need to start recovery
+ * @RPROC_ALWAYS_ON: device is always on, doesn't need to power on/off.
* @RPROC_LAST: just keep this one at the end
*
* Please note that the values of these states are used as indices
@@ -357,7 +358,8 @@ enum rproc_state {
RPROC_SUSPENDED = 1,
RPROC_RUNNING = 2,
RPROC_CRASHED = 3,
- RPROC_LAST = 4,
+ RPROC_ALWAYS_ON = 4,
+ RPROC_LAST = 5,
};

/**
--
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/