diff mbox series

ASoC: qcom: lpass-sc7180: Add system suspend/resume PM ops

Message ID 1669621742-28524-1-git-send-email-quic_srivasam@quicinc.com (mailing list archive)
State Accepted
Commit 2d68148f8f85ca5a4bf5e80c821b56167cfc0f8b
Headers show
Series ASoC: qcom: lpass-sc7180: Add system suspend/resume PM ops | expand

Commit Message

Srinivasa Rao Mandadapu Nov. 28, 2022, 7:49 a.m. UTC
Update lpass sc7180 platform driver with PM ops, such as
system supend and resume callbacks.
This update is required to disable clocks during supend and
avoid XO shutdown issue.

Signed-off-by: Srinivasa Rao Mandadapu <quic_srivasam@quicinc.com>
Tested-by: Rahul Ajmeriya <quic_rajmeriy@quicinc.com>
---
 sound/soc/qcom/lpass-sc7180.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

Comments

Mark Brown Nov. 28, 2022, 4:39 p.m. UTC | #1
On Mon, 28 Nov 2022 13:19:02 +0530, Srinivasa Rao Mandadapu wrote:
> Update lpass sc7180 platform driver with PM ops, such as
> system supend and resume callbacks.
> This update is required to disable clocks during supend and
> avoid XO shutdown issue.
> 
> 

Applied to

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

Thanks!

[1/1] ASoC: qcom: lpass-sc7180: Add system suspend/resume PM ops
      commit: 2d68148f8f85ca5a4bf5e80c821b56167cfc0f8b

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
Stephen Boyd Nov. 28, 2022, 7:40 p.m. UTC | #2
Quoting Srinivasa Rao Mandadapu (2022-11-27 23:49:02)
> Update lpass sc7180 platform driver with PM ops, such as
> system supend and resume callbacks.
> This update is required to disable clocks during supend and
> avoid XO shutdown issue.
>
> Signed-off-by: Srinivasa Rao Mandadapu <quic_srivasam@quicinc.com>
> Tested-by: Rahul Ajmeriya <quic_rajmeriy@quicinc.com>
> ---
>  sound/soc/qcom/lpass-sc7180.c | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
>
> diff --git a/sound/soc/qcom/lpass-sc7180.c b/sound/soc/qcom/lpass-sc7180.c
> index 77a556b..6ad1c5b 100644
> --- a/sound/soc/qcom/lpass-sc7180.c
> +++ b/sound/soc/qcom/lpass-sc7180.c
> @@ -12,6 +12,7 @@
>  #include <linux/module.h>
>  #include <linux/of.h>
>  #include <linux/platform_device.h>
> +#include <linux/pm_runtime.h>

Why is this include needed? Did you mean to include linux/pm.h?

