Commit 1429cca1 authored by Loic Pallardy's avatar Loic Pallardy Committed by Bjorn Andersson

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: default avatarLoic Pallardy <loic.pallardy@st.com>
Signed-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
parent d7c51706
...@@ -857,6 +857,7 @@ rproc_mem_entry_init(struct device *dev, ...@@ -857,6 +857,7 @@ rproc_mem_entry_init(struct device *dev,
mem->alloc = alloc; mem->alloc = alloc;
mem->release = release; mem->release = release;
mem->rsc_offset = FW_RSC_ADDR_ANY; mem->rsc_offset = FW_RSC_ADDR_ANY;
mem->of_resm_idx = -1;
va_start(args, name); va_start(args, name);
vsnprintf(mem->name, sizeof(mem->name), name, args); vsnprintf(mem->name, sizeof(mem->name), name, args);
...@@ -866,6 +867,42 @@ rproc_mem_entry_init(struct device *dev, ...@@ -866,6 +867,42 @@ rproc_mem_entry_init(struct device *dev,
} }
EXPORT_SYMBOL(rproc_mem_entry_init); EXPORT_SYMBOL(rproc_mem_entry_init);
/**
* rproc_of_resm_mem_entry_init() - allocate and initialize rproc_mem_entry struct
* from a reserved memory phandle
* @dev: pointer on device struct
* @of_resm_idx: reserved memory phandle index in "memory-region"
* @len: memory carveout length
* @da: device address
* @name: carveout name
*
* This function allocates a rproc_mem_entry struct and fill it with parameters
* provided by client.
*/
struct rproc_mem_entry *
rproc_of_resm_mem_entry_init(struct device *dev, u32 of_resm_idx, int len,
u32 da, const char *name, ...)
{
struct rproc_mem_entry *mem;
va_list args;
mem = kzalloc(sizeof(*mem), GFP_KERNEL);
if (!mem)
return mem;
mem->da = da;
mem->len = len;
mem->rsc_offset = FW_RSC_ADDR_ANY;
mem->of_resm_idx = of_resm_idx;
va_start(args, name);
vsnprintf(mem->name, sizeof(mem->name), name, args);
va_end(args);
return mem;
}
EXPORT_SYMBOL(rproc_of_resm_mem_entry_init);
/** /**
* A lookup table for resource handlers. The indices are defined in * A lookup table for resource handlers. The indices are defined in
* enum fw_resource_type. * enum fw_resource_type.
......
...@@ -319,6 +319,7 @@ struct rproc; ...@@ -319,6 +319,7 @@ struct rproc;
* @node: list node * @node: list node
* @rsc_offset: offset in resource table * @rsc_offset: offset in resource table
* @flags: iommu protection flags * @flags: iommu protection flags
* @of_resm_idx: reserved memory phandle index
* @alloc: specific memory allocator function * @alloc: specific memory allocator function
*/ */
struct rproc_mem_entry { struct rproc_mem_entry {
...@@ -331,6 +332,7 @@ struct rproc_mem_entry { ...@@ -331,6 +332,7 @@ struct rproc_mem_entry {
struct list_head node; struct list_head node;
u32 rsc_offset; u32 rsc_offset;
u32 flags; u32 flags;
u32 of_resm_idx;
int (*alloc)(struct rproc *rproc, struct rproc_mem_entry *mem); int (*alloc)(struct rproc *rproc, struct rproc_mem_entry *mem);
int (*release)(struct rproc *rproc, struct rproc_mem_entry *mem); int (*release)(struct rproc *rproc, struct rproc_mem_entry *mem);
}; };
...@@ -574,6 +576,10 @@ rproc_mem_entry_init(struct device *dev, ...@@ -574,6 +576,10 @@ rproc_mem_entry_init(struct device *dev,
int (*release)(struct rproc *, struct rproc_mem_entry *), int (*release)(struct rproc *, struct rproc_mem_entry *),
const char *name, ...); const char *name, ...);
struct rproc_mem_entry *
rproc_of_resm_mem_entry_init(struct device *dev, u32 of_resm_idx, int len,
u32 da, const char *name, ...);
int rproc_boot(struct rproc *rproc); int rproc_boot(struct rproc *rproc);
void rproc_shutdown(struct rproc *rproc); void rproc_shutdown(struct rproc *rproc);
void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type); void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type);
......
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