remoteproc: add per rproc resource handling
Subsystems (2)
RFC PATCH 1/1 remoteproc: add per rproc resource handling
In order to allow rproc backend to handle vendor resources, add a handle_rsc hook. This hook allow the rproc backends to handle vendor resources as they like. It also allows them to parse standard RSC_* if needed. The hook should return RSC_HANDLED on successful resource handling, RSC_IGNORED if resource was ignored, or a negative value on error.
--- drivers/remoteproc/remoteproc_core.c | 7 +++++++ drivers/remoteproc/remoteproc_internal.h | 11 +++++++++++ include/linux/remoteproc.h | 15 +++++++++++++++ 3 files changed, 33 insertions(+)
drivers/remoteproc/remoteproc_core.c +7 -0
@@ -1009,6 +1009,13 @@ static int rproc_handle_resources(struct rproc *rproc,dev_dbg (dev,"rsc: type %d\n" , hdr->type); + ret =rproc_handle_rsc (rproc, hdr->type, rsc, + offset +sizeof (*hdr), avail); +if (ret ==RSC_HANDLED ) +continue ; +else if (ret <0 ) +break ; +if (hdr->type >=RSC_LAST ) {dev_warn (dev,"unsupported resource %d\n" , hdr->type);continue ;
drivers/remoteproc/remoteproc_internal.h +11 -0
@@ -98,6 +98,17 @@ static inline int rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)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 struct resource_table *rproc_find_loaded_rsc_table (struct rproc *rproc,const struct firmware *fw)
include/linux/remoteproc.h +15 -0
@@ -339,12 +339,25 @@ struct rproc_mem_entry {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 * @start: power on the device and boot it * @stop: power off the device * @kick: kick a virtqueue (virtqueue id given as a parameter) * @da_to_va: optional platform hook to perform address translations +* @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 * @load: load firmeware to memory, where the remote processor
@@ -358,6 +371,8 @@ struct rproc_ops {void (*kick)(struct rproc *rproc,int vqid);void * (*da_to_va)(struct rproc *rproc,u64 da,int len);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 rproc *rproc,const struct firmware *fw);int (*load)(struct rproc *rproc,const struct firmware *fw);
Signature · 1 line
2.15.0.276.g89ea799
V2:
- Use vendor resources definitions from OpenAMP
- Call rproc->handle_rsc only for vendor resources
- Update remoteproc documentation
In order to allow rproc backend to handle vendor resources, 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.
--- Documentation/remoteproc.txt | 14 +++++++++----- drivers/remoteproc/remoteproc_core.c | 15 +++++++++++++++ drivers/remoteproc/remoteproc_internal.h | 11 +++++++++++ include/linux/remoteproc.h | 31 +++++++++++++++++++++++++------ 4 files changed, 60 insertions(+), 11 deletions(-)
Documentation/remoteproc.txt +9 -5
@@ -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 * virtio header. * @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 * 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:: * please update it as needed. */ enum fw_resource_type { - RSC_CARVEOUT = 0, - RSC_DEVMEM = 1, - RSC_TRACE = 2, - RSC_VDEV = 3, - RSC_LAST = 4, + RSC_CARVEOUT = 0, + RSC_DEVMEM = 1, + RSC_TRACE = 2, + RSC_VDEV = 3, + RSC_LAST = 4, + RSC_VENDOR_START = 128, + RSC_VENDOR_END = 512, }; For more details regarding a specific resource type, please see its
drivers/remoteproc/remoteproc_core.c +15 -0
@@ -1009,6 +1009,21 @@ static int rproc_handle_resources(struct rproc *rproc,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 ) {dev_warn (dev,"unsupported resource %d\n" , hdr->type);continue ;
drivers/remoteproc/remoteproc_internal.h +11 -0
@@ -98,6 +98,17 @@ static inline int rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)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 struct resource_table *rproc_find_loaded_rsc_table (struct rproc *rproc,const struct firmware *fw)
include/linux/remoteproc.h +25 -6
@@ -100,7 +100,9 @@ struct fw_rsc_hdr {* the remote processor will be writing logs. * @RSC_VDEV: declare support for a virtio device, and serve as its * 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 * dedicated structure below.
@@ -111,11 +113,13 @@ struct fw_rsc_hdr {* please update it as needed. */ enum fw_resource_type { -RSC_CARVEOUT =0 , -RSC_DEVMEM =1 , -RSC_TRACE =2 , -RSC_VDEV =3 , -RSC_LAST =4 , +RSC_CARVEOUT =0 , +RSC_DEVMEM =1 , +RSC_TRACE =2 , +RSC_VDEV =3 , +RSC_LAST =4 , +RSC_VENDOR_START =128 , +RSC_VENDOR_END =512 , };#define FW_RSC_ADDR_ANY (-1)
@@ -339,12 +343,25 @@ struct rproc_mem_entry {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 * @start: power on the device and boot it * @stop: power off the device * @kick: kick a virtqueue (virtqueue id given as a parameter) * @da_to_va: optional platform hook to perform address translations +* @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 * @load: load firmeware to memory, where the remote processor
@@ -358,6 +375,8 @@ struct rproc_ops {void (*kick)(struct rproc *rproc,int vqid);void * (*da_to_va)(struct rproc *rproc,u64 da,int len);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 rproc *rproc,const struct firmware *fw);int (*load)(struct rproc *rproc,const struct firmware *fw);
Signature · 20 lines
2.15.0.276.g89ea799 ----- Mail original ----- De: "Clément Leger" <[email protected]> À: "linux-remoteproc" <[email protected]> Envoyé: Lundi 4 Mars 2019 10:40:58 Objet: [RFC PATCH] remoteproc: add per rproc resource handling In order to allow rproc backend to handle vendor resources, add a handle_rsc hook. This hook allow the rproc backends to handle vendor resources as they like. It also allows them to parse standard RSC_* if needed. The hook should return RSC_HANDLED on successful resource handling, RSC_IGNORED if resource was ignored, or a negative value on error. --- drivers/remoteproc/remoteproc_core.c | 7 +++++++ drivers/remoteproc/remoteproc_internal.h | 11 +++++++++++ include/linux/remoteproc.h | 15 +++++++++++++++ 3 files changed, 33 insertions(+)
drivers/remoteproc/remoteproc_core.c +7 -0
@@ -1009,6 +1009,13 @@ static int rproc_handle_resources(struct rproc *rproc,dev_dbg (dev,"rsc: type %d\n" , hdr->type); + ret =rproc_handle_rsc (rproc, hdr->type, rsc, + offset +sizeof (*hdr), avail); +if (ret ==RSC_HANDLED ) +continue ; +else if (ret <0 ) +break ; +if (hdr->type >=RSC_LAST ) {dev_warn (dev,"unsupported resource %d\n" , hdr->type);continue ;
drivers/remoteproc/remoteproc_internal.h +11 -0
@@ -98,6 +98,17 @@ static inline int rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)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 struct resource_table *rproc_find_loaded_rsc_table (struct rproc *rproc,const struct firmware *fw)
include/linux/remoteproc.h +15 -0
@@ -339,12 +339,25 @@ struct rproc_mem_entry {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 * @start: power on the device and boot it * @stop: power off the device * @kick: kick a virtqueue (virtqueue id given as a parameter) * @da_to_va: optional platform hook to perform address translations +* @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 * @load: load firmeware to memory, where the remote processor
@@ -358,6 +371,8 @@ struct rproc_ops {void (*kick)(struct rproc *rproc,int vqid);void * (*da_to_va)(struct rproc *rproc,u64 da,int len);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 rproc *rproc,const struct firmware *fw);int (*load)(struct rproc *rproc,const struct firmware *fw);
Signature · 1 line
2.15.0.276.g89ea799
With appropriate recipients.
Quoted 283 lines
V2:
- Use vendor resources definitions from OpenAMP
- Callrproc->handle_rsconly for vendor resources
- Update remoteproc documentationIn order to allow rproc backend to handle vendor resources, add a
handle_rschook. This hook allow the rproc backends to handle vendor resources as they like. The hook will be called only for vendor resources and should returnRSC_HANDLEDon successful resource handling,RSC_IGNOREDif resource was ignored, or a negative value on error.Signed-off-by Clément Léger <[email protected]>---
Documentation/remoteproc.txt | 14 +++++++++----- drivers/remoteproc/remoteproc_core.c | 15 +++++++++++++++ drivers/remoteproc/remoteproc_internal.h | 11 +++++++++++ include/linux/remoteproc.h | 31 +++++++++++++++++++++++++------ 4 files changed, 60 insertions(+), 11 deletions(-)Documentation/remoteproc.txt +0
-0@@ -314,6 +314,8 @@ Here are the various resource types that are currentlysupported::
* @RSC_VDEV: declare support for a virtio device, and serve as its
* virtio header.
* @RSC_LAST: just keep this one at the endDocumentation/remoteproc.txt +2
-0+ * @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 * 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 currentlysupported::
* please update it as needed.
*/
enumfw_resource_type{Documentation/remoteproc.txt +7
-5- RSC_CARVEOUT = 0, - RSC_DEVMEM = 1, - RSC_TRACE = 2, - RSC_VDEV = 3, - RSC_LAST = 4, + RSC_CARVEOUT = 0, + RSC_DEVMEM = 1, + RSC_TRACE = 2, + RSC_VDEV = 3, + RSC_LAST = 4, + RSC_VENDOR_START = 128, + RSC_VENDOR_END = 512, };For more details regarding a specific resource type, please see its
drivers/remoteproc/remoteproc_core.c +15
-0@@ -1009,6 +1009,21 @@ static int rproc_handle_resources(struct rproc *rproc,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 ) {dev_warn (dev,"unsupported resource %d\n" , hdr->type);continue ;drivers/remoteproc/remoteproc_internal.h +11
-0@@ -98,6 +98,17 @@ static inline int rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)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
structresource_table*rproc_find_loaded_rsc_table(struct rproc *rproc,
const struct firmware *fw)include/linux/remoteproc.h +21
-6@@ -100,7 +100,9 @@ struct fw_rsc_hdr {* the remote processor will be writing logs. * @RSC_VDEV: declare support for a virtio device, and serve as its * 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 * dedicated structure below. @@ -111,11 +113,13 @@ struct fw_rsc_hdr {* please update it as needed. */ enum fw_resource_type { -RSC_CARVEOUT =0 , -RSC_DEVMEM =1 , -RSC_TRACE =2 , -RSC_VDEV =3 , -RSC_LAST =4 , +RSC_CARVEOUT =0 , +RSC_DEVMEM =1 , +RSC_TRACE =2 , +RSC_VDEV =3 , +RSC_LAST =4 , +RSC_VENDOR_START =128 , +RSC_VENDOR_END =512 , };#define FW_RSC_ADDR_ANY (-1)@@ -339,12 +343,25 @@ struct rproc_mem_entry {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 * @start: power on the device and boot it * @stop: power off the device * @kick: kick a virtqueue (virtqueue id given as a parameter) * @da_to_va: optional platform hook to perform address translations +* @handle_rsc: optional platform hook to handle vendor resources. Should return
+ *RSC_HANDLEDif resource was handled,RSC_IGNOREDif 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
* @load: load firmeware to memory, where the remote processorinclude/linux/remoteproc.h +2
-1@@ -358,6 +375,8 @@ struct rproc_ops {void (*kick)(struct rproc *rproc,int vqid);void * (*da_to_va)(struct rproc *rproc,u64 da,int len);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 rproc *rproc,const struct firmware *fw);int (*load)(struct rproc *rproc,const struct firmware *fw); --2.15.0.276.g89ea799
----- Mail original -----
De: "Clément Leger" <[email protected]>
À: "linux-remoteproc" <[email protected]> Envoyé: Lundi 4 Mars 2019 10:40:58
Objet: [RFC PATCH] remoteproc: add per rproc resource handlingIn order to allow rproc backend to handle vendor resources, add a
handle_rschook. This hook allow the rproc backends to handle vendor resources as they like. It also allows them to parse standard RSC_* if needed. The hook should returnRSC_HANDLEDon successful resource handling,RSC_IGNOREDif resource was ignored, or a negative value on error.---
drivers/remoteproc/remoteproc_core.c | 7 +++++++ drivers/remoteproc/remoteproc_internal.h | 11 +++++++++++ include/linux/remoteproc.h | 15 +++++++++++++++ 3 files changed, 33 insertions(+)drivers/remoteproc/remoteproc_core.c +7
-0@@ -1009,6 +1009,13 @@ static int rproc_handle_resources(struct rproc *rproc,dev_dbg (dev,"rsc: type %d\n" , hdr->type); + ret =rproc_handle_rsc (rproc, hdr->type, rsc, + offset +sizeof (*hdr), avail); +if (ret ==RSC_HANDLED ) +continue ; +else if (ret <0 ) +break ; +if (hdr->type >=RSC_LAST ) {dev_warn (dev,"unsupported resource %d\n" , hdr->type);continue ;drivers/remoteproc/remoteproc_internal.h +11
-0@@ -98,6 +98,17 @@ static inline int rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)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
structresource_table*rproc_find_loaded_rsc_table(struct rproc *rproc,
const struct firmware *fw)include/linux/remoteproc.h +11
-0@@ -339,12 +339,25 @@ struct rproc_mem_entry {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 * @start: power on the device and boot it * @stop: power off the device * @kick: kick a virtqueue (virtqueue id given as a parameter) * @da_to_va: optional platform hook to perform address translations +* @handle_rsc: optional platform hook to handle vendor resources. Should return
+ *RSC_HANDLEDif resource was handled,RSC_IGNOREDif 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
* @load: load firmeware to memory, where the remote processorinclude/linux/remoteproc.h +2
-1@@ -358,6 +371,8 @@ struct rproc_ops {void (*kick)(struct rproc *rproc,int vqid);void * (*da_to_va)(struct rproc *rproc,u64 da,int len);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 rproc *rproc,const struct firmware *fw);int (*load)(struct rproc *rproc,const struct firmware *fw); --2.15.0.276.g89ea799