aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjorn Andersson <bjorn.andersson@linaro.org>2016-10-19 22:40:12 -0400
committerBjorn Andersson <bjorn.andersson@linaro.org>2016-11-15 00:52:18 -0500
commitcda8529346935fc86f476999ac4fbfe4e17abf11 (patch)
tree2bc8729a0e4a4d3380d6e660122f682b17b53670
parent2ca7d866ca13eb8394c6a4431465a6faa0c92fd6 (diff)
remoteproc: Merge table_ptr and cached_table pointers
As all vdev resources are allocated before we boot the remote processor we no longer need to support modifying the resource table while the remote is running. This saves us from the table_ptr dance, but more importantly allow the remote processor to enable security lock down of the loaded table memory region. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
-rw-r--r--drivers/remoteproc/remoteproc_core.c26
-rw-r--r--include/linux/remoteproc.h4
2 files changed, 11 insertions, 19 deletions
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 1abd78bfce6a..f0f6ec1ab12b 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -889,15 +889,13 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
889 /* 889 /*
890 * Create a copy of the resource table. When a virtio device starts 890 * Create a copy of the resource table. When a virtio device starts
891 * and calls vring_new_virtqueue() the address of the allocated vring 891 * and calls vring_new_virtqueue() the address of the allocated vring
892 * will be stored in the cached_table. Before the device is started, 892 * will be stored in the table_ptr. Before the device is started,
893 * cached_table will be copied into device memory. 893 * table_ptr will be copied into device memory.
894 */ 894 */
895 rproc->cached_table = kmemdup(table, tablesz, GFP_KERNEL); 895 rproc->table_ptr = kmemdup(table, tablesz, GFP_KERNEL);
896 if (!rproc->cached_table) 896 if (!rproc->table_ptr)
897 goto clean_up; 897 goto clean_up;
898 898
899 rproc->table_ptr = rproc->cached_table;
900
901 /* reset max_notifyid */ 899 /* reset max_notifyid */
902 rproc->max_notifyid = -1; 900 rproc->max_notifyid = -1;
903 901
@@ -916,18 +914,16 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
916 } 914 }
917 915
918 /* 916 /*
919 * The starting device has been given the rproc->cached_table as the 917 * The starting device has been given the rproc->table_ptr as the
920 * resource table. The address of the vring along with the other 918 * resource table. The address of the vring along with the other
921 * allocated resources (carveouts etc) is stored in cached_table. 919 * allocated resources (carveouts etc) is stored in table_ptr.
922 * In order to pass this information to the remote device we must copy 920 * In order to pass this information to the remote device we must copy
923 * this information to device memory. We also update the table_ptr so 921 * this information to device memory. We also update the table_ptr so
924 * that any subsequent changes will be applied to the loaded version. 922 * that any subsequent changes will be applied to the loaded version.
925 */ 923 */
926 loaded_table = rproc_find_loaded_rsc_table(rproc, fw); 924 loaded_table = rproc_find_loaded_rsc_table(rproc, fw);
927 if (loaded_table) { 925 if (loaded_table)
928 memcpy(loaded_table, rproc->cached_table, tablesz); 926 memcpy(loaded_table, rproc->table_ptr, tablesz);
929 rproc->table_ptr = loaded_table;
930 }
931 927
932 /* power up the remote processor */ 928 /* power up the remote processor */
933 ret = rproc->ops->start(rproc); 929 ret = rproc->ops->start(rproc);
@@ -955,8 +951,7 @@ stop_rproc:
955clean_up_resources: 951clean_up_resources:
956 rproc_resource_cleanup(rproc); 952 rproc_resource_cleanup(rproc);
957clean_up: 953clean_up:
958 kfree(rproc->cached_table); 954 kfree(rproc->table_ptr);
959 rproc->cached_table = NULL;
960 rproc->table_ptr = NULL; 955 rproc->table_ptr = NULL;
961 956
962 rproc_disable_iommu(rproc); 957 rproc_disable_iommu(rproc);
@@ -1206,8 +1201,7 @@ void rproc_shutdown(struct rproc *rproc)
1206 rproc_disable_iommu(rproc); 1201 rproc_disable_iommu(rproc);
1207 1202
1208 /* Free the copy of the resource table */ 1203 /* Free the copy of the resource table */
1209 kfree(rproc->cached_table); 1204 kfree(rproc->table_ptr);
1210 rproc->cached_table = NULL;
1211 rproc->table_ptr = NULL; 1205 rproc->table_ptr = NULL;
1212 1206
1213 /* if in crash state, unlock crash handler */ 1207 /* if in crash state, unlock crash handler */
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index 8265d351c9f0..e2f3a3281d8f 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -408,8 +408,7 @@ enum rproc_crash_type {
408 * @crash_comp: completion used to sync crash handler and the rproc reload 408 * @crash_comp: completion used to sync crash handler and the rproc reload
409 * @recovery_disabled: flag that state if recovery was disabled 409 * @recovery_disabled: flag that state if recovery was disabled
410 * @max_notifyid: largest allocated notify id. 410 * @max_notifyid: largest allocated notify id.
411 * @table_ptr: pointer to the resource table in effect 411 * @table_ptr: our copy of the resource table
412 * @cached_table: copy of the resource table
413 * @has_iommu: flag to indicate if remote processor is behind an MMU 412 * @has_iommu: flag to indicate if remote processor is behind an MMU
414 */ 413 */
415struct rproc { 414struct rproc {
@@ -441,7 +440,6 @@ struct rproc {
441 bool recovery_disabled; 440 bool recovery_disabled;
442 int max_notifyid; 441 int max_notifyid;
443 struct resource_table *table_ptr; 442 struct resource_table *table_ptr;
444 struct resource_table *cached_table;
445 bool has_iommu; 443 bool has_iommu;
446 bool auto_boot; 444 bool auto_boot;
447}; 445};