Hi,

On Mon, Jun 22, 2020 at 12:18:04AM -0700, Bjorn Andersson wrote:
> On Mon 22 Jun 00:07 PDT 2020, Bjorn Andersson wrote:
> 
> > On Mon 01 Jun 10:51 PDT 2020, Mathieu Poirier wrote:
> > 
> > > Introducing function rproc_attach() to enact the same actions as
> > > rproc_start(), but without the steps related to the handling of
> > > a firmware image.  That way we can properly deal with scenarios
> > > where the remoteproc core needs to attach with a remote processsor
> > > that has been booted by another entity.
> > > 
> > > Signed-off-by: Mathieu Poirier <[email protected]>
> > > ---
> > >  drivers/remoteproc/remoteproc_core.c | 42 ++++++++++++++++++++++++++++
> > >  1 file changed, 42 insertions(+)
> > > 
> > > diff --git a/drivers/remoteproc/remoteproc_core.c 
> > > b/drivers/remoteproc/remoteproc_core.c
> > > index 9f04c30c4aaf..0b323f6b554b 100644
> > > --- a/drivers/remoteproc/remoteproc_core.c
> > > +++ b/drivers/remoteproc/remoteproc_core.c
> > > @@ -1370,6 +1370,48 @@ static int rproc_start(struct rproc *rproc, const 
> > > struct firmware *fw)
> > >   return ret;
> > >  }
> > >  
> > > +static int __maybe_unused rproc_attach(struct rproc *rproc)
> > > +{
> > > + struct device *dev = &rproc->dev;
> > > + int ret;
> > > +
> > 
> > For the case where we're going DETACHED -> RUNNING - > OFFLINE we
> > need to consider the pm_runtime (and prepare/unprepare) state of the
> > device as well...
> > 
> 
> Missed that you do indeed pm_runtime_get() in the calling function, so I
> think we're good on that part. Still need how to actually implement
> that (and the prepare/unprepare), in particular if we're moving into
> detaching a remoteproc.

I had planned to look at the interaction between the PM runtime and 
prepare/unprepare
callbacks later today.  Depending on what I find I may end up modifying this
patch... 

> 
> > 
> > Apart from that I think this looks good.
> > 
> 
> Reviewed-by: Bjorn Andersson <[email protected]>
> 
> Regards,
> Bjorn
> 
> > Regards,
> > Bjorn
> > 
> > > + ret = rproc_prepare_subdevices(rproc);
> > > + if (ret) {
> > > +         dev_err(dev, "failed to prepare subdevices for %s: %d\n",
> > > +                 rproc->name, ret);
> > > +         goto out;
> > > + }
> > > +
> > > + /* Attach to the remote processor */
> > > + ret = rproc_attach_device(rproc);
> > > + if (ret) {
> > > +         dev_err(dev, "can't attach to rproc %s: %d\n",
> > > +                 rproc->name, ret);
> > > +         goto unprepare_subdevices;
> > > + }
> > > +
> > > + /* Start any subdevices for the remote processor */
> > > + ret = rproc_start_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 attached\n", rproc->name);
> > > +
> > > + return 0;
> > > +
> > > +stop_rproc:
> > > + rproc->ops->stop(rproc);
> > > +unprepare_subdevices:
> > > + rproc_unprepare_subdevices(rproc);
> > > +out:
> > > + return ret;
> > > +}
> > > +
> > >  /*
> > >   * take a firmware and boot a remote processor with it.
> > >   */
> > > -- 
> > > 2.20.1
> > > 

Reply via email to