From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Cc: Daniel Vetter <daniel.vetter@intel.com>, intel-gfx@lists.freedesktop.org
Subject: [PATCH 3/3] ALSA: hda - Support deferred i915 audio component binding
Date: Thu, 7 Apr 2016 12:57:24 +0200 [thread overview]
Message-ID: <1460026644-30479-4-git-send-email-tiwai@suse.de> (raw)
In-Reply-To: <1460026644-30479-1-git-send-email-tiwai@suse.de>
Since we have the reliable way to detect the availability of i915
audio component, the HD-audio driver may wait for the binding safely.
This patch puts a simple completion call in the binding callback and
let snd_hdac_i915_init() waiting until the i915 component gets bound
or it notifies.
The wait for binding has a timeout of 60 seconds, in case where the
i915 module isn't present on the media by some reason. Such a
situation is rather the system error, but it's still safe to get a
timeout and indicate user about that.
The explicit call of request_module() is still kept in this patch in
order to avoid regression even for a system without the implicit
driver loading. But now it's called in the condition only when no ops
is found, so it's slightly optimized.
The pin-down of i915 module is still kept, too, as the dynamic
unbinding is still problematic. It may be racy and lead to the
refcount unbalance.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/hda/hdac_i915.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/sound/hda/hdac_i915.c b/sound/hda/hdac_i915.c
index 812777f9af1f..6455d239a928 100644
--- a/sound/hda/hdac_i915.c
+++ b/sound/hda/hdac_i915.c
@@ -22,6 +22,7 @@
#include <sound/hda_i915.h>
static struct i915_audio_component *hdac_acomp;
+static DECLARE_COMPLETION(bind_comp);
/**
* snd_hdac_set_codec_wakeup - Enable / disable HDMI/DP codec wakeup
@@ -248,10 +249,12 @@ static int hdac_component_master_bind(struct device *dev)
goto out_unbind;
}
+ complete_all(&bind_comp);
return 0;
out_unbind:
component_unbind_all(dev, acomp);
+ complete_all(&bind_comp);
return ret;
}
@@ -339,6 +342,7 @@ int snd_hdac_i915_init(struct hdac_bus *bus)
return -ENOMEM;
bus->audio_component = acomp;
hdac_acomp = acomp;
+ init_completion(&bind_comp);
component_match_add(dev, &match, hdac_component_master_match, bus);
ret = component_master_add_with_match(dev, &hdac_component_master_ops,
@@ -346,12 +350,10 @@ int snd_hdac_i915_init(struct hdac_bus *bus)
if (ret < 0)
goto out_err;
- /*
- * Atm, we don't support deferring the component binding, so make sure
- * i915 is loaded and that the binding successfully completes.
- */
- request_module("i915");
+ if (!acomp->ops)
+ request_module("i915");
+ wait_for_completion_timeout(&bind_comp, msecs_to_jiffies(60 * 1000));
if (!acomp->ops || acomp->ops->disabled) {
ret = -ENODEV;
goto out_master_del;
--
2.8.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
prev parent reply other threads:[~2016-04-07 10:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-07 10:57 [PATCH 0/3] More robust i915 / audio binding Takashi Iwai
2016-04-07 10:57 ` [PATCH 1/3] drm/i915/hda: Add audio component stub Takashi Iwai
2016-04-07 11:55 ` Ville Syrjälä
2016-04-07 12:30 ` Imre Deak
2016-04-25 12:46 ` Takashi Iwai
2016-04-07 10:57 ` [PATCH 2/3] ALSA: hda - Immediately fail if the i915 audio component is disabled Takashi Iwai
2016-04-07 10:57 ` Takashi Iwai [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1460026644-30479-4-git-send-email-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=daniel.vetter@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).