public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: loic.pallardy@st•com (loic pallardy)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH 7/9] remoteproc: core: Add function to over-ride current resource table
Date: Mon, 8 Aug 2016 15:47:17 +0200	[thread overview]
Message-ID: <57A88D65.3060104@st.com> (raw)
In-Reply-To: <20160804092153.23032-8-lee.jones@linaro.org>

Hi Lee

On 08/04/2016 11:21 AM, Lee Jones wrote:
> Most of the new resource table handling function are now in place, so
> it's time to put it all together.  Once new resource table information
> has been requested, the structures will be held in a holding pen until
> boot-time.  During boot-time rproc_apply_resource_overrides() will be
> invoked which in turn will pull the new information out of the holding
> pen and edit the table accordingly.
>
> Signed-off-by: Lee Jones <lee.jones@linaro•org>
> ---
>   drivers/remoteproc/remoteproc_core.c | 65 ++++++++++++++++++++++++++++++++++++
>   1 file changed, 65 insertions(+)
>
> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> index 111350e..6b4e29a 100644
> --- a/drivers/remoteproc/remoteproc_core.c
> +++ b/drivers/remoteproc/remoteproc_core.c
> @@ -1035,6 +1035,65 @@ rproc_add_resource_table_entry(struct rproc *rproc,
>   	return table;
>   }
>
> +static struct resource_table*
> +rproc_apply_resource_overrides(struct rproc *rproc,
> +			       struct resource_table **orig_table,
> +			       int *tablesz)
> +{
> +	struct rproc_request_resource *resource;
> +	struct resource_table *table = *orig_table;
> +	int size = *tablesz;
> +
> +	if (!table && size != 0) {
> +		dev_err(&rproc->dev, "No table present but table size is set\n");
> +		return ERR_PTR(-EINVAL);
> +	}
> +
> +	mutex_lock(&rproc->lock);
> +
> +	rproc_dump_resource_table(rproc, table, size);
It will be good to find a way to not dump resource table if debug is not 
activated. For the same reason as you mentioned in your patch 8, 
resource table parsing will waste CPUS cycles.

> +
> +	if (!table) {
> +		size = sizeof(*table);
> +		table = devm_kzalloc(&rproc->dev, size, GFP_KERNEL);
> +		if (!table) {
> +			table = ERR_PTR(-ENOMEM);
> +			goto out;
> +		}
> +		table->ver = 1;
> +	}
> +
> +	list_for_each_entry(resource, &rproc->override_resources, node) {
> +		int updated = 0;
> +
> +		/* If we already have a table, update it with the new values. */
> +		updated = rproc_update_resource_table_entry(rproc, resource,
> +							    table, size);
> +		if (updated < 0) {
> +			table = ERR_PTR(updated);
> +			goto out;
> +		}
> +		if (updated)
> +			continue;
> +
> +		/* Didn't find matching resource entry -- creating a new one. */
> +		table = rproc_add_resource_table_entry(rproc, resource,
> +						       table, &size);
> +		if (IS_ERR(table))
> +			goto out;
> +
> +		*orig_table = table;
> +	}
> +
> +	rproc_dump_resource_table(rproc, table, size);
ditto

Regards,
Loic
> +
> +	*tablesz = size;
> +
> + out:
> +	mutex_unlock(&rproc->lock);
> +	return table;
> +}
> +
>   /*
>    * take a firmware and boot a remote processor with it.
>    */
> @@ -1153,6 +1212,12 @@ static void rproc_fw_config_virtio(const struct firmware *fw, void *context)
>   	if (!table)
>   		goto out;
>
> +	if (!list_empty(&rproc->override_resources)) {
> +		table = rproc_apply_resource_overrides(rproc, &table, &tablesz);
> +		if (IS_ERR(table))
> +			goto out;
> +	}
> +
>   	rproc->table_csum = crc32(0, table, tablesz);
>
>   	/*
>

  reply	other threads:[~2016-08-08 13:47 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-04  9:21 [PATCH 0/9] remoteproc: Allow platform-specific drivers to request resources Lee Jones
2016-08-04  9:21 ` [PATCH 1/9] remoteproc: core: Ensure error message is clear Lee Jones
2016-08-09 17:28   ` Bjorn Andersson
2016-08-09 18:12     ` Lee Jones
2016-08-10 20:11       ` Suman Anna
2016-08-11  7:36         ` Lee Jones
2016-08-11 19:19           ` Bjorn Andersson
2016-08-11 20:09             ` Suman Anna
2016-08-04  9:21 ` [PATCH 2/9] remoteproc: core: Trivial: Improve error checking, spelling and debug prints Lee Jones
2016-08-09 17:32   ` Bjorn Andersson
2016-08-09 18:12     ` Lee Jones
2016-08-04  9:21 ` [PATCH 3/9] remoteproc: core: Remove pointless OOM print Lee Jones
2016-08-09 17:36   ` Bjorn Andersson
2016-08-09 18:10     ` Lee Jones
2016-08-10 17:47       ` Bjorn Andersson
2016-08-04  9:21 ` [PATCH 4/9] remoteproc: core: New API to add new resources to the resource table Lee Jones
2016-08-04 14:00   ` Lee Jones
2016-08-08 13:41   ` loic pallardy
2016-08-09 12:48     ` Lee Jones
2016-08-04  9:21 ` [PATCH 5/9] remoteproc: core: Add function to amend an existing resource table entry Lee Jones
2016-08-04  9:21 ` [PATCH 6/9] remoteproc: core: Add function to append a new " Lee Jones
2016-08-11  7:51   ` loic pallardy
2016-08-11 20:20     ` Bjorn Andersson
2016-08-12 11:54       ` loic pallardy
2016-08-04  9:21 ` [PATCH 7/9] remoteproc: core: Add function to over-ride current resource table Lee Jones
2016-08-08 13:47   ` loic pallardy [this message]
2016-08-09 12:46     ` Lee Jones
2016-08-04  9:21 ` [PATCH 8/9] remoteproc: core: Skip resource table integrity checks if there are amendments Lee Jones
2016-08-09 17:40   ` Bjorn Andersson
2016-08-04  9:21 ` [PATCH 9/9] remoteproc: core: Support empty resource tables Lee Jones
2016-08-05  7:38   ` Lee Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57A88D65.3060104@st.com \
    --to=loic.pallardy@st$(echo .)com \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox