From patchwork Thu Apr 7 10:57:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 8770971 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7E365C0553 for ; Thu, 7 Apr 2016 10:57:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A5E5720222 for ; Thu, 7 Apr 2016 10:57:35 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 5B6332020F for ; Thu, 7 Apr 2016 10:57:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A11866E977; Thu, 7 Apr 2016 10:57:33 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0A8F36E976 for ; Thu, 7 Apr 2016 10:57:31 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 4E4E3AD61; Thu, 7 Apr 2016 10:57:28 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Date: Thu, 7 Apr 2016 12:57:24 +0200 Message-Id: <1460026644-30479-4-git-send-email-tiwai@suse.de> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1460026644-30479-1-git-send-email-tiwai@suse.de> References: <1460026644-30479-1-git-send-email-tiwai@suse.de> Cc: Daniel Vetter , intel-gfx@lists.freedesktop.org Subject: [Intel-gfx] [PATCH 3/3] ALSA: hda - Support deferred i915 audio component binding X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 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;