* [PATCH 1/2] ALSA: x86: intel_hdmi_audio: enable pm_runtime and set autosuspend delay
2022-06-16 22:29 [PATCH 0/2] ALSA: x86: intel_hdmi_audio: pm_runtime updates Pierre-Louis Bossart
@ 2022-06-16 22:29 ` Pierre-Louis Bossart
2022-06-16 22:29 ` [PATCH 2/2] ALSA: x86: intel_hdmi_audio: use pm_runtime_resume_and_get() Pierre-Louis Bossart
2022-06-17 8:46 ` [PATCH 0/2] ALSA: x86: intel_hdmi_audio: pm_runtime updates Takashi Iwai
2 siblings, 0 replies; 4+ messages in thread
From: Pierre-Louis Bossart @ 2022-06-16 22:29 UTC (permalink / raw)
To: alsa-devel
Cc: Kai Vehmanen, tiwai, Pierre-Louis Bossart, Ranjani Sridharan,
Hans de Goede, broonie, Bard Liao
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.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
---
sound/x86/intel_hdmi_audio.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index 0d828e35b4019..3b04c70a73e33 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -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) {
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/2] ALSA: x86: intel_hdmi_audio: use pm_runtime_resume_and_get()
2022-06-16 22:29 [PATCH 0/2] ALSA: x86: intel_hdmi_audio: pm_runtime updates Pierre-Louis Bossart
2022-06-16 22:29 ` [PATCH 1/2] ALSA: x86: intel_hdmi_audio: enable pm_runtime and set autosuspend delay Pierre-Louis Bossart
@ 2022-06-16 22:29 ` Pierre-Louis Bossart
2022-06-17 8:46 ` [PATCH 0/2] ALSA: x86: intel_hdmi_audio: pm_runtime updates Takashi Iwai
2 siblings, 0 replies; 4+ messages in thread
From: Pierre-Louis Bossart @ 2022-06-16 22:29 UTC (permalink / raw)
To: alsa-devel
Cc: Kai Vehmanen, tiwai, Pierre-Louis Bossart, Ranjani Sridharan,
Hans de Goede, broonie, Bard Liao
The current code does not check for errors and does not release the
reference on errors.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
---
sound/x86/intel_hdmi_audio.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index 3b04c70a73e33..ab95fb34a6358 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -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",
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 0/2] ALSA: x86: intel_hdmi_audio: pm_runtime updates
2022-06-16 22:29 [PATCH 0/2] ALSA: x86: intel_hdmi_audio: pm_runtime updates Pierre-Louis Bossart
2022-06-16 22:29 ` [PATCH 1/2] ALSA: x86: intel_hdmi_audio: enable pm_runtime and set autosuspend delay Pierre-Louis Bossart
2022-06-16 22:29 ` [PATCH 2/2] ALSA: x86: intel_hdmi_audio: use pm_runtime_resume_and_get() Pierre-Louis Bossart
@ 2022-06-17 8:46 ` Takashi Iwai
2 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2022-06-17 8:46 UTC (permalink / raw)
To: Pierre-Louis Bossart; +Cc: Hans de Goede, alsa-devel, broonie
On Fri, 17 Jun 2022 00:29:08 +0200,
Pierre-Louis Bossart wrote:
>
> 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()
Applied both patches now. Thanks.
Takashi
^ permalink raw reply [flat|nested] 4+ messages in thread