From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C976CCA483 for ; Fri, 1 Jul 2022 01:27:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232223AbiGAB1W (ORCPT ); Thu, 30 Jun 2022 21:27:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232760AbiGAB1S (ORCPT ); Thu, 30 Jun 2022 21:27:18 -0400 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FDDD5A478 for ; Thu, 30 Jun 2022 18:26:56 -0700 (PDT) Received: by mail-pf1-x449.google.com with SMTP id c67-20020a621c46000000b005251cf9feb0so199871pfc.20 for ; Thu, 30 Jun 2022 18:26:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=N2ZBZX0ts4Mk2TYGZHAbQ0+iD2FAHUFhD02Oe5yw0x8=; b=O1+XSLj0oSVLFId1abGtsY3tm0452of7YtoG6NXZHX/e84inEivfhRvPM2mxa0YyIW IVE4lsrSj5BWadwFDlAWpmHnRK/doKl5AOePnDPGsAS+cA+NgfaWURouVPcfJ+UegMnP gFn2YJgYpdS58AkA+jg1y+IJirkP1kEzvd9LDdSLlSQ/Sq4aCkWSKEc/oTe6fZiOhW65 BjkrHlyKrTJJXC29sJDuGTXqd5/40GhwO7WCZbDbcQB2MuJGIhtqAJ7KaIiPcGoYN1l9 s4fr0zbsiZbvNiOgTU00jLdLs0pkeLRUFjFRS2ioFddA+CNMuoRvkffPzuaP06JwXoHV SNqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=N2ZBZX0ts4Mk2TYGZHAbQ0+iD2FAHUFhD02Oe5yw0x8=; b=DvuFyqOP7NwbHMeRw3U/026KupEidsPtEOjJjMinZ4lD9hNW2EzM7yHcN6krr9zsiS O24V9nc2hFk+OeApHc2LimgDISG6lcJkkT4/QIr5IymdyYxwLHtGwap7CF62hUzeSU2J IInmVzGn/w3+Y1SUqpIRNoiZ028HkuLVaAFcn9Lwcjfw9np/kizStulSAzE64LEUgTot selb78YQQUB9kMMKlx6e9fbz+C5bbE0AAQLdSbVW+X/Qwp9NU3IfEDuB9XtaOF5V5wxd 90BH+hlF4suOQt8k62OK2fj9KRY6wSh91OSkN3sCgOnTLwEdtXe2AMZwZyEx2d0e3wGm HFEw== X-Gm-Message-State: AJIora/4hU3TY+0NmF28McQkZOYjCunHq3B0ZJ6Kye3Ks7RCMhSQwTzr dTXj1iF+FZBoRFfkTW8vxnmwARMUTURPhTk= X-Google-Smtp-Source: AGRyM1sj2jrR3+blrSHPqJTzLp24osPeSbuJ6WFdrG/ishciKwr2k4mXrnUZAcDZaxDsMilQN7eUGTW8uxdoZkM= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:3973:d0f0:34a8:bf61]) (user=saravanak job=sendgmr) by 2002:a05:6a00:1995:b0:525:bca8:b062 with SMTP id d21-20020a056a00199500b00525bca8b062mr18860129pfl.26.1656638814784; Thu, 30 Jun 2022 18:26:54 -0700 (PDT) Date: Thu, 30 Jun 2022 18:26:39 -0700 In-Reply-To: <20220701012647.2007122-1-saravanak@google.com> Message-Id: <20220701012647.2007122-2-saravanak@google.com> Mime-Version: 1.0 References: <20220701012647.2007122-1-saravanak@google.com> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [PATCH v2 1/2] driver core: Add probe_no_timeout flag for drivers From: Saravana Kannan To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Laurentiu Tudor , Jiri Slaby , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Joel Stanley , Andrew Jeffery , Nicolas Saenz Julienne , Broadcom internal kernel review list , Florian Fainelli , Ray Jui , Scott Branden , Al Cooper , Andy Shevchenko , Paul Cercueil , Vladimir Zapolskiy , Matthias Brugger , Thierry Reding , Jonathan Hunter , Kunihiko Hayashi , Masami Hiramatsu , Tobias Klauser , Russell King , Vineet Gupta , Richard Genoud , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Alexander Shiyan , Baruch Siach , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Karol Gugala , Mateusz Holenko , Gabriel Somlo , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Taichi Sugaya , Takao Orito , Liviu Dudau , Sudeep Holla , Lorenzo Pieralisi , Andy Gross , Bjorn Andersson , Pali Rohar , Andreas Farber , Manivannan Sadhasivam , Krzysztof Kozlowski , Alim Akhtar , Laxman Dewangan , Palmer Dabbelt , Paul Walmsley , Orson Zhai , Baolin Wang , Chunyan Zhang , Patrice Chotard , Maxime Coquelin , Alexandre Torgue , "David S. Miller" , Hammer Hsieh , Peter Korsgaard , Timur Tabi , Michal Simek , Saravana Kannan Cc: Rob Herring , sascha hauer , peng fan , kevin hilman , ulf hansson , len brown , pavel machek , joerg roedel , will deacon , andrew lunn , heiner kallweit , eric dumazet , jakub kicinski , paolo abeni , linus walleij , hideaki yoshifuji , david ahern , kernel-team@android.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, iommu@lists.linux-foundation.org, netdev@vger.kernel.org, linux-gpio@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-rpi-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-tegra@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-actions@lists.infradead.org, linux-unisoc@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, sparclinux@vger.kernel.org, Ahmad Fatoum Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org This flag only needs to be set for drivers of devices that meet all the following conditions: - Need to probe successfully before userspace init in started - Have optional suppliers - Can't wait for deferred_probe_timeout to expire fw_devlink=on uses this info, as needed, to ignore dependencies on supplier devices that have not been added or supplier devices that don't have any drivers. It's still up to the driver to decide which of the missing suppliers are optional or not. Fixes: 71066545b48e ("driver core: Set fw_devlink.strict=1 by default") Reported-by: Sascha Hauer Reported-by: Peng Fan Reported-by: Fabio Estevam Reported-by: Ahmad Fatoum Tested-by: Fabio Estevam Signed-off-by: Saravana Kannan --- drivers/base/base.h | 1 + drivers/base/core.c | 7 +++++++ drivers/base/dd.c | 3 +++ include/linux/device.h | 7 +++++++ include/linux/device/driver.h | 11 +++++++++++ 5 files changed, 29 insertions(+) diff --git a/drivers/base/base.h b/drivers/base/base.h index b3a43a164dcd..149822d2086f 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -193,6 +193,7 @@ extern void device_links_no_driver(struct device *dev); extern bool device_links_busy(struct device *dev); extern void device_links_unbind_consumers(struct device *dev); extern void fw_devlink_drivers_done(void); +extern void fw_devlink_probe_no_timeout(void); /* device pm support */ void device_pm_move_to_tail(struct device *dev); diff --git a/drivers/base/core.c b/drivers/base/core.c index ccdd5b4295de..8e18904a1584 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -54,6 +54,7 @@ static unsigned int defer_sync_state_count = 1; static DEFINE_MUTEX(fwnode_link_lock); static bool fw_devlink_is_permissive(void); static bool fw_devlink_drv_reg_done; +static bool fw_devlink_no_timeout; static bool fw_devlink_best_effort; /** @@ -969,6 +970,7 @@ static void device_links_missing_supplier(struct device *dev) static bool dev_is_best_effort(struct device *dev) { return (fw_devlink_best_effort && dev->can_match) || + (fw_devlink_no_timeout && dev->probe_no_timeout) || (dev->fwnode && (dev->fwnode->flags & FWNODE_FLAG_BEST_EFFORT)); } @@ -1688,6 +1690,11 @@ void fw_devlink_drivers_done(void) device_links_write_unlock(); } +void fw_devlink_probe_no_timeout(void) +{ + fw_devlink_no_timeout = true; +} + /** * wait_for_init_devices_probe - Try to probe any device needed for init * diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 70f79fc71539..943b0363aaab 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -324,6 +324,8 @@ static int deferred_probe_initcall(void) if (!IS_ENABLED(CONFIG_MODULES)) fw_devlink_drivers_done(); + else + fw_devlink_probe_no_timeout(); /* * Trigger deferred probe again, this time we won't defer anything @@ -734,6 +736,7 @@ static int __driver_probe_device(struct device_driver *drv, struct device *dev) return -EBUSY; dev->can_match = true; + dev->probe_no_timeout = drv->probe_no_timeout; pr_debug("bus: '%s': %s: matched device %s with driver %s\n", drv->bus->name, __func__, dev_name(dev), drv->name); diff --git a/include/linux/device.h b/include/linux/device.h index 424b55df0272..e6246b6cf6cf 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -536,6 +536,12 @@ struct device_physical_location { * @can_match: The device has matched with a driver at least once or it is in * a bus (like AMBA) which can't check for matching drivers until * other devices probe successfully. + * @probe_no_timeout: Set by driver core to indicate that this device's probe + * can't wait till driver_probe_timeout expires. This information + * is used by fw_devlink=on to avoid deferring the probe of this + * device to wait on supplier devices that haven't been added or + * probed successfully. + * See also: probe_no_timeout in struct driver. * @dma_coherent: this particular device is dma coherent, even if the * architecture supports non-coherent devices. * @dma_ops_bypass: If set to %true then the dma_ops are bypassed for the @@ -642,6 +648,7 @@ struct device { bool of_node_reused:1; bool state_synced:1; bool can_match:1; + bool probe_no_timeout:1; #if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \ defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \ defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL) diff --git a/include/linux/device/driver.h b/include/linux/device/driver.h index 7acaabde5396..2ce60e511504 100644 --- a/include/linux/device/driver.h +++ b/include/linux/device/driver.h @@ -55,6 +55,15 @@ enum probe_type { * @owner: The module owner. * @mod_name: Used for built-in modules. * @suppress_bind_attrs: Disables bind/unbind via sysfs. + * @probe_no_timeout: Set to true by drivers that bind to devices that meet all + * these conditions: + * - Need to probe successfully before userspace init in started + * - Have optional suppliers + * - Can't wait for deferred_probe_timeout to expire + * fw_devlink=on uses this info, as needed, to ignore dependencies + * on supplier devices that have not been added or supplier devices + * that don't have any drivers. It's still up to the driver to + * decide which of the missing suppliers are optional or not. * @probe_type: Type of the probe (synchronous or asynchronous) to use. * @of_match_table: The open firmware table. * @acpi_match_table: The ACPI match table. @@ -101,6 +110,8 @@ struct device_driver { const char *mod_name; /* used for built-in modules */ bool suppress_bind_attrs; /* disables bind/unbind via sysfs */ + bool probe_no_timeout; + enum probe_type probe_type; const struct of_device_id *of_match_table; -- 2.37.0.rc0.161.g10f37bed90-goog From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 88AABCCA488 for ; Fri, 1 Jul 2022 01:27:00 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 1F0F38465D; Fri, 1 Jul 2022 01:27:00 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 1F0F38465D Authentication-Results: smtp1.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=O1+XSLj0 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id w8cgO-ju0GIb; Fri, 1 Jul 2022 01:26:59 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id BB1588465A; Fri, 1 Jul 2022 01:26:58 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org BB1588465A Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 83FC3C002D; Fri, 1 Jul 2022 01:26:58 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id C2EA6C0011 for ; Fri, 1 Jul 2022 01:26:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 9D0B240B59 for ; Fri, 1 Jul 2022 01:26:56 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 9D0B240B59 Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=O1+XSLj0 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qsDOmdCnTEiV for ; Fri, 1 Jul 2022 01:26:55 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org AD55340931 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by smtp2.osuosl.org (Postfix) with ESMTPS id AD55340931 for ; Fri, 1 Jul 2022 01:26:55 +0000 (UTC) Received: by mail-pg1-x549.google.com with SMTP id e18-20020a656492000000b003fa4033f9a7so484229pgv.17 for ; Thu, 30 Jun 2022 18:26:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=N2ZBZX0ts4Mk2TYGZHAbQ0+iD2FAHUFhD02Oe5yw0x8=; b=O1+XSLj0oSVLFId1abGtsY3tm0452of7YtoG6NXZHX/e84inEivfhRvPM2mxa0YyIW IVE4lsrSj5BWadwFDlAWpmHnRK/doKl5AOePnDPGsAS+cA+NgfaWURouVPcfJ+UegMnP gFn2YJgYpdS58AkA+jg1y+IJirkP1kEzvd9LDdSLlSQ/Sq4aCkWSKEc/oTe6fZiOhW65 BjkrHlyKrTJJXC29sJDuGTXqd5/40GhwO7WCZbDbcQB2MuJGIhtqAJ7KaIiPcGoYN1l9 s4fr0zbsiZbvNiOgTU00jLdLs0pkeLRUFjFRS2ioFddA+CNMuoRvkffPzuaP06JwXoHV SNqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=N2ZBZX0ts4Mk2TYGZHAbQ0+iD2FAHUFhD02Oe5yw0x8=; b=LXS3QDDd0bFDG/wUih20B9cuOYFV9YSO7Z5mYj65H2Maof+S9gBeXzUXnN/CvGUsbH Mxkz8oUPUXSKoHGgyzPjXnJ+0fLw4CDD13kuwBunjECAZIN/RjlTVe+mIisJC0wIXge/ VMHIWINK7ddVjWDOh1gcDQ7h04WRWC8NIJSdS9hodmHReNIG1KOvDw7LzyAzuayGjX2s ZJS1dZ+y4O+Qoj1TegWYnkK3JngeT2urZ144ehKMW4UkR4rv0mbGXSJyjQL0Pt25ISxZ wzMYhDDcASG9gd9EdP0+75KeJktynaFQf0eaXa378dCorpMCL2Jzk0lmPOnZejdTcb70 5CVg== X-Gm-Message-State: AJIora8gUuY4nFPmqaaYBzaTYMw0o5/XBCG5+/TZEnOIuxfwECBzZLL0 rzSMgSrq0ylle/w39x7O3dOIZMXlUBfL2vM= X-Google-Smtp-Source: AGRyM1sj2jrR3+blrSHPqJTzLp24osPeSbuJ6WFdrG/ishciKwr2k4mXrnUZAcDZaxDsMilQN7eUGTW8uxdoZkM= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:3973:d0f0:34a8:bf61]) (user=saravanak job=sendgmr) by 2002:a05:6a00:1995:b0:525:bca8:b062 with SMTP id d21-20020a056a00199500b00525bca8b062mr18860129pfl.26.1656638814784; Thu, 30 Jun 2022 18:26:54 -0700 (PDT) Date: Thu, 30 Jun 2022 18:26:39 -0700 In-Reply-To: <20220701012647.2007122-1-saravanak@google.com> Message-Id: <20220701012647.2007122-2-saravanak@google.com> Mime-Version: 1.0 References: <20220701012647.2007122-1-saravanak@google.com> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [PATCH v2 1/2] driver core: Add probe_no_timeout flag for drivers To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Laurentiu Tudor , Jiri Slaby , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Joel Stanley , Andrew Jeffery , Nicolas Saenz Julienne , Broadcom internal kernel review list , Florian Fainelli , Ray Jui , Scott Branden , Al Cooper , Andy Shevchenko , Paul Cercueil , Vladimir Zapolskiy , Matthias Brugger , Thierry Reding , Jonathan Hunter , Kunihiko Hayashi , Masami Hiramatsu , Tobias Klauser , Russell King , Vineet Gupta , Richard Genoud , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Alexander Shiyan , Baruch Siach , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Karol Gugala , Mateusz Holenko , Gabriel Somlo , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Taichi Sugaya , Takao Orito , Liviu Dudau , Sudeep Holla , Lorenzo Pieralisi , Andy Gross , Bjorn Andersson , Pali Rohar , Andreas Farber , Manivannan Sadhasivam , Krzysztof Kozlowski , Alim Akhtar , Laxman Dewangan , Palmer Dabbelt , Paul Walmsley , Orson Zhai , Baolin Wang , Chunyan Zhang , Patrice Chotard , Maxime Coquelin , Alexandre Torgue , "David S. Miller" , Hammer Hsieh , Peter Korsgaard , Timur Tabi , Michal Simek , Saravana Kannan Cc: andrew lunn , peng fan , linux-aspeed@lists.ozlabs.org, linus walleij , ulf hansson , linux-mips@vger.kernel.org, eric dumazet , pavel machek , sparclinux@vger.kernel.org, linux-riscv@lists.infradead.org, will deacon , linux-stm32@st-md-mailman.stormreply.com, sascha hauer , Rob Herring , linux-samsung-soc@vger.kernel.org, Ahmad Fatoum , kevin hilman , linux-serial@vger.kernel.org, jakub kicinski , paolo abeni , kernel-team@android.com, len brown , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-actions@lists.infradead.org, linux-gpio@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rpi-kernel@lists.infradead.org, linux-tegra@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-snps-arc@lists.infradead.org, linux-unisoc@lists.infradead.org, hideaki yoshifuji , netdev@vger.kernel.org, david ahern , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, linuxppc-dev@lists.ozlabs.org, heiner kallweit X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Saravana Kannan via iommu Reply-To: Saravana Kannan Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" This flag only needs to be set for drivers of devices that meet all the following conditions: - Need to probe successfully before userspace init in started - Have optional suppliers - Can't wait for deferred_probe_timeout to expire fw_devlink=on uses this info, as needed, to ignore dependencies on supplier devices that have not been added or supplier devices that don't have any drivers. It's still up to the driver to decide which of the missing suppliers are optional or not. Fixes: 71066545b48e ("driver core: Set fw_devlink.strict=1 by default") Reported-by: Sascha Hauer Reported-by: Peng Fan Reported-by: Fabio Estevam Reported-by: Ahmad Fatoum Tested-by: Fabio Estevam Signed-off-by: Saravana Kannan --- drivers/base/base.h | 1 + drivers/base/core.c | 7 +++++++ drivers/base/dd.c | 3 +++ include/linux/device.h | 7 +++++++ include/linux/device/driver.h | 11 +++++++++++ 5 files changed, 29 insertions(+) diff --git a/drivers/base/base.h b/drivers/base/base.h index b3a43a164dcd..149822d2086f 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -193,6 +193,7 @@ extern void device_links_no_driver(struct device *dev); extern bool device_links_busy(struct device *dev); extern void device_links_unbind_consumers(struct device *dev); extern void fw_devlink_drivers_done(void); +extern void fw_devlink_probe_no_timeout(void); /* device pm support */ void device_pm_move_to_tail(struct device *dev); diff --git a/drivers/base/core.c b/drivers/base/core.c index ccdd5b4295de..8e18904a1584 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -54,6 +54,7 @@ static unsigned int defer_sync_state_count = 1; static DEFINE_MUTEX(fwnode_link_lock); static bool fw_devlink_is_permissive(void); static bool fw_devlink_drv_reg_done; +static bool fw_devlink_no_timeout; static bool fw_devlink_best_effort; /** @@ -969,6 +970,7 @@ static void device_links_missing_supplier(struct device *dev) static bool dev_is_best_effort(struct device *dev) { return (fw_devlink_best_effort && dev->can_match) || + (fw_devlink_no_timeout && dev->probe_no_timeout) || (dev->fwnode && (dev->fwnode->flags & FWNODE_FLAG_BEST_EFFORT)); } @@ -1688,6 +1690,11 @@ void fw_devlink_drivers_done(void) device_links_write_unlock(); } +void fw_devlink_probe_no_timeout(void) +{ + fw_devlink_no_timeout = true; +} + /** * wait_for_init_devices_probe - Try to probe any device needed for init * diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 70f79fc71539..943b0363aaab 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -324,6 +324,8 @@ static int deferred_probe_initcall(void) if (!IS_ENABLED(CONFIG_MODULES)) fw_devlink_drivers_done(); + else + fw_devlink_probe_no_timeout(); /* * Trigger deferred probe again, this time we won't defer anything @@ -734,6 +736,7 @@ static int __driver_probe_device(struct device_driver *drv, struct device *dev) return -EBUSY; dev->can_match = true; + dev->probe_no_timeout = drv->probe_no_timeout; pr_debug("bus: '%s': %s: matched device %s with driver %s\n", drv->bus->name, __func__, dev_name(dev), drv->name); diff --git a/include/linux/device.h b/include/linux/device.h index 424b55df0272..e6246b6cf6cf 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -536,6 +536,12 @@ struct device_physical_location { * @can_match: The device has matched with a driver at least once or it is in * a bus (like AMBA) which can't check for matching drivers until * other devices probe successfully. + * @probe_no_timeout: Set by driver core to indicate that this device's probe + * can't wait till driver_probe_timeout expires. This information + * is used by fw_devlink=on to avoid deferring the probe of this + * device to wait on supplier devices that haven't been added or + * probed successfully. + * See also: probe_no_timeout in struct driver. * @dma_coherent: this particular device is dma coherent, even if the * architecture supports non-coherent devices. * @dma_ops_bypass: If set to %true then the dma_ops are bypassed for the @@ -642,6 +648,7 @@ struct device { bool of_node_reused:1; bool state_synced:1; bool can_match:1; + bool probe_no_timeout:1; #if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \ defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \ defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL) diff --git a/include/linux/device/driver.h b/include/linux/device/driver.h index 7acaabde5396..2ce60e511504 100644 --- a/include/linux/device/driver.h +++ b/include/linux/device/driver.h @@ -55,6 +55,15 @@ enum probe_type { * @owner: The module owner. * @mod_name: Used for built-in modules. * @suppress_bind_attrs: Disables bind/unbind via sysfs. + * @probe_no_timeout: Set to true by drivers that bind to devices that meet all + * these conditions: + * - Need to probe successfully before userspace init in started + * - Have optional suppliers + * - Can't wait for deferred_probe_timeout to expire + * fw_devlink=on uses this info, as needed, to ignore dependencies + * on supplier devices that have not been added or supplier devices + * that don't have any drivers. It's still up to the driver to + * decide which of the missing suppliers are optional or not. * @probe_type: Type of the probe (synchronous or asynchronous) to use. * @of_match_table: The open firmware table. * @acpi_match_table: The ACPI match table. @@ -101,6 +110,8 @@ struct device_driver { const char *mod_name; /* used for built-in modules */ bool suppress_bind_attrs; /* disables bind/unbind via sysfs */ + bool probe_no_timeout; + enum probe_type probe_type; const struct of_device_id *of_match_table; -- 2.37.0.rc0.161.g10f37bed90-goog _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B715FC433EF for ; Fri, 1 Jul 2022 02:30:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=538z5MvBYdDRZRTAGx8Awtto9urRcTqNg/oXqb2g7Mc=; b=3B/cifrIk7BuHRGd8BUgjwT1kH V0b6S3SI1vpV55L9gm9Aa4vhPgOiYFTeo7tozDRndF9/RzWADgpzny05t+D2x5IE3XrxuvAX5565F 6Co4o9E9WDMTJLd8mvnQdz2zZyXNEtJE7sCnB+yP+anodS2U3/jfzAYcKODl2Iz94fLPuGwPY8Nnk Dt49KB/j32JC1z6CZDzuJ4frPHSuiUOHwfUAkCuudnpxon1tuVd4/F3e60BW2+ZamseUtxr4FNCxW EE/g/teQNjobsXgQEZwJ9O4QGykbEV0hrYkrX171QlkQTkvrQ6rBw2+puHA/LUOv5h/v7RHmFBH2+ WQ0tN/fw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o76Qr-002QLY-Ln; Fri, 01 Jul 2022 02:30:57 +0000 Received: from mail-pg1-x549.google.com ([2607:f8b0:4864:20::549]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o75Qw-002H5f-8z for linux-snps-arc@lists.infradead.org; Fri, 01 Jul 2022 01:27:02 +0000 Received: by mail-pg1-x549.google.com with SMTP id r142-20020a632b94000000b0040c978aef47so492309pgr.10 for ; Thu, 30 Jun 2022 18:26:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=N2ZBZX0ts4Mk2TYGZHAbQ0+iD2FAHUFhD02Oe5yw0x8=; b=O1+XSLj0oSVLFId1abGtsY3tm0452of7YtoG6NXZHX/e84inEivfhRvPM2mxa0YyIW IVE4lsrSj5BWadwFDlAWpmHnRK/doKl5AOePnDPGsAS+cA+NgfaWURouVPcfJ+UegMnP gFn2YJgYpdS58AkA+jg1y+IJirkP1kEzvd9LDdSLlSQ/Sq4aCkWSKEc/oTe6fZiOhW65 BjkrHlyKrTJJXC29sJDuGTXqd5/40GhwO7WCZbDbcQB2MuJGIhtqAJ7KaIiPcGoYN1l9 s4fr0zbsiZbvNiOgTU00jLdLs0pkeLRUFjFRS2ioFddA+CNMuoRvkffPzuaP06JwXoHV SNqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=N2ZBZX0ts4Mk2TYGZHAbQ0+iD2FAHUFhD02Oe5yw0x8=; b=kqmjAKjT1C3cdX1YCUxw9o3fxU7rZ3NN8YKf3magkQ8QaNwQD6c3/W3dVrMsC+5xfD 8uquCedPOUzFfUxgAKMVCUyh3/2ZS35G0VLWblD7tTI1X0+TqJqhgG+15E95Pjkycnow tJE++TgsrCogDZ+CxNHdf2HH+qNYvfZat2NqmLzS7rRWIeSCasYNBWgo0eS/5pOf8F6d UwFDmQzAXOOnkBdI9LEETjSb+bLTH2GDRvR+vTrNVMqnj2MRWBdHHGk3p0DjjinvVrrt pxfA33+KHDK+uSCq4DEFOE36AY9ZXviw8CiXm02ArgsNZuP59fUBgPxuHcqqv2y+aK47 cNgQ== X-Gm-Message-State: AJIora+c/j6dYLbN5PH6vYr9A2u50VWMSYH7TM8inxG42Sn5BgnvTCLU u/ZeGNUN6S5ZQrJ55HNsk/kcl2FM0fsN28c= X-Google-Smtp-Source: AGRyM1sj2jrR3+blrSHPqJTzLp24osPeSbuJ6WFdrG/ishciKwr2k4mXrnUZAcDZaxDsMilQN7eUGTW8uxdoZkM= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:3973:d0f0:34a8:bf61]) (user=saravanak job=sendgmr) by 2002:a05:6a00:1995:b0:525:bca8:b062 with SMTP id d21-20020a056a00199500b00525bca8b062mr18860129pfl.26.1656638814784; Thu, 30 Jun 2022 18:26:54 -0700 (PDT) Date: Thu, 30 Jun 2022 18:26:39 -0700 In-Reply-To: <20220701012647.2007122-1-saravanak@google.com> Message-Id: <20220701012647.2007122-2-saravanak@google.com> Mime-Version: 1.0 References: <20220701012647.2007122-1-saravanak@google.com> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [PATCH v2 1/2] driver core: Add probe_no_timeout flag for drivers From: Saravana Kannan To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Laurentiu Tudor , Jiri Slaby , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Joel Stanley , Andrew Jeffery , Nicolas Saenz Julienne , Broadcom internal kernel review list , Florian Fainelli , Ray Jui , Scott Branden , Al Cooper , Andy Shevchenko , Paul Cercueil , Vladimir Zapolskiy , Matthias Brugger , Thierry Reding , Jonathan Hunter , Kunihiko Hayashi , Masami Hiramatsu , Tobias Klauser , Russell King , Vineet Gupta , Richard Genoud , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Alexander Shiyan , Baruch Siach , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Karol Gugala , Mateusz Holenko , Gabriel Somlo , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Taichi Sugaya , Takao Orito , Liviu Dudau , Sudeep Holla , Lorenzo Pieralisi , Andy Gross , Bjorn Andersson , Pali Rohar , Andreas Farber , Manivannan Sadhasivam , Krzysztof Kozlowski , Alim Akhtar , Laxman Dewangan , Palmer Dabbelt , Paul Walmsley , Orson Zhai , Baolin Wang , Chunyan Zhang , Patrice Chotard , Maxime Coquelin , Alexandre Torgue , "David S. Miller" , Hammer Hsieh , Peter Korsgaard , Timur Tabi , Michal Simek , Saravana Kannan Cc: Rob Herring , sascha hauer , peng fan , kevin hilman , ulf hansson , len brown , pavel machek , joerg roedel , will deacon , andrew lunn , heiner kallweit , eric dumazet , jakub kicinski , paolo abeni , linus walleij , hideaki yoshifuji , david ahern , kernel-team@android.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, iommu@lists.linux-foundation.org, netdev@vger.kernel.org, linux-gpio@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-rpi-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-tegra@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-actions@lists.infradead.org, linux-unisoc@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, sparclinux@vger.kernel.org, Ahmad Fatoum X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220630_182658_348446_E04A52EF X-CRM114-Status: GOOD ( 23.04 ) X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+linux-snps-arc=archiver.kernel.org@lists.infradead.org This flag only needs to be set for drivers of devices that meet all the following conditions: - Need to probe successfully before userspace init in started - Have optional suppliers - Can't wait for deferred_probe_timeout to expire fw_devlink=on uses this info, as needed, to ignore dependencies on supplier devices that have not been added or supplier devices that don't have any drivers. It's still up to the driver to decide which of the missing suppliers are optional or not. Fixes: 71066545b48e ("driver core: Set fw_devlink.strict=1 by default") Reported-by: Sascha Hauer Reported-by: Peng Fan Reported-by: Fabio Estevam Reported-by: Ahmad Fatoum Tested-by: Fabio Estevam Signed-off-by: Saravana Kannan --- drivers/base/base.h | 1 + drivers/base/core.c | 7 +++++++ drivers/base/dd.c | 3 +++ include/linux/device.h | 7 +++++++ include/linux/device/driver.h | 11 +++++++++++ 5 files changed, 29 insertions(+) diff --git a/drivers/base/base.h b/drivers/base/base.h index b3a43a164dcd..149822d2086f 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -193,6 +193,7 @@ extern void device_links_no_driver(struct device *dev); extern bool device_links_busy(struct device *dev); extern void device_links_unbind_consumers(struct device *dev); extern void fw_devlink_drivers_done(void); +extern void fw_devlink_probe_no_timeout(void); /* device pm support */ void device_pm_move_to_tail(struct device *dev); diff --git a/drivers/base/core.c b/drivers/base/core.c index ccdd5b4295de..8e18904a1584 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -54,6 +54,7 @@ static unsigned int defer_sync_state_count = 1; static DEFINE_MUTEX(fwnode_link_lock); static bool fw_devlink_is_permissive(void); static bool fw_devlink_drv_reg_done; +static bool fw_devlink_no_timeout; static bool fw_devlink_best_effort; /** @@ -969,6 +970,7 @@ static void device_links_missing_supplier(struct device *dev) static bool dev_is_best_effort(struct device *dev) { return (fw_devlink_best_effort && dev->can_match) || + (fw_devlink_no_timeout && dev->probe_no_timeout) || (dev->fwnode && (dev->fwnode->flags & FWNODE_FLAG_BEST_EFFORT)); } @@ -1688,6 +1690,11 @@ void fw_devlink_drivers_done(void) device_links_write_unlock(); } +void fw_devlink_probe_no_timeout(void) +{ + fw_devlink_no_timeout = true; +} + /** * wait_for_init_devices_probe - Try to probe any device needed for init * diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 70f79fc71539..943b0363aaab 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -324,6 +324,8 @@ static int deferred_probe_initcall(void) if (!IS_ENABLED(CONFIG_MODULES)) fw_devlink_drivers_done(); + else + fw_devlink_probe_no_timeout(); /* * Trigger deferred probe again, this time we won't defer anything @@ -734,6 +736,7 @@ static int __driver_probe_device(struct device_driver *drv, struct device *dev) return -EBUSY; dev->can_match = true; + dev->probe_no_timeout = drv->probe_no_timeout; pr_debug("bus: '%s': %s: matched device %s with driver %s\n", drv->bus->name, __func__, dev_name(dev), drv->name); diff --git a/include/linux/device.h b/include/linux/device.h index 424b55df0272..e6246b6cf6cf 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -536,6 +536,12 @@ struct device_physical_location { * @can_match: The device has matched with a driver at least once or it is in * a bus (like AMBA) which can't check for matching drivers until * other devices probe successfully. + * @probe_no_timeout: Set by driver core to indicate that this device's probe + * can't wait till driver_probe_timeout expires. This information + * is used by fw_devlink=on to avoid deferring the probe of this + * device to wait on supplier devices that haven't been added or + * probed successfully. + * See also: probe_no_timeout in struct driver. * @dma_coherent: this particular device is dma coherent, even if the * architecture supports non-coherent devices. * @dma_ops_bypass: If set to %true then the dma_ops are bypassed for the @@ -642,6 +648,7 @@ struct device { bool of_node_reused:1; bool state_synced:1; bool can_match:1; + bool probe_no_timeout:1; #if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \ defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \ defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL) diff --git a/include/linux/device/driver.h b/include/linux/device/driver.h index 7acaabde5396..2ce60e511504 100644 --- a/include/linux/device/driver.h +++ b/include/linux/device/driver.h @@ -55,6 +55,15 @@ enum probe_type { * @owner: The module owner. * @mod_name: Used for built-in modules. * @suppress_bind_attrs: Disables bind/unbind via sysfs. + * @probe_no_timeout: Set to true by drivers that bind to devices that meet all + * these conditions: + * - Need to probe successfully before userspace init in started + * - Have optional suppliers + * - Can't wait for deferred_probe_timeout to expire + * fw_devlink=on uses this info, as needed, to ignore dependencies + * on supplier devices that have not been added or supplier devices + * that don't have any drivers. It's still up to the driver to + * decide which of the missing suppliers are optional or not. * @probe_type: Type of the probe (synchronous or asynchronous) to use. * @of_match_table: The open firmware table. * @acpi_match_table: The ACPI match table. @@ -101,6 +110,8 @@ struct device_driver { const char *mod_name; /* used for built-in modules */ bool suppress_bind_attrs; /* disables bind/unbind via sysfs */ + bool probe_no_timeout; + enum probe_type probe_type; const struct of_device_id *of_match_table; -- 2.37.0.rc0.161.g10f37bed90-goog _______________________________________________ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 291FDC433EF for ; Fri, 1 Jul 2022 15:21:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=FHF/jsB+4UXr/fu7sjsCQY2zBcN6P3F/eRYMQxBzdWo=; b=lYtpuLrJrYWCDi5+aEoagYUDY2 hqX6fkCUJmGuLXA+MV8pYNhZ+JkIeLy35DKMGdZx+sCJTYyO4mIl1A80p714TewdDHOyZ3OrAleJ/ TgQBfEswLNghm93JHQ+lRiA0GB010tNfC7pIjeILgpabX+wht4qP8K6AIp1gEFDu3/HbskUgVKQSX gwX3uah9BLHYqe/xs5l5bKe5IgPJa0TIiLOtdF7PYEOjwyIDVjH7Yy7rdNVTAMAUZ+DBW8+tA1PtV VclnOmejxZW1FyXxbNdCTWqdMZw+gSNz9NP2ekAyFeL+Yg/Csh1eHhY6BCVunNes8VkDEdjjR5q4N ucVRHLAg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o7ISb-005dX3-Tb; Fri, 01 Jul 2022 15:21:33 +0000 Received: from mail-pf1-x449.google.com ([2607:f8b0:4864:20::449]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o75Qx-002H5j-BM for linux-riscv@lists.infradead.org; Fri, 01 Jul 2022 01:27:07 +0000 Received: by mail-pf1-x449.google.com with SMTP id bw5-20020a056a00408500b005251b5ea852so208808pfb.4 for ; Thu, 30 Jun 2022 18:26:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=N2ZBZX0ts4Mk2TYGZHAbQ0+iD2FAHUFhD02Oe5yw0x8=; b=O1+XSLj0oSVLFId1abGtsY3tm0452of7YtoG6NXZHX/e84inEivfhRvPM2mxa0YyIW IVE4lsrSj5BWadwFDlAWpmHnRK/doKl5AOePnDPGsAS+cA+NgfaWURouVPcfJ+UegMnP gFn2YJgYpdS58AkA+jg1y+IJirkP1kEzvd9LDdSLlSQ/Sq4aCkWSKEc/oTe6fZiOhW65 BjkrHlyKrTJJXC29sJDuGTXqd5/40GhwO7WCZbDbcQB2MuJGIhtqAJ7KaIiPcGoYN1l9 s4fr0zbsiZbvNiOgTU00jLdLs0pkeLRUFjFRS2ioFddA+CNMuoRvkffPzuaP06JwXoHV SNqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=N2ZBZX0ts4Mk2TYGZHAbQ0+iD2FAHUFhD02Oe5yw0x8=; b=Sr/Ck/I9pEqOGr1Dj2ReDZIMVk+tLbtxI2uC/RhKNibu5X23UguPremZW2FT0/KbZf fqU5clo8slxdRXx3ICdztdaT+Z5MM/CCoHKE5vJGVNKCRsojVGVVsn7kBTh13ue0KzIe GJ80m9V+4bA2VUSuM5Kfi0rtw6O3En0CSGcOyBLyffJ/knXXedBZussY+9ovCT4QJbrm zXg1V0/3vRyYmspTaj7SJolmx352ZQbhsNDt6EdvZ4mcjwbD7NdKxn0PIZrfZu4n6G4P kBjySNMwPzDl4jHZldJRF8Qr51SCADn6TqoXCh0w7472qD+gHXA2P+N2/LDKCNWHMINV EqMQ== X-Gm-Message-State: AJIora8+2wTFnr4GbU9+jheR1/Zfq5ytzu65g4QwJB040VsRdCvXBqzN PO6UgPo/oqcChE6x/ulGIeadomYbUKSxHnM= X-Google-Smtp-Source: AGRyM1sj2jrR3+blrSHPqJTzLp24osPeSbuJ6WFdrG/ishciKwr2k4mXrnUZAcDZaxDsMilQN7eUGTW8uxdoZkM= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:3973:d0f0:34a8:bf61]) (user=saravanak job=sendgmr) by 2002:a05:6a00:1995:b0:525:bca8:b062 with SMTP id d21-20020a056a00199500b00525bca8b062mr18860129pfl.26.1656638814784; Thu, 30 Jun 2022 18:26:54 -0700 (PDT) Date: Thu, 30 Jun 2022 18:26:39 -0700 In-Reply-To: <20220701012647.2007122-1-saravanak@google.com> Message-Id: <20220701012647.2007122-2-saravanak@google.com> Mime-Version: 1.0 References: <20220701012647.2007122-1-saravanak@google.com> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [PATCH v2 1/2] driver core: Add probe_no_timeout flag for drivers From: Saravana Kannan To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Laurentiu Tudor , Jiri Slaby , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Joel Stanley , Andrew Jeffery , Nicolas Saenz Julienne , Broadcom internal kernel review list , Florian Fainelli , Ray Jui , Scott Branden , Al Cooper , Andy Shevchenko , Paul Cercueil , Vladimir Zapolskiy , Matthias Brugger , Thierry Reding , Jonathan Hunter , Kunihiko Hayashi , Masami Hiramatsu , Tobias Klauser , Russell King , Vineet Gupta , Richard Genoud , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Alexander Shiyan , Baruch Siach , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Karol Gugala , Mateusz Holenko , Gabriel Somlo , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Taichi Sugaya , Takao Orito , Liviu Dudau , Sudeep Holla , Lorenzo Pieralisi , Andy Gross , Bjorn Andersson , Pali Rohar , Andreas Farber , Manivannan Sadhasivam , Krzysztof Kozlowski , Alim Akhtar , Laxman Dewangan , Palmer Dabbelt , Paul Walmsley , Orson Zhai , Baolin Wang , Chunyan Zhang , Patrice Chotard , Maxime Coquelin , Alexandre Torgue , "David S. Miller" , Hammer Hsieh , Peter Korsgaard , Timur Tabi , Michal Simek , Saravana Kannan Cc: Rob Herring , sascha hauer , peng fan , kevin hilman , ulf hansson , len brown , pavel machek , joerg roedel , will deacon , andrew lunn , heiner kallweit , eric dumazet , jakub kicinski , paolo abeni , linus walleij , hideaki yoshifuji , david ahern , kernel-team@android.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, iommu@lists.linux-foundation.org, netdev@vger.kernel.org, linux-gpio@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-rpi-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-tegra@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-actions@lists.infradead.org, linux-unisoc@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, sparclinux@vger.kernel.org, Ahmad Fatoum X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220630_182659_419882_397D794F X-CRM114-Status: GOOD ( 23.04 ) X-Mailman-Approved-At: Fri, 01 Jul 2022 08:21:30 -0700 X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This flag only needs to be set for drivers of devices that meet all the following conditions: - Need to probe successfully before userspace init in started - Have optional suppliers - Can't wait for deferred_probe_timeout to expire fw_devlink=on uses this info, as needed, to ignore dependencies on supplier devices that have not been added or supplier devices that don't have any drivers. It's still up to the driver to decide which of the missing suppliers are optional or not. Fixes: 71066545b48e ("driver core: Set fw_devlink.strict=1 by default") Reported-by: Sascha Hauer Reported-by: Peng Fan Reported-by: Fabio Estevam Reported-by: Ahmad Fatoum Tested-by: Fabio Estevam Signed-off-by: Saravana Kannan --- drivers/base/base.h | 1 + drivers/base/core.c | 7 +++++++ drivers/base/dd.c | 3 +++ include/linux/device.h | 7 +++++++ include/linux/device/driver.h | 11 +++++++++++ 5 files changed, 29 insertions(+) diff --git a/drivers/base/base.h b/drivers/base/base.h index b3a43a164dcd..149822d2086f 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -193,6 +193,7 @@ extern void device_links_no_driver(struct device *dev); extern bool device_links_busy(struct device *dev); extern void device_links_unbind_consumers(struct device *dev); extern void fw_devlink_drivers_done(void); +extern void fw_devlink_probe_no_timeout(void); /* device pm support */ void device_pm_move_to_tail(struct device *dev); diff --git a/drivers/base/core.c b/drivers/base/core.c index ccdd5b4295de..8e18904a1584 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -54,6 +54,7 @@ static unsigned int defer_sync_state_count = 1; static DEFINE_MUTEX(fwnode_link_lock); static bool fw_devlink_is_permissive(void); static bool fw_devlink_drv_reg_done; +static bool fw_devlink_no_timeout; static bool fw_devlink_best_effort; /** @@ -969,6 +970,7 @@ static void device_links_missing_supplier(struct device *dev) static bool dev_is_best_effort(struct device *dev) { return (fw_devlink_best_effort && dev->can_match) || + (fw_devlink_no_timeout && dev->probe_no_timeout) || (dev->fwnode && (dev->fwnode->flags & FWNODE_FLAG_BEST_EFFORT)); } @@ -1688,6 +1690,11 @@ void fw_devlink_drivers_done(void) device_links_write_unlock(); } +void fw_devlink_probe_no_timeout(void) +{ + fw_devlink_no_timeout = true; +} + /** * wait_for_init_devices_probe - Try to probe any device needed for init * diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 70f79fc71539..943b0363aaab 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -324,6 +324,8 @@ static int deferred_probe_initcall(void) if (!IS_ENABLED(CONFIG_MODULES)) fw_devlink_drivers_done(); + else + fw_devlink_probe_no_timeout(); /* * Trigger deferred probe again, this time we won't defer anything @@ -734,6 +736,7 @@ static int __driver_probe_device(struct device_driver *drv, struct device *dev) return -EBUSY; dev->can_match = true; + dev->probe_no_timeout = drv->probe_no_timeout; pr_debug("bus: '%s': %s: matched device %s with driver %s\n", drv->bus->name, __func__, dev_name(dev), drv->name); diff --git a/include/linux/device.h b/include/linux/device.h index 424b55df0272..e6246b6cf6cf 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -536,6 +536,12 @@ struct device_physical_location { * @can_match: The device has matched with a driver at least once or it is in * a bus (like AMBA) which can't check for matching drivers until * other devices probe successfully. + * @probe_no_timeout: Set by driver core to indicate that this device's probe + * can't wait till driver_probe_timeout expires. This information + * is used by fw_devlink=on to avoid deferring the probe of this + * device to wait on supplier devices that haven't been added or + * probed successfully. + * See also: probe_no_timeout in struct driver. * @dma_coherent: this particular device is dma coherent, even if the * architecture supports non-coherent devices. * @dma_ops_bypass: If set to %true then the dma_ops are bypassed for the @@ -642,6 +648,7 @@ struct device { bool of_node_reused:1; bool state_synced:1; bool can_match:1; + bool probe_no_timeout:1; #if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \ defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \ defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL) diff --git a/include/linux/device/driver.h b/include/linux/device/driver.h index 7acaabde5396..2ce60e511504 100644 --- a/include/linux/device/driver.h +++ b/include/linux/device/driver.h @@ -55,6 +55,15 @@ enum probe_type { * @owner: The module owner. * @mod_name: Used for built-in modules. * @suppress_bind_attrs: Disables bind/unbind via sysfs. + * @probe_no_timeout: Set to true by drivers that bind to devices that meet all + * these conditions: + * - Need to probe successfully before userspace init in started + * - Have optional suppliers + * - Can't wait for deferred_probe_timeout to expire + * fw_devlink=on uses this info, as needed, to ignore dependencies + * on supplier devices that have not been added or supplier devices + * that don't have any drivers. It's still up to the driver to + * decide which of the missing suppliers are optional or not. * @probe_type: Type of the probe (synchronous or asynchronous) to use. * @of_match_table: The open firmware table. * @acpi_match_table: The ACPI match table. @@ -101,6 +110,8 @@ struct device_driver { const char *mod_name; /* used for built-in modules */ bool suppress_bind_attrs; /* disables bind/unbind via sysfs */ + bool probe_no_timeout; + enum probe_type probe_type; const struct of_device_id *of_match_table; -- 2.37.0.rc0.161.g10f37bed90-goog _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2ADD7C43334 for ; Fri, 1 Jul 2022 07:57:41 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4LZ6xb476wz3f66 for ; Fri, 1 Jul 2022 17:57:39 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=O1+XSLj0; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=flex--saravanak.bounces.google.com (client-ip=2607:f8b0:4864:20::549; helo=mail-pg1-x549.google.com; envelope-from=3xk2-ygkkda87p6pap2pzv33v0t.r310x29c44r-sta0x787.3e0pq7.36v@flex--saravanak.bounces.google.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=O1+XSLj0; dkim-atps=neutral Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4LYyGn4QWWz3bkQ for ; Fri, 1 Jul 2022 11:26:57 +1000 (AEST) Received: by mail-pg1-x549.google.com with SMTP id 15-20020a63040f000000b0040c9f7f2978so488410pge.12 for ; Thu, 30 Jun 2022 18:26:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=N2ZBZX0ts4Mk2TYGZHAbQ0+iD2FAHUFhD02Oe5yw0x8=; b=O1+XSLj0oSVLFId1abGtsY3tm0452of7YtoG6NXZHX/e84inEivfhRvPM2mxa0YyIW IVE4lsrSj5BWadwFDlAWpmHnRK/doKl5AOePnDPGsAS+cA+NgfaWURouVPcfJ+UegMnP gFn2YJgYpdS58AkA+jg1y+IJirkP1kEzvd9LDdSLlSQ/Sq4aCkWSKEc/oTe6fZiOhW65 BjkrHlyKrTJJXC29sJDuGTXqd5/40GhwO7WCZbDbcQB2MuJGIhtqAJ7KaIiPcGoYN1l9 s4fr0zbsiZbvNiOgTU00jLdLs0pkeLRUFjFRS2ioFddA+CNMuoRvkffPzuaP06JwXoHV SNqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=N2ZBZX0ts4Mk2TYGZHAbQ0+iD2FAHUFhD02Oe5yw0x8=; b=4ooNkUx29eYs4huvisEzUkNNZiCXVVlqkRbgLZy6CGCjJqmZSOiayIPla/VG40WyMN 2dLpJMYzR4pSrrfe3ytu0BYiYZaQvsiArwmOigQYtABW+9XBITCMxQzGySap51URFz2V wrZzdlakeEbKbv2Wuf8kBZsmgOhyMFgJxFeSpwiBF23vnm50iTzn3aekkrjVQB7YhpGh qKLbNo0t9sslV91LnhTg9V/xt4zZHMafk+YvlbqQdZFYU4l2z/FJ7JYPBgy7XBhPFNsX gW/E+YnFfgsDsgiBGtI0NGNyD86qw/i7beK7bV27mkoa1wkmMD7FDiRxx9sUK91TL399 Q0JQ== X-Gm-Message-State: AJIora9z8EfpsSZQnRfACvLCI4scCvrGnMyDC/9JVYQh7nVPEnAOABr4 N7yPHqt2a6taDnzn8FoApoUA9WBPfTNNaKQ= X-Google-Smtp-Source: AGRyM1sj2jrR3+blrSHPqJTzLp24osPeSbuJ6WFdrG/ishciKwr2k4mXrnUZAcDZaxDsMilQN7eUGTW8uxdoZkM= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:3973:d0f0:34a8:bf61]) (user=saravanak job=sendgmr) by 2002:a05:6a00:1995:b0:525:bca8:b062 with SMTP id d21-20020a056a00199500b00525bca8b062mr18860129pfl.26.1656638814784; Thu, 30 Jun 2022 18:26:54 -0700 (PDT) Date: Thu, 30 Jun 2022 18:26:39 -0700 In-Reply-To: <20220701012647.2007122-1-saravanak@google.com> Message-Id: <20220701012647.2007122-2-saravanak@google.com> Mime-Version: 1.0 References: <20220701012647.2007122-1-saravanak@google.com> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [PATCH v2 1/2] driver core: Add probe_no_timeout flag for drivers From: Saravana Kannan To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Laurentiu Tudor , Jiri Slaby , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Joel Stanley , Andrew Jeffery , Nicolas Saenz Julienne , Broadcom internal kernel review list , Florian Fainelli , Ray Jui , Scott Branden , Al Cooper , Andy Shevchenko , Paul Cercueil , Vladimir Zapolskiy , Matthias Brugger , Thierry Reding , Jonathan Hunter , Kunihiko Hayashi , Masami Hiramatsu , Tobias Klauser , Russell King , Vineet Gupta , Richard Genoud , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Alexander Shiyan , Baruch Siach , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Karol Gugala , Mateusz Holenko , Gabriel Somlo , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Taichi Sugaya , Takao Orito , Liviu Dudau , Sudeep Holla , Lorenzo Pieralisi , Andy Gross , Bjorn Andersson , Pali Rohar , Andreas Farber , Manivannan Sadhasivam , Krzysztof Kozlowski , Alim Akhtar , Laxman Dewangan , Palmer Dabbelt , Paul Walmsley , Orson Zhai , Baolin Wang , Chunyan Zhang , Patrice Chotard , Maxime Coquelin , Alexandre Torgue , "David S. Miller" , Hammer Hsieh , Peter Korsgaard , Timur Tabi , Michal Simek , Saravana Kannan Content-Type: text/plain; charset="UTF-8" X-Mailman-Approved-At: Fri, 01 Jul 2022 17:55:19 +1000 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: andrew lunn , peng fan , linux-aspeed@lists.ozlabs.org, linus walleij , ulf hansson , linux-mips@vger.kernel.org, eric dumazet , pavel machek , sparclinux@vger.kernel.org, linux-riscv@lists.infradead.org, will deacon , linux-stm32@st-md-mailman.stormreply.com, sascha hauer , Rob Herring , linux-samsung-soc@vger.kernel.org, Ahmad Fatoum , kevin hilman , joerg roedel , linux-serial@vger.kernel.org, jakub kicinski , paolo abeni , kernel-team@android.com, len brown , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-actions@lists.infradead.org, linux-gpio@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rpi-kernel@lists.infradead.org, linux-tegra@vger.kernel.org, linux-amlog ic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-snps-arc@lists.infradead.org, linux-unisoc@lists.infradead.org, hideaki yoshifuji , netdev@vger.kernel.org, david ahern , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, linuxppc-dev@lists.ozlabs.org, heiner kallweit Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" This flag only needs to be set for drivers of devices that meet all the following conditions: - Need to probe successfully before userspace init in started - Have optional suppliers - Can't wait for deferred_probe_timeout to expire fw_devlink=on uses this info, as needed, to ignore dependencies on supplier devices that have not been added or supplier devices that don't have any drivers. It's still up to the driver to decide which of the missing suppliers are optional or not. Fixes: 71066545b48e ("driver core: Set fw_devlink.strict=1 by default") Reported-by: Sascha Hauer Reported-by: Peng Fan Reported-by: Fabio Estevam Reported-by: Ahmad Fatoum Tested-by: Fabio Estevam Signed-off-by: Saravana Kannan --- drivers/base/base.h | 1 + drivers/base/core.c | 7 +++++++ drivers/base/dd.c | 3 +++ include/linux/device.h | 7 +++++++ include/linux/device/driver.h | 11 +++++++++++ 5 files changed, 29 insertions(+) diff --git a/drivers/base/base.h b/drivers/base/base.h index b3a43a164dcd..149822d2086f 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -193,6 +193,7 @@ extern void device_links_no_driver(struct device *dev); extern bool device_links_busy(struct device *dev); extern void device_links_unbind_consumers(struct device *dev); extern void fw_devlink_drivers_done(void); +extern void fw_devlink_probe_no_timeout(void); /* device pm support */ void device_pm_move_to_tail(struct device *dev); diff --git a/drivers/base/core.c b/drivers/base/core.c index ccdd5b4295de..8e18904a1584 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -54,6 +54,7 @@ static unsigned int defer_sync_state_count = 1; static DEFINE_MUTEX(fwnode_link_lock); static bool fw_devlink_is_permissive(void); static bool fw_devlink_drv_reg_done; +static bool fw_devlink_no_timeout; static bool fw_devlink_best_effort; /** @@ -969,6 +970,7 @@ static void device_links_missing_supplier(struct device *dev) static bool dev_is_best_effort(struct device *dev) { return (fw_devlink_best_effort && dev->can_match) || + (fw_devlink_no_timeout && dev->probe_no_timeout) || (dev->fwnode && (dev->fwnode->flags & FWNODE_FLAG_BEST_EFFORT)); } @@ -1688,6 +1690,11 @@ void fw_devlink_drivers_done(void) device_links_write_unlock(); } +void fw_devlink_probe_no_timeout(void) +{ + fw_devlink_no_timeout = true; +} + /** * wait_for_init_devices_probe - Try to probe any device needed for init * diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 70f79fc71539..943b0363aaab 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -324,6 +324,8 @@ static int deferred_probe_initcall(void) if (!IS_ENABLED(CONFIG_MODULES)) fw_devlink_drivers_done(); + else + fw_devlink_probe_no_timeout(); /* * Trigger deferred probe again, this time we won't defer anything @@ -734,6 +736,7 @@ static int __driver_probe_device(struct device_driver *drv, struct device *dev) return -EBUSY; dev->can_match = true; + dev->probe_no_timeout = drv->probe_no_timeout; pr_debug("bus: '%s': %s: matched device %s with driver %s\n", drv->bus->name, __func__, dev_name(dev), drv->name); diff --git a/include/linux/device.h b/include/linux/device.h index 424b55df0272..e6246b6cf6cf 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -536,6 +536,12 @@ struct device_physical_location { * @can_match: The device has matched with a driver at least once or it is in * a bus (like AMBA) which can't check for matching drivers until * other devices probe successfully. + * @probe_no_timeout: Set by driver core to indicate that this device's probe + * can't wait till driver_probe_timeout expires. This information + * is used by fw_devlink=on to avoid deferring the probe of this + * device to wait on supplier devices that haven't been added or + * probed successfully. + * See also: probe_no_timeout in struct driver. * @dma_coherent: this particular device is dma coherent, even if the * architecture supports non-coherent devices. * @dma_ops_bypass: If set to %true then the dma_ops are bypassed for the @@ -642,6 +648,7 @@ struct device { bool of_node_reused:1; bool state_synced:1; bool can_match:1; + bool probe_no_timeout:1; #if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \ defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \ defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL) diff --git a/include/linux/device/driver.h b/include/linux/device/driver.h index 7acaabde5396..2ce60e511504 100644 --- a/include/linux/device/driver.h +++ b/include/linux/device/driver.h @@ -55,6 +55,15 @@ enum probe_type { * @owner: The module owner. * @mod_name: Used for built-in modules. * @suppress_bind_attrs: Disables bind/unbind via sysfs. + * @probe_no_timeout: Set to true by drivers that bind to devices that meet all + * these conditions: + * - Need to probe successfully before userspace init in started + * - Have optional suppliers + * - Can't wait for deferred_probe_timeout to expire + * fw_devlink=on uses this info, as needed, to ignore dependencies + * on supplier devices that have not been added or supplier devices + * that don't have any drivers. It's still up to the driver to + * decide which of the missing suppliers are optional or not. * @probe_type: Type of the probe (synchronous or asynchronous) to use. * @of_match_table: The open firmware table. * @acpi_match_table: The ACPI match table. @@ -101,6 +110,8 @@ struct device_driver { const char *mod_name; /* used for built-in modules */ bool suppress_bind_attrs; /* disables bind/unbind via sysfs */ + bool probe_no_timeout; + enum probe_type probe_type; const struct of_device_id *of_match_table; -- 2.37.0.rc0.161.g10f37bed90-goog From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A1A45C25B0E for ; Fri, 12 Aug 2022 09:07:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=VRzrV6EaGkh7A7Gj3iKho9aMUC4LUAfjBdJHnThV+nI=; b=wTcqbIzB7/v7Vj6trsNAMZ2UrG rAaok1st8iHDZeDh2Hzuc3kTVPj9qCsvh+c7y8jLpsDtXQ/taAaGqGsbcm6whTwY8UPa/FOTZ4kjr QvR2Gb4VD9k+UU5ndOAS1e1DbTDhv7LmfIvvMNmW+D/Mg1/tSTJUQQfagLt2qvYyGKGMhj74UQZaE cP60Xrj7Vqrh0guRzkRBZiQS9ddjveQaLFsJ2H1c9i0QEiDn/VhHu2NVFJvPPJRiApFMwBUY6ygQq ODNCZYwKkYVm+aD9LsVH1B4sp9dtxvG/JKv0rNfOGVieDI/+oSg5puqSl9pTn3Em5a3EOOlPxbQ7F fCtYqkMg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oMQd8-003SOl-Fo; Fri, 12 Aug 2022 09:06:58 +0000 Received: from mail-pg1-x549.google.com ([2607:f8b0:4864:20::549]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o75Qw-002H5g-6H for linux-amlogic@lists.infradead.org; Fri, 01 Jul 2022 01:27:00 +0000 Received: by mail-pg1-x549.google.com with SMTP id 134-20020a63018c000000b0040cf04213a1so492607pgb.6 for ; Thu, 30 Jun 2022 18:26:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=N2ZBZX0ts4Mk2TYGZHAbQ0+iD2FAHUFhD02Oe5yw0x8=; b=O1+XSLj0oSVLFId1abGtsY3tm0452of7YtoG6NXZHX/e84inEivfhRvPM2mxa0YyIW IVE4lsrSj5BWadwFDlAWpmHnRK/doKl5AOePnDPGsAS+cA+NgfaWURouVPcfJ+UegMnP gFn2YJgYpdS58AkA+jg1y+IJirkP1kEzvd9LDdSLlSQ/Sq4aCkWSKEc/oTe6fZiOhW65 BjkrHlyKrTJJXC29sJDuGTXqd5/40GhwO7WCZbDbcQB2MuJGIhtqAJ7KaIiPcGoYN1l9 s4fr0zbsiZbvNiOgTU00jLdLs0pkeLRUFjFRS2ioFddA+CNMuoRvkffPzuaP06JwXoHV SNqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=N2ZBZX0ts4Mk2TYGZHAbQ0+iD2FAHUFhD02Oe5yw0x8=; b=isbXeqlnBeWlcPZKJcODGsKTTJ5ZTqBaoIicgl5GgXkI6/sVZIDuXNdqczDfsA03ZY KF4piJ2mlDEjtihl+nt+PbTUMkg+6M1ExXuynQx1jxj/M0AJNMv7p3YrhnFtuOSQ6RSN BNNkUxxHtllWFenGHk0sfdwllKPbDtzG1t/d69VHKyLel2KluyRzgc15Mj1LHsxslxvz z9D5HzvQrjiPn4I5ivSiETmag3aYggOHvXoU88I1/HyK0Glapk6x7SBsUbzotEO21+SU 09zXoAWOwRXX21cXSY8s8xPjYoy3h6q95ia3H8LFFmfyEq9tXJ1nyQj2YHrmVb3xivXB Togw== X-Gm-Message-State: AJIora9yORJH+C/+pfPLV8eV9dthu/rpmPFG3hTFt8lyOP70ZISgeMOX eCRupILSgAEhlufwk7lkzSPqKPsz6SUY1bA= X-Google-Smtp-Source: AGRyM1sj2jrR3+blrSHPqJTzLp24osPeSbuJ6WFdrG/ishciKwr2k4mXrnUZAcDZaxDsMilQN7eUGTW8uxdoZkM= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:3973:d0f0:34a8:bf61]) (user=saravanak job=sendgmr) by 2002:a05:6a00:1995:b0:525:bca8:b062 with SMTP id d21-20020a056a00199500b00525bca8b062mr18860129pfl.26.1656638814784; Thu, 30 Jun 2022 18:26:54 -0700 (PDT) Date: Thu, 30 Jun 2022 18:26:39 -0700 In-Reply-To: <20220701012647.2007122-1-saravanak@google.com> Message-Id: <20220701012647.2007122-2-saravanak@google.com> Mime-Version: 1.0 References: <20220701012647.2007122-1-saravanak@google.com> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [PATCH v2 1/2] driver core: Add probe_no_timeout flag for drivers From: Saravana Kannan To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Laurentiu Tudor , Jiri Slaby , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Joel Stanley , Andrew Jeffery , Nicolas Saenz Julienne , Broadcom internal kernel review list , Florian Fainelli , Ray Jui , Scott Branden , Al Cooper , Andy Shevchenko , Paul Cercueil , Vladimir Zapolskiy , Matthias Brugger , Thierry Reding , Jonathan Hunter , Kunihiko Hayashi , Masami Hiramatsu , Tobias Klauser , Russell King , Vineet Gupta , Richard Genoud , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Alexander Shiyan , Baruch Siach , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Karol Gugala , Mateusz Holenko , Gabriel Somlo , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Taichi Sugaya , Takao Orito , Liviu Dudau , Sudeep Holla , Lorenzo Pieralisi , Andy Gross , Bjorn Andersson , Pali Rohar , Andreas Farber , Manivannan Sadhasivam , Krzysztof Kozlowski , Alim Akhtar , Laxman Dewangan , Palmer Dabbelt , Paul Walmsley , Orson Zhai , Baolin Wang , Chunyan Zhang , Patrice Chotard , Maxime Coquelin , Alexandre Torgue , "David S. Miller" , Hammer Hsieh , Peter Korsgaard , Timur Tabi , Michal Simek , Saravana Kannan Cc: Rob Herring , sascha hauer , peng fan , kevin hilman , ulf hansson , len brown , pavel machek , joerg roedel , will deacon , andrew lunn , heiner kallweit , eric dumazet , jakub kicinski , paolo abeni , linus walleij , hideaki yoshifuji , david ahern , kernel-team@android.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, iommu@lists.linux-foundation.org, netdev@vger.kernel.org, linux-gpio@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-rpi-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-tegra@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-actions@lists.infradead.org, linux-unisoc@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, sparclinux@vger.kernel.org, Ahmad Fatoum X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220630_182658_338155_78DD27DC X-CRM114-Status: GOOD ( 23.04 ) X-Mailman-Approved-At: Fri, 12 Aug 2022 02:06:54 -0700 X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org This flag only needs to be set for drivers of devices that meet all the following conditions: - Need to probe successfully before userspace init in started - Have optional suppliers - Can't wait for deferred_probe_timeout to expire fw_devlink=on uses this info, as needed, to ignore dependencies on supplier devices that have not been added or supplier devices that don't have any drivers. It's still up to the driver to decide which of the missing suppliers are optional or not. Fixes: 71066545b48e ("driver core: Set fw_devlink.strict=1 by default") Reported-by: Sascha Hauer Reported-by: Peng Fan Reported-by: Fabio Estevam Reported-by: Ahmad Fatoum Tested-by: Fabio Estevam Signed-off-by: Saravana Kannan --- drivers/base/base.h | 1 + drivers/base/core.c | 7 +++++++ drivers/base/dd.c | 3 +++ include/linux/device.h | 7 +++++++ include/linux/device/driver.h | 11 +++++++++++ 5 files changed, 29 insertions(+) diff --git a/drivers/base/base.h b/drivers/base/base.h index b3a43a164dcd..149822d2086f 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -193,6 +193,7 @@ extern void device_links_no_driver(struct device *dev); extern bool device_links_busy(struct device *dev); extern void device_links_unbind_consumers(struct device *dev); extern void fw_devlink_drivers_done(void); +extern void fw_devlink_probe_no_timeout(void); /* device pm support */ void device_pm_move_to_tail(struct device *dev); diff --git a/drivers/base/core.c b/drivers/base/core.c index ccdd5b4295de..8e18904a1584 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -54,6 +54,7 @@ static unsigned int defer_sync_state_count = 1; static DEFINE_MUTEX(fwnode_link_lock); static bool fw_devlink_is_permissive(void); static bool fw_devlink_drv_reg_done; +static bool fw_devlink_no_timeout; static bool fw_devlink_best_effort; /** @@ -969,6 +970,7 @@ static void device_links_missing_supplier(struct device *dev) static bool dev_is_best_effort(struct device *dev) { return (fw_devlink_best_effort && dev->can_match) || + (fw_devlink_no_timeout && dev->probe_no_timeout) || (dev->fwnode && (dev->fwnode->flags & FWNODE_FLAG_BEST_EFFORT)); } @@ -1688,6 +1690,11 @@ void fw_devlink_drivers_done(void) device_links_write_unlock(); } +void fw_devlink_probe_no_timeout(void) +{ + fw_devlink_no_timeout = true; +} + /** * wait_for_init_devices_probe - Try to probe any device needed for init * diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 70f79fc71539..943b0363aaab 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -324,6 +324,8 @@ static int deferred_probe_initcall(void) if (!IS_ENABLED(CONFIG_MODULES)) fw_devlink_drivers_done(); + else + fw_devlink_probe_no_timeout(); /* * Trigger deferred probe again, this time we won't defer anything @@ -734,6 +736,7 @@ static int __driver_probe_device(struct device_driver *drv, struct device *dev) return -EBUSY; dev->can_match = true; + dev->probe_no_timeout = drv->probe_no_timeout; pr_debug("bus: '%s': %s: matched device %s with driver %s\n", drv->bus->name, __func__, dev_name(dev), drv->name); diff --git a/include/linux/device.h b/include/linux/device.h index 424b55df0272..e6246b6cf6cf 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -536,6 +536,12 @@ struct device_physical_location { * @can_match: The device has matched with a driver at least once or it is in * a bus (like AMBA) which can't check for matching drivers until * other devices probe successfully. + * @probe_no_timeout: Set by driver core to indicate that this device's probe + * can't wait till driver_probe_timeout expires. This information + * is used by fw_devlink=on to avoid deferring the probe of this + * device to wait on supplier devices that haven't been added or + * probed successfully. + * See also: probe_no_timeout in struct driver. * @dma_coherent: this particular device is dma coherent, even if the * architecture supports non-coherent devices. * @dma_ops_bypass: If set to %true then the dma_ops are bypassed for the @@ -642,6 +648,7 @@ struct device { bool of_node_reused:1; bool state_synced:1; bool can_match:1; + bool probe_no_timeout:1; #if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \ defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \ defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL) diff --git a/include/linux/device/driver.h b/include/linux/device/driver.h index 7acaabde5396..2ce60e511504 100644 --- a/include/linux/device/driver.h +++ b/include/linux/device/driver.h @@ -55,6 +55,15 @@ enum probe_type { * @owner: The module owner. * @mod_name: Used for built-in modules. * @suppress_bind_attrs: Disables bind/unbind via sysfs. + * @probe_no_timeout: Set to true by drivers that bind to devices that meet all + * these conditions: + * - Need to probe successfully before userspace init in started + * - Have optional suppliers + * - Can't wait for deferred_probe_timeout to expire + * fw_devlink=on uses this info, as needed, to ignore dependencies + * on supplier devices that have not been added or supplier devices + * that don't have any drivers. It's still up to the driver to + * decide which of the missing suppliers are optional or not. * @probe_type: Type of the probe (synchronous or asynchronous) to use. * @of_match_table: The open firmware table. * @acpi_match_table: The ACPI match table. @@ -101,6 +110,8 @@ struct device_driver { const char *mod_name; /* used for built-in modules */ bool suppress_bind_attrs; /* disables bind/unbind via sysfs */ + bool probe_no_timeout; + enum probe_type probe_type; const struct of_device_id *of_match_table; -- 2.37.0.rc0.161.g10f37bed90-goog _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic