remoteproc: Add new get_loaded_rsc_table() to rproc_ops

Add a new get_loaded_rsc_table() operation in order to support
scenarios where the remoteproc core has booted a remote processor
and detaches from it.  When re-attaching to the remote processor,
the core needs to know where the resource table has been placed
in memory.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Link: https://lore.kernel.org/r/20210312162453.1234145-6-mathieu.poirier@linaro.org
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
This commit is contained in:
Mathieu Poirier 2021-03-12 09:24:41 -07:00 committed by Bjorn Andersson
parent 76f4c87587
commit 1a631382be
3 changed files with 47 additions and 1 deletions

View File

@ -1543,6 +1543,32 @@ disable_iommu:
return ret;
}
static int rproc_set_rsc_table(struct rproc *rproc)
{
struct resource_table *table_ptr;
struct device *dev = &rproc->dev;
size_t table_sz;
int ret;
table_ptr = rproc_get_loaded_rsc_table(rproc, &table_sz);
if (!table_ptr) {
/* Not having a resource table is acceptable */
return 0;
}
if (IS_ERR(table_ptr)) {
ret = PTR_ERR(table_ptr);
dev_err(dev, "can't load resource table: %d\n", ret);
return ret;
}
rproc->cached_table = NULL;
rproc->table_ptr = table_ptr;
rproc->table_sz = table_sz;
return 0;
}
/*
* Attach to remote processor - similar to rproc_fw_boot() but without
* the steps that deal with the firmware image.
@ -1562,6 +1588,12 @@ static int rproc_attach(struct rproc *rproc)
return ret;
}
ret = rproc_set_rsc_table(rproc);
if (ret) {
dev_err(dev, "can't load resource table: %d\n", ret);
goto disable_iommu;
}
/* reset max_notifyid */
rproc->max_notifyid = -1;

View File

@ -177,6 +177,16 @@ struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc,
return NULL;
}
static inline
struct resource_table *rproc_get_loaded_rsc_table(struct rproc *rproc,
size_t *size)
{
if (rproc->ops->get_loaded_rsc_table)
return rproc->ops->get_loaded_rsc_table(rproc, size);
return NULL;
}
static inline
bool rproc_u64_fit_in_size_t(u64 val)
{

View File

@ -370,7 +370,9 @@ enum rsc_handling_status {
* 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 resource table from firmware image
* @get_loaded_rsc_table: get resource table installed in memory
* by external entity
* @load: load firmware to memory, where the remote processor
* expects to find it
* @sanity_check: sanity check the fw image
@ -392,6 +394,8 @@ struct rproc_ops {
int offset, int avail);
struct resource_table *(*find_loaded_rsc_table)(
struct rproc *rproc, const struct firmware *fw);
struct resource_table *(*get_loaded_rsc_table)(
struct rproc *rproc, size_t *size);
int (*load)(struct rproc *rproc, const struct firmware *fw);
int (*sanity_check)(struct rproc *rproc, const struct firmware *fw);
u64 (*get_boot_addr)(struct rproc *rproc, const struct firmware *fw);