From patchwork Wed Jun 20 06:25:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Feng Tang X-Patchwork-Id: 10476125 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D4BE9600F6 for ; Wed, 20 Jun 2018 06:23:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2A1428647 for ; Wed, 20 Jun 2018 06:23:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B619F286FF; Wed, 20 Jun 2018 06:23:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5F05628647 for ; Wed, 20 Jun 2018 06:23:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B6E736E6A4; Wed, 20 Jun 2018 06:23:27 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0C85A6E6A4 for ; Wed, 20 Jun 2018 06:23:26 +0000 (UTC) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Jun 2018 23:23:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,246,1526367600"; d="scan'208";a="49115850" Received: from shbuild888.sh.intel.com (HELO localhost) ([10.239.146.239]) by fmsmga008.fm.intel.com with ESMTP; 19 Jun 2018 23:23:10 -0700 Date: Wed, 20 Jun 2018 14:25:23 +0800 From: Feng Tang To: Jani Nikula , Chris Wilson , Takashi Iwai Message-ID: <20180620062523.xpkqeknrklgrihpl@shbuild888> References: <20180604053219.2040-1-feng.tang@intel.com> <878t7t7ka7.fsf@intel.com> <20180605075101.ipkhu57i4abpkbjn@shbuild888> <87602x7ijd.fsf@intel.com> <20180606073611.esunkbud45gddoo4@shbuild888> <87wovc5nqg.fsf@intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87wovc5nqg.fsf@intel.com> User-Agent: NeoMutt/20170609 (1.8.3) Subject: Re: [Intel-gfx] [RFC] i915: make the probe asynchronous X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Takashi Iwai , Daniel Vetter , intel-gfx@lists.freedesktop.org, alek.du@intel.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Hi Jani/Chris/Takashi, On Wed, Jun 06, 2018 at 11:21:43AM +0300, Jani Nikula wrote: > >> > >> http://patchwork.freedesktop.org/patch/msgid/20180323083048.13327-1-chris@chris-wilson.co.uk > > > > IIUC, you are waiting for the HDA audio driver to first handle the > > i915 sync probel case? > > I wouldn't hold my breath waiting. If you want to do i915 async probe, > you'll probably have to figure hda out as well. I made the following patch based on 4.18-rc1, and tested on my machine, which basically works fine with Async probe taking effect (I tried builtin and modules way). Please review this initial version, and I'll separate to clean patches if you think it's OK. thanks! - Feng ------ diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index 4364922..16a59ae 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c @@ -671,6 +671,21 @@ static const struct pci_device_id pciidlist[] = { }; MODULE_DEVICE_TABLE(pci, pciidlist); +static struct completion i915_probe_done; + +int wait_i915_probe_done(int timeout) +{ + int ret; + + ret = wait_for_completion_interruptible_timeout(&i915_probe_done, timeout); + if (ret <= 0) + return -ENODEV; + + return 0; +} +EXPORT_SYMBOL_GPL(wait_i915_probe_done); + + static void i915_pci_remove(struct pci_dev *pdev) { struct drm_device *dev = pci_get_drvdata(pdev); @@ -717,6 +732,7 @@ static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) return err > 0 ? -ENOTTY : err; } + complete_all(&i915_probe_done); return 0; } @@ -726,6 +742,7 @@ static struct pci_driver i915_pci_driver = { .probe = i915_pci_probe, .remove = i915_pci_remove, .driver.pm = &i915_pm_ops, + .driver.probe_type = PROBE_PREFER_ASYNCHRONOUS, }; static int __init i915_init(void) @@ -755,6 +772,8 @@ static int __init i915_init(void) return 0; } + init_completion(&i915_probe_done); + return pci_register_driver(&i915_pci_driver); } diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h index c9e5a66..adae172 100644 --- a/include/drm/i915_drm.h +++ b/include/drm/i915_drm.h @@ -36,6 +36,12 @@ extern bool i915_gpu_lower(void); extern bool i915_gpu_busy(void); extern bool i915_gpu_turbo_disable(void); +/* + * For use by HDA driver for now + * Return 0 on i915 probe is done, and -ENODEV on error + */ +extern int wait_i915_probe_done(int timeout); + /* Exported from arch/x86/kernel/early-quirks.c */ extern struct resource intel_graphics_stolen_res; diff --git a/sound/hda/hdac_i915.c b/sound/hda/hdac_i915.c index cbe818e..48e5039 100644 --- a/sound/hda/hdac_i915.c +++ b/sound/hda/hdac_i915.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -357,6 +358,7 @@ static bool i915_gfx_present(void) * * Returns zero for success or a negative error code. */ +#define HDAC_WAIT_I915_LOAD_MS 3000 int snd_hdac_i915_init(struct hdac_bus *bus) { struct component_match *match = NULL; @@ -386,7 +388,11 @@ int snd_hdac_i915_init(struct hdac_bus *bus) * Atm, we don't support deferring the component binding, so make sure * i915 is loaded and that the binding successfully completes. */ - request_module("i915"); + ret = wait_i915_probe_done(HDAC_WAIT_I915_LOAD_MS); + if (ret) { + dev_info(dev, "failed to wait for i915 probe done\n"); + goto out_master_del; + } if (!acomp->ops) { ret = -ENODEV;