From patchwork Thu Sep 17 10:00:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 7205281 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 589129F336 for ; Thu, 17 Sep 2015 10:02:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 605E7207F5 for ; Thu, 17 Sep 2015 10:02:13 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 12393207B8 for ; Thu, 17 Sep 2015 10:02:12 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 2E092265821; Thu, 17 Sep 2015 12:02:11 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 0CD5F2656F0; Thu, 17 Sep 2015 12:00:26 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 6948226568F; Thu, 17 Sep 2015 12:00:24 +0200 (CEST) Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com [209.85.212.182]) by alsa0.perex.cz (Postfix) with ESMTP id AE1602656F3 for ; Thu, 17 Sep 2015 12:00:12 +0200 (CEST) Received: by wiclk2 with SMTP id lk2so20164181wic.1 for ; Thu, 17 Sep 2015 03:00:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zDj+1WbWRVRrfwsyv4AHrvSUz93z38QPQFYBD9EEi9Q=; b=I3LWk8UxkqhWtYBScfceBp5wfKQoTzs9v49narTpdyHwYyJlBZ20UMDof9N5OFNYcG V383NZinOp247gyvAwMSLIK6FeQjleqoEjSQX4viH/ExsNWTyzSMasxx9OzCBliwkfaA bkqIxHY48VlsyoZft2UN1ZXegqDWdaj4Q2cqrCKBZoLHacOoU1Y7OmMtrWnDQTkE3Ao1 MySiqkNMPJu+F9BkAAuPRka2bG5ydoaVpUQP3nDJ0kyQEjDFh+0D0WKCOcEjlHkljicG 5HEyb04eRZXNXBcTBrCM9yq331Gsi/DwA8kawOOMaeLgrLRC3ZbcfqS4jA2TxQ8a6tS4 raCA== X-Received: by 10.194.234.71 with SMTP id uc7mr37949315wjc.105.1442484012370; Thu, 17 Sep 2015 03:00:12 -0700 (PDT) Received: from localhost (port-4883.pppoe.wtnet.de. [84.46.19.38]) by smtp.gmail.com with ESMTPSA id lf10sm2512119wjb.23.2015.09.17.03.00.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2015 03:00:11 -0700 (PDT) From: Thierry Reding To: Takashi Iwai Date: Thu, 17 Sep 2015 12:00:06 +0200 Message-Id: <1442484006-9614-4-git-send-email-thierry.reding@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1442484006-9614-1-git-send-email-thierry.reding@gmail.com> References: <1442484006-9614-1-git-send-email-thierry.reding@gmail.com> Cc: alsa-devel@alsa-project.org, Kevin Hilman , Tyler Baker , linux-kernel@vger.kernel.org, Jon Hunter , linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [alsa-devel] [PATCH 3/3] ALSA: hda: Do not rely on explicit module loading X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Thierry Reding With MODALIAS information being properly exported to userspace helpers, there is no need to explicitly request modules. Upon registration of new codec devices, userspace will know which kernel module to load. This removes request_module() from the HDA controller's ->probe() path. Recursively loading a module this way causes a deadlock in the driver core because the HDA controller is locked as part of its own probe but probing its children (the HDA codec devices) will attempt to lock them again. In the past this has been worked around by splitting the probe into synchronous and asynchronous parts, where the request_module() is executed from a workqueue to avoid the deadlock. Since all the information necessary to let userspace load the proper kernel modules is now exported, there is no need for such workarounds anymore. Signed-off-by: Thierry Reding --- sound/pci/hda/hda_bind.c | 80 ------------------------------------------------ 1 file changed, 80 deletions(-) diff --git a/sound/pci/hda/hda_bind.c b/sound/pci/hda/hda_bind.c index d5ac25cc7fee..bbc7e2081b0d 100644 --- a/sound/pci/hda/hda_bind.c +++ b/sound/pci/hda/hda_bind.c @@ -146,72 +146,6 @@ void hda_codec_driver_unregister(struct hda_codec_driver *drv) } EXPORT_SYMBOL_GPL(hda_codec_driver_unregister); -static inline bool codec_probed(struct hda_codec *codec) -{ - return device_attach(hda_codec_dev(codec)) > 0 && codec->preset; -} - -/* try to auto-load and bind the codec module */ -static void codec_bind_module(struct hda_codec *codec) -{ -#ifdef MODULE - request_module("snd-hda-codec-id:%08x", codec->core.vendor_id); - if (codec_probed(codec)) - return; - request_module("snd-hda-codec-id:%04x*", - (codec->core.vendor_id >> 16) & 0xffff); - if (codec_probed(codec)) - return; -#endif -} - -#if IS_ENABLED(CONFIG_SND_HDA_CODEC_HDMI) -/* if all audio out widgets are digital, let's assume the codec as a HDMI/DP */ -static bool is_likely_hdmi_codec(struct hda_codec *codec) -{ - hda_nid_t nid; - - for_each_hda_codec_node(nid, codec) { - unsigned int wcaps = get_wcaps(codec, nid); - switch (get_wcaps_type(wcaps)) { - case AC_WID_AUD_IN: - return false; /* HDMI parser supports only HDMI out */ - case AC_WID_AUD_OUT: - if (!(wcaps & AC_WCAP_DIGITAL)) - return false; - break; - } - } - return true; -} -#else -/* no HDMI codec parser support */ -#define is_likely_hdmi_codec(codec) false -#endif /* CONFIG_SND_HDA_CODEC_HDMI */ - -static int codec_bind_generic(struct hda_codec *codec) -{ - if (codec->probe_id) - return -ENODEV; - - if (is_likely_hdmi_codec(codec)) { - codec->probe_id = HDA_CODEC_ID_GENERIC_HDMI; -#if IS_MODULE(CONFIG_SND_HDA_CODEC_HDMI) - request_module("snd-hda-codec-hdmi"); -#endif - if (codec_probed(codec)) - return 0; - } - - codec->probe_id = HDA_CODEC_ID_GENERIC; -#if IS_MODULE(CONFIG_SND_HDA_GENERIC) - request_module("snd-hda-codec-generic"); -#endif - if (codec_probed(codec)) - return 0; - return -ENODEV; -} - #if IS_ENABLED(CONFIG_SND_HDA_GENERIC) #define is_generic_config(codec) \ (codec->modelname && !strcmp(codec->modelname, "generic")) @@ -241,25 +175,11 @@ int snd_hda_codec_configure(struct hda_codec *codec) if (err < 0) return err; - if (!codec->preset) - codec_bind_module(codec); - if (!codec->preset) { - err = codec_bind_generic(codec); - if (err < 0) { - codec_err(codec, "Unable to bind the codec\n"); - goto error; - } - } - /* audio codec should override the mixer name */ if (codec->core.afg || !*codec->card->mixername) snprintf(codec->card->mixername, sizeof(codec->card->mixername), "%s %s", codec->core.vendor_name, codec->core.chip_name); return 0; - - error: - snd_hdac_device_unregister(&codec->core); - return err; } EXPORT_SYMBOL_GPL(snd_hda_codec_configure);