Skip to contentSkip to conversation

ALSA: x86: intel_hdmi_audio: pm_runtime updates

PATCH Applied Pierre-Louis Bossart 2 participants 4 messages Jun 16, 2022 – Jun 17, 2022 Sound

lore
Share & tools
lore
#0 lore raw

cover ALSA: x86: intel_hdmi_audio: pm_runtime updates

While cleaning up the code to use pm_runtime_resume_and_get(), I realized we never called pm_runtime_enable() for this driver. This is potentially very invasive and error-prone, so feedback and test results are welcome - all my BYT/CHT devices are not longer functional unfortunately, and our CI MinnowBoard uses the 'other' HDMI solution based on HDaudio.

In addition, the resume was assumed to be always successful, which isn't a very good idea.

Pierre-Louis Bossart (2):
ALSA: x86: intel_hdmi_audio: enable pm_runtime and set autosuspend
delay
ALSA: x86: intel_hdmi_audio: use pm_runtime_resume_and_get()

 sound/x86/intel_hdmi_audio.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/2 ALSA: x86: intel_hdmi_audio: enable pm_runtime and set autosuspend delay

The existing code uses pm_runtime_get_sync/put_autosuspend, but pm_runtime was not explicitly enabled. The autosuspend delay was not set either, the value is set to 5s since HDMI is rather painful to resume.

---
 sound/x86/intel_hdmi_audio.c | 5 +++++
 1 file changed, 5 insertions(+)
sound/x86/intel_hdmi_audio.c +5 -0
index 0d828e35b4019..3b04c70a73e33 100644
@@ -33,6 +33,8 @@
 #include <drm/intel_lpe_audio.h>
 #include "intel_hdmi_audio.h"
 
+#define INTEL_HDMI_AUDIO_SUSPEND_DELAY_MS  5000
+
 #define for_each_pipe(card_ctx, pipe) \
 	for ((pipe) = 0; (pipe) < (card_ctx)->num_pipes; (pipe)++)
 #define for_each_port(card_ctx, port) \
@@ -1802,8 +1804,11 @@ static int __hdmi_lpe_audio_probe(struct platform_device *pdev)
 	pdata->notify_audio_lpe = notify_audio_lpe;
 	spin_unlock_irq(&pdata->lpe_audio_slock);
 
+	pm_runtime_set_autosuspend_delay(&pdev->dev, INTEL_HDMI_AUDIO_SUSPEND_DELAY_MS);
 	pm_runtime_use_autosuspend(&pdev->dev);
+	pm_runtime_enable(&pdev->dev);
 	pm_runtime_mark_last_busy(&pdev->dev);
+	pm_runtime_idle(&pdev->dev);
 
 	dev_dbg(&pdev->dev, "%s: handle pending notification\n", __func__);
 	for_each_port(card_ctx, port) {
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/2 ALSA: x86: intel_hdmi_audio: use pm_runtime_resume_and_get()

In reply to Pierre-Louis Bossart

The current code does not check for errors and does not release the reference on errors.

---
 sound/x86/intel_hdmi_audio.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
sound/x86/intel_hdmi_audio.c +8 -2
index 3b04c70a73e33..ab95fb34a6358 100644
@@ -1068,7 +1068,9 @@ static int had_pcm_open(struct snd_pcm_substream *substream)
 	intelhaddata = snd_pcm_substream_chip(substream);
 	runtime = substream->runtime;
 
-	pm_runtime_get_sync(intelhaddata->dev);
+	retval = pm_runtime_resume_and_get(intelhaddata->dev);
+	if (retval < 0)
+		return retval;
 
 	/* set the runtime hw parameter with local snd_pcm_hardware struct */
 	runtime->hw = had_pcm_hardware;
@@ -1536,8 +1538,12 @@ static void had_audio_wq(struct work_struct *work)
 		container_of(work, struct snd_intelhad, hdmi_audio_wq);
 	struct intel_hdmi_lpe_audio_pdata *pdata = ctx->dev->platform_data;
 	struct intel_hdmi_lpe_audio_port_pdata *ppdata = &pdata->port[ctx->port];
+	int ret;
+
+	ret = pm_runtime_resume_and_get(ctx->dev);
+	if (ret < 0)
+		return;
 
-	pm_runtime_get_sync(ctx->dev);
 	mutex_lock(&ctx->mutex);
 	if (ppdata->pipe < 0) {
 		dev_dbg(ctx->dev, "%s: Event: HAD_NOTIFY_HOT_UNPLUG : port = %d\n",
Signature · 1 line
2.34.1
Applied
#3 lore raw
In reply to Pierre-Louis Bossart
Quoted 8 lines · Pierre-Louis Bossart

While cleaning up the code to use pm_runtime_resume_and_get(), I realized we never called pm_runtime_enable() for this driver. This is potentially very invasive and error-prone, so feedback and test results are welcome - all my BYT/CHT devices are not longer functional unfortunately, and our CI MinnowBoard uses the 'other' HDMI solution based on HDaudio.

Quoted 7 lines

In addition, the resume was assumed to be always successful, which isn't a very good idea.

Pierre-Louis Bossart (2):
ALSA: x86: intel_hdmi_audio: enable pm_runtime and set autosuspend
delay
ALSA: x86: intel_hdmi_audio: use pm_runtime_resume_and_get()

Applied both patches now. Thanks.

Takashi