All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Loic Pallardy <loic.pallardy@st.com>
Cc: ohad@wizery.com, lee.jones@linaro.org,
	linux-remoteproc@vger.kernel.org, kernel@stlinux.com
Subject: Re: [PATCH 1/1] remoteproc: core: probe subdevices before booting coprocessor
Date: Fri, 2 Dec 2016 17:33:45 -0800	[thread overview]
Message-ID: <20161203013345.GG9322@tuxbot> (raw)
In-Reply-To: <1480096150-5795-1-git-send-email-loic.pallardy@st.com>

On Fri 25 Nov 09:49 PST 2016, Loic Pallardy wrote:

> With subdevice support introduction, coprocessor boot sequence has
> changed. Related coprocessor subdevices are now starting after firmware
> and resource table loading and coprocessor boot.
> 
> But some subdevices can resources to allocate before coprocessor start,
> like rpmsg buffers allocation for example.
> 
> This patch probes subdevices just before loading resource table,
> to keep backward compatibility with existing firmwares.
> 

I'm sorry, it looks like I didn't properly describe this change in
behavior in the git log.

If you look in an older kernel (e.g. v4.0) you will find the following
sequence (abbreviated):

rproc_add()
  rproc_fw_config_virtio()
    rproc_add_virtio_dev()
      rpmsg_probe()
        rproc_virtio_find_vqs()
          rproc_alloc_vring()
          rproc_alloc_vring()
          rproc_boot()
            rproc->ops->start()
        dma_alloc_coherent() <- rpmsg buffers after start()
      rpmsg_probe()
        rproc_virtio_find_vqs()
          rproc_alloc_vring( <- vrings after start()!!!
          rproc_alloc_vring()
          rproc_boot()
        dma_alloc_coherent()
        virtqueue_add_inbuf()
      ...

I.e. we allocated vrings for the first virtio device, booted the
remoteproc and then allocate rpmsg buffers.

I accidentally screwed up the order of things when I introduced [2], so
in v4.9 we actually do:

rproc_add()
  rproc_fw_config_virtio()
    rproc_boot()
      rproc_add_virtio_dev()
        rpmsg_probe()
          rproc_virtio_find_vqs()
            rproc_alloc_vring()
            rproc_alloc_vring()
          dma_alloc_coherent() <- rpmsg buffers now before start()
        rpmsg_probe()
          rproc_virtio_find_vqs()
            rproc_alloc_vring() <- secondary vrings before start()
            rproc_alloc_vring()
          dma_alloc_coherent()
      rproc->ops->start()

As you point out we would here allocate the rpmsg buffers and add those
to the virtqueues. The rpmsg buffers are however added and removed from
the virtqueues dynamically, so this should not impact the firmware - it
has to be able to cope with a shortage of send buffers anyways.

The real difference was that we with this change allocated vrings for
all virtio devices, not only the first.

(And if someone has out-of-tree patches for static rpmsg devices these
will be probed before we actually start the remoteproc)


With the subdevices series in place ([1] in particular) the order is
changed to the following:

rproc_add()
  rproc_fw_config_virtio()
    rproc_boot()
      rproc_handle_vdev()
        rproc_alloc_vring()
        rproc_alloc_vring()
      rproc_handle_vdev()
        rproc_alloc_vring()
        rproc_alloc_vring()
      rproc->ops->start()
      rproc_probe_subdevices()
        rproc_add_virtio_dev()
          rpmsg_probe()
            rproc_virtio_find_vqs()
            dma_alloc_coherent()
          rpmsg_probe()
            rproc_virtio_find_vqs()
            dma_alloc_coherent()

With this the ordering wrt the first virtio device is restored and the
order of allocation for any additional virtio devices are now also
correct.


So, in my view the staged patches for v4.10 are doing the right thing
and it looks like v4.9 will be the outlier - but afaict this should be
fine (and we're too late to redesign it now).

[1] a863af5d4193 ("remoteproc: virtio: Anchor vring life cycle in vdev")
[2] ddf711872c9d ("remoteproc: Introduce auto-boot flag")

Regards,
Bjorn

> Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
> ---
>  drivers/remoteproc/remoteproc_core.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> index f0f6ec1..15e9331 100644
> --- a/drivers/remoteproc/remoteproc_core.c
> +++ b/drivers/remoteproc/remoteproc_core.c
> @@ -913,6 +913,14 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
>  		goto clean_up_resources;
>  	}
>  
> +	/* probe any subdevices for the remote processor */
> +	ret = rproc_probe_subdevices(rproc);
> +	if (ret) {
> +		dev_err(dev, "failed to probe subdevices for %s: %d\n",
> +			rproc->name, ret);
> +		goto clean_up_resources;
> +	}
> +
>  	/*
>  	 * The starting device has been given the rproc->table_ptr as the
>  	 * resource table. The address of the vring along with the other
> @@ -932,14 +940,6 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
>  		goto clean_up_resources;
>  	}
>  
> -	/* probe any subdevices for the remote processor */
> -	ret = rproc_probe_subdevices(rproc);
> -	if (ret) {
> -		dev_err(dev, "failed to probe subdevices for %s: %d\n",
> -			rproc->name, ret);
> -		goto stop_rproc;
> -	}
> -
>  	rproc->state = RPROC_RUNNING;
>  
>  	dev_info(dev, "remote processor %s is now up\n", rproc->name);
> -- 
> 1.9.1
> 

  parent reply	other threads:[~2016-12-03  1:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-25 17:49 [PATCH 1/1] remoteproc: core: probe subdevices before booting coprocessor Loic Pallardy
2016-11-29  9:20 ` Lee Jones
2016-12-03  1:33 ` Bjorn Andersson [this message]
2016-12-05  9:04   ` loic pallardy

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=20161203013345.GG9322@tuxbot \
    --to=bjorn.andersson@linaro.org \
    --cc=kernel@stlinux.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=loic.pallardy@st.com \
    --cc=ohad@wizery.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.