All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: bjorn.andersson@linaro.org
Cc: ohad@wizery.com, loic.pallardy@st.com, s-anna@ti.com,
	peng.fan@nxp.com, arnaud.pouliquen@st.com,
	fabien.dessenne@st.com, linux-remoteproc@vger.kernel.org
Subject: [PATCH 03/11] remoteproc: stm32: Decouple rproc from DT parsing
Date: Tue, 24 Mar 2020 16:03:21 -0600	[thread overview]
Message-ID: <20200324220329.15523-4-mathieu.poirier@linaro.org> (raw)
In-Reply-To: <20200324220329.15523-1-mathieu.poirier@linaro.org>

Remove the remote processor from the process of parsing the device tree
since (1) there is no correlation between them and (2) to use the
information that was gathered to make a decision on whether to
synchronise with the MCU or not.

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

diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c
index 0c1f0b84e057..ca60c917e218 100644
--- a/drivers/remoteproc/stm32_rproc.c
+++ b/drivers/remoteproc/stm32_rproc.c
@@ -538,12 +538,11 @@ static int stm32_rproc_get_syscon(struct device_node *np, const char *prop,
 	return err;
 }
 
-static int stm32_rproc_parse_dt(struct platform_device *pdev)
+static int stm32_rproc_parse_dt(struct platform_device *pdev,
+				struct stm32_rproc *ddata, bool *auto_boot)
 {
 	struct device *dev = &pdev->dev;
 	struct device_node *np = dev->of_node;
-	struct rproc *rproc = platform_get_drvdata(pdev);
-	struct stm32_rproc *ddata = rproc->priv;
 	struct stm32_syscon tz;
 	unsigned int tzen;
 	int err, irq;
@@ -589,7 +588,7 @@ static int stm32_rproc_parse_dt(struct platform_device *pdev)
 
 	err = regmap_read(tz.map, tz.reg, &tzen);
 	if (err) {
-		dev_err(&rproc->dev, "failed to read tzen\n");
+		dev_err(dev, "failed to read tzen\n");
 		return err;
 	}
 	ddata->secured_soc = tzen & tz.mask;
@@ -605,7 +604,7 @@ static int stm32_rproc_parse_dt(struct platform_device *pdev)
 	if (err)
 		dev_warn(dev, "failed to get pdds\n");
 
-	rproc->auto_boot = of_property_read_bool(np, "st,auto-boot");
+	*auto_boot = of_property_read_bool(np, "st,auto-boot");
 
 	return stm32_rproc_of_memory_translations(pdev, ddata);
 }
@@ -616,18 +615,29 @@ static int stm32_rproc_probe(struct platform_device *pdev)
 	struct stm32_rproc *ddata;
 	struct device_node *np = dev->of_node;
 	struct rproc *rproc;
+	bool auto_boot = false;
 	int ret;
 
 	ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32));
 	if (ret)
 		return ret;
 
-	rproc = rproc_alloc(dev, np->name, &st_rproc_ops, NULL, sizeof(*ddata));
-	if (!rproc)
+	ddata = kzalloc(sizeof(*ddata), GFP_KERNEL);
+	if (!ddata)
 		return -ENOMEM;
 
+	ret = stm32_rproc_parse_dt(pdev, ddata, &auto_boot);
+	if (ret)
+		goto free_ddata;
+
+	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 = rproc->priv;
 	ddata->workqueue = create_workqueue(dev_name(dev));
 	if (!ddata->workqueue) {
 		dev_err(dev, "cannot create workqueue\n");
@@ -635,20 +645,20 @@ static int stm32_rproc_probe(struct platform_device *pdev)
 		goto free_rproc;
 	}
 
-	platform_set_drvdata(pdev, rproc);
+	memcpy(rproc->priv, ddata, sizeof(*ddata));
 
-	ret = stm32_rproc_parse_dt(pdev);
-	if (ret)
-		goto free_wkq;
+	platform_set_drvdata(pdev, rproc);
 
 	ret = stm32_rproc_request_mbox(rproc);
 	if (ret)
-		goto free_rproc;
+		goto free_wkq;
 
 	ret = rproc_add(rproc);
 	if (ret)
 		goto free_mb;
 
+	kfree(ddata);
+
 	return 0;
 
 free_mb:
@@ -661,6 +671,8 @@ static int stm32_rproc_probe(struct platform_device *pdev)
 		device_init_wakeup(dev, false);
 	}
 	rproc_free(rproc);
+free_ddata:
+	kfree(ddata);
 	return ret;
 }
 
-- 
2.20.1

  parent reply	other threads:[~2020-03-24 22:03 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-24 22:03 [PATCH 00/11] remoteproc: stm32: Add support for synchronisation with MCU Mathieu Poirier
2020-03-24 22:03 ` [PATCH 01/11] remoteproc: stm32: Decouple rproc from memory translation Mathieu Poirier
2020-03-27 16:51   ` Loic PALLARDY
2020-03-24 22:03 ` [PATCH 02/11] remoteproc: stm32: Request IRQ with platform device Mathieu Poirier
2020-03-27 16:54   ` Loic PALLARDY
2020-03-24 22:03 ` Mathieu Poirier [this message]
2020-03-27 16:55   ` [PATCH 03/11] remoteproc: stm32: Decouple rproc from DT parsing Loic PALLARDY
2020-03-24 22:03 ` [PATCH 04/11] remoteproc: stm32: Remove memory translation " Mathieu Poirier
2020-03-27 16:55   ` Loic PALLARDY
2020-03-24 22:03 ` [PATCH 05/11] remoteproc: stm32: Parse syscon that will manage M4 synchronisation Mathieu Poirier
2020-03-27 16:56   ` Loic PALLARDY
2020-03-24 22:03 ` [PATCH 06/11] remoteproc: stm32: Get coprocessor state Mathieu Poirier
2020-03-27 16:58   ` Loic PALLARDY
2020-03-30 22:44     ` Mathieu Poirier
2020-03-24 22:03 ` [PATCH 07/11] remoteproc: stm32: Get loaded resource table for synchronisation Mathieu Poirier
2020-03-27 16:59   ` Loic PALLARDY
2020-03-24 22:03 ` [PATCH 08/11] remoteproc: stm32: Introduce new start and stop ops " Mathieu Poirier
2020-03-27 17:04   ` Loic PALLARDY
2020-03-30 22:56     ` Mathieu Poirier
2020-03-24 22:03 ` [PATCH 09/11] remoteproc: stm32: Introduce new parse fw " Mathieu Poirier
2020-03-27 17:05   ` Loic PALLARDY
2020-03-24 22:03 ` [PATCH 10/11] remoteproc: stm32: Introduce new loaded rsc " Mathieu Poirier
2020-03-27 17:05   ` Loic PALLARDY
2020-03-24 22:03 ` [PATCH 11/11] remoteproc: stm32: Allocate rproc for synchronisation with MCU Mathieu Poirier
2020-03-27 17:11   ` Loic PALLARDY
2020-03-27 21:49     ` Mathieu Poirier

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=20200324220329.15523-4-mathieu.poirier@linaro.org \
    --to=mathieu.poirier@linaro.org \
    --cc=arnaud.pouliquen@st.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=fabien.dessenne@st.com \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=loic.pallardy@st.com \
    --cc=ohad@wizery.com \
    --cc=peng.fan@nxp.com \
    --cc=s-anna@ti.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.