From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: Tinghan Shen <tinghan.shen@mediatek.com>
Cc: Bjorn Andersson <andersson@kernel.org>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org,
Project_Global_Chrome_Upstream_Group@mediatek.com
Subject: Re: [PATCH v13 07/11] remoteproc: mediatek: Add scp_boot_peers and scp_shutdown_peers operations
Date: Mon, 12 Jun 2023 11:54:54 -0600 [thread overview]
Message-ID: <ZIdb7n3LWKRekOdu@p14s> (raw)
In-Reply-To: <20230607072222.8628-8-tinghan.shen@mediatek.com>
On Wed, Jun 07, 2023 at 03:22:18PM +0800, Tinghan Shen wrote:
> Due to that SCP core 0 controls the SCP clock and SRAM power, add two
> new mtk_scp_of_data operations, scp_boot_peers and scp_shutdown_peers,
> to manage the boot sequence and watchdog timeout handling of SCP core 1.
> It ensures that core 1 boots after or shuts down before core 0 for
> maintaining the proper control flow over SCP core 1.
>
> Signed-off-by: Tinghan Shen <tinghan.shen@mediatek.com>
> ---
> drivers/remoteproc/mtk_common.h | 3 ++
> drivers/remoteproc/mtk_scp.c | 55 +++++++++++++++++++++++++++++++++
> 2 files changed, 58 insertions(+)
>
> diff --git a/drivers/remoteproc/mtk_common.h b/drivers/remoteproc/mtk_common.h
> index 56395e8664cb..0bfd242c41cc 100644
> --- a/drivers/remoteproc/mtk_common.h
> +++ b/drivers/remoteproc/mtk_common.h
> @@ -93,6 +93,8 @@ struct mtk_scp_of_data {
> void (*scp_reset_deassert)(struct mtk_scp *scp);
> void (*scp_stop)(struct mtk_scp *scp);
> void *(*scp_da_to_va)(struct mtk_scp *scp, u64 da, size_t len);
> + void (*scp_boot_peers)(struct mtk_scp *scp);
> + void (*scp_shutdown_peers)(struct mtk_scp *scp);
This isn't what I suggested in my previous email. This solution will not work
if a user is looking to independently start/stop CPU1 from sysfs.
I will not go further with this revision.
Mathieu
>
> u32 host_to_scp_reg;
> u32 host_to_scp_int_bit;
> @@ -130,6 +132,7 @@ struct mtk_scp {
> struct rproc_subdev *rpmsg_subdev;
>
> struct list_head elem;
> + struct list_head *cluster;
> };
>
> /**
> diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c
> index d644e232dfec..edbf71f4c21e 100644
> --- a/drivers/remoteproc/mtk_scp.c
> +++ b/drivers/remoteproc/mtk_scp.c
> @@ -74,8 +74,21 @@ void scp_put(struct mtk_scp *scp)
> }
> EXPORT_SYMBOL_GPL(scp_put);
>
> +static void mt8195_scp_shutdown_peers(struct mtk_scp *scp)
> +{
> + struct mtk_scp *next_scp;
> +
> + next_scp = list_next_entry(scp, elem);
> + list_for_each_entry_from(next_scp, scp->cluster, elem) {
> + rproc_shutdown(next_scp->rproc);
> + }
> +}
> +
> static void scp_wdt_handler(struct mtk_scp *scp, u32 scp_to_host)
> {
> + if (scp->data->scp_shutdown_peers)
> + scp->data->scp_shutdown_peers(scp);
> +
> dev_err(scp->dev, "SCP watchdog timeout! 0x%x", scp_to_host);
> rproc_report_crash(scp->rproc, RPROC_WATCHDOG);
> }
> @@ -539,6 +552,18 @@ static int scp_parse_fw(struct rproc *rproc, const struct firmware *fw)
> return ret;
> }
>
> +static void mt8195_scp_boot_peers(struct mtk_scp *scp)
> +{
> + struct mtk_scp *next_scp;
> +
> + if (scp->cluster && !list_empty(scp->cluster)) {
> + next_scp = list_next_entry(scp, elem);
> + list_for_each_entry_from(next_scp, scp->cluster, elem) {
> + rproc_boot(next_scp->rproc);
> + }
> + }
> +}
> +
> static int scp_start(struct rproc *rproc)
> {
> struct mtk_scp *scp = rproc->priv;
> @@ -574,6 +599,9 @@ static int scp_start(struct rproc *rproc)
> clk_disable_unprepare(scp->clk);
> dev_info(dev, "SCP is ready. FW version %s\n", run->fw_ver);
>
> + if (scp->data->scp_boot_peers)
> + scp->data->scp_boot_peers(scp);
> +
> return 0;
>
> stop:
> @@ -977,6 +1005,8 @@ static int scp_add_single_core(struct platform_device *pdev)
> if (IS_ERR(scp))
> return PTR_ERR(scp);
>
> + scp->cluster = cluster;
> +
> ret = rproc_add(scp->rproc);
> if (ret) {
> dev_err(dev, "Failed to add rproc\n");
> @@ -989,6 +1019,15 @@ static int scp_add_single_core(struct platform_device *pdev)
> return 0;
> }
>
> +static void scp_rproc_boot_core0(const struct firmware *fw, void *context)
> +{
> + struct rproc *rproc = context;
> +
> + rproc_boot(rproc);
> +
> + release_firmware(fw);
> +}
> +
> static int scp_add_multi_core(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> @@ -1029,6 +1068,10 @@ static int scp_add_multi_core(struct platform_device *pdev)
> goto init_fail;
> }
>
> + /* boot after all cores are discovered */
> + scp->rproc->auto_boot = false;
> + scp->cluster = cluster;
> +
> ret = rproc_add(scp->rproc);
> if (ret) {
> dev_err(dev, "Failed to add rproc of core %d\n", core_id);
> @@ -1041,6 +1084,16 @@ static int scp_add_multi_core(struct platform_device *pdev)
> core_id++;
> }
>
> + /* boot core 0, and other cores are booted following core 0 */
> + scp = list_first_entry(cluster, struct mtk_scp, elem);
> + ret = request_firmware_nowait(THIS_MODULE, FW_ACTION_UEVENT,
> + scp->rproc->firmware, &scp->rproc->dev, GFP_KERNEL,
> + scp->rproc, scp_rproc_boot_core0);
> + if (ret < 0) {
> + dev_err(dev, "request_firmware_nowait err: %d\n", ret);
> + goto init_fail;
> + }
> +
> return 0;
>
> init_fail:
> @@ -1198,6 +1251,8 @@ static const struct mtk_scp_of_data mt8195_of_data = {
> .scp_reset_deassert = mt8192_scp_reset_deassert,
> .scp_stop = mt8195_scp_stop,
> .scp_da_to_va = mt8192_scp_da_to_va,
> + .scp_boot_peers = mt8195_scp_boot_peers,
> + .scp_shutdown_peers = mt8195_scp_shutdown_peers,
> .host_to_scp_reg = MT8192_GIPC_IN_SET,
> .host_to_scp_int_bit = MT8192_HOST_IPC_INT_BIT,
> };
> --
> 2.18.0
>
next prev parent reply other threads:[~2023-06-12 17:55 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-07 7:22 [PATCH v13 00/11] Add support for MT8195 SCP 2nd core Tinghan Shen
2023-06-07 7:22 ` [PATCH v13 01/11] dt-bindings: remoteproc: mediatek: Improve the rpmsg subnode definition Tinghan Shen
2023-06-07 7:39 ` AngeloGioacchino Del Regno
2023-06-07 7:22 ` [PATCH v13 02/11] arm64: dts: mediatek: Update the node name of SCP rpmsg subnode Tinghan Shen
2023-06-07 7:22 ` [PATCH v13 03/11] dt-bindings: remoteproc: mediatek: Support MT8195 dual-core SCP Tinghan Shen
2023-06-07 7:22 ` [PATCH v13 04/11] remoteproc: mediatek: Add MT8195 SCP core 1 operations Tinghan Shen
2023-06-07 7:22 ` [PATCH v13 05/11] remoteproc: mediatek: Introduce cluster on single-core SCP Tinghan Shen
2023-06-07 7:43 ` AngeloGioacchino Del Regno
2023-06-07 8:00 ` TingHan Shen (沈廷翰)
2023-06-07 8:01 ` AngeloGioacchino Del Regno
2023-06-12 17:25 ` Mathieu Poirier
2023-06-14 8:13 ` TingHan Shen (沈廷翰)
2023-06-15 16:48 ` Mathieu Poirier
2023-06-07 7:22 ` [PATCH v13 06/11] remoteproc: mediatek: Probe multi-core SCP Tinghan Shen
2023-06-07 7:44 ` AngeloGioacchino Del Regno
2023-06-07 7:22 ` [PATCH v13 07/11] remoteproc: mediatek: Add scp_boot_peers and scp_shutdown_peers operations Tinghan Shen
2023-06-07 7:49 ` AngeloGioacchino Del Regno
2023-06-12 17:54 ` Mathieu Poirier [this message]
2023-06-07 7:22 ` [PATCH v13 08/11] remoteproc: mediatek: Setup MT8195 SCP core 1 SRAM offset Tinghan Shen
2023-06-07 7:22 ` [PATCH v13 09/11] remoteproc: mediatek: Handle MT8195 SCP core 1 watchdog timeout Tinghan Shen
2023-06-07 7:22 ` [PATCH v13 10/11] remoteproc: mediatek: Refine ipi handler error message Tinghan Shen
2023-06-07 7:22 ` [PATCH v13 11/11] arm64: dts: mediatek: mt8195: Add SCP 2nd core Tinghan Shen
2023-06-22 10:00 ` [PATCH v13 00/11] Add support for MT8195 " AngeloGioacchino Del Regno
2023-06-22 17:17 ` Mathieu Poirier
2023-06-23 8:11 ` AngeloGioacchino Del Regno
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=ZIdb7n3LWKRekOdu@p14s \
--to=mathieu.poirier@linaro.org \
--cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
--cc=andersson@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski+dt@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=matthias.bgg@gmail.com \
--cc=robh+dt@kernel.org \
--cc=tinghan.shen@mediatek.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).