public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ido Yariv <ido@wizery.com>
To: "Sjur Brændeland" <sjur.brandeland@stericsson.com>
Cc: "Ohad Ben-Cohen" <ohad@wizery.com>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	linux-kernel@vger.kernel.org,
	"Sjur Brændeland" <sjur@brendeland.net>
Subject: Re: [RFCv2 05/11] remoteproc: Load firmware once.
Date: Fri, 21 Dec 2012 04:16:17 +0200	[thread overview]
Message-ID: <20121221021616.GC28692@WorkStation.localnet> (raw)
In-Reply-To: <1355501220-4572-6-git-send-email-sjur.brandeland@stericsson.com>

Hi Sjur,

On Fri, Dec 14, 2012 at 05:06:54PM +0100, Sjur Brændeland wrote:
> Load the firmware once and pave the way for two way
> communication of virtio configuration and status bits.
> The virtio ring device address is now stored in the resource
> table.
> 
> NOTE:  This patch requires device firmware change! The device
> 	memory layout changes. The virtio rings are no longer
> 	located at start of device memory. But the vring address
> 	can be read from the resource table. Also Carveout
> 	must be located before the virtio rings in the resource
> 	table.
> 
> Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>

In case the remote processor is added, booted and then rebooted, the
program sections wont be reinitialized. This can be a bit problematic,
since the firmware might assume values are initialized in its data
sections.

How about the following alternative approach - instead of loading the
firmware in advance, we could allocate just a small (private) buffer,
holding a copy of the resource table. Our copy will be updated with the
addresses of the vrings we allocate, along with the notification ids.
Each time the remote processor is booted, we could reload the firmware
and overwrite the resource table section with our own private copy.
virtio's configuration space and status will probably need to be updated
in both copies of the resource table, so it would be consistent across
boots.

...

> -static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
> +static void rproc_fw_load(const struct firmware *fw, void *context)
>  {
> +	struct rproc *rproc = context;
>  	struct device *dev = &rproc->dev;
>  	const char *name = rproc->firmware;
>  	struct resource_table *table;
>  	int ret, tablesz;
>  
> +	if (!fw)
> +		goto release_fw;
> +
>  	ret = rproc_fw_sanity_check(rproc, fw);
>  	if (ret)
> -		return ret;
> +		goto release_fw;
>  
>  	dev_info(dev, "Booting fw image %s, size %zd\n", name, fw->size);
>  
> @@ -800,7 +805,7 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
>  	ret = rproc_enable_iommu(rproc);

iommu is enabled when the firmware is loaded, but disabled on shutdown,
so it could get out of balance when the remote processor is rebooted.

...

>  int rproc_boot(struct rproc *rproc)
>  {
> -	const struct firmware *firmware_p;
>  	struct device *dev;
>  	int ret;
>  
> @@ -1004,27 +967,28 @@ int rproc_boot(struct rproc *rproc)
>  	/* skip the boot process if rproc is already powered up */
>  	if (atomic_inc_return(&rproc->power) > 1) {
>  		ret = 0;
> -		goto unlock_mutex;
> +		goto downref_driver;

In case the rproc is already powered up, module_put should probably be
called to balance try_module_get. This is actually an existing bug in the
code.

Thanks,
Ido.

  reply	other threads:[~2012-12-21  2:21 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-14 16:06 [RFCv2 00/10] remoteproc: Support bi-directional vdev config space Sjur Brændeland
2012-12-14 16:06 ` [RFCv2 01/11] remoteproc: Code cleanup of resource parsing Sjur Brændeland
2012-12-14 16:06 ` [RFCv2 02/11] remoteproc: Move check on firmware name to rproc_add Sjur Brændeland
2012-12-14 16:06 ` [RFCv2 03/11] remoteproc: Set vring addresses in resource table Sjur Brændeland
2012-12-21  2:13   ` Ido Yariv
2013-01-15 15:07     ` Sjur BRENDELAND
2012-12-14 16:06 ` [RFCv2 04/11] remoteproc: Add state RPROC_LOADED Sjur Brændeland
2012-12-21  2:14   ` Ido Yariv
2013-01-15 15:08     ` Sjur BRENDELAND
2012-12-14 16:06 ` [RFCv2 05/11] remoteproc: Load firmware once Sjur Brændeland
2012-12-21  2:16   ` Ido Yariv [this message]
2012-12-21 12:02     ` Sjur BRENDELAND
2012-12-21 13:30       ` Ido Yariv
2012-12-21 14:04         ` Sjur BRENDELAND
2013-01-15 15:11     ` Sjur BRENDELAND
2012-12-14 16:06 ` [RFCv2 06/11] remoteproc: Add resource entry number to callbacks Sjur Brændeland
2012-12-14 16:06 ` [RFCv2 07/11] remoteproc: Register virtio devices after vring allocation Sjur Brændeland
2012-12-21  2:18   ` Ido Yariv
2012-12-21 12:20     ` Sjur BRENDELAND
2012-12-21 13:40       ` Ido Yariv
2012-12-21 13:50         ` Sjur BRENDELAND
2012-12-21 15:26           ` Ohad Ben-Cohen
2013-01-15 15:11     ` Sjur BRENDELAND
2012-12-14 16:06 ` [RFCv2 08/11] remoteproc: Refactor function rproc_elf_find_rsc_table Sjur Brændeland
2012-12-21  2:18   ` Ido Yariv
2013-01-15 15:11     ` Sjur BRENDELAND
2012-12-14 16:06 ` [RFCv2 09/11] remoteproc: Add operation to find resource table in memory Sjur Brændeland
2012-12-21  2:19   ` Ido Yariv
2013-01-15 15:13     ` Sjur BRENDELAND
2012-12-14 16:06 ` [RFCv2 10/11] remoteproc: Find resource table in device memory Sjur Brændeland
2012-12-21  2:20   ` Ido Yariv
2013-01-15 15:05     ` Sjur BRENDELAND
2012-12-14 16:07 ` [RFCv2 11/11] remoteproc: Support virtio config space Sjur Brændeland
2012-12-21  2:21   ` Ido Yariv
2013-01-15 15:14     ` Sjur BRENDELAND

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=20121221021616.GC28692@WorkStation.localnet \
    --to=ido@wizery.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ohad@wizery.com \
    --cc=sjur.brandeland@stericsson.com \
    --cc=sjur@brendeland.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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