linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] ASoC: stm32: add pm runtime support
@ 2021-11-18  9:00 Olivier Moysan
  2021-11-18  9:00 ` [PATCH 1/3] ASoC: stm32: i2s: add pm_runtime support Olivier Moysan
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Olivier Moysan @ 2021-11-18  9:00 UTC (permalink / raw)
  To: Alexandre Torgue, Arnaud Pouliquen, Jaroslav Kysela,
	Liam Girdwood, Mark Brown, Maxime Coquelin, Olivier Moysan,
	Takashi Iwai
  Cc: alsa-devel, linux-arm-kernel, linux-kernel, linux-stm32

Enable support of pm runtime on STM32 SPDIFRX, I2S and DFSDM drivers
to allow power state monitoring.

Olivier Moysan (3):
  ASoC: stm32: i2s: add pm_runtime support
  ASoC: stm32: dfsdm: add pm_runtime support for audio
  ASoC: stm32: spdifrx: add pm_runtime support

 sound/soc/stm/stm32_adfsdm.c  | 11 ++++++++---
 sound/soc/stm/stm32_i2s.c     |  4 ++++
 sound/soc/stm/stm32_spdifrx.c |  4 ++++
 3 files changed, 16 insertions(+), 3 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] ASoC: stm32: i2s: add pm_runtime support
  2021-11-18  9:00 [PATCH 0/3] ASoC: stm32: add pm runtime support Olivier Moysan
@ 2021-11-18  9:00 ` Olivier Moysan
  2021-11-18  9:00 ` [PATCH 2/3] ASoC: stm32: dfsdm: add pm_runtime support for audio Olivier Moysan
  2021-11-18  9:00 ` [PATCH 3/3] ASoC: stm32: spdifrx: add pm_runtime support Olivier Moysan
  2 siblings, 0 replies; 5+ messages in thread
From: Olivier Moysan @ 2021-11-18  9:00 UTC (permalink / raw)
  To: Alexandre Torgue, Arnaud Pouliquen, Jaroslav Kysela,
	Liam Girdwood, Mark Brown, Maxime Coquelin, Olivier Moysan,
	Takashi Iwai
  Cc: alsa-devel, linux-arm-kernel, linux-kernel, linux-stm32

Enable support of pm_runtime on STM32 I2S driver to allow
I2S power state monitoring.

Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
---
 sound/soc/stm/stm32_i2s.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sound/soc/stm/stm32_i2s.c b/sound/soc/stm/stm32_i2s.c
index 6254bacad6eb..52cd1df49be1 100644
--- a/sound/soc/stm/stm32_i2s.c
+++ b/sound/soc/stm/stm32_i2s.c
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
+#include <linux/pm_runtime.h>
 #include <linux/regmap.h>
 #include <linux/reset.h>
 #include <linux/spinlock.h>
@@ -1113,6 +1114,7 @@ static int stm32_i2s_remove(struct platform_device *pdev)
 {
 	snd_dmaengine_pcm_unregister(&pdev->dev);
 	snd_soc_unregister_component(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
 
 	return 0;
 }
@@ -1195,6 +1197,8 @@ static int stm32_i2s_probe(struct platform_device *pdev)
 			FIELD_GET(I2S_VERR_MIN_MASK, val));
 	}
 
+	pm_runtime_enable(&pdev->dev);
+
 	return ret;
 
 error:
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] ASoC: stm32: dfsdm: add pm_runtime support for audio
  2021-11-18  9:00 [PATCH 0/3] ASoC: stm32: add pm runtime support Olivier Moysan
  2021-11-18  9:00 ` [PATCH 1/3] ASoC: stm32: i2s: add pm_runtime support Olivier Moysan
@ 2021-11-18  9:00 ` Olivier Moysan
  2021-11-18 13:56   ` Mark Brown
  2021-11-18  9:00 ` [PATCH 3/3] ASoC: stm32: spdifrx: add pm_runtime support Olivier Moysan
  2 siblings, 1 reply; 5+ messages in thread
From: Olivier Moysan @ 2021-11-18  9:00 UTC (permalink / raw)
  To: Alexandre Torgue, Arnaud Pouliquen, Jaroslav Kysela,
	Liam Girdwood, Mark Brown, Maxime Coquelin, Olivier Moysan,
	Takashi Iwai
  Cc: alsa-devel, linux-arm-kernel, linux-kernel, linux-stm32

Enable support of pm_runtime on STM32 DFSDM audio driver
to allow power state monitoring.

Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
---
 sound/soc/stm/stm32_adfsdm.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/sound/soc/stm/stm32_adfsdm.c b/sound/soc/stm/stm32_adfsdm.c
index e6078f50e508..534f96af97c5 100644
--- a/sound/soc/stm/stm32_adfsdm.c
+++ b/sound/soc/stm/stm32_adfsdm.c
@@ -12,7 +12,7 @@
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
-
+#include <linux/pm_runtime.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/consumer.h>
 #include <linux/iio/adc/stm32-dfsdm-adc.h>
