lkml.org 
[lkml]   [2020]   [May]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH v3 02/14] remoteproc: Introduce function rproc_alloc_internals()
On Fri 24 Apr 13:01 PDT 2020, Mathieu Poirier wrote:

> In scenarios where the remote processor's lifecycle is entirely
> managed by another entity there is no point in allocating memory for
> a firmware name since it will never be used. The same goes for a core
> set of operations.
>
> As such introduce function rproc_alloc_internals() to decide if the
> allocation of a firmware name and the core operations need to be done.
> That way rproc_alloc() can be kept as clean as possible.
>
> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> ---
> drivers/remoteproc/remoteproc_core.c | 31 +++++++++++++++++++++++-----
> 1 file changed, 26 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> index 448262470fc7..1b4756909584 100644
> --- a/drivers/remoteproc/remoteproc_core.c
> +++ b/drivers/remoteproc/remoteproc_core.c
> @@ -2076,6 +2076,30 @@ static int rproc_alloc_ops(struct rproc *rproc, const struct rproc_ops *ops)
> return 0;
> }
>
> +static int rproc_alloc_internals(struct rproc *rproc,
> + const struct rproc_ops *ops,
> + const char *name, const char *firmware)
> +{
> + int ret;
> +
> + /*
> + * In scenarios where the remote processor's lifecycle is entirely
> + * managed by another entity there is no point in carrying a set
> + * of operations that will never be used.
> + *
> + * And since no firmware will ever be loaded, there is no point in
> + * allocating memory for it either.

While this is true, I would expect that there are cases where the
remoteproc has ops but no firmware.

How about splitting this decision already now; i.e. moving the if(!ops)
to rproc_alloc_ops() and perhaps only allocate firmware if ops->load is
specified?

Regards,
Bjorn

> + */
> + if (!ops)
> + return 0;
> +
> + ret = rproc_alloc_firmware(rproc, name, firmware);
> + if (ret)
> + return ret;
> +
> + return rproc_alloc_ops(rproc, ops);
> +}
> +
> /**
> * rproc_alloc() - allocate a remote processor handle
> * @dev: the underlying device
> @@ -2105,7 +2129,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
> {
> struct rproc *rproc;
>
> - if (!dev || !name || !ops)
> + if (!dev || !name)
> return NULL;
>
> rproc = kzalloc(sizeof(struct rproc) + len, GFP_KERNEL);
> @@ -2128,10 +2152,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
> if (!rproc->name)
> goto put_device;
>
> - if (rproc_alloc_firmware(rproc, name, firmware))
> - goto put_device;
> -
> - if (rproc_alloc_ops(rproc, ops))
> + if (rproc_alloc_internals(rproc, ops, name, firmware))
> goto put_device;
>
> /* Assign a unique device index and name */
> --
> 2.20.1
>

\
 
 \ /
  Last update: 2020-05-06 00:32    [W:1.875 / U:0.380 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site