Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Mathieu Poirier and committed by
Bjorn Andersson
1a631382 76f4c875

+47 -1
+32
drivers/remoteproc/remoteproc_core.c
··· 1543 1543 return ret; 1544 1544 } 1545 1545 1546 + static int rproc_set_rsc_table(struct rproc *rproc) 1547 + { 1548 + struct resource_table *table_ptr; 1549 + struct device *dev = &rproc->dev; 1550 + size_t table_sz; 1551 + int ret; 1552 + 1553 + table_ptr = rproc_get_loaded_rsc_table(rproc, &table_sz); 1554 + if (!table_ptr) { 1555 + /* Not having a resource table is acceptable */ 1556 + return 0; 1557 + } 1558 + 1559 + if (IS_ERR(table_ptr)) { 1560 + ret = PTR_ERR(table_ptr); 1561 + dev_err(dev, "can't load resource table: %d\n", ret); 1562 + return ret; 1563 + } 1564 + 1565 + rproc->cached_table = NULL; 1566 + rproc->table_ptr = table_ptr; 1567 + rproc->table_sz = table_sz; 1568 + 1569 + return 0; 1570 + } 1571 + 1546 1572 /* 1547 1573 * Attach to remote processor - similar to rproc_fw_boot() but without 1548 1574 * the steps that deal with the firmware image. ··· 1586 1560 if (ret) { 1587 1561 dev_err(dev, "can't enable iommu: %d\n", ret); 1588 1562 return ret; 1563 + } 1564 + 1565 + ret = rproc_set_rsc_table(rproc); 1566 + if (ret) { 1567 + dev_err(dev, "can't load resource table: %d\n", ret); 1568 + goto disable_iommu; 1589 1569 } 1590 1570 1591 1571 /* reset max_notifyid */
+10
drivers/remoteproc/remoteproc_internal.h
··· 178 178 } 179 179 180 180 static inline 181 + struct resource_table *rproc_get_loaded_rsc_table(struct rproc *rproc, 182 + size_t *size) 183 + { 184 + if (rproc->ops->get_loaded_rsc_table) 185 + return rproc->ops->get_loaded_rsc_table(rproc, size); 186 + 187 + return NULL; 188 + } 189 + 190 + static inline 181 191 bool rproc_u64_fit_in_size_t(u64 val) 182 192 { 183 193 if (sizeof(size_t) == sizeof(u64))
+5 -1
include/linux/remoteproc.h
··· 370 370 * RSC_HANDLED if resource was handled, RSC_IGNORED if not handled and a 371 371 * negative value on error 372 372 * @load_rsc_table: load resource table from firmware image 373 - * @find_loaded_rsc_table: find the loaded resouce table 373 + * @find_loaded_rsc_table: find the loaded resource table from firmware image 374 + * @get_loaded_rsc_table: get resource table installed in memory 375 + * by external entity 374 376 * @load: load firmware to memory, where the remote processor 375 377 * expects to find it 376 378 * @sanity_check: sanity check the fw image ··· 394 392 int offset, int avail); 395 393 struct resource_table *(*find_loaded_rsc_table)( 396 394 struct rproc *rproc, const struct firmware *fw); 395 + struct resource_table *(*get_loaded_rsc_table)( 396 + struct rproc *rproc, size_t *size); 397 397 int (*load)(struct rproc *rproc, const struct firmware *fw); 398 398 int (*sanity_check)(struct rproc *rproc, const struct firmware *fw); 399 399 u64 (*get_boot_addr)(struct rproc *rproc, const struct firmware *fw);