Re: [RFC 5/6] remoteproc: Support custom firmware handlers

From: Ohad Ben-Cohen
Date: Sun Jun 03 2012 - 09:37:56 EST


On Tue, May 22, 2012 at 4:26 PM, <sjur.brandeland@xxxxxxxxxxxxxx> wrote:
> From: Sjur Brændeland <sjur.brandeland@xxxxxxxxxxxxxx>
>
> Make the firmware handling customizable by creating
> a rproc_fw_ops structure. Expose the existing
> Elf firmware handling in rproc_elf_fw_ops.
>
> Signed-off-by: Sjur Brændeland <sjur.brandeland@xxxxxxxxxxxxxx>
..
> @@ -171,6 +171,7 @@ static struct rproc_ops omap_rproc_ops = {
>        .start          = omap_rproc_start,
>        .stop           = omap_rproc_stop,
>        .kick           = omap_rproc_kick,
> +       .fw             = &rproc_elf_fw_ops
>  };

Can we instead make these ops dynamically assigned, without mandating
them in the low level driver ?

E.g. with ELF it's easy (first four bytes of the binary), but I'm not
sure how feasible it is with proprietary binary formats (such as
yours).

> @@ -781,12 +780,13 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
>  {
>        struct device *dev = rproc->dev;
>        const char *name = rproc->firmware;
> -       struct elf32_hdr *ehdr;
>        struct resource_table *table;
>        int ret, tablesz;
>
> -       ehdr = (struct elf32_hdr *)fw->data;
> -
> +       if (!rproc->ops->fw_ops || !try_module_get(rproc->ops->fw_ops->owner)) {

I'm not sure we need loaders' ops to be full-fledged modules of their
own. For simplicity, we might just have them statically linked with
the remoteproc module.

>        /* look for the resource table */
> -       table = rproc_find_rsc_table(rproc, fw, &tablesz);
> +       table = rproc->ops->fw_ops->find_rsc_table(rproc, fw, &tablesz);

Might be easier on the eyes if we turn rproc_find_rsc_table() (and
friends) into static inline "macros" which does all this
de-referencing.

Thanks,
Ohad.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/