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

remoteproc: add find_loaded_rsc_table firmware ops

Add function find_loaded_rsc_table to firmware ops. This function
returns the location of the resource table in shared memory
after loading.

Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
Acked-by: Ido Yariv <ido@wizery.com>
[align function name with existing terminology, update commit log]
[document new function, rebase patch, small cleanups]
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>

authored by

Sjur Brændeland and committed by
Ohad Ben-Cohen
95f95781 f665b2cd

+39 -1
+25
drivers/remoteproc/remoteproc_elf_loader.c
··· 304 304 return table; 305 305 } 306 306 307 + /** 308 + * rproc_elf_find_loaded_rsc_table() - find the loaded resource table 309 + * @rproc: the rproc handle 310 + * @fw: the ELF firmware image 311 + * 312 + * This function finds the location of the loaded resource table. Don't 313 + * call this function if the table wasn't loaded yet - it's a bug if you do. 314 + * 315 + * Returns the pointer to the resource table if it is found or NULL otherwise. 316 + * If the table wasn't loaded yet the result is unspecified. 317 + */ 318 + static struct resource_table * 319 + rproc_elf_find_loaded_rsc_table(struct rproc *rproc, const struct firmware *fw) 320 + { 321 + struct elf32_hdr *ehdr = (struct elf32_hdr *)fw->data; 322 + struct elf32_shdr *shdr; 323 + 324 + shdr = find_table(&rproc->dev, ehdr, fw->size); 325 + if (!shdr) 326 + return NULL; 327 + 328 + return rproc_da_to_va(rproc, shdr->sh_addr, shdr->sh_size); 329 + } 330 + 307 331 const struct rproc_fw_ops rproc_elf_fw_ops = { 308 332 .load = rproc_elf_load_segments, 309 333 .find_rsc_table = rproc_elf_find_rsc_table, 334 + .find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table, 310 335 .sanity_check = rproc_elf_sanity_check, 311 336 .get_boot_addr = rproc_elf_get_boot_addr 312 337 };
+14 -1
drivers/remoteproc/remoteproc_internal.h
··· 27 27 28 28 /** 29 29 * struct rproc_fw_ops - firmware format specific operations. 30 - * @find_rsc_table: finds the resource table inside the firmware image 30 + * @find_rsc_table: find the resource table inside the firmware image 31 + * @find_loaded_rsc_table: find the loaded resouce table 31 32 * @load: load firmeware to memory, where the remote processor 32 33 * expects to find it 33 34 * @sanity_check: sanity check the fw image ··· 38 37 struct resource_table *(*find_rsc_table) (struct rproc *rproc, 39 38 const struct firmware *fw, 40 39 int *tablesz); 40 + struct resource_table *(*find_loaded_rsc_table)(struct rproc *rproc, 41 + const struct firmware *fw); 41 42 int (*load)(struct rproc *rproc, const struct firmware *fw); 42 43 int (*sanity_check)(struct rproc *rproc, const struct firmware *fw); 43 44 u32 (*get_boot_addr)(struct rproc *rproc, const struct firmware *fw); ··· 103 100 return rproc->fw_ops->find_rsc_table(rproc, fw, tablesz); 104 101 105 102 return NULL; 103 + } 104 + 105 + static inline 106 + struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc, 107 + const struct firmware *fw) 108 + { 109 + if (rproc->fw_ops->find_loaded_rsc_table) 110 + return rproc->fw_ops->find_loaded_rsc_table(rproc, fw); 111 + 112 + return NULL; 106 113 } 107 114 108 115 extern const struct rproc_fw_ops rproc_elf_fw_ops;