From: Tinghan Shen <tinghan.shen@mediatek.com>
To: Bjorn Andersson <bjorn.andersson@linaro.org>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
Rob Herring <robh+dt@kernel.org>,
"Krzysztof Kozlowski" <krzysztof.kozlowski+dt@linaro.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
Lee Jones <lee.jones@linaro.org>,
Benson Leung <bleung@chromium.org>,
Guenter Roeck <groeck@chromium.org>,
Daisuke Nojiri <dnojiri@chromium.org>,
Sebastian Reichel <sebastian.reichel@collabora.com>,
"Dustin L. Howett" <dustin@howett.net>,
Tzung-Bi Shih <tzungbi@kernel.org>,
Tinghan Shen <tinghan.shen@mediatek.com>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
Prashant Malani <pmalani@chromium.org>,
"Enric Balletbo i Serra" <enric.balletbo@collabora.com>,
Brian Norris <briannorris@chromium.org>
Cc: <linux-remoteproc@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-mediatek@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <chrome-platform@lists.linux.dev>,
<Project_Global_Chrome_Upstream_Group@mediatek.com>,
<weishunc@google.com>
Subject: [PATCH v1 13/15] remoteproc: mediatek: Wait SCP core 1 probe done
Date: Wed, 1 Jun 2022 19:21:59 +0800 [thread overview]
Message-ID: <20220601112201.15510-14-tinghan.shen@mediatek.com> (raw)
In-Reply-To: <20220601112201.15510-1-tinghan.shen@mediatek.com>
SCP core 1 driver probing must finish before start loading SCP core 1
image. Add a simple flag checking mechanism when preparing SCP core 1
subdevice.
Signed-off-by: Tinghan Shen <tinghan.shen@mediatek.com>
---
drivers/remoteproc/mtk_common.h | 1 +
drivers/remoteproc/mtk_scp_dual.c | 2 ++
drivers/remoteproc/mtk_scp_subdev.c | 35 ++++++++++++++++++++++++++++-
3 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/drivers/remoteproc/mtk_common.h b/drivers/remoteproc/mtk_common.h
index a5c26e56277d..464d013ed6b2 100644
--- a/drivers/remoteproc/mtk_common.h
+++ b/drivers/remoteproc/mtk_common.h
@@ -153,6 +153,7 @@ struct mtk_scp {
struct rproc_subdev *rpmsg_subdev;
struct rproc_subdev *dual_subdev;
+ int dual_probe_done;
};
/**
diff --git a/drivers/remoteproc/mtk_scp_dual.c b/drivers/remoteproc/mtk_scp_dual.c
index 90c49716dd39..ab62ab54175c 100644
--- a/drivers/remoteproc/mtk_scp_dual.c
+++ b/drivers/remoteproc/mtk_scp_dual.c
@@ -266,6 +266,8 @@ static int scp_dual_probe(struct platform_device *pdev)
if (ret)
goto remove_ipi;
+ scp->dual_probe_done = 1;
+
return 0;
remove_ipi:
diff --git a/drivers/remoteproc/mtk_scp_subdev.c b/drivers/remoteproc/mtk_scp_subdev.c
index 197fb207c756..71dc6fcad61a 100644
--- a/drivers/remoteproc/mtk_scp_subdev.c
+++ b/drivers/remoteproc/mtk_scp_subdev.c
@@ -20,6 +20,7 @@ static struct mtk_scp *scp_dual_get(struct mtk_scp *scp)
struct device *dev = scp->dev;
struct device_node *np;
struct platform_device *dual_pdev;
+ struct mtk_scp *scp_dual;
np = of_parse_phandle(dev->of_node, "mediatek,scp-core", SCP_DTS_CORE_REF);
dual_pdev = of_find_device_by_node(np);
@@ -30,7 +31,11 @@ static struct mtk_scp *scp_dual_get(struct mtk_scp *scp)
return NULL;
}
- return platform_get_drvdata(dual_pdev);
+ scp_dual = platform_get_drvdata(dual_pdev);
+ if (!scp_dual)
+ put_device(&dual_pdev->dev);
+
+ return scp_dual;
}
static void scp_dual_put(struct mtk_scp *scp)
@@ -38,6 +43,33 @@ static void scp_dual_put(struct mtk_scp *scp)
put_device(scp->dev);
}
+static int scp_dual_rproc_prepare(struct rproc_subdev *subdev)
+{
+ struct scp_subdev_core *subdev_core = to_subdev_core(subdev);
+ struct mtk_scp *scp = subdev_core->main_scp;
+ unsigned long timeout;
+
+ timeout = jiffies + msecs_to_jiffies(100);
+ while (1) {
+ struct mtk_scp *scp_dual = scp_dual_get(scp);
+
+ if (scp_dual && scp_dual->dual_probe_done) {
+ scp_dual_put(scp_dual);
+ break;
+ }
+
+ if (scp_dual && !scp_dual->dual_probe_done)
+ scp_dual_put(scp_dual);
+
+ if (time_after(jiffies, timeout)) {
+ dev_err(scp->dev, "scp-dual probe timeout\n");
+ return -ETIMEDOUT;
+ }
+ }
+
+ return 0;
+}
+
static int scp_dual_rproc_start(struct rproc_subdev *subdev)
{
struct scp_subdev_core *subdev_core = to_subdev_core(subdev);
@@ -111,6 +143,7 @@ struct rproc_subdev *scp_dual_create_subdev(struct mtk_scp *scp)
subdev_core->main_scp = scp;
subdev_core->scp_dual_wdt_timeout = scp_dual_wdt_handler;
+ subdev_core->subdev.prepare = scp_dual_rproc_prepare;
subdev_core->subdev.start = scp_dual_rproc_start;
subdev_core->subdev.stop = scp_dual_rproc_stop;
--
2.18.0
next prev parent reply other threads:[~2022-06-01 11:22 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-01 11:21 [PATCH v1 00/15] Add support for MT8195 SCP 2nd core Tinghan Shen
2022-06-01 11:21 ` [PATCH v1 01/15] dt-binding: remoteproc: mediatek: Support dual-core SCP Tinghan Shen
2022-06-01 11:50 ` Krzysztof Kozlowski
2022-06-02 5:21 ` Tinghan Shen
2022-06-02 6:55 ` Krzysztof Kozlowski
2022-06-02 8:58 ` Tinghan Shen
2022-06-02 10:37 ` Krzysztof Kozlowski
2022-06-02 11:29 ` Tinghan Shen
2022-06-02 12:02 ` Krzysztof Kozlowski
2022-06-01 11:21 ` [PATCH v1 02/15] remoteproc: Kconfig: Add mt8195 SCP dual core configuration Tinghan Shen
2022-06-01 11:21 ` [PATCH v1 03/15] remoteproc: mediatek: Support hanlding scp core 1 wdt timeout Tinghan Shen
2022-06-01 11:21 ` [PATCH v1 04/15] remoteproc: mediatek: Add SCP core 1 register definitions Tinghan Shen
2022-06-01 11:21 ` [PATCH v1 05/15] remoteproc: mediatek: Add SCP core 1 driver for dual-core scp Tinghan Shen
2022-06-06 9:15 ` AngeloGioacchino Del Regno
2022-06-06 9:52 ` Tinghan Shen
2022-06-06 10:08 ` AngeloGioacchino Del Regno
2022-06-06 10:41 ` Tinghan Shen
2022-06-01 11:21 ` [PATCH v1 06/15] remoteproc: mediatek: Add SCP core 1 rproc operations Tinghan Shen
2022-06-01 11:21 ` [PATCH v1 07/15] remoteproc: mediatek: Add SCP core 1 reserved memory support Tinghan Shen
2022-06-01 11:21 ` [PATCH v1 08/15] remoteproc: mediatek: Add SCP core 1 interrupt support Tinghan Shen
2022-06-01 11:21 ` [PATCH v1 09/15] remoteproc: mediatek: Register SCP core 1 initialization ipi Tinghan Shen
2022-06-01 11:21 ` [PATCH v1 10/15] remoteproc: mediatek: Add chip dependent operations for SCP core 1 Tinghan Shen
2022-06-01 11:21 ` [PATCH v1 11/15] remoteproc: mediatek: Add SCP core 1 SRAM offset Tinghan Shen
2022-06-01 11:21 ` [PATCH v1 12/15] remoteproc: mediatek: Add SCP core 1 as a rproc subdevice Tinghan Shen
2022-06-01 11:21 ` Tinghan Shen [this message]
2022-06-01 11:22 ` [PATCH v1 14/15] remoteproc: mediatek: Support rpmsg for SCP core 1 Tinghan Shen
2022-06-01 11:22 ` [PATCH v1 15/15] mfd: cros_ec: Add SCP core 1 as a new CrOS EC MCU Tinghan Shen
2022-06-15 22:28 ` Lee Jones
2022-06-01 11:46 ` [PATCH v1 00/15] Add support for MT8195 SCP 2nd core Krzysztof Kozlowski
2022-06-02 3:52 ` Tinghan Shen
2022-06-02 6:56 ` Krzysztof Kozlowski
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=20220601112201.15510-14-tinghan.shen@mediatek.com \
--to=tinghan.shen@mediatek.com \
--cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
--cc=bjorn.andersson@linaro.org \
--cc=bleung@chromium.org \
--cc=briannorris@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=devicetree@vger.kernel.org \
--cc=dnojiri@chromium.org \
--cc=dustin@howett.net \
--cc=enric.balletbo@collabora.com \
--cc=groeck@chromium.org \
--cc=gustavoars@kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lee.jones@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=matthias.bgg@gmail.com \
--cc=pmalani@chromium.org \
--cc=robh+dt@kernel.org \
--cc=sebastian.reichel@collabora.com \
--cc=tzungbi@kernel.org \
--cc=weishunc@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).