>  #include <dt-bindings/sound/sc7180-lpass.h>
>  #include <sound/pcm.h>
>  #include <sound/soc.h>
> @@ -156,10 +157,34 @@ static int sc7180_lpass_exit(struct platform_device *pdev)
>         struct lpass_data *drvdata = platform_get_drvdata(pdev);
>
>         clk_bulk_disable_unprepare(drvdata->num_clks, drvdata->clks);
> +       return 0;
> +}
> +
> +static int sc7180_lpass_dev_resume(struct device *dev)
> +{
> +       int ret = 0;

Please don't assign ret and then assign it again. It hides use before
true assignment bugs.

> +       struct lpass_data *drvdata = dev_get_drvdata(dev);
>
> +       ret = clk_bulk_prepare_enable(drvdata->num_clks, drvdata->clks);
> +       if (ret) {
> +               dev_err(dev, "sc7180 clk prepare and enable failed\n");
> +               return ret;
> +       }
> +       return ret;

This could be simplified to

	ret = clk_bulk_prepare_enable(...);
	if (ret)
		dev_err(dev, ...);

	return ret;
Geert Uytterhoeven Nov. 29, 2022, 7:53 a.m. UTC | #3
Hi Srinivasa,

On Mon, Nov 28, 2022 at 8:50 AM Srinivasa Rao Mandadapu
<quic_srivasam@quicinc.com> wrote:
> Update lpass sc7180 platform driver with PM ops, such as
> system supend and resume callbacks.
> This update is required to disable clocks during supend and
> avoid XO shutdown issue.
>
> Signed-off-by: Srinivasa Rao Mandadapu <quic_srivasam@quicinc.com>
> Tested-by: Rahul Ajmeriya <quic_rajmeriy@quicinc.com>

Thanks for your patch, which is now commit 2d68148f8f85ca5a ("ASoC:
qcom: lpass-sc7180: Add system suspend/resume PM ops") in next-20221129.

> --- a/sound/soc/qcom/lpass-sc7180.c
> +++ b/sound/soc/qcom/lpass-sc7180.c
> @@ -12,6 +12,7 @@
>  #include <linux/module.h>
>  #include <linux/of.h>
>  #include <linux/platform_device.h>
> +#include <linux/pm_runtime.h>
>  #include <dt-bindings/sound/sc7180-lpass.h>
>  #include <sound/pcm.h>
>  #include <sound/soc.h>
> @@ -156,10 +157,34 @@ static int sc7180_lpass_exit(struct platform_device *pdev)
>         struct lpass_data *drvdata = platform_get_drvdata(pdev);
>
>         clk_bulk_disable_unprepare(drvdata->num_clks, drvdata->clks);
> +       return 0;
> +}
> +
> +static int sc7180_lpass_dev_resume(struct device *dev)
> +{
> +       int ret = 0;
> +       struct lpass_data *drvdata = dev_get_drvdata(dev);
>
> +       ret = clk_bulk_prepare_enable(drvdata->num_clks, drvdata->clks);
> +       if (ret) {
> +               dev_err(dev, "sc7180 clk prepare and enable failed\n");
> +               return ret;
> +       }
> +       return ret;
> +}
> +
> +static int sc7180_lpass_dev_suspend(struct device *dev)
> +{
> +       struct lpass_data *drvdata = dev_get_drvdata(dev);
> +
> +       clk_bulk_disable_unprepare(drvdata->num_clks, drvdata->clks);
>         return 0;
>  }

noreply@ellerman.id.au reports for e.g. m68k-allmodconfig:

    sound/soc/qcom/lpass-sc7180.c:179:12: error:
'sc7180_lpass_dev_suspend' defined but not used
[-Werror=unused-function]
    sound/soc/qcom/lpass-sc7180.c:166:12: error:
'sc7180_lpass_dev_resume' defined but not used
[-Werror=unused-function]

>
> +static const struct dev_pm_ops sc7180_lpass_pm_ops = {
> +       SET_SYSTEM_SLEEP_PM_OPS(sc7180_lpass_dev_suspend, sc7180_lpass_dev_resume)
> +};

Please use DEFINE_SIMPLE_DEV_PM_OPS()...

> +
>  static struct lpass_variant sc7180_data = {
>         .i2sctrl_reg_base       = 0x1000,
>         .i2sctrl_reg_stride     = 0x1000,
> @@ -293,6 +318,7 @@ static struct platform_driver sc7180_lpass_cpu_platform_driver = {
>         .driver = {
>                 .name = "sc7180-lpass-cpu",
>                 .of_match_table = of_match_ptr(sc7180_lpass_cpu_device_id),
> +               .pm = &sc7180_lpass_pm_ops,

... and pm_sleep_ptr().

>         },
>         .probe = asoc_qcom_lpass_cpu_platform_probe,
>         .remove = asoc_qcom_lpass_cpu_platform_remove,

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Srinivasa Rao Mandadapu Nov. 29, 2022, 10:35 a.m. UTC | #4
Hi Geert,

Thanks for your time!!!

On 11/29/2022 1:23 PM, Geert Uytterhoeven wrote:
> Hi Srinivasa,
>
> On Mon, Nov 28, 2022 at 8:50 AM Srinivasa Rao Mandadapu
> <quic_srivasam@quicinc.com> wrote:
>> Update lpass sc7180 platform driver with PM ops, such as
>> system supend and resume callbacks.
>> This update is required to disable clocks during supend and
>> avoid XO shutdown issue.
>>
>> Signed-off-by: Srinivasa Rao Mandadapu <quic_srivasam@quicinc.com>
>> Tested-by: Rahul Ajmeriya <quic_rajmeriy@quicinc.com>
> Thanks for your patch, which is now commit 2d68148f8f85ca5a ("ASoC:
> qcom: lpass-sc7180: Add system suspend/resume PM ops") in next-20221129.
>
>> --- a/sound/soc/qcom/lpass-sc7180.c
>> +++ b/sound/soc/qcom/lpass-sc7180.c
>> @@ -12,6 +12,7 @@
>>   #include <linux/module.h>
>>   #include <linux/of.h>
>>   #include <linux/platform_device.h>
>> +#include <linux/pm_runtime.h>
>>   #include <dt-bindings/sound/sc7180-lpass.h>
>>   #include <sound/pcm.h>
>>   #include <sound/soc.h>
>> @@ -156,10 +157,34 @@ static int sc7180_lpass_exit(struct platform_device *pdev)
>>          struct lpass_data *drvdata = platform_get_drvdata(pdev);
>>
>>          clk_bulk_disable_unprepare(drvdata->num_clks, drvdata->clks);
>> +       return 0;
>> +}
>> +
>> +static int sc7180_lpass_dev_resume(struct device *dev)
>> +{
>> +       int ret = 0;
>> +       struct lpass_data *drvdata = dev_get_drvdata(dev);
>>
>> +       ret = clk_bulk_prepare_enable(drvdata->num_clks, drvdata->clks);
>> +       if (ret) {
>> +               dev_err(dev, "sc7180 clk prepare and enable failed\n");
>> +               return ret;
>> +       }
>> +       return ret;
>> +}
>> +
>> +static int sc7180_lpass_dev_suspend(struct device *dev)
>> +{
>> +       struct lpass_data *drvdata = dev_get_drvdata(dev);
>> +
>> +       clk_bulk_disable_unprepare(drvdata->num_clks, drvdata->clks);
>>          return 0;
>>   }
> noreply@ellerman.id.au reports for e.g. m68k-allmodconfig:
>
>      sound/soc/qcom/lpass-sc7180.c:179:12: error:
> 'sc7180_lpass_dev_suspend' defined but not used
> [-Werror=unused-function]
>      sound/soc/qcom/lpass-sc7180.c:166:12: error:
> 'sc7180_lpass_dev_resume' defined but not used
> [-Werror=unused-function]
>
>> +static const struct dev_pm_ops sc7180_lpass_pm_ops = {
>> +       SET_SYSTEM_SLEEP_PM_OPS(sc7180_lpass_dev_suspend, sc7180_lpass_dev_resume)
>> +};
> Please use DEFINE_SIMPLE_DEV_PM_OPS()...
Actually, we need to use this patch in in previous kernels 5.4 and 5.15.
I think these changes won't apply on previous kernel.
Hence ignoring for now and will take care next time.
>
>> +
>>   static struct lpass_variant sc7180_data = {
>>          .i2sctrl_reg_base       = 0x1000,
>>          .i2sctrl_reg_stride     = 0x1000,
>> @@ -293,6 +318,7 @@ static struct platform_driver sc7180_lpass_cpu_platform_driver = {
>>          .driver = {
>>                  .name = "sc7180-lpass-cpu",
>>                  .of_match_table = of_match_ptr(sc7180_lpass_cpu_device_id),
>> +               .pm = &sc7180_lpass_pm_ops,
> ... and pm_sleep_ptr().
>
>>          },
>>          .probe = asoc_qcom_lpass_cpu_platform_probe,
>>          .remove = asoc_qcom_lpass_cpu_platform_remove,
> Gr{oetje,eeting}s,
>
>                          Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                  -- Linus Torvalds
Geert Uytterhoeven Nov. 29, 2022, 10:53 a.m. UTC | #5
Hi Srinivasa,

On Tue, Nov 29, 2022 at 11:36 AM Srinivasa Rao Mandadapu
<quic_srivasam@quicinc.com> wrote:
> On 11/29/2022 1:23 PM, Geert Uytterhoeven wrote:
> > On Mon, Nov 28, 2022 at 8:50 AM Srinivasa Rao Mandadapu
> > <quic_srivasam@quicinc.com> wrote:
> >> Update lpass sc7180 platform driver with PM ops, such as
> >> system supend and resume callbacks.
> >> This update is required to disable clocks during supend and
> >> avoid XO shutdown issue.
> >>
> >> Signed-off-by: Srinivasa Rao Mandadapu <quic_srivasam@quicinc.com>
> >> Tested-by: Rahul Ajmeriya <quic_rajmeriy@quicinc.com>
> > Thanks for your patch, which is now commit 2d68148f8f85ca5a ("ASoC:
> > qcom: lpass-sc7180: Add system suspend/resume PM ops") in next-20221129.
> >
> >> --- a/sound/soc/qcom/lpass-sc7180.c
> >> +++ b/sound/soc/qcom/lpass-sc7180.c
> >> @@ -12,6 +12,7 @@
> >>   #include <linux/module.h>
> >>   #include <linux/of.h>
> >>   #include <linux/platform_device.h>
> >> +#include <linux/pm_runtime.h>
> >>   #include <dt-bindings/sound/sc7180-lpass.h>
> >>   #include <sound/pcm.h>
> >>   #include <sound/soc.h>
> >> @@ -156,10 +157,34 @@ static int sc7180_lpass_exit(struct platform_device *pdev)
> >>          struct lpass_data *drvdata = platform_get_drvdata(pdev);
> >>
> >>          clk_bulk_disable_unprepare(drvdata->num_clks, drvdata->clks);
> >> +       return 0;
> >> +}
> >> +
> >> +static int sc7180_lpass_dev_resume(struct device *dev)
> >> +{
> >> +       int ret = 0;
> >> +       struct lpass_data *drvdata = dev_get_drvdata(dev);
> >>
> >> +       ret = clk_bulk_prepare_enable(drvdata->num_clks, drvdata->clks);
> >> +       if (ret) {
> >> +               dev_err(dev, "sc7180 clk prepare and enable failed\n");
> >> +               return ret;
> >> +       }
> >> +       return ret;
> >> +}
> >> +
> >> +static int sc7180_lpass_dev_suspend(struct device *dev)
> >> +{
> >> +       struct lpass_data *drvdata = dev_get_drvdata(dev);
> >> +
> >> +       clk_bulk_disable_unprepare(drvdata->num_clks, drvdata->clks);
> >>          return 0;
> >>   }
> > noreply@ellerman.id.au reports for e.g. m68k-allmodconfig:
> >
> >      sound/soc/qcom/lpass-sc7180.c:179:12: error:
> > 'sc7180_lpass_dev_suspend' defined but not used
> > [-Werror=unused-function]
> >      sound/soc/qcom/lpass-sc7180.c:166:12: error:
> > 'sc7180_lpass_dev_resume' defined but not used
> > [-Werror=unused-function]
> >
> >> +static const struct dev_pm_ops sc7180_lpass_pm_ops = {
> >> +       SET_SYSTEM_SLEEP_PM_OPS(sc7180_lpass_dev_suspend, sc7180_lpass_dev_resume)
> >> +};
> > Please use DEFINE_SIMPLE_DEV_PM_OPS()...
> Actually, we need to use this patch in in previous kernels 5.4 and 5.15.
> I think these changes won't apply on previous kernel.
> Hence ignoring for now and will take care next time.

In that case you should add __maybe_unused tags to
sc7180_lpass_dev_suspend() and sc7180_lpass_dev_resume() first, so it
can be backported to 5.4 and 5.15, and do the DEFINE_SIMPLE_DEV_PM_OPS()
conversion later.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Conor Dooley Nov. 29, 2022, 12:14 p.m. UTC | #6
On Tue, Nov 29, 2022 at 11:53:10AM +0100, Geert Uytterhoeven wrote:
> Hi Srinivasa,
> 
> On Tue, Nov 29, 2022 at 11:36 AM Srinivasa Rao Mandadapu
> <quic_srivasam@quicinc.com> wrote:
> > On 11/29/2022 1:23 PM, Geert Uytterhoeven wrote:
> > > On Mon, Nov 28, 2022 at 8:50 AM Srinivasa Rao Mandadapu
> > > <quic_srivasam@quicinc.com> wrote:
> > >> Update lpass sc7180 platform driver with PM ops, such as
> > >> system supend and resume callbacks.
> > >> This update is required to disable clocks during supend and
> > >> avoid XO shutdown issue.
> > >>
> > >> Signed-off-by: Srinivasa Rao Mandadapu <quic_srivasam@quicinc.com>
> > >> Tested-by: Rahul Ajmeriya <quic_rajmeriy@quicinc.com>
> > > Thanks for your patch, which is now commit 2d68148f8f85ca5a ("ASoC:
> > > qcom: lpass-sc7180: Add system suspend/resume PM ops") in next-20221129.
> > >
> > >> --- a/sound/soc/qcom/lpass-sc7180.c
> > >> +++ b/sound/soc/qcom/lpass-sc7180.c
> > >> @@ -12,6 +12,7 @@
> > >>   #include <linux/module.h>
> > >>   #include <linux/of.h>
> > >>   #include <linux/platform_device.h>
> > >> +#include <linux/pm_runtime.h>
> > >>   #include <dt-bindings/sound/sc7180-lpass.h>
> > >>   #include <sound/pcm.h>
> > >>   #include <sound/soc.h>
> > >> @@ -156,10 +157,34 @@ static int sc7180_lpass_exit(struct platform_device *pdev)
> > >>          struct lpass_data *drvdata = platform_get_drvdata(pdev);
> > >>
> > >>          clk_bulk_disable_unprepare(drvdata->num_clks, drvdata->clks);
> > >> +       return 0;
> > >> +}
> > >> +
> > >> +static int sc7180_lpass_dev_resume(struct device *dev)
> > >> +{
> > >> +       int ret = 0;
> > >> +       struct lpass_data *drvdata = dev_get_drvdata(dev);
> > >>
> > >> +       ret = clk_bulk_prepare_enable(drvdata->num_clks, drvdata->clks);
> > >> +       if (ret) {
> > >> +               dev_err(dev, "sc7180 clk prepare and enable failed\n");
> > >> +               return ret;
> > >> +       }
> > >> +       return ret;
> > >> +}
> > >> +
> > >> +static int sc7180_lpass_dev_suspend(struct device *dev)
> > >> +{
> > >> +       struct lpass_data *drvdata = dev_get_drvdata(dev);
> > >> +
> > >> +       clk_bulk_disable_unprepare(drvdata->num_clks, drvdata->clks);
> > >>          return 0;
> > >>   }
> > > noreply@ellerman.id.au reports for e.g. m68k-allmodconfig:
> > >
> > >      sound/soc/qcom/lpass-sc7180.c:179:12: error:
> > > 'sc7180_lpass_dev_suspend' defined but not used
> > > [-Werror=unused-function]
> > >      sound/soc/qcom/lpass-sc7180.c:166:12: error:
> > > 'sc7180_lpass_dev_resume' defined but not used
> > > [-Werror=unused-function]
> > >
> > >> +static const struct dev_pm_ops sc7180_lpass_pm_ops = {
> > >> +       SET_SYSTEM_SLEEP_PM_OPS(sc7180_lpass_dev_suspend, sc7180_lpass_dev_resume)
> > >> +};
> > > Please use DEFINE_SIMPLE_DEV_PM_OPS()...
> > Actually, we need to use this patch in in previous kernels 5.4 and 5.15.
> > I think these changes won't apply on previous kernel.
> > Hence ignoring for now and will take care next time.
> 
> In that case you should add __maybe_unused tags to
> sc7180_lpass_dev_suspend() and sc7180_lpass_dev_resume() first, so it
> can be backported to 5.4 and 5.15, and do the DEFINE_SIMPLE_DEV_PM_OPS()
> conversion later.

FWIW, this is now breaking allmodconfig on RISC-V for this reason:

make[2]: *** [../scripts/Makefile.build:504: lib] Error 2
../sound/soc/qcom/lpass-sc7180.c:179:12: error: 'sc7180_lpass_dev_suspend' defined but not used [-Werror=unused-function]
  179 | static int sc7180_lpass_dev_suspend(struct device *dev)
      |            ^~~~~~~~~~~~~~~~~~~~~~~~
../sound/soc/qcom/lpass-sc7180.c:166:12: error: 'sc7180_lpass_dev_resume' defined but not used [-Werror=unused-function]
  166 | static int sc7180_lpass_dev_resume(struct device *dev)
      |            ^~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Thanks,
Conor.
diff mbox series

Patch

diff --git a/sound/soc/qcom/lpass-sc7180.c b/sound/soc/qcom/lpass-sc7180.c
index 77a556b..6ad1c5b 100644
--- a/sound/soc/qcom/lpass-sc7180.c
+++ b/sound/soc/qcom/lpass-sc7180.c
@@ -12,6 +12,7 @@ 
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <dt-bindings/sound/sc7180-lpass.h>
 #include <sound/pcm.h>
 #include <sound/soc.h>
@@ -156,10 +157,34 @@  static int sc7180_lpass_exit(struct platform_device *pdev)
 	struct lpass_data *drvdata = platform_get_drvdata(pdev);
 
 	clk_bulk_disable_unprepare(drvdata->num_clks, drvdata->clks);
+	return 0;
+}
+
+static int sc7180_lpass_dev_resume(struct device *dev)
+{
+	int ret = 0;
+	struct lpass_data *drvdata = dev_get_drvdata(dev);
 
+	ret = clk_bulk_prepare_enable(drvdata->num_clks, drvdata->clks);
+	if (ret) {
+		dev_err(dev, "sc7180 clk prepare and enable failed\n");
+		return ret;
+	}
+	return ret;
+}
+
+static int sc7180_lpass_dev_suspend(struct device *dev)
+{
+	struct lpass_data *drvdata = dev_get_drvdata(dev);
+
+	clk_bulk_disable_unprepare(drvdata->num_clks, drvdata->clks);
 	return 0;
 }
 
+static const struct dev_pm_ops sc7180_lpass_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(sc7180_lpass_dev_suspend, sc7180_lpass_dev_resume)
+};
+
 static struct lpass_variant sc7180_data = {
 	.i2sctrl_reg_base	= 0x1000,
 	.i2sctrl_reg_stride	= 0x1000,
@@ -293,6 +318,7 @@  static struct platform_driver sc7180_lpass_cpu_platform_driver = {
 	.driver = {
 		.name = "sc7180-lpass-cpu",
 		.of_match_table = of_match_ptr(sc7180_lpass_cpu_device_id),
+		.pm = &sc7180_lpass_pm_ops,
 	},
 	.probe = asoc_qcom_lpass_cpu_platform_probe,
 	.remove = asoc_qcom_lpass_cpu_platform_remove,