@@ -363,15 +363,20 @@ static int stm32_adfsdm_probe(struct platform_device *pdev)
 #endif
 
 	ret = snd_soc_add_component(component, NULL, 0);
-	if (ret < 0)
+	if (ret < 0) {
 		dev_err(&pdev->dev, "%s: Failed to register PCM platform\n",
 			__func__);
+		return ret;
+	}
 
-	return ret;
+	pm_runtime_enable(&pdev->dev);
+
+	return 0;
 }
 
 static int stm32_adfsdm_remove(struct platform_device *pdev)
 {
+	pm_runtime_disable(&pdev->dev);
 	snd_soc_unregister_component(&pdev->dev);
 
 	return 0;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] ASoC: stm32: spdifrx: add pm_runtime support
  2021-11-18  9:00 [PATCH 0/3] ASoC: stm32: add pm runtime support Olivier Moysan
  2021-11-18  9:00 ` [PATCH 1/3] ASoC: stm32: i2s: add pm_runtime support Olivier Moysan
  2021-11-18  9:00 ` [PATCH 2/3] ASoC: stm32: dfsdm: add pm_runtime support for audio Olivier Moysan
@ 2021-11-18  9:00 ` Olivier Moysan
  2 siblings, 0 replies; 5+ messages in thread
From: Olivier Moysan @ 2021-11-18  9:00 UTC (permalink / raw)
  To: Alexandre Torgue, Arnaud Pouliquen, Jaroslav Kysela,
	Liam Girdwood, Mark Brown, Maxime Coquelin, Olivier Moysan,
	Takashi Iwai
  Cc: alsa-devel, linux-arm-kernel, linux-kernel, linux-stm32

Enable support of pm_runtime on STM32 SPDIFRX driver to allow
SPDIFRX power state monitoring.

Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
---
 sound/soc/stm/stm32_spdifrx.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sound/soc/stm/stm32_spdifrx.c b/sound/soc/stm/stm32_spdifrx.c
index 48145f553588..e885796ca5f4 100644
--- a/sound/soc/stm/stm32_spdifrx.c
+++ b/sound/soc/stm/stm32_spdifrx.c
@@ -12,6 +12,7 @@
 #include <linux/delay.h>
 #include <linux/module.h>
 #include <linux/of_platform.h>
+#include <linux/pm_runtime.h>
 #include <linux/regmap.h>
 #include <linux/reset.h>
 
@@ -955,6 +956,7 @@ static int stm32_spdifrx_remove(struct platform_device *pdev)
 
 	snd_dmaengine_pcm_unregister(&pdev->dev);
 	snd_soc_unregister_component(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
 
 	return 0;
 }
@@ -1045,6 +1047,8 @@ static int stm32_spdifrx_probe(struct platform_device *pdev)
 			FIELD_GET(SPDIFRX_VERR_MIN_MASK, ver));
 	}
 
+	pm_runtime_enable(&pdev->dev);
+
 	return ret;
 
 error:
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/3] ASoC: stm32: dfsdm: add pm_runtime support for audio
  2021-11-18  9:00 ` [PATCH 2/3] ASoC: stm32: dfsdm: add pm_runtime support for audio Olivier Moysan
@ 2021-11-18 13:56   ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2021-11-18 13:56 UTC (permalink / raw)
  To: Olivier Moysan
  Cc: Alexandre Torgue, Arnaud Pouliquen, Jaroslav Kysela,
	Liam Girdwood, Maxime Coquelin, Takashi Iwai, alsa-devel,
	linux-arm-kernel, linux-kernel, linux-stm32

[-- Attachment #1: Type: text/plain, Size: 643 bytes --]

On Thu, Nov 18, 2021 at 10:00:34AM +0100, Olivier Moysan wrote:

>  	ret = snd_soc_add_component(component, NULL, 0);
> -	if (ret < 0)
> +	if (ret < 0) {
>  		dev_err(&pdev->dev, "%s: Failed to register PCM platform\n",
>  			__func__);
> +		return ret;
> +	}
>  
> -	return ret;
> +	pm_runtime_enable(&pdev->dev);

Enabling runtime PM after registering the component may potentially lead
to a race where something manages to go in and starts using the device
including what should be runtime PM stuff.  That'd lead to a reference
not being taken that should be.  It's unlikely to actually happen but
it's better to be safe.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-11-18 13:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-18  9:00 [PATCH 0/3] ASoC: stm32: add pm runtime support Olivier Moysan
2021-11-18  9:00 ` [PATCH 1/3] ASoC: stm32: i2s: add pm_runtime support Olivier Moysan
2021-11-18  9:00 ` [PATCH 2/3] ASoC: stm32: dfsdm: add pm_runtime support for audio Olivier Moysan
2021-11-18 13:56   ` Mark Brown
2021-11-18  9:00 ` [PATCH 3/3] ASoC: stm32: spdifrx: add pm_runtime support Olivier Moysan

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).