diff mbox series

[11/11] remoteproc: stm32: Allocate rproc for synchronisation with MCU

Message ID 20200324220329.15523-12-mathieu.poirier@linaro.org
State New, archived
Headers show
Series remoteproc: stm32: Add support for synchronisation with MCU | expand

Commit Message

Mathieu Poirier March 24, 2020, 10:03 p.m. UTC
Allocate remote processor structure with state machine if the MCU
has already been started by an external entity.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 drivers/remoteproc/stm32_rproc.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

Comments

Loic PALLARDY March 27, 2020, 5:11 p.m. UTC | #1
Hi Mathieu,

> -----Original Message-----
> From: linux-remoteproc-owner@vger.kernel.org <linux-remoteproc-
> owner@vger.kernel.org> On Behalf Of Mathieu Poirier
> Sent: mardi 24 mars 2020 23:03
> To: bjorn.andersson@linaro.org
> Cc: ohad@wizery.com; Loic PALLARDY <loic.pallardy@st.com>; s-
> anna@ti.com; peng.fan@nxp.com; Arnaud POULIQUEN
> <arnaud.pouliquen@st.com>; Fabien DESSENNE
> <fabien.dessenne@st.com>; linux-remoteproc@vger.kernel.org
> Subject: [PATCH 11/11] remoteproc: stm32: Allocate rproc for
> synchronisation with MCU
> 
> Allocate remote processor structure with state machine if the MCU
> has already been started by an external entity.
> 
> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> ---
>  drivers/remoteproc/stm32_rproc.c | 19 ++++++++++++++++---
>  1 file changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/remoteproc/stm32_rproc.c
> b/drivers/remoteproc/stm32_rproc.c
> index 07be306c0fb1..f320ef9ee286 100644
> --- a/drivers/remoteproc/stm32_rproc.c
> +++ b/drivers/remoteproc/stm32_rproc.c
> @@ -608,7 +608,7 @@ 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_sync_stop,
>  	.kick		= stm32_rproc_kick,
> @@ -616,6 +616,12 @@ static __maybe_unused struct rproc_ops
> st_rproc_sync_ops = {
>  	.find_loaded_rsc_table =
> stm32_rproc_sync_elf_find_loaded_rsc_table,
>  };
> 
> +static struct rproc_sync_states st_sync_states = {
> +	.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" },
>  	{},
> @@ -847,15 +853,22 @@ static int stm32_rproc_probe(struct
> platform_device *pdev)
>  		ret = stm32_rproc_get_loaded_rsc_table(pdev, ddata);
>  		if (ret)
>  			goto free_ddata;
> +
> +		rproc = rproc_alloc_state_machine(dev, np->name,
> &st_rproc_ops,
> +						  &st_rproc_sync_ops,
> +						  &st_sync_states, NULL,
> +						  sizeof(*ddata));
Could we have only one call to rproc_alloc_state_machine(), simply configuring
st_sync_states according to m4_state and other DT properties?

Regards,
Loic
> +	} else {
> +		rproc = rproc_alloc(dev, np->name, &st_rproc_ops,
> +				    NULL, sizeof(*ddata));
> +		rproc->auto_boot = auto_boot;
>  	}
> 
> -	rproc = rproc_alloc(dev, np->name, &st_rproc_ops, NULL,
> sizeof(*ddata));
>  	if (!rproc) {
>  		ret = -ENOMEM;
>  		goto free_ddata;
>  	}
> 
> -	rproc->auto_boot = auto_boot;
>  	rproc->has_iommu = false;
>  	ddata->workqueue = create_workqueue(dev_name(dev));
>  	if (!ddata->workqueue) {
> --
> 2.20.1
Mathieu Poirier March 27, 2020, 9:49 p.m. UTC | #2
On Fri, Mar 27, 2020 at 05:11:37PM +0000, Loic PALLARDY wrote:
> Hi Mathieu,
> 
> > -----Original Message-----
> > From: linux-remoteproc-owner@vger.kernel.org <linux-remoteproc-
> > owner@vger.kernel.org> On Behalf Of Mathieu Poirier
> > Sent: mardi 24 mars 2020 23:03
> > To: bjorn.andersson@linaro.org
> > Cc: ohad@wizery.com; Loic PALLARDY <loic.pallardy@st.com>; s-
> > anna@ti.com; peng.fan@nxp.com; Arnaud POULIQUEN
> > <arnaud.pouliquen@st.com>; Fabien DESSENNE
> > <fabien.dessenne@st.com>; linux-remoteproc@vger.kernel.org
> > Subject: [PATCH 11/11] remoteproc: stm32: Allocate rproc for
> > synchronisation with MCU
> > 
> > Allocate remote processor structure with state machine if the MCU
> > has already been started by an external entity.
> > 
> > Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> > ---
> >  drivers/remoteproc/stm32_rproc.c | 19 ++++++++++++++++---
> >  1 file changed, 16 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/remoteproc/stm32_rproc.c
> > b/drivers/remoteproc/stm32_rproc.c
> > index 07be306c0fb1..f320ef9ee286 100644
> > --- a/drivers/remoteproc/stm32_rproc.c
> > +++ b/drivers/remoteproc/stm32_rproc.c
> > @@ -608,7 +608,7 @@ 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_sync_stop,
> >  	.kick		= stm32_rproc_kick,
> > @@ -616,6 +616,12 @@ static __maybe_unused struct rproc_ops
> > st_rproc_sync_ops = {
> >  	.find_loaded_rsc_table =
> > stm32_rproc_sync_elf_find_loaded_rsc_table,
> >  };
> > 
> > +static struct rproc_sync_states st_sync_states = {
> > +	.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" },
> >  	{},
> > @@ -847,15 +853,22 @@ static int stm32_rproc_probe(struct
> > platform_device *pdev)
> >  		ret = stm32_rproc_get_loaded_rsc_table(pdev, ddata);
> >  		if (ret)
> >  			goto free_ddata;
> > +
> > +		rproc = rproc_alloc_state_machine(dev, np->name,
> > &st_rproc_ops,
> > +						  &st_rproc_sync_ops,
> > +						  &st_sync_states, NULL,
> > +						  sizeof(*ddata));
> Could we have only one call to rproc_alloc_state_machine(), simply configuring
> st_sync_states according to m4_state and other DT properties?

Yes, very much so - I'll do that for V2.

Mathieu

> 
> Regards,
> Loic
> > +	} else {
> > +		rproc = rproc_alloc(dev, np->name, &st_rproc_ops,
> > +				    NULL, sizeof(*ddata));
> > +		rproc->auto_boot = auto_boot;
> >  	}
> > 
> > -	rproc = rproc_alloc(dev, np->name, &st_rproc_ops, NULL,
> > sizeof(*ddata));
> >  	if (!rproc) {
> >  		ret = -ENOMEM;
> >  		goto free_ddata;
> >  	}
> > 
> > -	rproc->auto_boot = auto_boot;
> >  	rproc->has_iommu = false;
> >  	ddata->workqueue = create_workqueue(dev_name(dev));
> >  	if (!ddata->workqueue) {
> > --
> > 2.20.1
>
diff mbox series

Patch

diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c
index 07be306c0fb1..f320ef9ee286 100644
--- a/drivers/remoteproc/stm32_rproc.c
+++ b/drivers/remoteproc/stm32_rproc.c
@@ -608,7 +608,7 @@  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_sync_stop,
 	.kick		= stm32_rproc_kick,
@@ -616,6 +616,12 @@  static __maybe_unused struct rproc_ops st_rproc_sync_ops = {
 	.find_loaded_rsc_table = stm32_rproc_sync_elf_find_loaded_rsc_table,
 };
 
+static struct rproc_sync_states st_sync_states = {
+	.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" },
 	{},
@@ -847,15 +853,22 @@  static int stm32_rproc_probe(struct platform_device *pdev)
 		ret = stm32_rproc_get_loaded_rsc_table(pdev, ddata);
 		if (ret)
 			goto free_ddata;
+
+		rproc = rproc_alloc_state_machine(dev, np->name, &st_rproc_ops,
+						  &st_rproc_sync_ops,
+						  &st_sync_states, NULL,
+						  sizeof(*ddata));
+	} else {
+		rproc = rproc_alloc(dev, np->name, &st_rproc_ops,
+				    NULL, sizeof(*ddata));
+		rproc->auto_boot = auto_boot;
 	}
 
-	rproc = rproc_alloc(dev, np->name, &st_rproc_ops, NULL, sizeof(*ddata));
 	if (!rproc) {
 		ret = -ENOMEM;
 		goto free_ddata;
 	}
 
-	rproc->auto_boot = auto_boot;
 	rproc->has_iommu = false;
 	ddata->workqueue = create_workqueue(dev_name(dev));
 	if (!ddata->workqueue) {