From patchwork Thu Apr 7 10:57:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 8771011 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 26A989F36E for ; Thu, 7 Apr 2016 10:59:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0F69C20204 for ; Thu, 7 Apr 2016 10:59:33 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id A4CDE201EC for ; Thu, 7 Apr 2016 10:59:31 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id BDFFC266659; Thu, 7 Apr 2016 12:59:30 +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=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 5860D26644E; Thu, 7 Apr 2016 12:57:43 +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 650AD266573; Thu, 7 Apr 2016 12:57:42 +0200 (CEST) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 100BD26644E for ; Thu, 7 Apr 2016 12:57:30 +0200 (CEST) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 51ABFAD85; 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:22 +0200 Message-Id: <1460026644-30479-2-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, Imre Deak , Jani Nikula Subject: [alsa-devel] [PATCH 1/3] drm/i915/hda: Add audio component stub 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: Imre Deak User may pass nomodeset or i915.modeset=0 option to disable i915 KMS explicitly. Although this itself works fine, it breaks the weak dependency the HD-audio driver requires, and it's the reason the delayed component binding isn't implemented in HD-audio. Since i915 doesn't notify its disablement, HD-audio would be blocked unnecessarily endlessly, waiting for the bind with i915. This patch introduces a stub audio component binding when i915 driver is loaded with KMS off like the boot options above. Then i915 driver still registers the slave component but with the new "disabled" ops flag, so that the master component (HD-audio) can know clearly the slave state. Signed-off-by: Imre Deak Signed-off-by: Takashi Iwai --- drivers/gpu/drm/i915/i915_drv.c | 34 +++++++++++++-------- drivers/gpu/drm/i915/intel_audio.c | 61 ++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_drv.h | 2 ++ include/drm/i915_component.h | 5 ++++ 4 files changed, 90 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index 20e82008b8b6..21c6bac5468e 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c @@ -950,6 +950,19 @@ static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) struct intel_device_info *intel_info = (struct intel_device_info *) ent->driver_data; + if (!(driver.driver_features & DRIVER_MODESET)) { + /* + * Notify the HDA driver so that it doesn't block waiting for + * i915 to become ready. + */ + i915_audio_component_stub_init(&pdev->dev); + + /* Silently fail loading to not upset userspace. */ + DRM_DEBUG_DRIVER("KMS and UMS disabled.\n"); + + return 0; + } + if (IS_PRELIMINARY_HW(intel_info) && !i915.preliminary_hw_support) { DRM_INFO("This hardware requires preliminary hardware support.\n" "See CONFIG_DRM_I915_PRELIMINARY_HW_SUPPORT, and/or modparam preliminary_hw_support\n"); @@ -979,8 +992,14 @@ static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) static void i915_pci_remove(struct pci_dev *pdev) { - struct drm_device *dev = pci_get_drvdata(pdev); + struct drm_device *dev; + if (!(driver.driver_features & DRIVER_MODESET)) { + i915_audio_component_stub_cleanup(&pdev->dev); + return; + } + + dev = pci_get_drvdata(pdev); drm_put_dev(dev); } @@ -1747,24 +1766,15 @@ static int __init i915_init(void) driver.driver_features &= ~DRIVER_MODESET; #endif - if (!(driver.driver_features & DRIVER_MODESET)) { - /* Silently fail loading to not upset userspace. */ - DRM_DEBUG_DRIVER("KMS and UMS disabled.\n"); - return 0; - } - if (i915.nuclear_pageflip) driver.driver_features |= DRIVER_ATOMIC; - return drm_pci_init(&driver, &i915_pci_driver); + return pci_register_driver(&i915_pci_driver); } static void __exit i915_exit(void) { - if (!(driver.driver_features & DRIVER_MODESET)) - return; /* Never loaded a driver. */ - - drm_pci_exit(&driver, &i915_pci_driver); + pci_unregister_driver(&i915_pci_driver); } module_init(i915_init); diff --git a/drivers/gpu/drm/i915/intel_audio.c b/drivers/gpu/drm/i915/intel_audio.c index 30f921421b0c..bd9e9760903a 100644 --- a/drivers/gpu/drm/i915/intel_audio.c +++ b/drivers/gpu/drm/i915/intel_audio.c @@ -835,3 +835,64 @@ void i915_audio_component_cleanup(struct drm_i915_private *dev_priv) component_del(dev_priv->dev->dev, &i915_audio_component_bind_ops); dev_priv->audio_component_registered = false; } + +static const struct i915_audio_component_ops i915_audio_component_stub_ops = { + .owner = THIS_MODULE, + .disabled = true, +}; + +static int i915_audio_component_stub_bind(struct device *i915_stub_dev, + struct device *hda_dev, void *data) +{ + struct i915_audio_component *acomp = data; + + if (WARN_ON(acomp->ops || acomp->dev)) + return -EEXIST; + + acomp->ops = &i915_audio_component_stub_ops; + acomp->dev = i915_stub_dev; + + return 0; +} + +static void i915_audio_component_stub_unbind(struct device *i915_stub_dev, + struct device *hda_dev, void *data) +{ + struct i915_audio_component *acomp = data; + + acomp->ops = NULL; + acomp->dev = NULL; +} + +static const struct component_ops i915_audio_component_stub_bind_ops = { + .bind = i915_audio_component_stub_bind, + .unbind = i915_audio_component_stub_unbind, +}; + +static const struct file_operations component_stub_dev_ops = { + .owner = THIS_MODULE, +}; + +static bool i915_audio_component_stub_registered; + +void i915_audio_component_stub_init(struct device *dev) +{ + int ret; + + ret = component_add(dev, &i915_audio_component_stub_bind_ops); + if (ret < 0) { + DRM_ERROR("failed to add audio stub component (%d)\n", ret); + return; + } + + i915_audio_component_stub_registered = true; +} + +void i915_audio_component_stub_cleanup(struct device *dev) +{ + if (!i915_audio_component_stub_registered) + return; + + component_del(dev, &i915_audio_component_stub_bind_ops); + i915_audio_component_stub_registered = false; +} diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 4c027d69fac9..e1d9c33b113e 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -1056,6 +1056,8 @@ void intel_audio_codec_enable(struct intel_encoder *encoder); void intel_audio_codec_disable(struct intel_encoder *encoder); void i915_audio_component_init(struct drm_i915_private *dev_priv); void i915_audio_component_cleanup(struct drm_i915_private *dev_priv); +void i915_audio_component_stub_init(struct device *dev); +void i915_audio_component_stub_cleanup(struct device *dev); /* intel_display.c */ extern const struct drm_plane_funcs intel_plane_funcs; diff --git a/include/drm/i915_component.h b/include/drm/i915_component.h index b46fa0ef3005..33da85aa70c3 100644 --- a/include/drm/i915_component.h +++ b/include/drm/i915_component.h @@ -39,6 +39,11 @@ struct i915_audio_component_ops { */ struct module *owner; /** + * @disabled: i915 driver loaded with modeset=0, the services provided + * via the audio component interface are not available. + */ + bool disabled; + /** * @get_power: get the POWER_DOMAIN_AUDIO power well * * Request the power well to be turned on.