diff mbox

ALSA: hda - Handle pm failure during hotplug

Message ID 20180627062532.29244-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson June 27, 2018, 6:25 a.m. UTC
Obtaining the runtime pm wakeref can fail, especially in a hotplug
scenario where i915.ko has been unloaded. If we do not catch the
failure, we end up with an unbalanced pm.

References: 222bde03881c ("ALSA: hda - Fix mutex deadlock at HDMI/DP hotplug")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Vinod Koul <vinod.koul@intel.com>
---
 sound/pci/hda/patch_hdmi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Takashi Iwai June 27, 2018, 6:30 a.m. UTC | #1
On Wed, 27 Jun 2018 08:25:32 +0200,
Chris Wilson wrote:
> 
> Obtaining the runtime pm wakeref can fail, especially in a hotplug
> scenario where i915.ko has been unloaded. If we do not catch the
> failure, we end up with an unbalanced pm.
> 
> References: 222bde03881c ("ALSA: hda - Fix mutex deadlock at HDMI/DP hotplug")
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Takashi Iwai <tiwai@suse.de>
> Cc: Vinod Koul <vinod.koul@intel.com>

Thanks, applied with Cc to stable.


Takashi
Takashi Iwai June 27, 2018, 9:57 p.m. UTC | #2
On Wed, 27 Jun 2018 08:30:37 +0200,
Takashi Iwai wrote:
> 
> On Wed, 27 Jun 2018 08:25:32 +0200,
> Chris Wilson wrote:
> > 
> > Obtaining the runtime pm wakeref can fail, especially in a hotplug
> > scenario where i915.ko has been unloaded. If we do not catch the
> > failure, we end up with an unbalanced pm.
> > 
> > References: 222bde03881c ("ALSA: hda - Fix mutex deadlock at HDMI/DP hotplug")
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > Cc: Takashi Iwai <tiwai@suse.de>
> > Cc: Vinod Koul <vinod.koul@intel.com>
> 
> Thanks, applied with Cc to stable.

After the disaster (not about football game but of my further fix
patch), I revisited this change, and found that it's also buggy.

When pm_runtime_get_sync() returns an error, it doesn't decrement the
refcount.  That is, you'd need to call pm_runtime_put_noidle() or
whatever after getting the error.

And, pm_runtime_get_sync() returns 1, not only a negative error.
So, non-zero check is anyway incorrect.

Due to these reasons, I nuked the commit again.

For the HDMI error without i915 binding, I'll resubmit the proper
patch to disable HDMI codec after i915 component bind failure, as an
alternative workaround.  The previous patch didn't work as expected.


thanks,

Takashi
diff mbox

Patch

diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 7d7eb1354eee..3ca98c9fcaee 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -1632,8 +1632,8 @@  static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll)
 	int ret;
 
 	/* no temporary power up/down needed for component notifier */
-	if (!codec_has_acomp(codec))
-		snd_hda_power_up_pm(codec);
+	if (!codec_has_acomp(codec) && snd_hda_power_up_pm(codec))
+		return false;
 
 	mutex_lock(&spec->pcm_lock);
 	if (codec_has_acomp(codec)) {