Message ID | 20200424202505.29562-13-mathieu.poirier@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | remoteproc: stm32: Add support for synchronising with M4 | expand |
On 4/24/20 10:25 PM, Mathieu Poirier wrote: > Set the flags and operations to use if the M4 has been started > by another entity than the remoteproc core. > > Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> > --- > drivers/remoteproc/stm32_rproc.c | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) > > diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c > index dcae6103e3df..02dad3f51c7a 100644 > --- a/drivers/remoteproc/stm32_rproc.c > +++ b/drivers/remoteproc/stm32_rproc.c > @@ -598,13 +598,20 @@ static struct rproc_ops st_rproc_ops = { > .get_boot_addr = rproc_elf_get_boot_addr, > }; > > -static __maybe_unused struct rproc_ops st_rproc_sync_ops = { > +static struct rproc_ops st_rproc_sync_ops = { > .start = stm32_rproc_sync_start, > .stop = stm32_rproc_stop, > + .kick = stm32_rproc_kick, Seems independent of the path. > .parse_fw = stm32_rproc_sync_parse_fw, > .find_loaded_rsc_table = stm32_rproc_sync_elf_find_loaded_rsc_table, > }; > > +static struct rproc_sync_flags st_sync_flags = { > + .on_init = true, /* sync with MCU when the kernel boots */ > + .after_stop = false, /* don't resync with MCU if stopped from sysfs */ > + .after_crash = false, /* don't resync with MCU after a crash */ > +}; > + could be const > static const struct of_device_id stm32_rproc_match[] = { > { .compatible = "st,stm32mp1-m4" }, > {}, > @@ -803,6 +810,7 @@ static int stm32_rproc_probe(struct platform_device *pdev) > struct stm32_rproc *ddata; > struct device_node *np = dev->of_node; > struct rproc *rproc; > + struct rproc_sync_flags sync_flags = {0}; > unsigned int state; > bool auto_boot = false; > int ret; > @@ -837,11 +845,17 @@ static int stm32_rproc_probe(struct platform_device *pdev) > } > > if (state == M4_STATE_CRUN) { > + auto_boot = true; > + sync_flags = st_sync_flags; seems an useless copy Regards, Arnaud > ret = stm32_rproc_get_loaded_rsc_table(pdev, ddata); > if (ret) > goto free_rproc; > } > > + ret = rproc_set_state_machine(rproc, &st_rproc_sync_ops, sync_flags); > + if (ret) > + goto free_rproc; > + > rproc->auto_boot = auto_boot; > rproc->has_iommu = false; > ddata->workqueue = create_workqueue(dev_name(dev)); >
On Wed, Apr 29, 2020 at 04:47:19PM +0200, Arnaud POULIQUEN wrote: > > > On 4/24/20 10:25 PM, Mathieu Poirier wrote: > > Set the flags and operations to use if the M4 has been started > > by another entity than the remoteproc core. > > > > Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> > > --- > > drivers/remoteproc/stm32_rproc.c | 16 +++++++++++++++- > > 1 file changed, 15 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c > > index dcae6103e3df..02dad3f51c7a 100644 > > --- a/drivers/remoteproc/stm32_rproc.c > > +++ b/drivers/remoteproc/stm32_rproc.c > > @@ -598,13 +598,20 @@ static struct rproc_ops st_rproc_ops = { > > .get_boot_addr = rproc_elf_get_boot_addr, > > }; > > > > -static __maybe_unused struct rproc_ops st_rproc_sync_ops = { > > +static struct rproc_ops st_rproc_sync_ops = { > > .start = stm32_rproc_sync_start, > > .stop = stm32_rproc_stop, > > + .kick = stm32_rproc_kick, > > Seems independent of the path. I agree - on the flip side I didn't find a better place to put it. Had I did a one line patch someone would have asked me to stuff it somewhere. I'll have another look to see if I can find something decent. > > > .parse_fw = stm32_rproc_sync_parse_fw, > > .find_loaded_rsc_table = stm32_rproc_sync_elf_find_loaded_rsc_table, > > }; > > > > +static struct rproc_sync_flags st_sync_flags = { > > + .on_init = true, /* sync with MCU when the kernel boots */ > > + .after_stop = false, /* don't resync with MCU if stopped from sysfs */ > > + .after_crash = false, /* don't resync with MCU after a crash */ > > +}; > > + > could be const If I do make this a const I'll have to move the call to rproc_set_state_machine() inside the "if (state == M4_STATE_CRUN)". It also means that people won't be able to make dynamic adjustment to the synchronisation states based on specifics discovered at probe() time. They will need to declare different synchronisation ops for all the potential scenarios. I don't have a strong opinion on any of this. I'll wait a little to see what other people think. If nobody chimes in I'll make this a const in the next revision. > > > static const struct of_device_id stm32_rproc_match[] = { > > { .compatible = "st,stm32mp1-m4" }, > > {}, > > @@ -803,6 +810,7 @@ static int stm32_rproc_probe(struct platform_device *pdev) > > struct stm32_rproc *ddata; > > struct device_node *np = dev->of_node; > > struct rproc *rproc; > > + struct rproc_sync_flags sync_flags = {0}; > > unsigned int state; > > bool auto_boot = false; > > int ret; > > @@ -837,11 +845,17 @@ static int stm32_rproc_probe(struct platform_device *pdev) > > } > > > > if (state == M4_STATE_CRUN) { > > + auto_boot = true; > > + sync_flags = st_sync_flags; > > seems an useless copy > > Regards, > Arnaud > > > ret = stm32_rproc_get_loaded_rsc_table(pdev, ddata); > > if (ret) > > goto free_rproc; > > } > > > > + ret = rproc_set_state_machine(rproc, &st_rproc_sync_ops, sync_flags); > > + if (ret) > > + goto free_rproc; > > + > > rproc->auto_boot = auto_boot; > > rproc->has_iommu = false; > > ddata->workqueue = create_workqueue(dev_name(dev)); > >
diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index dcae6103e3df..02dad3f51c7a 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -598,13 +598,20 @@ static struct rproc_ops st_rproc_ops = { .get_boot_addr = rproc_elf_get_boot_addr, }; -static __maybe_unused struct rproc_ops st_rproc_sync_ops = { +static struct rproc_ops st_rproc_sync_ops = { .start = stm32_rproc_sync_start, .stop = stm32_rproc_stop, + .kick = stm32_rproc_kick, .parse_fw = stm32_rproc_sync_parse_fw, .find_loaded_rsc_table = stm32_rproc_sync_elf_find_loaded_rsc_table, }; +static struct rproc_sync_flags st_sync_flags = { + .on_init = true, /* sync with MCU when the kernel boots */ + .after_stop = false, /* don't resync with MCU if stopped from sysfs */ + .after_crash = false, /* don't resync with MCU after a crash */ +}; + static const struct of_device_id stm32_rproc_match[] = { { .compatible = "st,stm32mp1-m4" }, {}, @@ -803,6 +810,7 @@ static int stm32_rproc_probe(struct platform_device *pdev) struct stm32_rproc *ddata; struct device_node *np = dev->of_node; struct rproc *rproc; + struct rproc_sync_flags sync_flags = {0}; unsigned int state; bool auto_boot = false; int ret; @@ -837,11 +845,17 @@ static int stm32_rproc_probe(struct platform_device *pdev) } if (state == M4_STATE_CRUN) { + auto_boot = true; + sync_flags = st_sync_flags; ret = stm32_rproc_get_loaded_rsc_table(pdev, ddata); if (ret) goto free_rproc; } + ret = rproc_set_state_machine(rproc, &st_rproc_sync_ops, sync_flags); + if (ret) + goto free_rproc; + rproc->auto_boot = auto_boot; rproc->has_iommu = false; ddata->workqueue = create_workqueue(dev_name(dev));
Set the flags and operations to use if the M4 has been started by another entity than the remoteproc core. Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> --- drivers/remoteproc/stm32_rproc.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)