diff options
author | Bjorn Andersson <bjorn.andersson@linaro.org> | 2016-08-11 17:52:52 -0400 |
---|---|---|
committer | Bjorn Andersson <bjorn.andersson@linaro.org> | 2016-08-18 02:18:51 -0400 |
commit | d81fb32f3da6c46863c9b736f991fc595d0373bd (patch) | |
tree | 2354b566dd808c6945d13e8109941c5355bee66c | |
parent | b35d7afc3ba9d5cf28655481aef1dd6a01c6421d (diff) |
remoteproc: Move vdev handling to boot/shutdown
The newly introduced "always-on" flag allows us to stop giving the vdevs
special treatment. The ordering of resource allocation and life cycle of
the remote processor is kept intact.
This allows us to mark a remote processor with vdevs to not boot unless
explicitly requested to do so by a client driver.
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.c | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index a6a8eba9da8c..a83429ccf862 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c | |||
@@ -752,6 +752,7 @@ static int rproc_handle_resources(struct rproc *rproc, int len, | |||
752 | static void rproc_resource_cleanup(struct rproc *rproc) | 752 | static void rproc_resource_cleanup(struct rproc *rproc) |
753 | { | 753 | { |
754 | struct rproc_mem_entry *entry, *tmp; | 754 | struct rproc_mem_entry *entry, *tmp; |
755 | struct rproc_vdev *rvdev, *rvtmp; | ||
755 | struct device *dev = &rproc->dev; | 756 | struct device *dev = &rproc->dev; |
756 | 757 | ||
757 | /* clean up debugfs trace entries */ | 758 | /* clean up debugfs trace entries */ |
@@ -784,6 +785,10 @@ static void rproc_resource_cleanup(struct rproc *rproc) | |||
784 | list_del(&entry->node); | 785 | list_del(&entry->node); |
785 | kfree(entry); | 786 | kfree(entry); |
786 | } | 787 | } |
788 | |||
789 | /* clean up remote vdev entries */ | ||
790 | list_for_each_entry_safe(rvdev, rvtmp, &rproc->rvdevs, node) | ||
791 | rproc_remove_virtio_dev(rvdev); | ||
787 | } | 792 | } |
788 | 793 | ||
789 | /* | 794 | /* |
@@ -834,6 +839,13 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) | |||
834 | /* reset max_notifyid */ | 839 | /* reset max_notifyid */ |
835 | rproc->max_notifyid = -1; | 840 | rproc->max_notifyid = -1; |
836 | 841 | ||
842 | /* look for virtio devices and register them */ | ||
843 | ret = rproc_handle_resources(rproc, tablesz, rproc_vdev_handler); | ||
844 | if (ret) { | ||
845 | dev_err(dev, "Failed to handle vdev resources: %d\n", ret); | ||
846 | goto clean_up; | ||
847 | } | ||
848 | |||
837 | /* handle fw resources which are required to boot rproc */ | 849 | /* handle fw resources which are required to boot rproc */ |
838 | ret = rproc_handle_resources(rproc, tablesz, rproc_loading_handlers); | 850 | ret = rproc_handle_resources(rproc, tablesz, rproc_loading_handlers); |
839 | if (ret) { | 851 | if (ret) { |
@@ -897,7 +909,7 @@ static void rproc_fw_config_virtio(const struct firmware *fw, void *context) | |||
897 | { | 909 | { |
898 | struct rproc *rproc = context; | 910 | struct rproc *rproc = context; |
899 | struct resource_table *table; | 911 | struct resource_table *table; |
900 | int ret, tablesz; | 912 | int tablesz; |
901 | 913 | ||
902 | if (rproc_fw_sanity_check(rproc, fw) < 0) | 914 | if (rproc_fw_sanity_check(rproc, fw) < 0) |
903 | goto out; | 915 | goto out; |
@@ -921,9 +933,6 @@ static void rproc_fw_config_virtio(const struct firmware *fw, void *context) | |||
921 | 933 | ||
922 | rproc->table_ptr = rproc->cached_table; | 934 | rproc->table_ptr = rproc->cached_table; |
923 | 935 | ||
924 | /* look for virtio devices and register them */ | ||
925 | ret = rproc_handle_resources(rproc, tablesz, rproc_vdev_handler); | ||
926 | |||
927 | /* if rproc is marked always-on, request it to boot */ | 936 | /* if rproc is marked always-on, request it to boot */ |
928 | if (rproc->auto_boot) | 937 | if (rproc->auto_boot) |
929 | rproc_boot_nowait(rproc); | 938 | rproc_boot_nowait(rproc); |
@@ -972,9 +981,6 @@ static int rproc_add_virtio_devices(struct rproc *rproc) | |||
972 | */ | 981 | */ |
973 | int rproc_trigger_recovery(struct rproc *rproc) | 982 | int rproc_trigger_recovery(struct rproc *rproc) |
974 | { | 983 | { |
975 | struct rproc_vdev *rvdev, *rvtmp; | ||
976 | int ret; | ||
977 | |||
978 | dev_err(&rproc->dev, "recovering %s\n", rproc->name); | 984 | dev_err(&rproc->dev, "recovering %s\n", rproc->name); |
979 | 985 | ||
980 | init_completion(&rproc->crash_comp); | 986 | init_completion(&rproc->crash_comp); |
@@ -983,26 +989,13 @@ int rproc_trigger_recovery(struct rproc *rproc) | |||
983 | /* TODO: make sure this works with rproc->power > 1 */ | 989 | /* TODO: make sure this works with rproc->power > 1 */ |
984 | rproc_shutdown(rproc); | 990 | rproc_shutdown(rproc); |
985 | 991 | ||
986 | /* clean up remote vdev entries */ | ||
987 | list_for_each_entry_safe(rvdev, rvtmp, &rproc->rvdevs, node) | ||
988 | rproc_remove_virtio_dev(rvdev); | ||
989 | |||
990 | /* wait until there is no more rproc users */ | 992 | /* wait until there is no more rproc users */ |
991 | wait_for_completion(&rproc->crash_comp); | 993 | wait_for_completion(&rproc->crash_comp); |
992 | 994 | ||
993 | /* Free the copy of the resource table */ | ||
994 | kfree(rproc->cached_table); | ||
995 | |||
996 | ret = rproc_add_virtio_devices(rproc); | ||
997 | if (ret) | ||
998 | return ret; | ||
999 | |||
1000 | /* | 995 | /* |
1001 | * boot the remote processor up again, if the async firmware loader | 996 | * boot the remote processor up again |
1002 | * didn't do so already, waiting for the async fw load to finish | ||
1003 | */ | 997 | */ |
1004 | if (!rproc->auto_boot) | 998 | rproc_boot(rproc); |
1005 | rproc_boot(rproc); | ||
1006 | 999 | ||
1007 | return 0; | 1000 | return 0; |
1008 | } | 1001 | } |