[PATCH] pmdomain: mediatek: Add error messages for missing regmaps

Chen-Yu Tsai posted 1 patch 9 months, 3 weeks ago
drivers/pmdomain/mediatek/mtk-pm-domains.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
[PATCH] pmdomain: mediatek: Add error messages for missing regmaps
Posted by Chen-Yu Tsai 9 months, 3 weeks ago
A recent change to the syscon regmap API caused the MediaTek power
controller drivers to fail, as the required regmap could no longer be
retrieved. The error did not have an accompanying message, making the
failure less obvious. The aforementioned change has since been reverted.

Add error messages to all the regmap retrievals, thereby making all
error paths in scpsys_add_one_domain() have visible error messages.

Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
---
 drivers/pmdomain/mediatek/mtk-pm-domains.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/pmdomain/mediatek/mtk-pm-domains.c b/drivers/pmdomain/mediatek/mtk-pm-domains.c
index b866b006af69..22cdd34ed008 100644
--- a/drivers/pmdomain/mediatek/mtk-pm-domains.c
+++ b/drivers/pmdomain/mediatek/mtk-pm-domains.c
@@ -397,20 +397,26 @@ generic_pm_domain *scpsys_add_one_domain(struct scpsys *scpsys, struct device_no
 
 	pd->infracfg = syscon_regmap_lookup_by_phandle_optional(node, "mediatek,infracfg");
 	if (IS_ERR(pd->infracfg))
-		return ERR_CAST(pd->infracfg);
+		return dev_err_cast_probe(scpsys->dev, pd->infracfg,
+					  "%pOF: failed to get infracfg regmap\n",
+					  node);
 
 	smi_node = of_parse_phandle(node, "mediatek,smi", 0);
 	if (smi_node) {
 		pd->smi = device_node_to_regmap(smi_node);
 		of_node_put(smi_node);
 		if (IS_ERR(pd->smi))
-			return ERR_CAST(pd->smi);
+			return dev_err_cast_probe(scpsys->dev, pd->smi,
+						  "%pOF: failed to get SMI regmap\n",
+						  node);
 	}
 
 	if (MTK_SCPD_CAPS(pd, MTK_SCPD_HAS_INFRA_NAO)) {
 		pd->infracfg_nao = syscon_regmap_lookup_by_phandle(node, "mediatek,infracfg-nao");
 		if (IS_ERR(pd->infracfg_nao))
-			return ERR_CAST(pd->infracfg_nao);
+			return dev_err_cast_probe(scpsys->dev, pd->infracfg_nao,
+						  "%pOF: failed to get infracfg-nao regmap\n",
+						  node);
 	} else {
 		pd->infracfg_nao = NULL;
 	}
-- 
2.49.0.805.g082f7c87e0-goog
Re: [PATCH] pmdomain: mediatek: Add error messages for missing regmaps
Posted by Ulf Hansson 9 months, 2 weeks ago
On Mon, 21 Apr 2025 at 11:09, Chen-Yu Tsai <wenst@chromium.org> wrote:
>
> A recent change to the syscon regmap API caused the MediaTek power
> controller drivers to fail, as the required regmap could no longer be
> retrieved. The error did not have an accompanying message, making the
> failure less obvious. The aforementioned change has since been reverted.
>
> Add error messages to all the regmap retrievals, thereby making all
> error paths in scpsys_add_one_domain() have visible error messages.
>
> Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>

Applied for next, thanks!

Kind regards
Uffe


> ---
>  drivers/pmdomain/mediatek/mtk-pm-domains.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/pmdomain/mediatek/mtk-pm-domains.c b/drivers/pmdomain/mediatek/mtk-pm-domains.c
> index b866b006af69..22cdd34ed008 100644
> --- a/drivers/pmdomain/mediatek/mtk-pm-domains.c
> +++ b/drivers/pmdomain/mediatek/mtk-pm-domains.c
> @@ -397,20 +397,26 @@ generic_pm_domain *scpsys_add_one_domain(struct scpsys *scpsys, struct device_no
>
>         pd->infracfg = syscon_regmap_lookup_by_phandle_optional(node, "mediatek,infracfg");
>         if (IS_ERR(pd->infracfg))
> -               return ERR_CAST(pd->infracfg);
> +               return dev_err_cast_probe(scpsys->dev, pd->infracfg,
> +                                         "%pOF: failed to get infracfg regmap\n",
> +                                         node);
>
>         smi_node = of_parse_phandle(node, "mediatek,smi", 0);
>         if (smi_node) {
>                 pd->smi = device_node_to_regmap(smi_node);
>                 of_node_put(smi_node);
>                 if (IS_ERR(pd->smi))
> -                       return ERR_CAST(pd->smi);
> +                       return dev_err_cast_probe(scpsys->dev, pd->smi,
> +                                                 "%pOF: failed to get SMI regmap\n",
> +                                                 node);
>         }
>
>         if (MTK_SCPD_CAPS(pd, MTK_SCPD_HAS_INFRA_NAO)) {
>                 pd->infracfg_nao = syscon_regmap_lookup_by_phandle(node, "mediatek,infracfg-nao");
>                 if (IS_ERR(pd->infracfg_nao))
> -                       return ERR_CAST(pd->infracfg_nao);
> +                       return dev_err_cast_probe(scpsys->dev, pd->infracfg_nao,
> +                                                 "%pOF: failed to get infracfg-nao regmap\n",
> +                                                 node);
>         } else {
>                 pd->infracfg_nao = NULL;
>         }
> --
> 2.49.0.805.g082f7c87e0-goog
>
Re: [PATCH] pmdomain: mediatek: Add error messages for missing regmaps
Posted by AngeloGioacchino Del Regno 9 months, 3 weeks ago
Il 21/04/25 11:09, Chen-Yu Tsai ha scritto:
> A recent change to the syscon regmap API caused the MediaTek power
> controller drivers to fail, as the required regmap could no longer be
> retrieved. The error did not have an accompanying message, making the
> failure less obvious. The aforementioned change has since been reverted.
> 
> Add error messages to all the regmap retrievals, thereby making all
> error paths in scpsys_add_one_domain() have visible error messages.
> 
> Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>

FYI - I'm restructuring this driver to handle retrieving the regmaps differently,
as the mt8196 mtcmos are a bit different and need even more, with different names
and this is a trend that goes on and on with new SoCs.... so I'm most probably
about to deprecate those "mediatek,infracfg" "mediatek,smi" "mediatek,something"
for external regmaps, and changing everything to an array of handles in a
"mediatek,bus-protection" (or different name anyway) property.

For now, though:

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>