aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjorn Andersson <bjorn.andersson@linaro.org>2016-08-11 17:52:53 -0400
committerBjorn Andersson <bjorn.andersson@linaro.org>2016-08-18 02:20:51 -0400
commit988d204cdaf604c59316dadb98eba2da2188b762 (patch)
treed18ed8daf7dfaaa4f03b64631ab32443a9328f15
parentd81fb32f3da6c46863c9b736f991fc595d0373bd (diff)
remoteproc: Move handling of cached table to boot/shutdown
As we moved the vdev handling to the main boot/shutdown code path we can further simplify the resource table handling by moving the parsing spet to boot as well. The lifespan of the resource table is changed to live from rproc_boot() to rproc_shutdown(). Cc: Lee Jones <lee.jones@linaro.org> Cc: Loic Pallardy <loic.pallardy@st.com> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
-rw-r--r--drivers/remoteproc/remoteproc_core.c55
-rw-r--r--include/linux/remoteproc.h2
2 files changed, 18 insertions, 39 deletions
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index a83429ccf862..e2c569151fe7 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -801,9 +801,6 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
801 struct resource_table *table, *loaded_table; 801 struct resource_table *table, *loaded_table;
802 int ret, tablesz; 802 int ret, tablesz;
803 803
804 if (!rproc->table_ptr)
805 return -ENOMEM;
806
807 ret = rproc_fw_sanity_check(rproc, fw); 804 ret = rproc_fw_sanity_check(rproc, fw);
808 if (ret) 805 if (ret)
809 return ret; 806 return ret;
@@ -830,11 +827,17 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
830 goto clean_up; 827 goto clean_up;
831 } 828 }
832 829
833 /* Verify that resource table in loaded fw is unchanged */ 830 /*
834 if (rproc->table_csum != crc32(0, table, tablesz)) { 831 * Create a copy of the resource table. When a virtio device starts
835 dev_err(dev, "resource checksum failed, fw changed?\n"); 832 * and calls vring_new_virtqueue() the address of the allocated vring
833 * will be stored in the cached_table. Before the device is started,
834 * cached_table will be copied into device memory.
835 */
836 rproc->cached_table = kmemdup(table, tablesz, GFP_KERNEL);
837 if (!rproc->cached_table)
836 goto clean_up; 838 goto clean_up;
837 } 839
840 rproc->table_ptr = rproc->cached_table;
838 841
839 /* reset max_notifyid */ 842 /* reset max_notifyid */
840 rproc->max_notifyid = -1; 843 rproc->max_notifyid = -1;
@@ -892,6 +895,10 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
892 return 0; 895 return 0;
893 896
894clean_up: 897clean_up:
898 kfree(rproc->cached_table);
899 rproc->cached_table = NULL;
900 rproc->table_ptr = NULL;
901
895 rproc_resource_cleanup(rproc); 902 rproc_resource_cleanup(rproc);
896 rproc_disable_iommu(rproc); 903 rproc_disable_iommu(rproc);
897 return ret; 904 return ret;
@@ -908,36 +915,11 @@ clean_up:
908static void rproc_fw_config_virtio(const struct firmware *fw, void *context) 915static void rproc_fw_config_virtio(const struct firmware *fw, void *context)
909{ 916{
910 struct rproc *rproc = context; 917 struct rproc *rproc = context;
911 struct resource_table *table;
912 int tablesz;
913
914 if (rproc_fw_sanity_check(rproc, fw) < 0)
915 goto out;
916
917 /* look for the resource table */
918 table = rproc_find_rsc_table(rproc, fw, &tablesz);
919 if (!table)
920 goto out;
921
922 rproc->table_csum = crc32(0, table, tablesz);
923
924 /*
925 * Create a copy of the resource table. When a virtio device starts
926 * and calls vring_new_virtqueue() the address of the allocated vring
927 * will be stored in the cached_table. Before the device is started,
928 * cached_table will be copied into device memory.
929 */
930 rproc->cached_table = kmemdup(table, tablesz, GFP_KERNEL);
931 if (!rproc->cached_table)
932 goto out;
933
934 rproc->table_ptr = rproc->cached_table;
935 918
936 /* if rproc is marked always-on, request it to boot */ 919 /* if rproc is marked always-on, request it to boot */
937 if (rproc->auto_boot) 920 if (rproc->auto_boot)
938 rproc_boot_nowait(rproc); 921 rproc_boot_nowait(rproc);
939 922
940out:
941 release_firmware(fw); 923 release_firmware(fw);
942 /* allow rproc_del() contexts, if any, to proceed */ 924 /* allow rproc_del() contexts, if any, to proceed */
943 complete_all(&rproc->firmware_loading_complete); 925 complete_all(&rproc->firmware_loading_complete);
@@ -1177,8 +1159,10 @@ void rproc_shutdown(struct rproc *rproc)
1177 1159
1178 rproc_disable_iommu(rproc); 1160 rproc_disable_iommu(rproc);
1179 1161
1180 /* Give the next start a clean resource table */ 1162 /* Free the copy of the resource table */
1181 rproc->table_ptr = rproc->cached_table; 1163 kfree(rproc->cached_table);
1164 rproc->cached_table = NULL;
1165 rproc->table_ptr = NULL;
1182 1166
1183 /* if in crash state, unlock crash handler */ 1167 /* if in crash state, unlock crash handler */
1184 if (rproc->state == RPROC_CRASHED) 1168 if (rproc->state == RPROC_CRASHED)
@@ -1466,9 +1450,6 @@ int rproc_del(struct rproc *rproc)
1466 list_for_each_entry_safe(rvdev, tmp, &rproc->rvdevs, node) 1450 list_for_each_entry_safe(rvdev, tmp, &rproc->rvdevs, node)
1467 rproc_remove_virtio_dev(rvdev); 1451 rproc_remove_virtio_dev(rvdev);
1468 1452
1469 /* Free the copy of the resource table */
1470 kfree(rproc->cached_table);
1471
1472 /* the rproc is downref'ed as soon as it's removed from the klist */ 1453 /* the rproc is downref'ed as soon as it's removed from the klist */
1473 mutex_lock(&rproc_list_mutex); 1454 mutex_lock(&rproc_list_mutex);
1474 list_del(&rproc->node); 1455 list_del(&rproc->node);
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index 4783c8c4645a..d488f9e1e08c 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -409,7 +409,6 @@ enum rproc_crash_type {
409 * @max_notifyid: largest allocated notify id. 409 * @max_notifyid: largest allocated notify id.
410 * @table_ptr: pointer to the resource table in effect 410 * @table_ptr: pointer to the resource table in effect
411 * @cached_table: copy of the resource table 411 * @cached_table: copy of the resource table
412 * @table_csum: checksum 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 int max_notifyid; 440 int max_notifyid;
442 struct resource_table *table_ptr; 441 struct resource_table *table_ptr;
443 struct resource_table *cached_table; 442 struct resource_table *cached_table;
444 u32 table_csum;
445 bool has_iommu; 443 bool has_iommu;
446 bool auto_boot; 444 bool auto_boot;
447}; 445};