From patchwork Tue Aug 17 19:00:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 499040 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 565B2C4338F for ; Tue, 17 Aug 2021 19:03:31 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 386F960FBF for ; Tue, 17 Aug 2021 19:03:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 386F960FBF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id F0F7D1672; Tue, 17 Aug 2021 21:02:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz F0F7D1672 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1629227006; bh=UJVy7bw6a3CMbYJsNbFzfoqqRW2aI5YEmnqMNFvQ758=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ue+s7M1Q5gSErSCl03oPtOPTCWw95kPF8oTr0V8cdMV3eJY0Gk5fSb+x7o0ug/bvE I7VGvTphue7FHBlfuWA7oQAvvnKkwfKPVF72R7xsc0xJT2ZCWYxveuAi5H7AYagn1p tPu2lVjjag0kR/mPoJCXQqg0+VS/TkP97LaFsomM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 773EEF80272; Tue, 17 Aug 2021 21:01:46 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5FEC7F804B0; Tue, 17 Aug 2021 21:01:45 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9CDD6F8026D for ; Tue, 17 Aug 2021 21:01:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9CDD6F8026D X-IronPort-AV: E=McAfee;i="6200,9189,10079"; a="215898769" X-IronPort-AV: E=Sophos;i="5.84,329,1620716400"; d="scan'208";a="215898769" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2021 12:01:32 -0700 X-IronPort-AV: E=Sophos;i="5.84,329,1620716400"; d="scan'208";a="488147342" Received: from aaadelek-mobl3.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.212.12.89]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2021 12:01:31 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Subject: [RFC PATCH 1/2] driver core: export driver_deferred_probe_trigger() Date: Tue, 17 Aug 2021 14:00:56 -0500 Message-Id: <20210817190057.255264-2-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210817190057.255264-1-pierre-louis.bossart@linux.intel.com> References: <20210817190057.255264-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Cc: "Rafael J . Wysocki" , tiwai@suse.de, Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Pierre-Louis Bossart , liam.r.girdwood@linux.intel.com, vkoul@kernel.org, broonie@kernel.org, Geert Uytterhoeven , Jason Gunthorpe , Dan Williams , Andy Shevchenko , Christoph Hellwig X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" The premise of the deferred probe implementation is that a successful driver binding is a proxy for the resources provided by this driver becoming available. While this is a correct assumption in most of the cases, there are exceptions to the rule such as a) the use of request_firmware_nowait(). In this case, the resources may become available when the 'cont' callback completes, for example when if the firmware needs to be downloaded and executed on a SoC core or DSP. b) a split implementation of the probe with a workqueue when one or ore request_module() calls are required: a synchronous probe prevents other drivers from probing, impacting boot time, and an async probe is not allowed to avoid a deadlock. This is the case on all Intel audio platforms, with request_module() being required for the i915 display audio and HDaudio external codecs. In these cases, there is no way to notify the deferred probe infrastructure of the enablement of resources after the driver binding. The driver_deferred_probe_trigger() function is currently used 'anytime a driver is successfully bound to a device', this patch suggest exporing by exporting it so that drivers can kick-off re-probing of deferred devices at the end of a deferred processing. Signed-off-by: Pierre-Louis Bossart --- drivers/base/dd.c | 3 ++- include/linux/device/driver.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 437cd61343b2..33eca45aa65a 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -171,7 +171,7 @@ static bool driver_deferred_probe_enable = false; * changes in the midst of a probe, then deferred processing should be triggered * again. */ -static void driver_deferred_probe_trigger(void) +void driver_deferred_probe_trigger(void) { if (!driver_deferred_probe_enable) return; @@ -193,6 +193,7 @@ static void driver_deferred_probe_trigger(void) */ queue_work(system_unbound_wq, &deferred_probe_work); } +EXPORT_SYMBOL_GPL(driver_deferred_probe_trigger); /** * device_block_probing() - Block/defer device's probes diff --git a/include/linux/device/driver.h b/include/linux/device/driver.h index a498ebcf4993..2eec79d752a9 100644 --- a/include/linux/device/driver.h +++ b/include/linux/device/driver.h @@ -240,6 +240,7 @@ extern int driver_deferred_probe_timeout; void driver_deferred_probe_add(struct device *dev); int driver_deferred_probe_check_state(struct device *dev); void driver_init(void); +void driver_deferred_probe_trigger(void); /** * module_driver() - Helper macro for drivers that don't do anything From patchwork Tue Aug 17 19:00:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 498145 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1423AC4338F for ; Tue, 17 Aug 2021 19:03:39 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DB7F360FBF for ; Tue, 17 Aug 2021 19:03:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DB7F360FBF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 789291670; Tue, 17 Aug 2021 21:02:46 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 789291670 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1629227016; bh=uCQGeaBlBs/ROYwhgVF6hLlc6dQ0l/z831bMMjogEXk=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=VCUVJz0/szn0Dc3K+qz14VAJqRHioh2ok7Eh5dXaqkrbuzClbG9W8wADks20xZhVY saGVqHF2g+UmDRu2yTAddcKVitlExkjc53YNUfwvPeYQNU/gA63QiIhpTBA++FzsV0 LH5S/45+I3o/Fuc3B63h0/uaAKRuo/C0s9UXw+3k= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3A47DF804EB; Tue, 17 Aug 2021 21:01:55 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7E183F804DA; Tue, 17 Aug 2021 21:01:48 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 8F34DF80134; Tue, 17 Aug 2021 21:01:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8F34DF80134 X-IronPort-AV: E=McAfee;i="6200,9189,10079"; a="215898776" X-IronPort-AV: E=Sophos;i="5.84,329,1620716400"; d="scan'208";a="215898776" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2021 12:01:34 -0700 X-IronPort-AV: E=Sophos;i="5.84,329,1620716400"; d="scan'208";a="488147352" Received: from aaadelek-mobl3.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.212.12.89]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2021 12:01:32 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Subject: [RFC PATCH 2/2] ASoC: SOF: trigger re-probing of deferred devices from workqueue Date: Tue, 17 Aug 2021 14:00:57 -0500 Message-Id: <20210817190057.255264-3-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210817190057.255264-1-pierre-louis.bossart@linux.intel.com> References: <20210817190057.255264-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Cc: Liam Girdwood , Kai Vehmanen , "Rafael J . Wysocki" , tiwai@suse.de, Greg Kroah-Hartman , Takashi Iwai , linux-kernel@vger.kernel.org, Pierre-Louis Bossart , liam.r.girdwood@linux.intel.com, vkoul@kernel.org, broonie@kernel.org, Ranjani Sridharan , Jason Gunthorpe , Dan Williams , Andy Shevchenko , Daniel Baluta , Christoph Hellwig , "moderated list:SOUND - SOUND OPEN FIRMWARE SOF DRIVERS" X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Audio drivers such as HDaudio legacy and SOF rely on a workqueue to split the probe into two, with a first pass returning success immediately, and the second pass taking a lot more time due to the use of request_module() and the DSP initializations. This workqueue-based solution helps deal with conflicting requirements a) other drivers should not be blocked by a long probe b) a PROBE_PREFER_ASYNCHRONOUS probe_type is explicitly not allowed to avoid a deadlock when request_module() is used. This patch makes sure the deferred probe framework is triggered when the provider of resources successfully completes its initialization. Signed-off-by: Pierre-Louis Bossart --- sound/soc/sof/core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index 3e4dd4a86363..cecc0e914807 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -251,6 +251,9 @@ static int sof_probe_continue(struct snd_sof_dev *sdev) sdev->probe_completed = true; + /* kick-off re-probing of deferred devices */ + driver_deferred_probe_trigger(); + return 0; fw_trace_err: