diff options
author | Bjorn Andersson <bjorn.andersson@linaro.org> | 2018-01-05 18:57:59 -0500 |
---|---|---|
committer | Bjorn Andersson <bjorn.andersson@linaro.org> | 2018-01-15 12:29:29 -0500 |
commit | a4b24c7560ba64c3c54d8f90ee033a6f0565f8d3 (patch) | |
tree | 7e702e463226973154bdd126f8d61f964865bd3b | |
parent | b26210cda63564a7478486faaea713f6ea965633 (diff) |
remoteproc: Cache resource table size
We don't re-read the resource table during a recovery, so it is possible
in the recovery path that the resource table has a different size than
cached_table. Store the original size of cached_table to avoid these
getting out of sync.
Reviewed-By: Loic Pallardy <loic.pallardy@st.com>
Tested-By: Loic Pallardy <loic.pallardy@st.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
-rw-r--r-- | drivers/remoteproc/remoteproc_core.c | 20 | ||||
-rw-r--r-- | include/linux/remoteproc.h | 2 |
2 files changed, 9 insertions, 13 deletions
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 758fad3131a3..208ccf709cad 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c | |||
@@ -732,7 +732,7 @@ static rproc_handle_resource_t rproc_loading_handlers[RSC_LAST] = { | |||
732 | }; | 732 | }; |
733 | 733 | ||
734 | /* handle firmware resource entries before booting the remote processor */ | 734 | /* handle firmware resource entries before booting the remote processor */ |
735 | static int rproc_handle_resources(struct rproc *rproc, int len, | 735 | static int rproc_handle_resources(struct rproc *rproc, |
736 | rproc_handle_resource_t handlers[RSC_LAST]) | 736 | rproc_handle_resource_t handlers[RSC_LAST]) |
737 | { | 737 | { |
738 | struct device *dev = &rproc->dev; | 738 | struct device *dev = &rproc->dev; |
@@ -742,7 +742,7 @@ static int rproc_handle_resources(struct rproc *rproc, int len, | |||
742 | for (i = 0; i < rproc->table_ptr->num; i++) { | 742 | for (i = 0; i < rproc->table_ptr->num; i++) { |
743 | int offset = rproc->table_ptr->offset[i]; | 743 | int offset = rproc->table_ptr->offset[i]; |
744 | struct fw_rsc_hdr *hdr = (void *)rproc->table_ptr + offset; | 744 | struct fw_rsc_hdr *hdr = (void *)rproc->table_ptr + offset; |
745 | int avail = len - offset - sizeof(*hdr); | 745 | int avail = rproc->table_sz - offset - sizeof(*hdr); |
746 | void *rsc = (void *)hdr + sizeof(*hdr); | 746 | void *rsc = (void *)hdr + sizeof(*hdr); |
747 | 747 | ||
748 | /* make sure table isn't truncated */ | 748 | /* make sure table isn't truncated */ |
@@ -849,16 +849,9 @@ static void rproc_resource_cleanup(struct rproc *rproc) | |||
849 | 849 | ||
850 | static int rproc_start(struct rproc *rproc, const struct firmware *fw) | 850 | static int rproc_start(struct rproc *rproc, const struct firmware *fw) |
851 | { | 851 | { |
852 | struct resource_table *table, *loaded_table; | 852 | struct resource_table *loaded_table; |
853 | struct device *dev = &rproc->dev; | 853 | struct device *dev = &rproc->dev; |
854 | int ret, tablesz; | 854 | int ret; |
855 | |||
856 | /* look for the resource table */ | ||
857 | table = rproc_find_rsc_table(rproc, fw, &tablesz); | ||
858 | if (!table) { | ||
859 | dev_err(dev, "Resource table look up failed\n"); | ||
860 | return -EINVAL; | ||
861 | } | ||
862 | 855 | ||
863 | /* load the ELF segments to memory */ | 856 | /* load the ELF segments to memory */ |
864 | ret = rproc_load_segments(rproc, fw); | 857 | ret = rproc_load_segments(rproc, fw); |
@@ -877,7 +870,7 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw) | |||
877 | */ | 870 | */ |
878 | loaded_table = rproc_find_loaded_rsc_table(rproc, fw); | 871 | loaded_table = rproc_find_loaded_rsc_table(rproc, fw); |
879 | if (loaded_table) { | 872 | if (loaded_table) { |
880 | memcpy(loaded_table, rproc->cached_table, tablesz); | 873 | memcpy(loaded_table, rproc->cached_table, rproc->table_sz); |
881 | rproc->table_ptr = loaded_table; | 874 | rproc->table_ptr = loaded_table; |
882 | } | 875 | } |
883 | 876 | ||
@@ -951,12 +944,13 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) | |||
951 | goto clean_up; | 944 | goto clean_up; |
952 | 945 | ||
953 | rproc->table_ptr = rproc->cached_table; | 946 | rproc->table_ptr = rproc->cached_table; |
947 | rproc->table_sz = tablesz; | ||
954 | 948 | ||
955 | /* reset max_notifyid */ | 949 | /* reset max_notifyid */ |
956 | rproc->max_notifyid = -1; | 950 | rproc->max_notifyid = -1; |
957 | 951 | ||
958 | /* handle fw resources which are required to boot rproc */ | 952 | /* handle fw resources which are required to boot rproc */ |
959 | ret = rproc_handle_resources(rproc, tablesz, rproc_loading_handlers); | 953 | ret = rproc_handle_resources(rproc, rproc_loading_handlers); |
960 | if (ret) { | 954 | if (ret) { |
961 | dev_err(dev, "Failed to process resources: %d\n", ret); | 955 | dev_err(dev, "Failed to process resources: %d\n", ret); |
962 | goto clean_up_resources; | 956 | goto clean_up_resources; |
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 6f1d8e025c81..6fdc62e29d6f 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h | |||
@@ -410,6 +410,7 @@ enum rproc_crash_type { | |||
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: pointer to the resource table in effect |
412 | * @cached_table: copy of the resource table | 412 | * @cached_table: copy of the resource table |
413 | * @table_sz: size of @cached_table | ||
413 | * @has_iommu: flag to indicate if remote processor is behind an MMU | 414 | * @has_iommu: flag to indicate if remote processor is behind an MMU |
414 | */ | 415 | */ |
415 | struct rproc { | 416 | struct rproc { |
@@ -440,6 +441,7 @@ struct rproc { | |||
440 | int max_notifyid; | 441 | int max_notifyid; |
441 | struct resource_table *table_ptr; | 442 | struct resource_table *table_ptr; |
442 | struct resource_table *cached_table; | 443 | struct resource_table *cached_table; |
444 | size_t table_sz; | ||
443 | bool has_iommu; | 445 | bool has_iommu; |
444 | bool auto_boot; | 446 | bool auto_boot; |
445 | }; | 447 | }; |