* [PATCH] remoteproc: mediatek: Don't attempt to remap l1tcm memory if missing
@ 2024-06-27 21:20 Nícolas F. R. A. Prado
2024-06-28 3:12 ` Tzung-Bi Shih
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Nícolas F. R. A. Prado @ 2024-06-27 21:20 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier, Matthias Brugger,
AngeloGioacchino Del Regno, Tzung-Bi Shih
Cc: kernel, linux-remoteproc, linux-kernel, linux-arm-kernel,
linux-mediatek, Nícolas F. R. A. Prado
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: ca23ecfdbd44 ("remoteproc/mediatek: support L1TCM")
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
drivers/remoteproc/mtk_scp.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c
index b885a9a041e4..b17757900cd7 100644
--- a/drivers/remoteproc/mtk_scp.c
+++ b/drivers/remoteproc/mtk_scp.c
@@ -1344,14 +1344,12 @@ static int scp_probe(struct platform_device *pdev)
/* l1tcm is an optional memory region */
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "l1tcm");
- scp_cluster->l1tcm_base = devm_ioremap_resource(dev, res);
- if (IS_ERR(scp_cluster->l1tcm_base)) {
- ret = PTR_ERR(scp_cluster->l1tcm_base);
- if (ret != -EINVAL)
- return dev_err_probe(dev, ret, "Failed to map l1tcm memory\n");
+ if (res) {
+ scp_cluster->l1tcm_base = devm_ioremap_resource(dev, res);
+ if (IS_ERR(scp_cluster->l1tcm_base))
+ return dev_err_probe(dev, PTR_ERR(scp_cluster->l1tcm_base),
+ "Failed to map l1tcm memory\n");
- scp_cluster->l1tcm_base = NULL;
- } else {
scp_cluster->l1tcm_size = resource_size(res);
scp_cluster->l1tcm_phys = res->start;
}
---
base-commit: 0fc4bfab2cd45f9acb86c4f04b5191e114e901ed
change-id: 20240627-scp-invalid-resource-l1tcm-9f7cf45c17e6
Best regards,
--
Nícolas F. R. A. Prado <nfraprado@collabora.com>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] remoteproc: mediatek: Don't attempt to remap l1tcm memory if missing
2024-06-27 21:20 [PATCH] remoteproc: mediatek: Don't attempt to remap l1tcm memory if missing Nícolas F. R. A. Prado
@ 2024-06-28 3:12 ` Tzung-Bi Shih
2024-06-28 9:53 ` AngeloGioacchino Del Regno
2024-06-28 18:04 ` Mathieu Poirier
2 siblings, 0 replies; 4+ messages in thread
From: Tzung-Bi Shih @ 2024-06-28 3:12 UTC (permalink / raw)
To: Nícolas F. R. A. Prado
Cc: Bjorn Andersson, Mathieu Poirier, Matthias Brugger,
AngeloGioacchino Del Regno, kernel, linux-remoteproc,
linux-kernel, linux-arm-kernel, linux-mediatek
On Thu, Jun 27, 2024 at 05:20:55PM -0400, Nícolas F. R. A. Prado wrote:
> 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: ca23ecfdbd44 ("remoteproc/mediatek: support L1TCM")
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] remoteproc: mediatek: Don't attempt to remap l1tcm memory if missing
2024-06-27 21:20 [PATCH] remoteproc: mediatek: Don't attempt to remap l1tcm memory if missing Nícolas F. R. A. Prado
2024-06-28 3:12 ` Tzung-Bi Shih
@ 2024-06-28 9:53 ` AngeloGioacchino Del Regno
2024-06-28 18:04 ` Mathieu Poirier
2 siblings, 0 replies; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2024-06-28 9:53 UTC (permalink / raw)
To: Nícolas F. R. A. Prado, Bjorn Andersson, Mathieu Poirier,
Matthias Brugger, Tzung-Bi Shih
Cc: kernel, linux-remoteproc, linux-kernel, linux-arm-kernel,
linux-mediatek
Il 27/06/24 23:20, Nícolas F. R. A. Prado ha scritto:
> 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: ca23ecfdbd44 ("remoteproc/mediatek: support L1TCM")
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] remoteproc: mediatek: Don't attempt to remap l1tcm memory if missing
2024-06-27 21:20 [PATCH] remoteproc: mediatek: Don't attempt to remap l1tcm memory if missing Nícolas F. R. A. Prado
2024-06-28 3:12 ` Tzung-Bi Shih
2024-06-28 9:53 ` AngeloGioacchino Del Regno
@ 2024-06-28 18:04 ` Mathieu Poirier
2 siblings, 0 replies; 4+ messages in thread
From: Mathieu Poirier @ 2024-06-28 18:04 UTC (permalink / raw)
To: Nícolas F. R. A. Prado
Cc: Bjorn Andersson, Matthias Brugger, AngeloGioacchino Del Regno,
Tzung-Bi Shih, kernel, linux-remoteproc, linux-kernel,
linux-arm-kernel, linux-mediatek
On Thu, Jun 27, 2024 at 05:20:55PM -0400, Nícolas F. R. A. Prado wrote:
> 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: ca23ecfdbd44 ("remoteproc/mediatek: support L1TCM")
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> ---
> drivers/remoteproc/mtk_scp.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c
> index b885a9a041e4..b17757900cd7 100644
> --- a/drivers/remoteproc/mtk_scp.c
> +++ b/drivers/remoteproc/mtk_scp.c
> @@ -1344,14 +1344,12 @@ static int scp_probe(struct platform_device *pdev)
>
> /* l1tcm is an optional memory region */
> res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "l1tcm");
> - scp_cluster->l1tcm_base = devm_ioremap_resource(dev, res);
> - if (IS_ERR(scp_cluster->l1tcm_base)) {
> - ret = PTR_ERR(scp_cluster->l1tcm_base);
> - if (ret != -EINVAL)
> - return dev_err_probe(dev, ret, "Failed to map l1tcm memory\n");
> + if (res) {
> + scp_cluster->l1tcm_base = devm_ioremap_resource(dev, res);
> + if (IS_ERR(scp_cluster->l1tcm_base))
> + return dev_err_probe(dev, PTR_ERR(scp_cluster->l1tcm_base),
> + "Failed to map l1tcm memory\n");
>
> - scp_cluster->l1tcm_base = NULL;
> - } else {
Much better - I have applied this patch.
Regards,
Mathieu
> scp_cluster->l1tcm_size = resource_size(res);
> scp_cluster->l1tcm_phys = res->start;
> }
>
> ---
> base-commit: 0fc4bfab2cd45f9acb86c4f04b5191e114e901ed
> change-id: 20240627-scp-invalid-resource-l1tcm-9f7cf45c17e6
>
> Best regards,
> --
> Nícolas F. R. A. Prado <nfraprado@collabora.com>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-06-28 18:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-27 21:20 [PATCH] remoteproc: mediatek: Don't attempt to remap l1tcm memory if missing Nícolas F. R. A. Prado
2024-06-28 3:12 ` Tzung-Bi Shih
2024-06-28 9:53 ` AngeloGioacchino Del Regno
2024-06-28 18:04 ` Mathieu Poirier
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).