From patchwork Tue Jun 28 02:01:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 12897830 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 07EB0CCA47E for ; Tue, 28 Jun 2022 07:05:58 +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=A9mIerG3GkWUphKXNOJDgoGn5+WTp87h6WSgzxVtE6w=; b=mqoeDlkhUKQgSTpbAyx1J+v/bz qkxesUFxS7XwqpqIk669ZfbHVsJXv1RBIUf7tpDtK0cAoxrivoxX3Eog6FAjOR9kLwIvXcQhBusGL YX2vW7tOadDSn4PUcXaqLHkapwwk4+pW9ObuyCZsz97UrfuhXSCSu+hBB/ReTqyMbcrseNr+XAe3x M0SQXTnJHpP69RXoxZ78y64c8LwIh1FIZpCKeAgqFTy9t98Gikqz2J5HLo3W6+62+/Etf+Jy4Kmy3 ZallirWj28bxTsRCEC0DyzX/FapOW0i7BOmf7PA3kLfCgGarXAqmKcG5+JYRblBiEyjiblaF7yQZ1 HwnaPoeg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o65IG-004sNp-Oc; Tue, 28 Jun 2022 07:05:52 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o60ZM-003c4Z-RR for linux-amlogic@lists.infradead.org; Tue, 28 Jun 2022 02:03:17 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-31814f7654dso91894987b3.15 for ; Mon, 27 Jun 2022 19:03:08 -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=YzHIr0V9HMEpxWmEi0Xj1DJ+4d2XCpwecNoe7o3TDGc=; b=WOYPYkzcX52RhlZvpifs4I6lPFXV+5C99yJcPGn4swZ412myqZhpEpJGG6JT8I+diP wmRTXCjvAFpcr/KomN65nvaJHvYHD4UymktEo8kdn5KBIufKB90oBi6uJgpha1QorqN4 FoHUev8RwrPNG+R9y5XCbQZGHm1ydbiuEHKmkqJMqr5AQVuz0Cn/swj+fCPxGk277wcm FeyAuVEaB9fajv1pTRajXKWxqwQb5RRy57WkXDveO+g9jxpPIug/uOD6UHEfjE7VM4eE 2vOtDCyMr9g/g/WN/lFcVpdMLesGVIWYzLk/qWic19C/MVsZG3elryvTosIN7O8GZ4ml x6ow== 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=YzHIr0V9HMEpxWmEi0Xj1DJ+4d2XCpwecNoe7o3TDGc=; b=RgYyWpUHFQSq51dH5WbnKLgB9RFry9/ZIpvC5nzu7vGyD3VQ25ORwTI6iLSDUZYZwH qZ+sLIKGyf6tSP5b1M/ZEhIcvkxIo2H2OaLCPPCoc8YDoBSjipYkCgyvzImk4l9h/WaP xN0m3mHNuo8l40mLwbWHjEpjI8NSUe8QR5E12winGAMTJ7T0O/9KkRYyyWxcLJfYTVy3 FVK939anWmQBjAp+keOM+kpfTqjUntmuydZedO10/FA7DhS6/0jAhVhIX9j2LX7GNBOb n+ElmeuHZY809lWvPxkxSYYbCD22Mucs4KMOk/ZOMMd39Tc/X7/8AMszZh25nE6PZWAk QSpQ== X-Gm-Message-State: AJIora8u7+UZ5jfqiWeqxG/GKJhgCoZ9+zY6XDiGfFGeYVxTIUizq0Df +PEG8uTBWhnfiQUFaxVElVtkcEnk4OaqoY4= X-Google-Smtp-Source: AGRyM1u1CI3RZWjDOxskNtWWSrcYu4D2aM8Nq4tr5iOtzOleCFvS4Q121j5zvIY5WKw81S4m4Q0aaxhGddgoJuc= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:1f27:a302:2101:1c82]) (user=saravanak job=sendgmr) by 2002:a81:12d3:0:b0:317:aa20:e4eb with SMTP id 202-20020a8112d3000000b00317aa20e4ebmr18821146yws.352.1656381787829; Mon, 27 Jun 2022 19:03:07 -0700 (PDT) Date: Mon, 27 Jun 2022 19:01:02 -0700 In-Reply-To: <20220628020110.1601693-1-saravanak@google.com> Message-Id: <20220628020110.1601693-2-saravanak@google.com> Mime-Version: 1.0 References: <20220628020110.1601693-1-saravanak@google.com> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [PATCH v1 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 , Florian Fainelli , Ray Jui , Scott Branden , Broadcom internal kernel review list , Nicolas Saenz Julienne , 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-20220627_190312_967719_5C5AD922 X-CRM114-Status: GOOD ( 23.06 ) X-Mailman-Approved-At: Tue, 28 Jun 2022 00:05:50 -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: , 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 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 e600dd2afc35..9b0ef2b6a058 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;