Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1156880iog; Thu, 30 Jun 2022 18:50:42 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sym7lGHw/sV0sdMBX2CiyT1g2we+dn+AGmgdr4UQEbbMGh5qiC6qxW3d6b/visfg/VSYrO X-Received: by 2002:a05:6402:50ce:b0:435:9249:dfe9 with SMTP id h14-20020a05640250ce00b004359249dfe9mr15326884edb.310.1656640241824; Thu, 30 Jun 2022 18:50:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656640241; cv=none; d=google.com; s=arc-20160816; b=VyusQn0QU5L9KTUVrku0jAiWpROXEV1+gDaKv4C/g6keKkY9cHw4dUihcM2Hz4EC5S ugNy3phXBXDpcS7zlxf9Vu1alsKSBsq+uthTcr50+1aW+pzraOuykh46Dw8eT9fB6C2o FDszcQHHbNEUIStAotT5+IHfIajSlA0gfezYEKa/QPWeDB/UXbcp+40yEymSRMXYdJZr pFEhD5VwTJfcE09FWo9ulkX700L2b0Gg5unTOIOCSXFztoivMAKCMvvDU5oHj8N5oQVh NV3/lsIkNlOJ17xAMIgynhI57HxBCzIePLhrKOaZnATmNW2LAvguLrJu0PUcUYYDYLYd tsiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=N2ZBZX0ts4Mk2TYGZHAbQ0+iD2FAHUFhD02Oe5yw0x8=; b=mDBhgUPe7o0E+LO6kFC5VFDn6ryahPgiFr1UoacHq+yz3t9BBQNUBNEU+9TLMXCLYm MX/WViKgee2zW1k6rXa5DWeVjDTeadAf81uf7Krg3u/RTQOw9OrV06e1gYshiWoBXraz Fj0RyOJPyDGFxaL2tUndQwpbDDamqyRWMnS5dCq0/lmrIgesEWUhVYKsYBUbl7uw8Wrg lbz/buzn+/u8xj3Iu7+DqK817vGhtrn0jqL+2IFJ45QewNdNGTv4SklKddJCVIsxAzPo nb6bX+QRKIjD1hKWwHjlpG2fZuCa1bxiONt/f0OJ42M3v9UeUoMOudyGA2h7+1Q0bJck MmTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=O1+XSLj0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o12-20020a056402438c00b00435e08047fasi29285609edc.582.2022.06.30.18.50.14; Thu, 30 Jun 2022 18:50:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=O1+XSLj0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232774AbiGAB1B (ORCPT + 99 others); Thu, 30 Jun 2022 21:27:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232760AbiGAB04 (ORCPT ); Thu, 30 Jun 2022 21:26:56 -0400 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 785175A44F for ; Thu, 30 Jun 2022 18:26:55 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id u24-20020a63d358000000b004119798494fso480230pgi.18 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=ZPHEzBjapn6vdEIrrNLkTMRDjKALgIG1g00BOmX3aYIUnzFc8tNzLruZuEhQCDLsMY R9oYGRqIlhgY1ZtLRZ9OOGxcVFpx4J39uRnFXU3bij5akyDlhAxDgzSBngT545Hod38U wARjxloSROy/YogwC4kWRZe2UVqAikTJE6m5iRsLMs8h9z5JygezV3v/D0weX9hQ7YCe 2nRerPsTNrB4zaGDi2krqnXvfOp/72FMZJ562ROgNs2qcnNFoCPFgz+v3BT+Dr2qk8Th KVG9CeBbuj7D7IgOXiI+gbySZNpwgQK5emHh3vHjS9SXroYeKr5XdnYIS45n97BHxC6O FC7w== X-Gm-Message-State: AJIora9JmC+DQJt+0V1Li+GGd8VCh4xSqXEDo+p/OaN0Zl+kw/lCS/GP i2Edhl3668V8Bv0CGs/kvZkLzkrF/NXwGRY= 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" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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