diff mbox series

[v2] isoc: mediatek: Check for error clk pointer

Message ID 20211222015157.1025853-1-jiasheng@iscas.ac.cn (mailing list archive)
State New, archived
Headers show
Series [v2] isoc: mediatek: Check for error clk pointer | expand

Commit Message

Jiasheng Jiang Dec. 22, 2021, 1:51 a.m. UTC
On Wed, Dec 22, 2021 at 01:57:15AM +0800, Mark Brown wrote:
>> +	for (i = CLK_NONE + 1; i < CLK_MAX; i++) {
>>  		clk[i] = devm_clk_get(&pdev->dev, clk_names[i]);
>> +		if (IS_ERR(clk[i]))
>> +			return PTR_ERR(clk[i]);
>
> This now pays attention to the error code here which is good but...
>
>> -	init_clks(pdev, clk);
>> +	ret = init_clks(pdev, clk);
>> +	if (ret)
>> +		return ERR_PTR(-ENOMEM);
>
> ...then discards it here with a random most likely inappropriate error
> code.

Yes, you are right and now the return code depending on the
init_clks().

Fixes: 6078c651947a ("soc: mediatek: Refine scpsys to support multiple platform")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
Changelog:

v1 -> v2

*Change 1. Change the return code.
---
 drivers/soc/mediatek/mtk-scpsys.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

Comments

Mark Brown Dec. 24, 2021, 2:06 p.m. UTC | #1
On Wed, Dec 22, 2021 at 09:51:57AM +0800, Jiasheng Jiang wrote:
> On Wed, Dec 22, 2021 at 01:57:15AM +0800, Mark Brown wrote:
> >> +	for (i = CLK_NONE + 1; i < CLK_MAX; i++) {
> >>  		clk[i] = devm_clk_get(&pdev->dev, clk_names[i]);
> >> +		if (IS_ERR(clk[i]))
> >> +			return PTR_ERR(clk[i]);
> >
> > This now pays attention to the error code here which is good but...
> >
> >> -	init_clks(pdev, clk);
> >> +	ret = init_clks(pdev, clk);
> >> +	if (ret)
> >> +		return ERR_PTR(-ENOMEM);
> >
> > ...then discards it here with a random most likely inappropriate error
> > code.
> 
> Yes, you are right and now the return code depending on the
> init_clks().

Please submit patches in the format covered in submitting-patches.rst -
write a proper changelog for your patches.

Please submit patches using subject lines reflecting the style for the
subsystem, this makes it easier for people to identify relevant patches.
Look at what existing commits in the area you're changing are doing and
make sure your subject lines visually resemble what they're doing.
There's no need to resubmit to fix this alone.
Mark Brown Dec. 24, 2021, 4:17 p.m. UTC | #2
On Wed, 22 Dec 2021 09:51:57 +0800, Jiasheng Jiang wrote:
> On Wed, Dec 22, 2021 at 01:57:15AM +0800, Mark Brown wrote:
> >> +	for (i = CLK_NONE + 1; i < CLK_MAX; i++) {
> >>  		clk[i] = devm_clk_get(&pdev->dev, clk_names[i]);
> >> +		if (IS_ERR(clk[i]))
> >> +			return PTR_ERR(clk[i]);
> >
> > This now pays attention to the error code here which is good but...
> >
> >> -	init_clks(pdev, clk);
> >> +	ret = init_clks(pdev, clk);
> >> +	if (ret)
> >> +		return ERR_PTR(-ENOMEM);
> >
> > ...then discards it here with a random most likely inappropriate error
> > code.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] isoc: mediatek: Check for error clk pointer
      commit: 9de2b9286a6dd16966959b3cb34fc2ddfd39213e

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
Frank Wunderlich Jan. 28, 2022, 9:51 a.m. UTC | #3
Hi,

this commit is merged in 5.17-rc1 and breaks scpsys on mt7622/bananapi R64

mtk-scpsys: probe of 10006000.power-controller failed with error -2

at least ethernet is affected (i guess usb,sata,btif,... too, but not checked), as gmacs do not get probed as depency of it

after reverting this commit it is working again.

have not yet digged deeper into it why it is failing, but maybe author has an idea

regards Frank

> Gesendet: Mittwoch, 22. Dezember 2021 um 02:51 Uhr
> Von: "Jiasheng Jiang" <jiasheng@iscas.ac.cn>
> An: matthias.bgg@gmail.com, lgirdwood@gmail.com, broonie@kernel.org
> Cc: linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, "Jiasheng Jiang" <jiasheng@iscas.ac.cn>
> Betreff: [PATCH v2] isoc: mediatek: Check for error clk pointer
>
> On Wed, Dec 22, 2021 at 01:57:15AM +0800, Mark Brown wrote:
> >> +	for (i = CLK_NONE + 1; i < CLK_MAX; i++) {
> >>  		clk[i] = devm_clk_get(&pdev->dev, clk_names[i]);
> >> +		if (IS_ERR(clk[i]))
> >> +			return PTR_ERR(clk[i]);
> >
> > This now pays attention to the error code here which is good but...
> >
> >> -	init_clks(pdev, clk);
> >> +	ret = init_clks(pdev, clk);
> >> +	if (ret)
> >> +		return ERR_PTR(-ENOMEM);
> >
> > ...then discards it here with a random most likely inappropriate error
> > code.
>
> Yes, you are right and now the return code depending on the
> init_clks().
>
> Fixes: 6078c651947a ("soc: mediatek: Refine scpsys to support multiple platform")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
> Changelog:
>
> v1 -> v2
>
> *Change 1. Change the return code.
> ---
>  drivers/soc/mediatek/mtk-scpsys.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/soc/mediatek/mtk-scpsys.c b/drivers/soc/mediatek/mtk-scpsys.c
> index ca75b14931ec..670cc82d17dc 100644
> --- a/drivers/soc/mediatek/mtk-scpsys.c
> +++ b/drivers/soc/mediatek/mtk-scpsys.c
> @@ -411,12 +411,17 @@ static int scpsys_power_off(struct generic_pm_domain *genpd)
>  	return ret;
>  }
>
> -static void init_clks(struct platform_device *pdev, struct clk **clk)
> +static int init_clks(struct platform_device *pdev, struct clk **clk)
>  {
>  	int i;
>
> -	for (i = CLK_NONE + 1; i < CLK_MAX; i++)
> +	for (i = CLK_NONE + 1; i < CLK_MAX; i++) {
>  		clk[i] = devm_clk_get(&pdev->dev, clk_names[i]);
> +		if (IS_ERR(clk[i]))
> +			return PTR_ERR(clk[i]);
> +	}
> +
> +	return 0;
>  }
>
>  static struct scp *init_scp(struct platform_device *pdev,
> @@ -426,7 +431,7 @@ static struct scp *init_scp(struct platform_device *pdev,
>  {
>  	struct genpd_onecell_data *pd_data;
>  	struct resource *res;
> -	int i, j;
> +	int i, j, ret;
>  	struct scp *scp;
>  	struct clk *clk[CLK_MAX];
>
> @@ -481,7 +486,9 @@ static struct scp *init_scp(struct platform_device *pdev,
>
>  	pd_data->num_domains = num;
>
> -	init_clks(pdev, clk);
> +	ret = init_clks(pdev, clk);
> +	if (ret)
> +		return ERR_PTR(ret);
>
>  	for (i = 0; i < num; i++) {
>  		struct scp_domain *scpd = &scp->domains[i];
> --
> 2.25.1
>
>
> _______________________________________________
> Linux-mediatek mailing list
> Linux-mediatek@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-mediatek
>
Guenter Roeck Feb. 6, 2022, 5:37 p.m. UTC | #4
On Fri, Jan 28, 2022 at 10:51:20AM +0100, Frank Wunderlich wrote:
> Hi,
> 
> this commit is merged in 5.17-rc1 and breaks scpsys on mt7622/bananapi R64
> 
> mtk-scpsys: probe of 10006000.power-controller failed with error -2
> 
> at least ethernet is affected (i guess usb,sata,btif,... too, but not checked), as gmacs do not get probed as depency of it
> 
> after reverting this commit it is working again.
> 
> have not yet digged deeper into it why it is failing, but maybe author has an idea
> 

I created a revert of the problematic patch with some explanation.

https://lore.kernel.org/lkml/20220205014755.699603-1-linux@roeck-us.net/

Sorry that I didn't reference this discussion; I only noticed it after
I wrote the revert. The revert and my analysis is based on the impact
of this patch on affected Chromebooks.

The revert is queued for v4.19.y and later stable releases because
the patch discussed here made it into all those releases and breaks
pretty much all Mediatek based systems using the affected driver.

Guenter
diff mbox series

Patch

diff --git a/drivers/soc/mediatek/mtk-scpsys.c b/drivers/soc/mediatek/mtk-scpsys.c
index ca75b14931ec..670cc82d17dc 100644
--- a/drivers/soc/mediatek/mtk-scpsys.c
+++ b/drivers/soc/mediatek/mtk-scpsys.c
@@ -411,12 +411,17 @@  static int scpsys_power_off(struct generic_pm_domain *genpd)
 	return ret;
 }
 
-static void init_clks(struct platform_device *pdev, struct clk **clk)
+static int init_clks(struct platform_device *pdev, struct clk **clk)
 {
 	int i;
 
-	for (i = CLK_NONE + 1; i < CLK_MAX; i++)
+	for (i = CLK_NONE + 1; i < CLK_MAX; i++) {
 		clk[i] = devm_clk_get(&pdev->dev, clk_names[i]);
+		if (IS_ERR(clk[i]))
+			return PTR_ERR(clk[i]);
+	}
+
+	return 0;
 }
 
 static struct scp *init_scp(struct platform_device *pdev,
@@ -426,7 +431,7 @@  static struct scp *init_scp(struct platform_device *pdev,
 {
 	struct genpd_onecell_data *pd_data;
 	struct resource *res;
-	int i, j;
+	int i, j, ret;
 	struct scp *scp;
 	struct clk *clk[CLK_MAX];
 
@@ -481,7 +486,9 @@  static struct scp *init_scp(struct platform_device *pdev,
 
 	pd_data->num_domains = num;
 
-	init_clks(pdev, clk);
+	ret = init_clks(pdev, clk);
+	if (ret)
+		return ERR_PTR(ret);
 
 	for (i = 0; i < num; i++) {
 		struct scp_domain *scpd = &scp->domains[i];