Skip to content

Commit 34eb78f

Browse files
AngeloGioacchino Del Regnomathieupoirier
authored andcommitted
remoteproc: mediatek: Refactor single core check and fix retrocompatibility
In older devicetrees we had the ChromeOS EC in a node called "cros-ec" instead of the newer "cros-ec-rpmsg", but this driver is now checking only for the latter, breaking compatibility with those. Besides, we can check if the SCP is single or dual core by simply walking through the children of the main SCP node and checking if if there's more than one "mediatek,scp-core" compatible node. Fixes: 1fdbf0c ("remoteproc: mediatek: Probe SCP cluster on multi-core SCP") Reported-by: "kernelci.org bot" <bot@kernelci.org> Tested-by: Laura Nao <laura.nao@collabora.com> Reviewed-by: Chen-Yu Tsai <wenst@chromium.org> Tested-by: Chen-Yu Tsai <wenst@chromium.org> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20230919092336.51007-1-angelogioacchino.delregno@collabora.com Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
1 parent e159298 commit 34eb78f

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

drivers/remoteproc/mtk_scp.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,29 +1144,25 @@ static int scp_add_multi_core(struct platform_device *pdev,
11441144
return ret;
11451145
}
11461146

1147-
static int scp_is_single_core(struct platform_device *pdev)
1147+
static bool scp_is_single_core(struct platform_device *pdev)
11481148
{
11491149
struct device *dev = &pdev->dev;
11501150
struct device_node *np = dev_of_node(dev);
11511151
struct device_node *child;
1152+
int num_cores = 0;
11521153

1153-
child = of_get_next_available_child(np, NULL);
1154-
if (!child)
1155-
return dev_err_probe(dev, -ENODEV, "No child node\n");
1154+
for_each_child_of_node(np, child)
1155+
if (of_device_is_compatible(child, "mediatek,scp-core"))
1156+
num_cores++;
11561157

1157-
of_node_put(child);
1158-
return of_node_name_eq(child, "cros-ec-rpmsg");
1158+
return num_cores < 2;
11591159
}
11601160

11611161
static int scp_cluster_init(struct platform_device *pdev, struct mtk_scp_of_cluster *scp_cluster)
11621162
{
11631163
int ret;
11641164

1165-
ret = scp_is_single_core(pdev);
1166-
if (ret < 0)
1167-
return ret;
1168-
1169-
if (ret)
1165+
if (scp_is_single_core(pdev))
11701166
ret = scp_add_single_core(pdev, scp_cluster);
11711167
else
11721168
ret = scp_add_multi_core(pdev, scp_cluster);

0 commit comments

Comments
 (0)