Skip to content

Commit 67ca3f9

Browse files
nfrapradomathieupoirier
authored andcommitted
remoteproc: mediatek: Don't attempt to remap l1tcm memory if missing
The current code doesn't check whether platform_get_resource_byname() succeeded to get the l1tcm memory, which is optional, before attempting to map it. This results in the following error message when it is missing: mtk-scp 10500000.scp: error -EINVAL: invalid resource (null) Add a check so that the remapping is only attempted if the memory region exists. This also allows to simplify the logic handling failure to remap, since a failure then is always a failure. Fixes: ca23ecf ("remoteproc/mediatek: support L1TCM") Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20240627-scp-invalid-resource-l1tcm-v1-1-7d221e6c495a@collabora.com Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
1 parent 5b9f51b commit 67ca3f9

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

drivers/remoteproc/mtk_scp.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,14 +1344,12 @@ static int scp_probe(struct platform_device *pdev)
13441344

13451345
/* l1tcm is an optional memory region */
13461346
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "l1tcm");
1347-
scp_cluster->l1tcm_base = devm_ioremap_resource(dev, res);
1348-
if (IS_ERR(scp_cluster->l1tcm_base)) {
1349-
ret = PTR_ERR(scp_cluster->l1tcm_base);
1350-
if (ret != -EINVAL)
1351-
return dev_err_probe(dev, ret, "Failed to map l1tcm memory\n");
1347+
if (res) {
1348+
scp_cluster->l1tcm_base = devm_ioremap_resource(dev, res);
1349+
if (IS_ERR(scp_cluster->l1tcm_base))
1350+
return dev_err_probe(dev, PTR_ERR(scp_cluster->l1tcm_base),
1351+
"Failed to map l1tcm memory\n");
13521352

1353-
scp_cluster->l1tcm_base = NULL;
1354-
} else {
13551353
scp_cluster->l1tcm_size = resource_size(res);
13561354
scp_cluster->l1tcm_phys = res->start;
13571355
}

0 commit comments

Comments
 (0)