From: Tinghan Shen <tinghan.shen@mediatek.com> To: Bjorn Andersson <andersson@kernel.org>, Mathieu Poirier <mathieu.poirier@linaro.org>, Matthias Brugger <matthias.bgg@gmail.com>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, "Chen-Yu Tsai" <wenst@chromium.org> Cc: <linux-remoteproc@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>, Tinghan Shen <tinghan.shen@mediatek.com> Subject: [PATCH] remoteproc: mediatek: Fix compatibility of probing SCP cores Date: Wed, 20 Sep 2023 16:46:11 +0800 [thread overview] Message-ID: <20230920084611.30890-1-tinghan.shen@mediatek.com> (raw) The SCP dt-binding introduces a new SCP node format to describe the multi-core SCP HW. However, the old format for single-core SCP is co-existed with the new format. It suggests that there are two different approaches, using either the old style or the new format, to describe the single-core SCP HW in devicetree. the driver checks the immediate child node name in the SCP node to determin the format that is being utilized. The node name is expected "scp" for new format and "cros-ec-rpmsg" for the old format. However, the expected node name for old format didn't defined in earlier SCP dt-binding and the old node name is "cros_ec" in old devicetree. So, this checking breaks the compatibility with old SCP devicetree. In order to distinguish between the various forms of SCP devicetree and maintain compatibility with the previous SCP devicetree, this fix verifies the existence of the compatible name "mediatek,scp-core" introduced in the new format. Reported-by: Laura Nao <laura.nao@collabora.com> Fixes: 1fdbf0cdde98 ("remoteproc: mediatek: Probe SCP cluster on multi-core SCP") Signed-off-by: Tinghan Shen <tinghan.shen@mediatek.com> --- drivers/remoteproc/mtk_scp.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c index ea227b566c54..76472e50c8f5 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -1144,29 +1144,29 @@ static int scp_add_multi_core(struct platform_device *pdev, return ret; } -static int scp_is_single_core(struct platform_device *pdev) +static bool scp_find_core_node(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *np = dev_of_node(dev); struct device_node *child; + int found = 0; - child = of_get_next_available_child(np, NULL); - if (!child) - return dev_err_probe(dev, -ENODEV, "No child node\n"); + for_each_child_of_node(np, child) { + if (of_device_is_compatible(child, "mediatek,scp-core")) { + found = 1; + of_node_put(child); + break; + } + } - of_node_put(child); - return of_node_name_eq(child, "cros-ec-rpmsg"); + return found; } static int scp_cluster_init(struct platform_device *pdev, struct mtk_scp_of_cluster *scp_cluster) { int ret; - ret = scp_is_single_core(pdev); - if (ret < 0) - return ret; - - if (ret) + if (!scp_find_core_node(pdev)) ret = scp_add_single_core(pdev, scp_cluster); else ret = scp_add_multi_core(pdev, scp_cluster); -- 2.18.0
WARNING: multiple messages have this Message-ID (diff)
From: Tinghan Shen <tinghan.shen@mediatek.com> To: Bjorn Andersson <andersson@kernel.org>, Mathieu Poirier <mathieu.poirier@linaro.org>, Matthias Brugger <matthias.bgg@gmail.com>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, "Chen-Yu Tsai" <wenst@chromium.org> Cc: <linux-remoteproc@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>, Tinghan Shen <tinghan.shen@mediatek.com> Subject: [PATCH] remoteproc: mediatek: Fix compatibility of probing SCP cores Date: Wed, 20 Sep 2023 16:46:11 +0800 [thread overview] Message-ID: <20230920084611.30890-1-tinghan.shen@mediatek.com> (raw) The SCP dt-binding introduces a new SCP node format to describe the multi-core SCP HW. However, the old format for single-core SCP is co-existed with the new format. It suggests that there are two different approaches, using either the old style or the new format, to describe the single-core SCP HW in devicetree. the driver checks the immediate child node name in the SCP node to determin the format that is being utilized. The node name is expected "scp" for new format and "cros-ec-rpmsg" for the old format. However, the expected node name for old format didn't defined in earlier SCP dt-binding and the old node name is "cros_ec" in old devicetree. So, this checking breaks the compatibility with old SCP devicetree. In order to distinguish between the various forms of SCP devicetree and maintain compatibility with the previous SCP devicetree, this fix verifies the existence of the compatible name "mediatek,scp-core" introduced in the new format. Reported-by: Laura Nao <laura.nao@collabora.com> Fixes: 1fdbf0cdde98 ("remoteproc: mediatek: Probe SCP cluster on multi-core SCP") Signed-off-by: Tinghan Shen <tinghan.shen@mediatek.com> --- drivers/remoteproc/mtk_scp.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c index ea227b566c54..76472e50c8f5 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -1144,29 +1144,29 @@ static int scp_add_multi_core(struct platform_device *pdev, return ret; } -static int scp_is_single_core(struct platform_device *pdev) +static bool scp_find_core_node(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *np = dev_of_node(dev); struct device_node *child; + int found = 0; - child = of_get_next_available_child(np, NULL); - if (!child) - return dev_err_probe(dev, -ENODEV, "No child node\n"); + for_each_child_of_node(np, child) { + if (of_device_is_compatible(child, "mediatek,scp-core")) { + found = 1; + of_node_put(child); + break; + } + } - of_node_put(child); - return of_node_name_eq(child, "cros-ec-rpmsg"); + return found; } static int scp_cluster_init(struct platform_device *pdev, struct mtk_scp_of_cluster *scp_cluster) { int ret; - ret = scp_is_single_core(pdev); - if (ret < 0) - return ret; - - if (ret) + if (!scp_find_core_node(pdev)) ret = scp_add_single_core(pdev, scp_cluster); else ret = scp_add_multi_core(pdev, scp_cluster); -- 2.18.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2023-09-20 8:47 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-09-20 8:46 Tinghan Shen [this message] 2023-09-20 8:46 ` [PATCH] remoteproc: mediatek: Fix compatibility of probing SCP cores Tinghan Shen
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=20230920084611.30890-1-tinghan.shen@mediatek.com \ --to=tinghan.shen@mediatek.com \ --cc=Project_Global_Chrome_Upstream_Group@mediatek.com \ --cc=andersson@kernel.org \ --cc=angelogioacchino.delregno@collabora.com \ --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=wenst@chromium.org \ /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: linkBe 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.