summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClement Leger <cleger@kalray.eu>2019-06-17 08:57:30 -0400
committerBjorn Andersson <bjorn.andersson@linaro.org>2019-06-29 15:02:17 -0400
commitb1a17513a2d60f9e933016bed04d0eeb8651a915 (patch)
tree3cdda74ef3de7317259b3651d03a6a542a9bee38
parent16a3c637f0742ec41bb69978e0d7b606a22a9c54 (diff)
remoteproc: add vendor resources handling
In order to allow rproc backend to handle vendor resources such as in OpenAMP, add a handle_rsc hook. This hook allow the rproc backends to handle vendor resources as they like. The hook will be called only for vendor resources and should return RSC_HANDLED on successful resource handling, RSC_IGNORED if resource was ignored, or a negative value on error. Signed-off-by: Clement Leger <cleger@kalray.eu> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
-rw-r--r--Documentation/remoteproc.txt14
-rw-r--r--drivers/remoteproc/remoteproc_core.c14
-rw-r--r--drivers/remoteproc/remoteproc_internal.h11
-rw-r--r--include/linux/remoteproc.h32
4 files changed, 60 insertions, 11 deletions
diff --git a/Documentation/remoteproc.txt b/Documentation/remoteproc.txt
index 77fb03acdbb4..03c3d2e568b0 100644
--- a/Documentation/remoteproc.txt
+++ b/Documentation/remoteproc.txt
@@ -314,6 +314,8 @@ Here are the various resource types that are currently supported::
314 * @RSC_VDEV: declare support for a virtio device, and serve as its 314 * @RSC_VDEV: declare support for a virtio device, and serve as its
315 * virtio header. 315 * virtio header.
316 * @RSC_LAST: just keep this one at the end 316 * @RSC_LAST: just keep this one at the end
317 * @RSC_VENDOR_START: start of the vendor specific resource types range
318 * @RSC_VENDOR_END: end of the vendor specific resource types range
317 * 319 *
318 * Please note that these values are used as indices to the rproc_handle_rsc 320 * Please note that these values are used as indices to the rproc_handle_rsc
319 * lookup table, so please keep them sane. Moreover, @RSC_LAST is used to 321 * lookup table, so please keep them sane. Moreover, @RSC_LAST is used to
@@ -321,11 +323,13 @@ Here are the various resource types that are currently supported::
321 * please update it as needed. 323 * please update it as needed.
322 */ 324 */
323 enum fw_resource_type { 325 enum fw_resource_type {
324 RSC_CARVEOUT = 0, 326 RSC_CARVEOUT = 0,
325 RSC_DEVMEM = 1, 327 RSC_DEVMEM = 1,
326 RSC_TRACE = 2, 328 RSC_TRACE = 2,
327 RSC_VDEV = 3, 329 RSC_VDEV = 3,
328 RSC_LAST = 4, 330 RSC_LAST = 4,
331 RSC_VENDOR_START = 128,
332 RSC_VENDOR_END = 512,
329 }; 333 };
330 334
331For more details regarding a specific resource type, please see its 335For more details regarding a specific resource type, please see its
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 48feebd6d0a2..263e9c9614a8 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -1066,6 +1066,20 @@ static int rproc_handle_resources(struct rproc *rproc,
1066 1066
1067 dev_dbg(dev, "rsc: type %d\n", hdr->type); 1067 dev_dbg(dev, "rsc: type %d\n", hdr->type);
1068 1068
1069 if (hdr->type >= RSC_VENDOR_START &&
1070 hdr->type <= RSC_VENDOR_END) {
1071 ret = rproc_handle_rsc(rproc, hdr->type, rsc,
1072 offset + sizeof(*hdr), avail);
1073 if (ret == RSC_HANDLED)
1074 continue;
1075 else if (ret < 0)
1076 break;
1077
1078 dev_warn(dev, "unsupported vendor resource %d\n",
1079 hdr->type);
1080 continue;
1081 }
1082
1069 if (hdr->type >= RSC_LAST) { 1083 if (hdr->type >= RSC_LAST) {
1070 dev_warn(dev, "unsupported resource %d\n", hdr->type); 1084 dev_warn(dev, "unsupported resource %d\n", hdr->type);
1071 continue; 1085 continue;
diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h
index 45ff76a06c72..4c77bdd517b9 100644
--- a/drivers/remoteproc/remoteproc_internal.h
+++ b/drivers/remoteproc/remoteproc_internal.h
@@ -107,6 +107,17 @@ static inline int rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)
107} 107}
108 108
109static inline 109static inline
110int rproc_handle_rsc(struct rproc *rproc, u32 rsc_type, void *rsc, int offset,
111 int avail)
112{
113 if (rproc->ops->handle_rsc)
114 return rproc->ops->handle_rsc(rproc, rsc_type, rsc, offset,
115 avail);
116
117 return RSC_IGNORED;
118}
119
120static inline
110struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc, 121struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc,
111 const struct firmware *fw) 122 const struct firmware *fw)
112{ 123{
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index 04d04709f2bd..16ad66683ad0 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -100,7 +100,9 @@ struct fw_rsc_hdr {
100 * the remote processor will be writing logs. 100 * the remote processor will be writing logs.
101 * @RSC_VDEV: declare support for a virtio device, and serve as its 101 * @RSC_VDEV: declare support for a virtio device, and serve as its
102 * virtio header. 102 * virtio header.
103 * @RSC_LAST: just keep this one at the end 103 * @RSC_LAST: just keep this one at the end of standard resources
104 * @RSC_VENDOR_START: start of the vendor specific resource types range
105 * @RSC_VENDOR_END: end of the vendor specific resource types range
104 * 106 *
105 * For more details regarding a specific resource type, please see its 107 * For more details regarding a specific resource type, please see its
106 * dedicated structure below. 108 * dedicated structure below.
@@ -111,11 +113,13 @@ struct fw_rsc_hdr {
111 * please update it as needed. 113 * please update it as needed.
112 */ 114 */
113enum fw_resource_type { 115enum fw_resource_type {
114 RSC_CARVEOUT = 0, 116 RSC_CARVEOUT = 0,
115 RSC_DEVMEM = 1, 117 RSC_DEVMEM = 1,
116 RSC_TRACE = 2, 118 RSC_TRACE = 2,
117 RSC_VDEV = 3, 119 RSC_VDEV = 3,
118 RSC_LAST = 4, 120 RSC_LAST = 4,
121 RSC_VENDOR_START = 128,
122 RSC_VENDOR_END = 512,
119}; 123};
120 124
121#define FW_RSC_ADDR_ANY (-1) 125#define FW_RSC_ADDR_ANY (-1)
@@ -340,12 +344,26 @@ struct rproc_mem_entry {
340struct firmware; 344struct firmware;
341 345
342/** 346/**
347 * enum rsc_handling_status - return status of rproc_ops handle_rsc hook
348 * @RSC_HANDLED: resource was handled
349 * @RSC_IGNORED: resource was ignored
350 */
351enum rsc_handling_status {
352 RSC_HANDLED = 0,
353 RSC_IGNORED = 1,
354};
355
356/**
343 * struct rproc_ops - platform-specific device handlers 357 * struct rproc_ops - platform-specific device handlers
344 * @start: power on the device and boot it 358 * @start: power on the device and boot it
345 * @stop: power off the device 359 * @stop: power off the device
346 * @kick: kick a virtqueue (virtqueue id given as a parameter) 360 * @kick: kick a virtqueue (virtqueue id given as a parameter)
347 * @da_to_va: optional platform hook to perform address translations 361 * @da_to_va: optional platform hook to perform address translations
348 * @parse_fw: parse firmware to extract information (e.g. resource table) 362 * @parse_fw: parse firmware to extract information (e.g. resource table)
363 * @handle_rsc: optional platform hook to handle vendor resources. Should return
364 * RSC_HANDLED if resource was handled, RSC_IGNORED if not handled and a
365 * negative value on error
366 * @load_rsc_table: load resource table from firmware image
349 * @find_loaded_rsc_table: find the loaded resouce table 367 * @find_loaded_rsc_table: find the loaded resouce table
350 * @load: load firmware to memory, where the remote processor 368 * @load: load firmware to memory, where the remote processor
351 * expects to find it 369 * expects to find it
@@ -358,6 +376,8 @@ struct rproc_ops {
358 void (*kick)(struct rproc *rproc, int vqid); 376 void (*kick)(struct rproc *rproc, int vqid);
359 void * (*da_to_va)(struct rproc *rproc, u64 da, int len); 377 void * (*da_to_va)(struct rproc *rproc, u64 da, int len);
360 int (*parse_fw)(struct rproc *rproc, const struct firmware *fw); 378 int (*parse_fw)(struct rproc *rproc, const struct firmware *fw);
379 int (*handle_rsc)(struct rproc *rproc, u32 rsc_type, void *rsc,
380 int offset, int avail);
361 struct resource_table *(*find_loaded_rsc_table)( 381 struct resource_table *(*find_loaded_rsc_table)(
362 struct rproc *rproc, const struct firmware *fw); 382 struct rproc *rproc, const struct firmware *fw);
363 int (*load)(struct rproc *rproc, const struct firmware *fw); 383 int (*load)(struct rproc *rproc, const struct firmware *fw);