aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjorn Andersson <bjorn.andersson@linaro.org>2016-12-30 06:21:38 -0500
committerBjorn Andersson <bjorn.andersson@linaro.org>2016-12-30 06:26:31 -0500
commita0c10687ec9506b5e14fe3dd47832a77f2f2500c (patch)
treea5e95d4bc6a67db98db71b5e288f6adc2deacc8f
parentc81c0e0710f031cb09eb7cbf0e75e6754d1d8346 (diff)
Revert "remoteproc: Merge table_ptr and cached_table pointers"
Following any fw_rsc_vdev entries in the resource table are two variable length arrays, the first one reference vring resources and the second one is the virtio config space. The virtio config space is used by virtio to communicate status and configuration changes and must as such be shared with the remote. The reverted commit incorrectly made any changes to the virtio config space only affect the local copy, in an attempt to allowing memory protection of the shared resource table. This reverts commit cda8529346935fc86f476999ac4fbfe4e17abf11. 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, 19 insertions, 11 deletions
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index feb24c43d4c7..90b05c72186c 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -886,13 +886,15 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
886 /* 886 /*
887 * Create a copy of the resource table. When a virtio device starts 887 * Create a copy of the resource table. When a virtio device starts
888 * and calls vring_new_virtqueue() the address of the allocated vring 888 * and calls vring_new_virtqueue() the address of the allocated vring
889 * will be stored in the table_ptr. Before the device is started, 889 * will be stored in the cached_table. Before the device is started,
890 * table_ptr will be copied into device memory. 890 * cached_table will be copied into device memory.
891 */ 891 */
892 rproc->table_ptr = kmemdup(table, tablesz, GFP_KERNEL); 892 rproc->cached_table = kmemdup(table, tablesz, GFP_KERNEL);
893 if (!rproc->table_ptr) 893 if (!rproc->cached_table)
894 goto clean_up; 894 goto clean_up;
895 895
896 rproc->table_ptr = rproc->cached_table;
897
896 /* reset max_notifyid */ 898 /* reset max_notifyid */
897 rproc->max_notifyid = -1; 899 rproc->max_notifyid = -1;
898 900
@@ -911,16 +913,18 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
911 } 913 }
912 914
913 /* 915 /*
914 * The starting device has been given the rproc->table_ptr as the 916 * The starting device has been given the rproc->cached_table as the
915 * resource table. The address of the vring along with the other 917 * resource table. The address of the vring along with the other
916 * allocated resources (carveouts etc) is stored in table_ptr. 918 * allocated resources (carveouts etc) is stored in cached_table.
917 * In order to pass this information to the remote device we must copy 919 * In order to pass this information to the remote device we must copy
918 * this information to device memory. We also update the table_ptr so 920 * this information to device memory. We also update the table_ptr so
919 * that any subsequent changes will be applied to the loaded version. 921 * that any subsequent changes will be applied to the loaded version.
920 */ 922 */
921 loaded_table = rproc_find_loaded_rsc_table(rproc, fw); 923 loaded_table = rproc_find_loaded_rsc_table(rproc, fw);
922 if (loaded_table) 924 if (loaded_table) {
923 memcpy(loaded_table, rproc->table_ptr, tablesz); 925 memcpy(loaded_table, rproc->cached_table, tablesz);
926 rproc->table_ptr = loaded_table;
927 }
924 928
925 /* power up the remote processor */ 929 /* power up the remote processor */
926 ret = rproc->ops->start(rproc); 930 ret = rproc->ops->start(rproc);
@@ -948,7 +952,8 @@ stop_rproc:
948clean_up_resources: 952clean_up_resources:
949 rproc_resource_cleanup(rproc); 953 rproc_resource_cleanup(rproc);
950clean_up: 954clean_up:
951 kfree(rproc->table_ptr); 955 kfree(rproc->cached_table);
956 rproc->cached_table = NULL;
952 rproc->table_ptr = NULL; 957 rproc->table_ptr = NULL;
953 958
954 rproc_disable_iommu(rproc); 959 rproc_disable_iommu(rproc);
@@ -1182,7 +1187,8 @@ void rproc_shutdown(struct rproc *rproc)
1182 rproc_disable_iommu(rproc); 1187 rproc_disable_iommu(rproc);
1183 1188
1184 /* Free the copy of the resource table */ 1189 /* Free the copy of the resource table */
1185 kfree(rproc->table_ptr); 1190 kfree(rproc->cached_table);
1191 rproc->cached_table = NULL;
1186 rproc->table_ptr = NULL; 1192 rproc->table_ptr = NULL;
1187 1193
1188 /* if in crash state, unlock crash handler */ 1194 /* if in crash state, unlock crash handler */
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index e2f3a3281d8f..8265d351c9f0 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -408,7 +408,8 @@ 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: our copy of the resource table 411 * @table_ptr: pointer to the resource table in effect
412 * @cached_table: copy of the resource table
412 * @has_iommu: flag to indicate if remote processor is behind an MMU 413 * @has_iommu: flag to indicate if remote processor is behind an MMU
413 */ 414 */
414struct rproc { 415struct rproc {
@@ -440,6 +441,7 @@ struct rproc {
440 bool recovery_disabled; 441 bool recovery_disabled;
441 int max_notifyid; 442 int max_notifyid;
442 struct resource_table *table_ptr; 443 struct resource_table *table_ptr;
444 struct resource_table *cached_table;
443 bool has_iommu; 445 bool has_iommu;
444 bool auto_boot; 446 bool auto_boot;
445}; 447};