Commit b1a17513 authored by Clement Leger's avatar Clement Leger Committed by Bjorn Andersson

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: default avatarClement Leger <cleger@kalray.eu>
Signed-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
parent 16a3c637
...@@ -314,6 +314,8 @@ Here are the various resource types that are currently supported:: ...@@ -314,6 +314,8 @@ Here are the various resource types that are currently supported::
* @RSC_VDEV: declare support for a virtio device, and serve as its * @RSC_VDEV: declare support for a virtio device, and serve as its
* virtio header. * virtio header.
* @RSC_LAST: just keep this one at the end * @RSC_LAST: just keep this one at the end
* @RSC_VENDOR_START: start of the vendor specific resource types range
* @RSC_VENDOR_END: end of the vendor specific resource types range
* *
* Please note that these values are used as indices to the rproc_handle_rsc * Please note that these values are used as indices to the rproc_handle_rsc
* lookup table, so please keep them sane. Moreover, @RSC_LAST is used to * 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,11 +323,13 @@ Here are the various resource types that are currently supported::
* please update it as needed. * please update it as needed.
*/ */
enum fw_resource_type { enum fw_resource_type {
RSC_CARVEOUT = 0, RSC_CARVEOUT = 0,
RSC_DEVMEM = 1, RSC_DEVMEM = 1,
RSC_TRACE = 2, RSC_TRACE = 2,
RSC_VDEV = 3, RSC_VDEV = 3,
RSC_LAST = 4, RSC_LAST = 4,
RSC_VENDOR_START = 128,
RSC_VENDOR_END = 512,
}; };
For more details regarding a specific resource type, please see its For more details regarding a specific resource type, please see its
......
...@@ -1066,6 +1066,20 @@ static int rproc_handle_resources(struct rproc *rproc, ...@@ -1066,6 +1066,20 @@ static int rproc_handle_resources(struct rproc *rproc,
dev_dbg(dev, "rsc: type %d\n", hdr->type); dev_dbg(dev, "rsc: type %d\n", hdr->type);
if (hdr->type >= RSC_VENDOR_START &&
hdr->type <= RSC_VENDOR_END) {
ret = rproc_handle_rsc(rproc, hdr->type, rsc,
offset + sizeof(*hdr), avail);
if (ret == RSC_HANDLED)
continue;
else if (ret < 0)
break;
dev_warn(dev, "unsupported vendor resource %d\n",
hdr->type);
continue;
}
if (hdr->type >= RSC_LAST) { if (hdr->type >= RSC_LAST) {
dev_warn(dev, "unsupported resource %d\n", hdr->type); dev_warn(dev, "unsupported resource %d\n", hdr->type);
continue; continue;
......
...@@ -106,6 +106,17 @@ static inline int rproc_parse_fw(struct rproc *rproc, const struct firmware *fw) ...@@ -106,6 +106,17 @@ static inline int rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)
return 0; return 0;
} }
static inline
int rproc_handle_rsc(struct rproc *rproc, u32 rsc_type, void *rsc, int offset,
int avail)
{
if (rproc->ops->handle_rsc)
return rproc->ops->handle_rsc(rproc, rsc_type, rsc, offset,
avail);
return RSC_IGNORED;
}
static inline static inline
struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc, struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc,
const struct firmware *fw) const struct firmware *fw)
......
...@@ -100,7 +100,9 @@ struct fw_rsc_hdr { ...@@ -100,7 +100,9 @@ struct fw_rsc_hdr {
* the remote processor will be writing logs. * the remote processor will be writing logs.
* @RSC_VDEV: declare support for a virtio device, and serve as its * @RSC_VDEV: declare support for a virtio device, and serve as its
* virtio header. * virtio header.
* @RSC_LAST: just keep this one at the end * @RSC_LAST: just keep this one at the end of standard resources
* @RSC_VENDOR_START: start of the vendor specific resource types range
* @RSC_VENDOR_END: end of the vendor specific resource types range
* *
* For more details regarding a specific resource type, please see its * For more details regarding a specific resource type, please see its
* dedicated structure below. * dedicated structure below.
...@@ -111,11 +113,13 @@ struct fw_rsc_hdr { ...@@ -111,11 +113,13 @@ struct fw_rsc_hdr {
* please update it as needed. * please update it as needed.
*/ */
enum fw_resource_type { enum fw_resource_type {
RSC_CARVEOUT = 0, RSC_CARVEOUT = 0,
RSC_DEVMEM = 1, RSC_DEVMEM = 1,
RSC_TRACE = 2, RSC_TRACE = 2,
RSC_VDEV = 3, RSC_VDEV = 3,
RSC_LAST = 4, RSC_LAST = 4,
RSC_VENDOR_START = 128,
RSC_VENDOR_END = 512,
}; };
#define FW_RSC_ADDR_ANY (-1) #define FW_RSC_ADDR_ANY (-1)
...@@ -339,6 +343,16 @@ struct rproc_mem_entry { ...@@ -339,6 +343,16 @@ struct rproc_mem_entry {
struct firmware; struct firmware;
/**
* enum rsc_handling_status - return status of rproc_ops handle_rsc hook
* @RSC_HANDLED: resource was handled
* @RSC_IGNORED: resource was ignored
*/
enum rsc_handling_status {
RSC_HANDLED = 0,
RSC_IGNORED = 1,
};
/** /**
* struct rproc_ops - platform-specific device handlers * struct rproc_ops - platform-specific device handlers
* @start: power on the device and boot it * @start: power on the device and boot it
...@@ -346,6 +360,10 @@ struct firmware; ...@@ -346,6 +360,10 @@ struct firmware;
* @kick: kick a virtqueue (virtqueue id given as a parameter) * @kick: kick a virtqueue (virtqueue id given as a parameter)
* @da_to_va: optional platform hook to perform address translations * @da_to_va: optional platform hook to perform address translations
* @parse_fw: parse firmware to extract information (e.g. resource table) * @parse_fw: parse firmware to extract information (e.g. resource table)
* @handle_rsc: optional platform hook to handle vendor resources. Should return
* RSC_HANDLED if resource was handled, RSC_IGNORED if not handled and a
* negative value on error
* @load_rsc_table: load resource table from firmware image
* @find_loaded_rsc_table: find the loaded resouce table * @find_loaded_rsc_table: find the loaded resouce table
* @load: load firmware to memory, where the remote processor * @load: load firmware to memory, where the remote processor
* expects to find it * expects to find it
...@@ -358,6 +376,8 @@ struct rproc_ops { ...@@ -358,6 +376,8 @@ struct rproc_ops {
void (*kick)(struct rproc *rproc, int vqid); void (*kick)(struct rproc *rproc, int vqid);
void * (*da_to_va)(struct rproc *rproc, u64 da, int len); void * (*da_to_va)(struct rproc *rproc, u64 da, int len);
int (*parse_fw)(struct rproc *rproc, const struct firmware *fw); int (*parse_fw)(struct rproc *rproc, const struct firmware *fw);
int (*handle_rsc)(struct rproc *rproc, u32 rsc_type, void *rsc,
int offset, int avail);
struct resource_table *(*find_loaded_rsc_table)( struct resource_table *(*find_loaded_rsc_table)(
struct rproc *rproc, const struct firmware *fw); struct rproc *rproc, const struct firmware *fw);
int (*load)(struct rproc *rproc, const struct firmware *fw); int (*load)(struct rproc *rproc, const struct firmware *fw);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment