aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-05-18 20:22:19 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-18 20:22:19 -0400
commit97f00905ec98472050d65c46629237b299f29035 (patch)
tree0187931abfe9d5088dfabe0c0de8129fa4055a75
parent676d9735cd010fc439566e2b6e9b6adc3e1179ef (diff)
parentb3d39032d7b33029373fbce6459aff6ac316e130 (diff)
Merge tag 'rproc-v4.7' of git://github.com/andersson/remoteproc
Pull remoteproc updates from Bjorn Andersson: "Introduce a synchronization point between the async firmware loading and clients requesting the remote processor to boot, as well as support for remote processors that are not interested in the resource table information" * tag 'rproc-v4.7' of git://github.com/andersson/remoteproc: remoteproc: Add additional crash reasons remoteproc: core: Make the loaded resource table optional remoteproc: core: Task sync during rproc_fw_boot()
-rw-r--r--drivers/remoteproc/remoteproc_core.c39
-rw-r--r--drivers/remoteproc/remoteproc_internal.h1
-rw-r--r--drivers/remoteproc/remoteproc_virtio.c2
-rw-r--r--include/linux/remoteproc.h4
4 files changed, 37 insertions, 9 deletions
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 3d7d58a109d8..db3958b3f094 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -57,6 +57,8 @@ static DEFINE_IDA(rproc_dev_index);
57 57
58static const char * const rproc_crash_names[] = { 58static const char * const rproc_crash_names[] = {
59 [RPROC_MMUFAULT] = "mmufault", 59 [RPROC_MMUFAULT] = "mmufault",
60 [RPROC_WATCHDOG] = "watchdog",
61 [RPROC_FATAL_ERROR] = "fatal error",
60}; 62};
61 63
62/* translate rproc_crash_type to string */ 64/* translate rproc_crash_type to string */
@@ -856,12 +858,8 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
856 * copy this information to device memory. 858 * copy this information to device memory.
857 */ 859 */
858 loaded_table = rproc_find_loaded_rsc_table(rproc, fw); 860 loaded_table = rproc_find_loaded_rsc_table(rproc, fw);
859 if (!loaded_table) { 861 if (loaded_table)
860 ret = -EINVAL; 862 memcpy(loaded_table, rproc->cached_table, tablesz);
861 goto clean_up;
862 }
863
864 memcpy(loaded_table, rproc->cached_table, tablesz);
865 863
866 /* power up the remote processor */ 864 /* power up the remote processor */
867 ret = rproc->ops->start(rproc); 865 ret = rproc->ops->start(rproc);
@@ -1030,8 +1028,9 @@ static void rproc_crash_handler_work(struct work_struct *work)
1030} 1028}
1031 1029
1032/** 1030/**
1033 * rproc_boot() - boot a remote processor 1031 * __rproc_boot() - boot a remote processor
1034 * @rproc: handle of a remote processor 1032 * @rproc: handle of a remote processor
1033 * @wait: wait for rproc registration completion
1035 * 1034 *
1036 * Boot a remote processor (i.e. load its firmware, power it on, ...). 1035 * Boot a remote processor (i.e. load its firmware, power it on, ...).
1037 * 1036 *
@@ -1040,7 +1039,7 @@ static void rproc_crash_handler_work(struct work_struct *work)
1040 * 1039 *
1041 * Returns 0 on success, and an appropriate error value otherwise. 1040 * Returns 0 on success, and an appropriate error value otherwise.
1042 */ 1041 */
1043int rproc_boot(struct rproc *rproc) 1042static int __rproc_boot(struct rproc *rproc, bool wait)
1044{ 1043{
1045 const struct firmware *firmware_p; 1044 const struct firmware *firmware_p;
1046 struct device *dev; 1045 struct device *dev;
@@ -1088,6 +1087,10 @@ int rproc_boot(struct rproc *rproc)
1088 goto downref_rproc; 1087 goto downref_rproc;
1089 } 1088 }
1090 1089
1090 /* if rproc virtio is not yet configured, wait */
1091 if (wait)
1092 wait_for_completion(&rproc->firmware_loading_complete);
1093
1091 ret = rproc_fw_boot(rproc, firmware_p); 1094 ret = rproc_fw_boot(rproc, firmware_p);
1092 1095
1093 release_firmware(firmware_p); 1096 release_firmware(firmware_p);
@@ -1101,9 +1104,29 @@ unlock_mutex:
1101 mutex_unlock(&rproc->lock); 1104 mutex_unlock(&rproc->lock);
1102 return ret; 1105 return ret;
1103} 1106}
1107
1108/**
1109 * rproc_boot() - boot a remote processor
1110 * @rproc: handle of a remote processor
1111 */
1112int rproc_boot(struct rproc *rproc)
1113{
1114 return __rproc_boot(rproc, true);
1115}
1104EXPORT_SYMBOL(rproc_boot); 1116EXPORT_SYMBOL(rproc_boot);
1105 1117
1106/** 1118/**
1119 * rproc_boot_nowait() - boot a remote processor
1120 * @rproc: handle of a remote processor
1121 *
1122 * Same as rproc_boot() but don't wait for rproc registration completion
1123 */
1124int rproc_boot_nowait(struct rproc *rproc)
1125{
1126 return __rproc_boot(rproc, false);
1127}
1128
1129/**
1107 * rproc_shutdown() - power off the remote processor 1130 * rproc_shutdown() - power off the remote processor
1108 * @rproc: the remote processor 1131 * @rproc: the remote processor
1109 * 1132 *
diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h
index 8041b95cb058..57e1de59bec8 100644
--- a/drivers/remoteproc/remoteproc_internal.h
+++ b/drivers/remoteproc/remoteproc_internal.h
@@ -48,6 +48,7 @@ struct rproc_fw_ops {
48/* from remoteproc_core.c */ 48/* from remoteproc_core.c */
49void rproc_release(struct kref *kref); 49void rproc_release(struct kref *kref);
50irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id); 50irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id);
51int rproc_boot_nowait(struct rproc *rproc);
51 52
52/* from remoteproc_virtio.c */ 53/* from remoteproc_virtio.c */
53int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id); 54int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id);
diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c
index e44872fb9e5e..cc91556313e1 100644
--- a/drivers/remoteproc/remoteproc_virtio.c
+++ b/drivers/remoteproc/remoteproc_virtio.c
@@ -161,7 +161,7 @@ static int rproc_virtio_find_vqs(struct virtio_device *vdev, unsigned nvqs,
161 } 161 }
162 162
163 /* now that the vqs are all set, boot the remote processor */ 163 /* now that the vqs are all set, boot the remote processor */
164 ret = rproc_boot(rproc); 164 ret = rproc_boot_nowait(rproc);
165 if (ret) { 165 if (ret) {
166 dev_err(&rproc->dev, "rproc_boot() failed %d\n", ret); 166 dev_err(&rproc->dev, "rproc_boot() failed %d\n", ret);
167 goto error; 167 goto error;
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index 9c4e1384f636..1c457a8dd5a6 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -365,6 +365,8 @@ enum rproc_state {
365/** 365/**
366 * enum rproc_crash_type - remote processor crash types 366 * enum rproc_crash_type - remote processor crash types
367 * @RPROC_MMUFAULT: iommu fault 367 * @RPROC_MMUFAULT: iommu fault
368 * @RPROC_WATCHDOG: watchdog bite
369 * @RPROC_FATAL_ERROR fatal error
368 * 370 *
369 * Each element of the enum is used as an array index. So that, the value of 371 * Each element of the enum is used as an array index. So that, the value of
370 * the elements should be always something sane. 372 * the elements should be always something sane.
@@ -373,6 +375,8 @@ enum rproc_state {
373 */ 375 */
374enum rproc_crash_type { 376enum rproc_crash_type {
375 RPROC_MMUFAULT, 377 RPROC_MMUFAULT,
378 RPROC_WATCHDOG,
379 RPROC_FATAL_ERROR,
376}; 380};
377 381
378/** 382/**