diff mbox series

mmc: sdhci-msm: When dev_pm_opp_of_add_table() returns 0 it's not an error

Message ID 20200827083330.1.I669bb4dc3d92bd04e9a695f97904797dc8241b79@changeid (mailing list archive)
State New, archived
Headers show
Series mmc: sdhci-msm: When dev_pm_opp_of_add_table() returns 0 it's not an error | expand

Commit Message

Douglas Anderson Aug. 27, 2020, 3:33 p.m. UTC
The commit d05a7238fe1c ("mmc: sdhci-msm: Unconditionally call
dev_pm_opp_of_remove_table()") works fine in the case where there is
no OPP table.  However, if there is an OPP table then
dev_pm_opp_of_add_table() will return 0.  Since 0 != -ENODEV then the
"if (ret != -ENODEV)" will evaluate to true and we'll fall into the
error case.  Oops.

Let's fix this.

Fixes: d05a7238fe1c ("mmc: sdhci-msm: Unconditionally call dev_pm_opp_of_remove_table()")
Signed-off-by: Douglas Anderson <dianders@chromium.org>
---

 drivers/mmc/host/sdhci-msm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Naresh Kamboju Aug. 27, 2020, 8:27 p.m. UTC | #1
On Thu, 27 Aug 2020 at 21:03, Douglas Anderson <dianders@chromium.org> wrote:
>
> The commit d05a7238fe1c ("mmc: sdhci-msm: Unconditionally call
> dev_pm_opp_of_remove_table()") works fine in the case where there is
> no OPP table.  However, if there is an OPP table then
> dev_pm_opp_of_add_table() will return 0.  Since 0 != -ENODEV then the
> "if (ret != -ENODEV)" will evaluate to true and we'll fall into the
> error case.  Oops.
>
> Let's fix this.
>
> Fixes: d05a7238fe1c ("mmc: sdhci-msm: Unconditionally call dev_pm_opp_of_remove_table()")
> Signed-off-by: Douglas Anderson <dianders@chromium.org>

Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>

I will test this patch and report again on this email thread.

> ---
>
>  drivers/mmc/host/sdhci-msm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
> index b7e47107a31a..55101dba42bd 100644
> --- a/drivers/mmc/host/sdhci-msm.c
> +++ b/drivers/mmc/host/sdhci-msm.c
> @@ -2284,7 +2284,7 @@ static int sdhci_msm_probe(struct platform_device *pdev)
>
>         /* OPP table is optional */
>         ret = dev_pm_opp_of_add_table(&pdev->dev);
> -       if (ret != -ENODEV) {
> +       if (ret && ret != -ENODEV) {
>                 dev_err(&pdev->dev, "Invalid OPP table in Device tree\n");
>                 goto opp_cleanup;
>         }
> --
> 2.28.0.297.g1956fa8f8d-goog
>

- Naresh
Viresh Kumar Aug. 28, 2020, 5:09 a.m. UTC | #2
On 27-08-20, 08:33, Douglas Anderson wrote:
> The commit d05a7238fe1c ("mmc: sdhci-msm: Unconditionally call
> dev_pm_opp_of_remove_table()") works fine in the case where there is
> no OPP table.  However, if there is an OPP table then
> dev_pm_opp_of_add_table() will return 0.  Since 0 != -ENODEV then the
> "if (ret != -ENODEV)" will evaluate to true and we'll fall into the
> error case.  Oops.
> 
> Let's fix this.
> 
> Fixes: d05a7238fe1c ("mmc: sdhci-msm: Unconditionally call dev_pm_opp_of_remove_table()")
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> ---
> 
>  drivers/mmc/host/sdhci-msm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
> index b7e47107a31a..55101dba42bd 100644
> --- a/drivers/mmc/host/sdhci-msm.c
> +++ b/drivers/mmc/host/sdhci-msm.c
> @@ -2284,7 +2284,7 @@ static int sdhci_msm_probe(struct platform_device *pdev)
>  
>  	/* OPP table is optional */
>  	ret = dev_pm_opp_of_add_table(&pdev->dev);
> -	if (ret != -ENODEV) {
> +	if (ret && ret != -ENODEV) {
>  		dev_err(&pdev->dev, "Invalid OPP table in Device tree\n");
>  		goto opp_cleanup;
>  	}

Wow!

How many bugs did I introduce with a simple patch :(

@Ulf, since this is material for 5.10 I was planning to resend the
original patch itself with all the things fixed. Will you be able to
rebase your tree? Or do you want to apply fixes separately ?
Ulf Hansson Aug. 28, 2020, 8:43 a.m. UTC | #3
On Fri, 28 Aug 2020 at 07:09, Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> On 27-08-20, 08:33, Douglas Anderson wrote:
> > The commit d05a7238fe1c ("mmc: sdhci-msm: Unconditionally call
> > dev_pm_opp_of_remove_table()") works fine in the case where there is
> > no OPP table.  However, if there is an OPP table then
> > dev_pm_opp_of_add_table() will return 0.  Since 0 != -ENODEV then the
> > "if (ret != -ENODEV)" will evaluate to true and we'll fall into the
> > error case.  Oops.
> >
> > Let's fix this.
> >
> > Fixes: d05a7238fe1c ("mmc: sdhci-msm: Unconditionally call dev_pm_opp_of_remove_table()")
> > Signed-off-by: Douglas Anderson <dianders@chromium.org>
> > ---
> >
> >  drivers/mmc/host/sdhci-msm.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
> > index b7e47107a31a..55101dba42bd 100644
> > --- a/drivers/mmc/host/sdhci-msm.c
> > +++ b/drivers/mmc/host/sdhci-msm.c
> > @@ -2284,7 +2284,7 @@ static int sdhci_msm_probe(struct platform_device *pdev)
> >
> >       /* OPP table is optional */
> >       ret = dev_pm_opp_of_add_table(&pdev->dev);
> > -     if (ret != -ENODEV) {
> > +     if (ret && ret != -ENODEV) {
> >               dev_err(&pdev->dev, "Invalid OPP table in Device tree\n");
> >               goto opp_cleanup;
> >       }
>
> Wow!
>
> How many bugs did I introduce with a simple patch :(
>
> @Ulf, since this is material for 5.10 I was planning to resend the
> original patch itself with all the things fixed. Will you be able to
> rebase your tree? Or do you want to apply fixes separately ?

I have rebased my tree, to get rid of the problems completely.

Thanks everybody for helping out!

Kind regards
Uffe
Naresh Kamboju Aug. 28, 2020, 9:15 a.m. UTC | #4
On Fri, 28 Aug 2020 at 01:57, Naresh Kamboju <naresh.kamboju@linaro.org> wrote:
>
> On Thu, 27 Aug 2020 at 21:03, Douglas Anderson <dianders@chromium.org> wrote:
> >
> > The commit d05a7238fe1c ("mmc: sdhci-msm: Unconditionally call
> > dev_pm_opp_of_remove_table()") works fine in the case where there is
> > no OPP table.  However, if there is an OPP table then
> > dev_pm_opp_of_add_table() will return 0.  Since 0 != -ENODEV then the
> > "if (ret != -ENODEV)" will evaluate to true and we'll fall into the
> > error case.  Oops.
> >
> > Let's fix this.
> >
> > Fixes: d05a7238fe1c ("mmc: sdhci-msm: Unconditionally call dev_pm_opp_of_remove_table()")
> > Signed-off-by: Douglas Anderson <dianders@chromium.org>
>
> Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
>
> I will test this patch and report again on this email thread.

Sorry this patch did not solve the reported problem.
However, I would be testing the V2 set from Viresh Kumar.

and report the test results on the other patch set [1].
[1] https://lore.kernel.org/linux-pm/cover.1598594714.git.viresh.kumar@linaro.org
Douglas Anderson Aug. 28, 2020, 2:56 p.m. UTC | #5
Hi,

On Fri, Aug 28, 2020 at 2:15 AM Naresh Kamboju
<naresh.kamboju@linaro.org> wrote:
>
> On Fri, 28 Aug 2020 at 01:57, Naresh Kamboju <naresh.kamboju@linaro.org> wrote:
> >
> > On Thu, 27 Aug 2020 at 21:03, Douglas Anderson <dianders@chromium.org> wrote:
> > >
> > > The commit d05a7238fe1c ("mmc: sdhci-msm: Unconditionally call
> > > dev_pm_opp_of_remove_table()") works fine in the case where there is
> > > no OPP table.  However, if there is an OPP table then
> > > dev_pm_opp_of_add_table() will return 0.  Since 0 != -ENODEV then the
> > > "if (ret != -ENODEV)" will evaluate to true and we'll fall into the
> > > error case.  Oops.
> > >
> > > Let's fix this.
> > >
> > > Fixes: d05a7238fe1c ("mmc: sdhci-msm: Unconditionally call dev_pm_opp_of_remove_table()")
> > > Signed-off-by: Douglas Anderson <dianders@chromium.org>
> >
> > Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
> >
> > I will test this patch and report again on this email thread.
>
> Sorry this patch did not solve the reported problem.

To be fair, I wasn't trying to.  ;-)  That's why I didn't add
Reported-by to my original patch.  I was trying to solve problems I
was seeing myself and my patch did solve the problems I was seeing.  I
only CCed you because I saw that you were having problems with the
same patch...

> However, I would be testing the V2 set from Viresh Kumar.

I've confirmed that the current mmc/next (with Viresh's new patch) no
longer breaks me.  :-)

$ git show --format=fuller linux_mmc/next | head -8
commit 174e889d08aa54219b841464458f81d13fafec93
Merge: c282fdb49b18 8048822bac01
Author:     Ulf Hansson <ulf.hansson@linaro.org>
AuthorDate: Fri Aug 28 14:26:25 2020 +0200
Commit:     Ulf Hansson <ulf.hansson@linaro.org>
CommitDate: Fri Aug 28 14:26:25 2020 +0200

    Merge branch 'fixes' into next

-Doug
Viresh Kumar Aug. 31, 2020, 4:50 a.m. UTC | #6
On 28-08-20, 07:56, Doug Anderson wrote:
> I've confirmed that the current mmc/next (with Viresh's new patch) no
> longer breaks me.  :-)
> 
> $ git show --format=fuller linux_mmc/next | head -8
> commit 174e889d08aa54219b841464458f81d13fafec93
> Merge: c282fdb49b18 8048822bac01
> Author:     Ulf Hansson <ulf.hansson@linaro.org>
> AuthorDate: Fri Aug 28 14:26:25 2020 +0200
> Commit:     Ulf Hansson <ulf.hansson@linaro.org>
> CommitDate: Fri Aug 28 14:26:25 2020 +0200
> 
>     Merge branch 'fixes' into next

Well, it fixed someone's problem at least :)
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index b7e47107a31a..55101dba42bd 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -2284,7 +2284,7 @@  static int sdhci_msm_probe(struct platform_device *pdev)
 
 	/* OPP table is optional */
 	ret = dev_pm_opp_of_add_table(&pdev->dev);
-	if (ret != -ENODEV) {
+	if (ret && ret != -ENODEV) {
 		dev_err(&pdev->dev, "Invalid OPP table in Device tree\n");
 		goto opp_cleanup;
 	}