diff options
author | Loic Pallardy <loic.pallardy@st.com> | 2018-07-27 09:14:44 -0400 |
---|---|---|
committer | Bjorn Andersson <bjorn.andersson@linaro.org> | 2018-10-10 01:39:14 -0400 |
commit | 1429cca1175f4cb64dd5d61ffd6037895a41d672 (patch) | |
tree | 3d62e3b206f6da65bf01f9d160698b6dcb927f68 | |
parent | d7c51706d0956472b7c0530b1bf8fba32d82ee6b (diff) |
remoteproc: add helper function to allocate rproc_mem_entry from reserved memory
This patch introduces rproc_res_mem_entry_init() helper function to
allocate a rproc_mem_entry structure from a reserved memory region.
In that case, rproc_mem_entry structure has no alloc and release ops.
It will be used to assigned the specified reserved memory to any
rproc sub device.
Relation between rproc_mem_entry and rproc sub device will be done
by name.
Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
-rw-r--r-- | drivers/remoteproc/remoteproc_core.c | 37 | ||||
-rw-r--r-- | include/linux/remoteproc.h | 6 |
2 files changed, 43 insertions, 0 deletions
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 9d17b3079506..d7a623b8801c 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c | |||
@@ -857,6 +857,7 @@ rproc_mem_entry_init(struct device *dev, | |||
857 | mem->alloc = alloc; | 857 | mem->alloc = alloc; |
858 | mem->release = release; | 858 | mem->release = release; |
859 | mem->rsc_offset = FW_RSC_ADDR_ANY; | 859 | mem->rsc_offset = FW_RSC_ADDR_ANY; |
860 | mem->of_resm_idx = -1; | ||
860 | 861 | ||
861 | va_start(args, name); | 862 | va_start(args, name); |
862 | vsnprintf(mem->name, sizeof(mem->name), name, args); | 863 | vsnprintf(mem->name, sizeof(mem->name), name, args); |
@@ -867,6 +868,42 @@ rproc_mem_entry_init(struct device *dev, | |||
867 | EXPORT_SYMBOL(rproc_mem_entry_init); | 868 | EXPORT_SYMBOL(rproc_mem_entry_init); |
868 | 869 | ||
869 | /** | 870 | /** |
871 | * rproc_of_resm_mem_entry_init() - allocate and initialize rproc_mem_entry struct | ||
872 | * from a reserved memory phandle | ||
873 | * @dev: pointer on device struct | ||
874 | * @of_resm_idx: reserved memory phandle index in "memory-region" | ||
875 | * @len: memory carveout length | ||
876 | * @da: device address | ||
877 | * @name: carveout name | ||
878 | * | ||
879 | * This function allocates a rproc_mem_entry struct and fill it with parameters | ||
880 | * provided by client. | ||
881 | */ | ||
882 | struct rproc_mem_entry * | ||
883 | rproc_of_resm_mem_entry_init(struct device *dev, u32 of_resm_idx, int len, | ||
884 | u32 da, const char *name, ...) | ||
885 | { | ||
886 | struct rproc_mem_entry *mem; | ||
887 | va_list args; | ||
888 | |||
889 | mem = kzalloc(sizeof(*mem), GFP_KERNEL); | ||
890 | if (!mem) | ||
891 | return mem; | ||
892 | |||
893 | mem->da = da; | ||
894 | mem->len = len; | ||
895 | mem->rsc_offset = FW_RSC_ADDR_ANY; | ||
896 | mem->of_resm_idx = of_resm_idx; | ||
897 | |||
898 | va_start(args, name); | ||
899 | vsnprintf(mem->name, sizeof(mem->name), name, args); | ||
900 | va_end(args); | ||
901 | |||
902 | return mem; | ||
903 | } | ||
904 | EXPORT_SYMBOL(rproc_of_resm_mem_entry_init); | ||
905 | |||
906 | /** | ||
870 | * A lookup table for resource handlers. The indices are defined in | 907 | * A lookup table for resource handlers. The indices are defined in |
871 | * enum fw_resource_type. | 908 | * enum fw_resource_type. |
872 | */ | 909 | */ |
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index d251c091303c..d4cabe8da507 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h | |||
@@ -319,6 +319,7 @@ struct rproc; | |||
319 | * @node: list node | 319 | * @node: list node |
320 | * @rsc_offset: offset in resource table | 320 | * @rsc_offset: offset in resource table |
321 | * @flags: iommu protection flags | 321 | * @flags: iommu protection flags |
322 | * @of_resm_idx: reserved memory phandle index | ||
322 | * @alloc: specific memory allocator function | 323 | * @alloc: specific memory allocator function |
323 | */ | 324 | */ |
324 | struct rproc_mem_entry { | 325 | struct rproc_mem_entry { |
@@ -331,6 +332,7 @@ struct rproc_mem_entry { | |||
331 | struct list_head node; | 332 | struct list_head node; |
332 | u32 rsc_offset; | 333 | u32 rsc_offset; |
333 | u32 flags; | 334 | u32 flags; |
335 | u32 of_resm_idx; | ||
334 | int (*alloc)(struct rproc *rproc, struct rproc_mem_entry *mem); | 336 | int (*alloc)(struct rproc *rproc, struct rproc_mem_entry *mem); |
335 | int (*release)(struct rproc *rproc, struct rproc_mem_entry *mem); | 337 | int (*release)(struct rproc *rproc, struct rproc_mem_entry *mem); |
336 | }; | 338 | }; |
@@ -574,6 +576,10 @@ rproc_mem_entry_init(struct device *dev, | |||
574 | int (*release)(struct rproc *, struct rproc_mem_entry *), | 576 | int (*release)(struct rproc *, struct rproc_mem_entry *), |
575 | const char *name, ...); | 577 | const char *name, ...); |
576 | 578 | ||
579 | struct rproc_mem_entry * | ||
580 | rproc_of_resm_mem_entry_init(struct device *dev, u32 of_resm_idx, int len, | ||
581 | u32 da, const char *name, ...); | ||
582 | |||
577 | int rproc_boot(struct rproc *rproc); | 583 | int rproc_boot(struct rproc *rproc); |
578 | void rproc_shutdown(struct rproc *rproc); | 584 | void rproc_shutdown(struct rproc *rproc); |
579 | void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type); | 585 | void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type); |