From patchwork Sat Nov 21 02:02:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 330035 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49B43C56202 for ; Sat, 21 Nov 2020 02:03:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 058A02408E for ; Sat, 21 Nov 2020 02:03:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="WRnGMJKi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727074AbgKUCCs (ORCPT ); Fri, 20 Nov 2020 21:02:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727071AbgKUCCs (ORCPT ); Fri, 20 Nov 2020 21:02:48 -0500 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8DB8C061A47 for ; Fri, 20 Nov 2020 18:02:47 -0800 (PST) Received: by mail-qt1-x849.google.com with SMTP id b10so8894050qtb.16 for ; Fri, 20 Nov 2020 18:02:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=1MIEjHYAUOmtfDtnN00T8oexuLD0a1GaxYDVE08u5Wg=; b=WRnGMJKiRCk+glHvgvynNYZv8x92G9pyeda7gKEvfbRpg9wlzldzuLg06cUuDtlwLU XVUNn90Kf8v22rIHed41Qj+nv4l1ynOtpQEApSlJD/2mZ9F9RPkrAKTTcXsYnS3+lPlt HM70l30j1V3rlsBytAQMz5JtXe/w2lKBJPIAr8bnoYQYNXB6mESh3Mo2ZYmyNjr0x4fn VKgHJwd7OYW2tCam3CHhiEs3oMmKgqTAuDvvPdsNAYdXPb6RH5p6eDoC6vbY6Rw/IMKZ dGrXBwzFvOl0lod6guKxN2S6Z/b1qG/OwhAojwkGMGNgWr4rlq9Mnww0d82Q2IA4ImNZ UlwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=1MIEjHYAUOmtfDtnN00T8oexuLD0a1GaxYDVE08u5Wg=; b=b5EHz8GDUGKQGLGjxbPmqT/Q+ZFAVBNFcBUFFXYf71rUEY8lfhQsN0BVnlb2zxwXWf iTF/zDRgdOnutu7wBB2W8wN76Rh1PwRPTuxL1TkuwHnTLBNQzO1/Xwj+3mKNnlBuNxjT vcRyDqp+Tok0TmIi9iAWGWrBcKZM8TKMBdwBCqGb0BGiq41vnXa3mTgJ+LOMBC+IxVp2 Nn+bSuZ7tuSewYcT8eayFrUA4kx/xsEaCPXjSQFYtcNI1lPNlkoi4JMCOvnIRgxYUxOr to1zoXC6BRotVAnhRtZ3dlrqfHmeYTgMP/XVtQNYEMPSraA8ntLxRStP5qyjIqmFclxq UX2w== X-Gm-Message-State: AOAM531UWRkz/35Mhey/FHVraK84zw0Ppmjw5AV8vcDj3tCdpJ5T7E0y 33D0uYDef2TOfX3tk1RaBCKNCJjnGTvMJXI= X-Google-Smtp-Source: ABdhPJwsK6KYV3vtcuQpWlijpToTJEH99q4w1i+0OrCZcZTmMCpUf85uz7XbU4cltly1bkZZXZr1IPTfDIdhv7A= Sender: "saravanak via sendgmr" X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:7220:84ff:fe09:fedc]) (user=saravanak job=sendgmr) by 2002:ad4:5587:: with SMTP id e7mr19801981qvx.33.1605924166877; Fri, 20 Nov 2020 18:02:46 -0800 (PST) Date: Fri, 20 Nov 2020 18:02:16 -0800 In-Reply-To: <20201121020232.908850-1-saravanak@google.com> Message-Id: <20201121020232.908850-2-saravanak@google.com> Mime-Version: 1.0 References: <20201121020232.908850-1-saravanak@google.com> X-Mailer: git-send-email 2.29.2.454.gaff20da3a2-goog Subject: [PATCH v2 01/17] Revert "driver core: Avoid deferred probe due to fw_devlink_pause/resume()" From: Saravana Kannan To: "Rafael J. Wysocki" , "Rafael J. Wysocki" , Len Brown , Greg Kroah-Hartman , Ard Biesheuvel , Rob Herring , Frank Rowand , Marc Zyngier , Thomas Gleixner Cc: Saravana Kannan , Tomi Valkeinen , Laurent Pinchart , Grygorii Strashko , kernel-team@android.com, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, devicetree@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org This reverts commit 2451e746478a6a6e981cfa66b62b791ca93b90c8. fw_devlink_pause/resume() was an incomplete attempt at boot time optimization. That's going to get replaced by a much better optimization at the end of the series. Since fw_devlink_pause/resume() is going away, changes made for that can also go away. Signed-off-by: Saravana Kannan --- drivers/base/core.c | 21 --------------------- include/linux/device.h | 3 +-- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index d661ada1518f..b202fe54f46a 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -51,7 +51,6 @@ static DEFINE_MUTEX(wfs_lock); static LIST_HEAD(deferred_sync); static unsigned int defer_sync_state_count = 1; static unsigned int defer_fw_devlink_count; -static LIST_HEAD(deferred_fw_devlink); static DEFINE_MUTEX(defer_fw_devlink_lock); static bool fw_devlink_is_permissive(void); @@ -1470,12 +1469,6 @@ static void fw_devlink_link_device(struct device *dev) fw_ret = -EAGAIN; } else { fw_ret = -ENODEV; - /* - * defer_hook is not used to add device to deferred_sync list - * until device is bound. Since deferred fw devlink also blocks - * probing, same list hook can be used for deferred_fw_devlink. - */ - list_add_tail(&dev->links.defer_hook, &deferred_fw_devlink); } if (fw_ret == -ENODEV) @@ -1544,9 +1537,6 @@ void fw_devlink_pause(void) */ void fw_devlink_resume(void) { - struct device *dev, *tmp; - LIST_HEAD(probe_list); - mutex_lock(&defer_fw_devlink_lock); if (!defer_fw_devlink_count) { WARN(true, "Unmatched fw_devlink pause/resume!"); @@ -1558,19 +1548,8 @@ void fw_devlink_resume(void) goto out; device_link_add_missing_supplier_links(); - list_splice_tail_init(&deferred_fw_devlink, &probe_list); out: mutex_unlock(&defer_fw_devlink_lock); - - /* - * bus_probe_device() can cause new devices to get added and they'll - * try to grab defer_fw_devlink_lock. So, this needs to be done outside - * the defer_fw_devlink_lock. - */ - list_for_each_entry_safe(dev, tmp, &probe_list, links.defer_hook) { - list_del_init(&dev->links.defer_hook); - bus_probe_device(dev); - } } /* Device links support end. */ diff --git a/include/linux/device.h b/include/linux/device.h index 5ed101be7b2e..da00f8e449bb 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -352,8 +352,7 @@ enum dl_dev_state { * @suppliers: List of links to supplier devices. * @consumers: List of links to consumer devices. * @needs_suppliers: Hook to global list of devices waiting for suppliers. - * @defer_hook: Hook to global list of devices that have deferred sync_state or - * deferred fw_devlink. + * @defer_hook: Hook to global list of devices that have deferred sync_state. * @need_for_probe: If needs_suppliers is on a list, this indicates if the * suppliers are needed for probe or not. * @status: Driver status information. From patchwork Sat Nov 21 02:02:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 330034 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E914C64E7C for ; Sat, 21 Nov 2020 02:03:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 49E3122202 for ; Sat, 21 Nov 2020 02:03:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="iyIhHWCU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727126AbgKUCCx (ORCPT ); Fri, 20 Nov 2020 21:02:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727124AbgKUCCx (ORCPT ); Fri, 20 Nov 2020 21:02:53 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D548CC061A48 for ; Fri, 20 Nov 2020 18:02:52 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id r4so13283245ybs.1 for ; Fri, 20 Nov 2020 18:02:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=W0J7h6NLwXezG3nw9wROdbEnvnNKGLsOxhSb3UWP0QY=; b=iyIhHWCU9fj/oBG0xaKujfMHdcE8iB1SHBs4M9uqPOEXOlyOZGNCOu4kJplToKtsqJ fm9DBFExGlNp0BWtvnxzXaRl0F2u7jENq1EfgLZiZAfHyGLUmsUve7IGj3V4JMdosQD/ tpoo12lOko1CXTc92SEtontayS9W0+oxCJIHIp3E6HX/pgQ70Q4/4/DvH/6Rm0Pzddet GinuxCIH3bZkCO68pDwYARdQQ0Ygh4QCrpj5fBxPcuGt1CKVwtdaMxLpxgy1flqww/JQ EA1F39eN5dGotPk2TCgI2lBfxTDM4CROmmwjA0+wZ6znQee7HUsmCtDzqXxzZk1Xo/4N vM9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=W0J7h6NLwXezG3nw9wROdbEnvnNKGLsOxhSb3UWP0QY=; b=ohkNDOIuLoBKE8jnmG2Qf9A+X7Ct+wkxU0x+hXYVRxNwCCR9LwL6LVYh9/qe1J8BRZ WGdgrX21Y5M0i+NOSkzIrqcqJMSvGJx8VtG9UkT+XsQjkJkq7CLH8JBIzl70YKGrYiGP +AaPxJGl9syC2LKMNhMB21Rd0z1tJ8g61nqZDLm4lhOLzwgl5QixN49BtjGecJiOY45e 8WMr8O5iU5tx4/dOPcoaY8uiPvvBI721n35hdQ2BolT81U3t6wGhggZuKwkyilRg4R3E pRRDtrGthT9cfXAf4kXDGKotw89jWAykc9f27oko7AjJiZGiWmdwYeurFZr/D5+c/mYh 0+dw== X-Gm-Message-State: AOAM533Me1QW50J0igMdKBU1qeBwvdWBpcnCJi4L6VKu9MSHTBn5KY/W 7uhx8sSBTBquTlnWKJvRkbGFvvl8Ls0ySyg= X-Google-Smtp-Source: ABdhPJxaPaEuH/NuIAbXGDdgzhB6YudXw1v6b5GdSJ/2qVXcj02CQC8DkQhxDv4As8NeECYbE4iKP/J9Hk/OB9Y= Sender: "saravanak via sendgmr" X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:7220:84ff:fe09:fedc]) (user=saravanak job=sendgmr) by 2002:a25:ac1a:: with SMTP id w26mr32786299ybi.395.1605924172031; Fri, 20 Nov 2020 18:02:52 -0800 (PST) Date: Fri, 20 Nov 2020 18:02:18 -0800 In-Reply-To: <20201121020232.908850-1-saravanak@google.com> Message-Id: <20201121020232.908850-4-saravanak@google.com> Mime-Version: 1.0 References: <20201121020232.908850-1-saravanak@google.com> X-Mailer: git-send-email 2.29.2.454.gaff20da3a2-goog Subject: [PATCH v2 03/17] Revert "driver core: Don't do deferred probe in parallel with kernel_init thread" From: Saravana Kannan To: "Rafael J. Wysocki" , "Rafael J. Wysocki" , Len Brown , Greg Kroah-Hartman , Ard Biesheuvel , Rob Herring , Frank Rowand , Marc Zyngier , Thomas Gleixner Cc: Saravana Kannan , Tomi Valkeinen , Laurent Pinchart , Grygorii Strashko , kernel-team@android.com, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, devicetree@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org This reverts commit cec72f3efc6272420c2c2c699607f03d09b93e41. Commit cec72f3efc62 ("driver core: Don't do deferred probe in parallel with kernel_init thread") was fixing a commit 716a7a259690 ("driver core: fw_devlink: Add support for batching fwnode parsing"). Since the commit being fixed itself is going to be reverted, the fix can also be reverted. Signed-off-by: Saravana Kannan --- drivers/base/base.h | 1 + drivers/base/core.c | 1 + drivers/base/dd.c | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/drivers/base/base.h b/drivers/base/base.h index 91cfb8405abd..c3562adf4789 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -156,6 +156,7 @@ extern char *make_class_name(const char *name, struct kobject *kobj); extern int devres_release_all(struct device *dev); extern void device_block_probing(void); extern void device_unblock_probing(void); +extern void driver_deferred_probe_force_trigger(void); /* /sys/devices directory */ extern struct kset *devices_kset; diff --git a/drivers/base/core.c b/drivers/base/core.c index c91ff2546247..e6bb4bf4f19d 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1548,6 +1548,7 @@ void fw_devlink_resume(void) goto out; device_link_add_missing_supplier_links(); + driver_deferred_probe_force_trigger(); out: mutex_unlock(&defer_fw_devlink_lock); } diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 148e81969e04..001caa0b447c 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -167,6 +167,11 @@ static void driver_deferred_probe_trigger(void) if (!driver_deferred_probe_enable) return; + driver_deferred_probe_force_trigger(); +} + +void driver_deferred_probe_force_trigger(void) +{ /* * A successful probe means that all the devices in the pending list * should be triggered to be reprobed. Move all the deferred devices From patchwork Sat Nov 21 02:02:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 330033 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD1CDC56202 for ; Sat, 21 Nov 2020 02:03:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8DE7B24171 for ; Sat, 21 Nov 2020 02:03:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="CFNlNuBG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727216AbgKUCDC (ORCPT ); Fri, 20 Nov 2020 21:03:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727214AbgKUCDC (ORCPT ); Fri, 20 Nov 2020 21:03:02 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A307CC061A48 for ; Fri, 20 Nov 2020 18:03:00 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id a6so14298972ybi.0 for ; Fri, 20 Nov 2020 18:03:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=S0ib8u/7wh3kLvhCXXOvflu8O0ETo4V/YijspRHnq78=; b=CFNlNuBG2O3fMz5BNHE+vG2DWMcvm6vBu+JFzEXnqkW7M5ASUNzjSLFtG7u4clwR4k VKt0OhbNlt8oedzo4uUSDpo7XB3ko1klYndvWBpBpAB1bWfR7wpjrCODPpfvKDGa8Vmq iC716fbdguC8L8NPzSsHMYBbcwz/hxKeyu50/Lvj8zw8+n2+yd2yRctzBWo4mok7ZmRI 5R1kizNMqoRsI6VCJhmW5qt7T9t7XMz9iQvTt1WMvXwnKjC3QnUGGDv6zNleC3zr8OHs OhAE2ZVli/EPb27MrAeMlK1CEEf/mhpymCzP7/JySqUi9XjbNaCgY3urTmyStQ5IZ1Ye gWpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=S0ib8u/7wh3kLvhCXXOvflu8O0ETo4V/YijspRHnq78=; b=Akp86rcybQOxWNpFLPnKxvxNQlDnT3c+kN0U1/cEysPUAWm2F+N+68YpDT6oNubv4I e1XsCdUie/FZ77P/I0OEBi6OCletLuKHWWEoMSXjDaIvSC/PfHqcWJ0OBxcxkZqPEMrn 251CQ77vBYmIg9o/+WCiXEvk/Amd8mognyoKt4GT1aWa+qGBPJxeF2N4ZA/mPVE45B0R vwlWTtr4olWkL+p6jgaIpcXkATqZ6gMzvOHRer8wM2QCyaua/A49M8TgUHlYQ2L4qSh3 6dIhzmC0ddxj+XhApFbgTWEb841IlxkAQ5JnmDHO7pFJgGZDr+OcsFp7V5SxJfxFYg/B 1HSA== X-Gm-Message-State: AOAM533ruCptKQSNhIngJV3SZZyyICFsmOluN0cGKgzmNDiZOxB1KuqD RM62StD3IW+MuH1WOvQnjfKNP3rX3u7XDdg= X-Google-Smtp-Source: ABdhPJy+eu6XVbcJYUcL1uW5OEWkz9CJ5VUEn/2gDqRl6e62WFu5zeESVjmr+EiKM+4B0WR4d+I2kbv3pN8nrPc= Sender: "saravanak via sendgmr" X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:7220:84ff:fe09:fedc]) (user=saravanak job=sendgmr) by 2002:a25:4f0b:: with SMTP id d11mr18621624ybb.147.1605924179889; Fri, 20 Nov 2020 18:02:59 -0800 (PST) Date: Fri, 20 Nov 2020 18:02:21 -0800 In-Reply-To: <20201121020232.908850-1-saravanak@google.com> Message-Id: <20201121020232.908850-7-saravanak@google.com> Mime-Version: 1.0 References: <20201121020232.908850-1-saravanak@google.com> X-Mailer: git-send-email 2.29.2.454.gaff20da3a2-goog Subject: [PATCH v2 06/17] Revert "driver core: fw_devlink: Add support for batching fwnode parsing" From: Saravana Kannan To: "Rafael J. Wysocki" , "Rafael J. Wysocki" , Len Brown , Greg Kroah-Hartman , Ard Biesheuvel , Rob Herring , Frank Rowand , Marc Zyngier , Thomas Gleixner Cc: Saravana Kannan , Tomi Valkeinen , Laurent Pinchart , Grygorii Strashko , kernel-team@android.com, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, devicetree@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org This reverts commit 716a7a25969003d82ab738179c3f1068a120ed11. The fw_devlink_pause/resume() APIs added by the commit being reverted were a first cut attempt at optimizing boot time. But these APIs don't fully solve the problem and are very fragile (can only be used for the top level devices being added). This series replaces them with a much better optimization that works for all device additions and also has the benefit of reducing the complexity of the firmware (DT, EFI) specific code and abstracting out common code to driver core. Signed-off-by: Saravana Kannan --- drivers/base/base.h | 1 - drivers/base/core.c | 116 +++-------------------------------------- drivers/base/dd.c | 8 --- include/linux/fwnode.h | 2 - 4 files changed, 7 insertions(+), 120 deletions(-) diff --git a/drivers/base/base.h b/drivers/base/base.h index c3562adf4789..91cfb8405abd 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -156,7 +156,6 @@ extern char *make_class_name(const char *name, struct kobject *kobj); extern int devres_release_all(struct device *dev); extern void device_block_probing(void); extern void device_unblock_probing(void); -extern void driver_deferred_probe_force_trigger(void); /* /sys/devices directory */ extern struct kset *devices_kset; diff --git a/drivers/base/core.c b/drivers/base/core.c index e6bb4bf4f19d..401fa7e3505c 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -50,9 +50,6 @@ static LIST_HEAD(wait_for_suppliers); static DEFINE_MUTEX(wfs_lock); static LIST_HEAD(deferred_sync); static unsigned int defer_sync_state_count = 1; -static unsigned int defer_fw_devlink_count; -static DEFINE_MUTEX(defer_fw_devlink_lock); -static bool fw_devlink_is_permissive(void); #ifdef CONFIG_SRCU static DEFINE_MUTEX(device_links_lock); @@ -758,7 +755,7 @@ static void device_link_add_missing_supplier_links(void) int ret = fwnode_call_int_op(dev->fwnode, add_links, dev); if (!ret) list_del_init(&dev->links.needs_suppliers); - else if (ret != -ENODEV || fw_devlink_is_permissive()) + else if (ret != -ENODEV) dev->links.need_for_probe = false; } mutex_unlock(&wfs_lock); @@ -1442,116 +1439,17 @@ static void fw_devlink_link_device(struct device *dev) { int fw_ret; - if (!fw_devlink_flags) - return; - - mutex_lock(&defer_fw_devlink_lock); - if (!defer_fw_devlink_count) - device_link_add_missing_supplier_links(); - - /* - * The device's fwnode not having add_links() doesn't affect if other - * consumers can find this device as a supplier. So, this check is - * intentionally placed after device_link_add_missing_supplier_links(). - */ - if (!fwnode_has_op(dev->fwnode, add_links)) - goto out; + device_link_add_missing_supplier_links(); - /* - * If fw_devlink is being deferred, assume all devices have mandatory - * suppliers they need to link to later. Then, when the fw_devlink is - * resumed, all these devices will get a chance to try and link to any - * suppliers they have. - */ - if (!defer_fw_devlink_count) { + if (fw_devlink_flags && fwnode_has_op(dev->fwnode, add_links)) { fw_ret = fwnode_call_int_op(dev->fwnode, add_links, dev); - if (fw_ret == -ENODEV && fw_devlink_is_permissive()) - fw_ret = -EAGAIN; - } else { - fw_ret = -ENODEV; + if (fw_ret == -ENODEV && !fw_devlink_is_permissive()) + device_link_wait_for_mandatory_supplier(dev); + else if (fw_ret) + device_link_wait_for_optional_supplier(dev); } - - if (fw_ret == -ENODEV) - device_link_wait_for_mandatory_supplier(dev); - else if (fw_ret) - device_link_wait_for_optional_supplier(dev); - -out: - mutex_unlock(&defer_fw_devlink_lock); } -/** - * fw_devlink_pause - Pause parsing of fwnode to create device links - * - * Calling this function defers any fwnode parsing to create device links until - * fw_devlink_resume() is called. Both these functions are ref counted and the - * caller needs to match the calls. - * - * While fw_devlink is paused: - * - Any device that is added won't have its fwnode parsed to create device - * links. - * - The probe of the device will also be deferred during this period. - * - Any devices that were already added, but waiting for suppliers won't be - * able to link to newly added devices. - * - * Once fw_devlink_resume(): - * - All the fwnodes that was not parsed will be parsed. - * - All the devices that were deferred probing will be reattempted if they - * aren't waiting for any more suppliers. - * - * This pair of functions, is mainly meant to optimize the parsing of fwnodes - * when a lot of devices that need to link to each other are added in a short - * interval of time. For example, adding all the top level devices in a system. - * - * For example, if N devices are added and: - * - All the consumers are added before their suppliers - * - All the suppliers of the N devices are part of the N devices - * - * Then: - * - * - With the use of fw_devlink_pause() and fw_devlink_resume(), each device - * will only need one parsing of its fwnode because it is guaranteed to find - * all the supplier devices already registered and ready to link to. It won't - * have to do another pass later to find one or more suppliers it couldn't - * find in the first parse of the fwnode. So, we'll only need O(N) fwnode - * parses. - * - * - Without the use of fw_devlink_pause() and fw_devlink_resume(), we would - * end up doing O(N^2) parses of fwnodes because every device that's added is - * guaranteed to trigger a parse of the fwnode of every device added before - * it. This O(N^2) parse is made worse by the fact that when a fwnode of a - * device is parsed, all it descendant devices might need to have their - * fwnodes parsed too (even if the devices themselves aren't added). - */ -void fw_devlink_pause(void) -{ - mutex_lock(&defer_fw_devlink_lock); - defer_fw_devlink_count++; - mutex_unlock(&defer_fw_devlink_lock); -} - -/** fw_devlink_resume - Resume parsing of fwnode to create device links - * - * This function is used in conjunction with fw_devlink_pause() and is ref - * counted. See documentation for fw_devlink_pause() for more details. - */ -void fw_devlink_resume(void) -{ - mutex_lock(&defer_fw_devlink_lock); - if (!defer_fw_devlink_count) { - WARN(true, "Unmatched fw_devlink pause/resume!"); - goto out; - } - - defer_fw_devlink_count--; - if (defer_fw_devlink_count) - goto out; - - device_link_add_missing_supplier_links(); - driver_deferred_probe_force_trigger(); -out: - mutex_unlock(&defer_fw_devlink_lock); -} /* Device links support end. */ int (*platform_notify)(struct device *dev) = NULL; diff --git a/drivers/base/dd.c b/drivers/base/dd.c index b4be35fa7fda..148e81969e04 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -163,14 +163,6 @@ static bool driver_deferred_probe_enable = false; * again. */ static void driver_deferred_probe_trigger(void) -{ - if (!driver_deferred_probe_enable) - return; - - driver_deferred_probe_force_trigger(); -} - -void driver_deferred_probe_force_trigger(void) { if (!driver_deferred_probe_enable) return; diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h index 9506f8ec0974..e0abafbb17f8 100644 --- a/include/linux/fwnode.h +++ b/include/linux/fwnode.h @@ -171,7 +171,5 @@ struct fwnode_operations { #define get_dev_from_fwnode(fwnode) get_device((fwnode)->dev) extern u32 fw_devlink_get_flags(void); -void fw_devlink_pause(void); -void fw_devlink_resume(void); #endif From patchwork Sat Nov 21 02:02:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 330032 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94114C8300E for ; Sat, 21 Nov 2020 02:03:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 56DE124124 for ; Sat, 21 Nov 2020 02:03:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Oy8wm9rw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727237AbgKUCDI (ORCPT ); Fri, 20 Nov 2020 21:03:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727229AbgKUCDI (ORCPT ); Fri, 20 Nov 2020 21:03:08 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33C3AC061A47 for ; Fri, 20 Nov 2020 18:03:06 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id c137so14145175ybf.21 for ; Fri, 20 Nov 2020 18:03:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=x2gFsEGnt1hKBTrd9Sh3BTzH1tCcPBvDnEqJhrf0jZk=; b=Oy8wm9rwe1xVP8CflmSHV6kS8mZ8CgBwaFnQT3haVq3hQfhTNPB3Dt+DC1srIEOHnJ 00ReduJqDRDAQo4YVHy1qpCiEQz2PNiibjyIT3lltB9/N4XBvYtaxgJiErfIRrfc04LQ HK3VL6wPuPvyARgqpnwh7mKN6u6Cqa0Qqguc/PqLj0TgOesrnHZZ9yRhqVOBaT7kxpd3 dYu6ejbMVZYfjOzk9mfZ+HZZdv455G6CXO+PAnMkBmajLUc/z8awlvJ1DwSX5FWgZtuK wF8ckZS3fTtZQZbuZE/wXm3mJ8ohZofNG7tgMMkx/gVSlH7velqealMro7ClhtycjfVJ 32NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=x2gFsEGnt1hKBTrd9Sh3BTzH1tCcPBvDnEqJhrf0jZk=; b=HRa0tsl3oyaLntHNsstdsSSCn9anBOp2u49tYi7pxFKRz05RBk+4qNGzdDxhzR0J4j nsrmlBr7eR3U0njPvpDEWQrZZTqZ2DQCL3vS9XXFb9tRtU7NI0eMDWfx6TEzcL6QxKoe c0Oi1BEOkh609OGl94fH4KvYH96W4dX5gQgMBWvSdCiBuvsEG8cRcVoXOwYZBmccbl8V 5MbipfatO53bCEo/yKHiBjzByrmFMzE+oyiLIHSdcmSDEyWBhPLDrgrKyvA0rSjnsI1d eGhktrn/w+eaCSYATBcikuMxAvqCzX3IImXzE9S6d03yTIX13GEs+lQsu3g4HeGvy4Xi 8qDA== X-Gm-Message-State: AOAM530gyRTy8aQizvIo51NH+RlYz8Hwrf4HiNKEZH7blo54so/oSIb9 xaN69at1BIPxB5HGMa5RmNppwoAVbulUQOQ= X-Google-Smtp-Source: ABdhPJw9Lk+TmjAMNEAUq1RSxqYyPt+9pEP3OOOGTSy7HY7WuXSKaV6EWWbJFhcTCdlhMAZY1adm2F1s03IEpYQ= Sender: "saravanak via sendgmr" X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:7220:84ff:fe09:fedc]) (user=saravanak job=sendgmr) by 2002:a25:8446:: with SMTP id r6mr21337325ybm.442.1605924185419; Fri, 20 Nov 2020 18:03:05 -0800 (PST) Date: Fri, 20 Nov 2020 18:02:23 -0800 In-Reply-To: <20201121020232.908850-1-saravanak@google.com> Message-Id: <20201121020232.908850-9-saravanak@google.com> Mime-Version: 1.0 References: <20201121020232.908850-1-saravanak@google.com> X-Mailer: git-send-email 2.29.2.454.gaff20da3a2-goog Subject: [PATCH v2 08/17] driver core: Add fwnode link support From: Saravana Kannan To: "Rafael J. Wysocki" , "Rafael J. Wysocki" , Len Brown , Greg Kroah-Hartman , Ard Biesheuvel , Rob Herring , Frank Rowand , Marc Zyngier , Thomas Gleixner Cc: Saravana Kannan , Tomi Valkeinen , Laurent Pinchart , Grygorii Strashko , kernel-team@android.com, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, devicetree@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Add support for creating supplier-consumer links between fwnodes. It is intended for internal use the driver core and generic firmware support code (eg. Device Tree, ACPI), so it is simple by design and the API provided is limited. Signed-off-by: Saravana Kannan Acked-by: Rob Herring --- drivers/base/core.c | 98 ++++++++++++++++++++++++++++++++++++++++++ drivers/of/dynamic.c | 1 + include/linux/fwnode.h | 14 ++++++ 3 files changed, 113 insertions(+) diff --git a/drivers/base/core.c b/drivers/base/core.c index 401fa7e3505c..e2b246a44d1a 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -50,6 +50,104 @@ static LIST_HEAD(wait_for_suppliers); static DEFINE_MUTEX(wfs_lock); static LIST_HEAD(deferred_sync); static unsigned int defer_sync_state_count = 1; +static DEFINE_MUTEX(fwnode_link_lock); + +/** + * fwnode_link_add - Create a link between two fwnode_handles. + * @con: Consumer end of the link. + * @sup: Supplier end of the link. + * + * Create a fwnode link between fwnode handles @con and @sup. The fwnode link + * represents the detail that the firmware lists @sup fwnode as supplying a + * resource to @con. + * + * The driver core will use the fwnode link to create a device link between the + * two device objects corresponding to @con and @sup when they are created. The + * driver core will automatically delete the fwnode link between @con and @sup + * after doing that. + * + * Attempts to create duplicate links between the same pair of fwnode handles + * are ignored and there is no reference counting. + */ +int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup) +{ + struct fwnode_link *link; + int ret = 0; + + mutex_lock(&fwnode_link_lock); + + list_for_each_entry(link, &sup->consumers, s_hook) + if (link->consumer == con) + goto out; + + link = kzalloc(sizeof(*link), GFP_KERNEL); + if (!link) { + ret = -ENOMEM; + goto out; + } + + link->supplier = sup; + INIT_LIST_HEAD(&link->s_hook); + link->consumer = con; + INIT_LIST_HEAD(&link->c_hook); + + list_add(&link->s_hook, &sup->consumers); + list_add(&link->c_hook, &con->suppliers); +out: + mutex_unlock(&fwnode_link_lock); + + return ret; +} + +/** + * fwnode_links_purge_suppliers - Delete all supplier links of fwnode_handle. + * @fwnode: fwnode whose supplier links need to be deleted + * + * Deletes all supplier links connecting directly to @fwnode. + */ +static void fwnode_links_purge_suppliers(struct fwnode_handle *fwnode) +{ + struct fwnode_link *link, *tmp; + + mutex_lock(&fwnode_link_lock); + list_for_each_entry_safe(link, tmp, &fwnode->suppliers, c_hook) { + list_del(&link->s_hook); + list_del(&link->c_hook); + kfree(link); + } + mutex_unlock(&fwnode_link_lock); +} + +/** + * fwnode_links_purge_consumers - Delete all consumer links of fwnode_handle. + * @fwnode: fwnode whose consumer links need to be deleted + * + * Deletes all consumer links connecting directly to @fwnode. + */ +static void fwnode_links_purge_consumers(struct fwnode_handle *fwnode) +{ + struct fwnode_link *link, *tmp; + + mutex_lock(&fwnode_link_lock); + list_for_each_entry_safe(link, tmp, &fwnode->consumers, s_hook) { + list_del(&link->s_hook); + list_del(&link->c_hook); + kfree(link); + } + mutex_unlock(&fwnode_link_lock); +} + +/** + * fwnode_links_purge - Delete all links connected to a fwnode_handle. + * @fwnode: fwnode whose links needs to be deleted + * + * Deletes all links connecting directly to a fwnode. + */ +void fwnode_links_purge(struct fwnode_handle *fwnode) +{ + fwnode_links_purge_suppliers(fwnode); + fwnode_links_purge_consumers(fwnode); +} #ifdef CONFIG_SRCU static DEFINE_MUTEX(device_links_lock); diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c index fe64430b438a..9a824decf61f 100644 --- a/drivers/of/dynamic.c +++ b/drivers/of/dynamic.c @@ -356,6 +356,7 @@ void of_node_release(struct kobject *kobj) property_list_free(node->properties); property_list_free(node->deadprops); + fwnode_links_purge(of_fwnode_handle(node)); kfree(node->full_name); kfree(node->data); diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h index 5589799708b5..b88365187347 100644 --- a/include/linux/fwnode.h +++ b/include/linux/fwnode.h @@ -10,6 +10,7 @@ #define _LINUX_FWNODE_H_ #include +#include struct fwnode_operations; struct device; @@ -18,6 +19,15 @@ struct fwnode_handle { struct fwnode_handle *secondary; const struct fwnode_operations *ops; struct device *dev; + struct list_head suppliers; + struct list_head consumers; +}; + +struct fwnode_link { + struct fwnode_handle *supplier; + struct list_head s_hook; + struct fwnode_handle *consumer; + struct list_head c_hook; }; /** @@ -174,8 +184,12 @@ static inline void fwnode_init(struct fwnode_handle *fwnode, const struct fwnode_operations *ops) { fwnode->ops = ops; + INIT_LIST_HEAD(&fwnode->consumers); + INIT_LIST_HEAD(&fwnode->suppliers); } extern u32 fw_devlink_get_flags(void); +int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup); +void fwnode_links_purge(struct fwnode_handle *fwnode); #endif From patchwork Sat Nov 21 02:02:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 330031 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B8F2C56201 for ; Sat, 21 Nov 2020 02:03:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 633852237B for ; Sat, 21 Nov 2020 02:03:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Vj45QhO9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727228AbgKUCDN (ORCPT ); Fri, 20 Nov 2020 21:03:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727287AbgKUCDL (ORCPT ); Fri, 20 Nov 2020 21:03:11 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C9B2C061A4B for ; Fri, 20 Nov 2020 18:03:11 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id g129so14191046ybf.20 for ; Fri, 20 Nov 2020 18:03:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=fcRX8EQ81IWbj6+XDTRlZFv8SxEOqV4OLStJQB/GoqQ=; b=Vj45QhO9ZSi0OFJycyK5AzWKxaZwGDVhvQ4z/YZwUXcrdiuvMasH3fQQMKIg41YWQa pxWXr0qGp7dzU4C6qYb+d7Uv1Gm56yYRHErC8Alp46BYKTHGkXivfK4K1eszSPOtCF1T tpeUyllcJhacOxSqD5nPFxhGX0OEg0wjMp7gvYrSFG7ogRg71wamSFLD/VlVbg2TuZX/ eBM7mLf3GEN1C5gWZTuOeL3ttJgas/vXbDCChXeOi/LtNg6+1tLMtqTAKP24z+iKFtH1 ri6FX3ocRYsaWv9UyFVDpTewGEgXUatlTpvthQ4OOMVXk8S57eg7RCCYzuaeEhWiHTXq Uivw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=fcRX8EQ81IWbj6+XDTRlZFv8SxEOqV4OLStJQB/GoqQ=; b=PV7+Syaj5cP0bFFRsPCj7r5eBiIlHoISD1E/UEyHTCd9hsd3C9/Zj2lVAsLybPEhkT lXIvfJ+O7VvXTN6TlBKjr75Dta6v7pb1YIsxoEK3m/LrADjFaAh4+pD8YkQQw39jdfjU yO+rMBtibfbf6yUnhWzP2+fgkKR1P4PerXyxFPHWmxjFLPSVw7UcCbZb4EKDaPVkx8CJ 7kBq1VShKd2RL+O6z6zHgOjKSr1hmd8OprTafNP61Wn6r7g6EdHx7hC5/PuxGn6yCbmw 3mhHQnMd45oSh+vgpERbYypMSs4WI4K/3YS9yondOZE4sCJm45J1H/b6WPVVT0PTl9hg BTDQ== X-Gm-Message-State: AOAM530LNFleeLuwXB67JNZtX4MyRXsPYBPvTPyonl5Xk2O4NAymfcJ5 iPIPUM/2Q4VK8+mAe0SLNhpClKBxFvuD43M= X-Google-Smtp-Source: ABdhPJyEhyYRg3K0ym/U8YyY3pTaho98WkVJn/HloZlFw1kCa8i1tKS3G+uhnmUgvyIN+LExLDVXMDROSAqKLBc= Sender: "saravanak via sendgmr" X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:7220:84ff:fe09:fedc]) (user=saravanak job=sendgmr) by 2002:a25:aa63:: with SMTP id s90mr25460026ybi.340.1605924190358; Fri, 20 Nov 2020 18:03:10 -0800 (PST) Date: Fri, 20 Nov 2020 18:02:25 -0800 In-Reply-To: <20201121020232.908850-1-saravanak@google.com> Message-Id: <20201121020232.908850-11-saravanak@google.com> Mime-Version: 1.0 References: <20201121020232.908850-1-saravanak@google.com> X-Mailer: git-send-email 2.29.2.454.gaff20da3a2-goog Subject: [PATCH v2 10/17] device property: Add fwnode_is_ancestor_of() and fwnode_get_next_parent_dev() From: Saravana Kannan To: "Rafael J. Wysocki" , "Rafael J. Wysocki" , Len Brown , Greg Kroah-Hartman , Ard Biesheuvel , Rob Herring , Frank Rowand , Marc Zyngier , Thomas Gleixner Cc: Saravana Kannan , Tomi Valkeinen , Laurent Pinchart , Grygorii Strashko , kernel-team@android.com, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, devicetree@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Add fwnode_is_ancestor_of() helper function to check if a fwnode is an ancestor of another fwnode. Add fwnode_get_next_parent_dev() helper function that take as input a fwnode and finds the closest ancestor fwnode that has a corresponding struct device and returns that struct device. Signed-off-by: Saravana Kannan --- drivers/base/property.c | 52 ++++++++++++++++++++++++++++++++++++++++ include/linux/property.h | 3 +++ 2 files changed, 55 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index 4c43d30145c6..35b95c6ac0c6 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -614,6 +614,31 @@ struct fwnode_handle *fwnode_get_next_parent(struct fwnode_handle *fwnode) } EXPORT_SYMBOL_GPL(fwnode_get_next_parent); +/** + * fwnode_get_next_parent_dev - Find device of closest ancestor fwnode + * @fwnode: firmware node + * + * Given a firmware node (@fwnode), this function finds its closest ancestor + * firmware node that has a corresponding struct device and returns that struct + * device. + * + * The caller of this function is expected to call put_device() on the returned + * device when they are done. + */ +struct device *fwnode_get_next_parent_dev(struct fwnode_handle *fwnode) +{ + struct device *dev = NULL; + + fwnode_handle_get(fwnode); + do { + fwnode = fwnode_get_next_parent(fwnode); + if (fwnode) + dev = get_dev_from_fwnode(fwnode); + } while (fwnode && !dev); + fwnode_handle_put(fwnode); + return dev; +} + /** * fwnode_count_parents - Return the number of parents a node has * @fwnode: The node the parents of which are to be counted @@ -660,6 +685,33 @@ struct fwnode_handle *fwnode_get_nth_parent(struct fwnode_handle *fwnode, } EXPORT_SYMBOL_GPL(fwnode_get_nth_parent); +/** + * fwnode_is_ancestor_of - Test if @test_ancestor is ancestor of @test_child + * @test_ancestor: Firmware which is tested for being an ancestor + * @test_child: Firmware which is tested for being the child + * + * A node is considered an ancestor of itself too. + * + * Returns true if @test_ancestor is an ancestor of @test_child. + * Otherwise, returns false. + */ +bool fwnode_is_ancestor_of(struct fwnode_handle *test_ancestor, + struct fwnode_handle *test_child) +{ + if (!test_ancestor) + return false; + + fwnode_handle_get(test_child); + while (test_child) { + if (test_child == test_ancestor) { + fwnode_handle_put(test_child); + return true; + } + test_child = fwnode_get_next_parent(test_child); + } + return false; +} + /** * fwnode_get_next_child_node - Return the next child node handle for a node * @fwnode: Firmware node to find the next child node for. diff --git a/include/linux/property.h b/include/linux/property.h index 2d4542629d80..0a9001fe7aea 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -85,9 +85,12 @@ const char *fwnode_get_name_prefix(const struct fwnode_handle *fwnode); struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode); struct fwnode_handle *fwnode_get_next_parent( struct fwnode_handle *fwnode); +struct device *fwnode_get_next_parent_dev(struct fwnode_handle *fwnode); unsigned int fwnode_count_parents(const struct fwnode_handle *fwn); struct fwnode_handle *fwnode_get_nth_parent(struct fwnode_handle *fwn, unsigned int depth); +bool fwnode_is_ancestor_of(struct fwnode_handle *test_ancestor, + struct fwnode_handle *test_child); struct fwnode_handle *fwnode_get_next_child_node( const struct fwnode_handle *fwnode, struct fwnode_handle *child); struct fwnode_handle *fwnode_get_next_available_child_node( From patchwork Sat Nov 21 02:02:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 330027 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41B46C83018 for ; Sat, 21 Nov 2020 02:04:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 01D5A2237B for ; Sat, 21 Nov 2020 02:03:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="bB0A+R+G" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727316AbgKUCDQ (ORCPT ); Fri, 20 Nov 2020 21:03:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727312AbgKUCDP (ORCPT ); Fri, 20 Nov 2020 21:03:15 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE33CC061A48 for ; Fri, 20 Nov 2020 18:03:13 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id r4so13284569ybs.1 for ; Fri, 20 Nov 2020 18:03:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=/LX9bJeHDDRylfNoVob87S2JlPxG5ImJS2h+ELTJVqI=; b=bB0A+R+G6PXveAVwcws7Z6i0PtnRk1Y3WmrGqeK19Oc30MPDpg5PLW8RW/9lvTNJ7X ZRTtvAXOk6zLLS0tWgmBiPMaXiHdzk5JqHUFBWNxyBSg0jQM1byyfIeB9eYkfVuzKhr1 X8ympijJHD7vExfoFyae6VvOI8Vx9VEFLgHHb0qBUNp2851U9GaspjHNdIxtBPBZYWWw 5ZgYR0vIK29DD9C+3cXe7HhXkzFBfkgliAr3qx4BD+Q87nz5OaTd9d2HZNawReGOZWFZ 4mRpulnPz5jPrf7xmdDNz/I/sOI1/6e8gnFM8roDKA1AsSml5IDh2Ec3EyYQQ94+kKeP IerQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=/LX9bJeHDDRylfNoVob87S2JlPxG5ImJS2h+ELTJVqI=; b=Y86DJ4kOYg+LX4Hm29Pcjr9cvox+JkN/MQLDb+HmE2Wkl/RFTyF0v0fFsnvCvy6siI Jw+mBBMv9HWHGSCTKaBxtUxaEd98wiqGshvyCo5+Dbf63KX5MzwCTDxPrlgXZ3v2YNqf aXhxiaDPsvbsXxWf0MWT9JItr9F3OZJdlJqlwu5IvHoMNeGA7rfpW7v/y1HvVeDTYPcn dnzNl+/rFitcv/Oyp7AOvsMiEjIzCHPCZr1QmCmqaGNO6PgMvs3Garksf2/0WZwUK7Ff FzBaGRWCY+M1Qw3hLXyVUam0bMztMq3Eeu/VW6a08ZL/QDBsLZwSHSDSp8vVJEO9WUxP 5oWQ== X-Gm-Message-State: AOAM531ME/PB5xuLjCjD1wGMMDz/Md+ToI+hGMWA6OFEYDE7mbNpZ2BD 0twn/jXBSXk3G5lQtONJwcD200b4RCuVvsg= X-Google-Smtp-Source: ABdhPJwpPqnlFJLkUZfisNfpE1+K8M+fKGEWW7MXjBtNcZY6hW80Mcdvb9sW2hFXXDlIpR63mRRi+3x532QOhRc= Sender: "saravanak via sendgmr" X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:7220:84ff:fe09:fedc]) (user=saravanak job=sendgmr) by 2002:a25:4943:: with SMTP id w64mr21803030yba.178.1605924192912; Fri, 20 Nov 2020 18:03:12 -0800 (PST) Date: Fri, 20 Nov 2020 18:02:26 -0800 In-Reply-To: <20201121020232.908850-1-saravanak@google.com> Message-Id: <20201121020232.908850-12-saravanak@google.com> Mime-Version: 1.0 References: <20201121020232.908850-1-saravanak@google.com> X-Mailer: git-send-email 2.29.2.454.gaff20da3a2-goog Subject: [PATCH v2 11/17] driver core: Redefine the meaning of fwnode_operations.add_links() From: Saravana Kannan To: "Rafael J. Wysocki" , "Rafael J. Wysocki" , Len Brown , Greg Kroah-Hartman , Ard Biesheuvel , Rob Herring , Frank Rowand , Marc Zyngier , Thomas Gleixner Cc: Saravana Kannan , Tomi Valkeinen , Laurent Pinchart , Grygorii Strashko , kernel-team@android.com, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, devicetree@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Change the meaning of fwnode_operations.add_links() to just create fwnode links by parsing the properties of a given fwnode. This patch doesn't actually make any code changes. To keeps things more digestable, the actual functional changes come in later patches in this series. Signed-off-by: Saravana Kannan --- drivers/firmware/efi/efi-init.c | 2 +- include/linux/fwnode.h | 42 +++------------------------------ 2 files changed, 4 insertions(+), 40 deletions(-) diff --git a/drivers/firmware/efi/efi-init.c b/drivers/firmware/efi/efi-init.c index b148f1459fb3..65bb97c391b0 100644 --- a/drivers/firmware/efi/efi-init.c +++ b/drivers/firmware/efi/efi-init.c @@ -316,7 +316,7 @@ static struct device_node *find_pci_overlap_node(void) * resource reservation conflict on the memory window that the efifb * framebuffer steals from the PCIe host bridge. */ -static int efifb_add_links(const struct fwnode_handle *fwnode, +static int efifb_add_links(struct fwnode_handle *fwnode, struct device *dev) { struct device_node *sup_np; diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h index b88365187347..942a6bb18201 100644 --- a/include/linux/fwnode.h +++ b/include/linux/fwnode.h @@ -78,44 +78,8 @@ struct fwnode_reference_args { * endpoint node. * @graph_get_port_parent: Return the parent node of a port node. * @graph_parse_endpoint: Parse endpoint for port and endpoint id. - * @add_links: Called after the device corresponding to the fwnode is added - * using device_add(). The function is expected to create device - * links to all the suppliers of the device that are available at - * the time this function is called. The function must NOT stop - * at the first failed device link if other unlinked supplier - * devices are present in the system. This is necessary for the - * driver/bus sync_state() callbacks to work correctly. - * - * For example, say Device-C depends on suppliers Device-S1 and - * Device-S2 and the dependency is listed in that order in the - * firmware. Say, S1 gets populated from the firmware after - * late_initcall_sync(). Say S2 is populated and probed way - * before that in device_initcall(). When C is populated, if this - * add_links() function doesn't continue past a "failed linking to - * S1" and continue linking C to S2, then S2 will get a - * sync_state() callback before C is probed. This is because from - * the perspective of S2, C was never a consumer when its - * sync_state() evaluation is done. To avoid this, the add_links() - * function has to go through all available suppliers of the - * device (that corresponds to this fwnode) and link to them - * before returning. - * - * If some suppliers are not yet available (indicated by an error - * return value), this function will be called again when other - * devices are added to allow creating device links to any newly - * available suppliers. - * - * Return 0 if device links have been successfully created to all - * the known suppliers of this device or if the supplier - * information is not known. - * - * Return -ENODEV if the suppliers needed for probing this device - * have not been registered yet (because device links can only be - * created to devices registered with the driver core). - * - * Return -EAGAIN if some of the suppliers of this device have not - * been registered yet, but none of those suppliers are necessary - * for probing the device. + * @add_links: Create fwnode links to all the suppliers of the fwnode. Return + * zero on success, a negative error code otherwise. */ struct fwnode_operations { struct fwnode_handle *(*get)(struct fwnode_handle *fwnode); @@ -155,7 +119,7 @@ struct fwnode_operations { (*graph_get_port_parent)(struct fwnode_handle *fwnode); int (*graph_parse_endpoint)(const struct fwnode_handle *fwnode, struct fwnode_endpoint *endpoint); - int (*add_links)(const struct fwnode_handle *fwnode, + int (*add_links)(struct fwnode_handle *fwnode, struct device *dev); }; From patchwork Sat Nov 21 02:02:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 330030 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 891D9C71155 for ; Sat, 21 Nov 2020 02:03:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6326D2237B for ; Sat, 21 Nov 2020 02:03:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="NUt98kIU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727403AbgKUCDZ (ORCPT ); Fri, 20 Nov 2020 21:03:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727401AbgKUCDX (ORCPT ); Fri, 20 Nov 2020 21:03:23 -0500 Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5877C061A47 for ; Fri, 20 Nov 2020 18:03:23 -0800 (PST) Received: by mail-qk1-x74a.google.com with SMTP id m76so9558716qke.3 for ; Fri, 20 Nov 2020 18:03:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=9o31eTNo5jewZMssyMhreBE99fTk9fWfix+IMNCftfM=; b=NUt98kIUoRedTYZR/hOWzj22LFXiaz89Di0iPSIbMugj22ZhE8V1wCasM5/hoh7dPD C4/8TMNmLkiJHOEZu7wim37d7s4b7MBJALayHmiuCVuddnXQqouHob4rm9wGJN2uLrMF Qa2rJ99RqjJChfp/LcuyZd7zA6PVh7sXRxjAjVC4RgHlgyAtcdkgc+BHCbtIshsYKqfF esnotmCO4mwSAq6WxLSxdyea39mHCauvAxQHiZhbXwuRX2RZebtE9G1d1BCqhTGtDpFg fmYMbFPks+GOqZe2KGAdUou1Nhk1bKImRT1+0LGGrEbmGHePM1zvytQMBQwTyQ84CWyv X9ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=9o31eTNo5jewZMssyMhreBE99fTk9fWfix+IMNCftfM=; b=LigpCR4nkYdiyLeWVayz4/alxt/m5A2opJqxV2Qy3BLeGktdVfX88ZMjfjoKWkvdgC 08S7EmDW84wg3VjDBiW6DS/8g8TNtPdpScVRa57ilO+mEyNnipKn2fuY8CNrucDvt0oS mYoznofcgUcY84V5QNwmvPKzRfBsjXhFCvJghBP5L3SbpcLieOV0Ax9dvf5ip7rnxSBd eRpksGQBMZTxboJYOZwm+kagQ/oI2KkuC4xuqBYCjfPQaHWJ09nKb7jvW/9zFp56LNyE 0N6dhqL/hQfd7pqh7nv2X1p5151pz9qs1NEO6QfdoQp+JPXOfOIYZizYcoe41d73vplO SbUA== X-Gm-Message-State: AOAM533TadfEADJA39MHeTHmjghlHwXLxmvZsBfRmC7/nzfZ4ZkU+oYd OA/IqzxW9S2LnponchLcmNuc/gDaBG4i8Cw= X-Google-Smtp-Source: ABdhPJzGgcfrOtRRkn0D0fR68l6T+z1eiCuDzxjSYY3YtIjfU62XgKotfm6cRt5W5QS4SAGVLKsSs5dj3i1L29U= Sender: "saravanak via sendgmr" X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:7220:84ff:fe09:fedc]) (user=saravanak job=sendgmr) by 2002:ad4:4346:: with SMTP id q6mr19199492qvs.37.1605924202910; Fri, 20 Nov 2020 18:03:22 -0800 (PST) Date: Fri, 20 Nov 2020 18:02:30 -0800 In-Reply-To: <20201121020232.908850-1-saravanak@google.com> Message-Id: <20201121020232.908850-16-saravanak@google.com> Mime-Version: 1.0 References: <20201121020232.908850-1-saravanak@google.com> X-Mailer: git-send-email 2.29.2.454.gaff20da3a2-goog Subject: [PATCH v2 15/17] efi: Update implementation of add_links() to create fwnode links From: Saravana Kannan To: "Rafael J. Wysocki" , "Rafael J. Wysocki" , Len Brown , Greg Kroah-Hartman , Ard Biesheuvel , Rob Herring , Frank Rowand , Marc Zyngier , Thomas Gleixner Cc: Saravana Kannan , Tomi Valkeinen , Laurent Pinchart , Grygorii Strashko , kernel-team@android.com, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, devicetree@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The semantics of add_links() has changed from creating device link between devices to creating fwnode links between fwnodes. So, update the implementation of add_links() to match the new semantics. Signed-off-by: Saravana Kannan --- drivers/firmware/efi/efi-init.c | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/drivers/firmware/efi/efi-init.c b/drivers/firmware/efi/efi-init.c index 65bb97c391b0..c0c3d4c3837a 100644 --- a/drivers/firmware/efi/efi-init.c +++ b/drivers/firmware/efi/efi-init.c @@ -320,7 +320,6 @@ static int efifb_add_links(struct fwnode_handle *fwnode, struct device *dev) { struct device_node *sup_np; - struct device *sup_dev; sup_np = find_pci_overlap_node(); @@ -331,27 +330,9 @@ static int efifb_add_links(struct fwnode_handle *fwnode, if (!sup_np) return 0; - sup_dev = get_dev_from_fwnode(&sup_np->fwnode); + fwnode_link_add(fwnode, of_fwnode_handle(sup_np)); of_node_put(sup_np); - /* - * Return -ENODEV if the PCI graphics controller device hasn't been - * registered yet. This ensures that efifb isn't allowed to probe - * and this function is retried again when new devices are - * registered. - */ - if (!sup_dev) - return -ENODEV; - - /* - * If this fails, retrying this function at a later point won't - * change anything. So, don't return an error after this. - */ - if (!device_link_add(dev, sup_dev, fw_devlink_get_flags())) - dev_warn(dev, "device_link_add() failed\n"); - - put_device(sup_dev); - return 0; } From patchwork Sat Nov 21 02:02:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 330028 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 557A7C56202 for ; Sat, 21 Nov 2020 02:03:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2146D24171 for ; Sat, 21 Nov 2020 02:03:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="EOisX5uj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727434AbgKUCD2 (ORCPT ); Fri, 20 Nov 2020 21:03:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727430AbgKUCD0 (ORCPT ); Fri, 20 Nov 2020 21:03:26 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78B61C061A04 for ; Fri, 20 Nov 2020 18:03:26 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id v13so14071750ybe.18 for ; Fri, 20 Nov 2020 18:03:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=v+jlLKbQYhdbkwDJlYGQgfAnA4xZcVmYNrUJDTCYlgk=; b=EOisX5ujN5GH5Gtm2PFAXgG0vD1Z9fjd0D+/laDdo/1yv1D6tGFbC4CsRTYN0U9DOo oiJnh6w6waFF5quWtTnVTcZkyGLPLuuGUKt1gajQWh2LE71wb3b3XihMxDLi7Rg4Y0r6 yM1Y9WAOXyI5SPeSi2c+BmSKurFhw0FfxB+2J39ntnzA0AiE5YpnfOPYMrW8Jdj5m+ws HGOnX03ngPwhna8EiTmzMx7+VjwXCT5+WPa4U+tQ17J2K0nEKL+hiqK8mvECoxurwKWW 62KMLvOl/asIbmSPnS3RzvWQTv7Vxb7F4SgnPIzguh8IjE3ZZI6wsqIYfIr9q3mXh2ua LtVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=v+jlLKbQYhdbkwDJlYGQgfAnA4xZcVmYNrUJDTCYlgk=; b=unR2USQjVJ0im7LgTuC2TJ3rOOP2e3qwLi2nhEaM/BGkjq7wR/yrgkuVHp/ffolmJB N0SsRAwWDzxJzNMLK2obx/7Q814oD5aQu4rkreQQ2y1d0iyk1Uol+u4vjSladtdMyuTu /kZjJ4u7B5GaiMkNACtO2/r8mO7e7ZLvDOIZWc8JXe1qlnRH9Tu7WJGxU1vMIq5f7sNf qb7phxUrMKFeZ1GYn3/0VjFbwjaCigmBqLN3SRDAQWSQEu+LvooMtxruZr/9X7OQ+ZpS IoL0XRsxDYqMb+B+WidglgBAitkl6w4w8OTVMisYAGyjwPeDC3X3K4+xFZOlR8J+JyhX 5qDg== X-Gm-Message-State: AOAM531jxbPzscL/ZncSqx9Vy6PefiwkR4a1CnCESKuupC3ziGU3AvLX WhAk8JgEQtBGWp8en+812sZIU+OAATgXpXw= X-Google-Smtp-Source: ABdhPJxeg8T+Mhc7G2Az25MlFHpCwFR3b7L/ARuRKth4MRpnFybrKAnBHVW10eOqp+7QeY+yAF1iyNoKZJd5qOs= Sender: "saravanak via sendgmr" X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:7220:84ff:fe09:fedc]) (user=saravanak job=sendgmr) by 2002:a25:5d4:: with SMTP id 203mr20992921ybf.182.1605924205686; Fri, 20 Nov 2020 18:03:25 -0800 (PST) Date: Fri, 20 Nov 2020 18:02:31 -0800 In-Reply-To: <20201121020232.908850-1-saravanak@google.com> Message-Id: <20201121020232.908850-17-saravanak@google.com> Mime-Version: 1.0 References: <20201121020232.908850-1-saravanak@google.com> X-Mailer: git-send-email 2.29.2.454.gaff20da3a2-goog Subject: [PATCH v2 16/17] driver core: Refactor fw_devlink feature From: Saravana Kannan To: "Rafael J. Wysocki" , "Rafael J. Wysocki" , Len Brown , Greg Kroah-Hartman , Ard Biesheuvel , Rob Herring , Frank Rowand , Marc Zyngier , Thomas Gleixner Cc: Saravana Kannan , Tomi Valkeinen , Laurent Pinchart , Grygorii Strashko , kernel-team@android.com, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, devicetree@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The current implementation of fw_devlink is very inefficient because it tries to get away without creating fwnode links in the name of saving memory usage. Past attempts to optimize runtime at the cost of memory usage were blocked with request for data showing that the optimization made significant improvement for real world scenarios. We have those scenarios now. There have been several reports of boot time increase in the order of seconds in this thread [1]. Several OEMs and SoC manufacturers have also privately reported significant (350-400ms) increase in boot time due to all the parsing done by fw_devlink. So this patch uses all the setup done by the previous patches in this series to refactor fw_devlink to be more efficient. Most of the code has been moved out of firmware specific (DT mostly) code into driver core. This brings the following benefits: - Instead of parsing the device tree multiple times during bootup, fw_devlink parses each fwnode node/property only once and creates fwnode links. The rest of the fw_devlink code then just looks at these fwnode links to do rest of the work. - Makes it much easier to debug probe issue due to fw_devlink in the future. fw_devlink=on blocks the probing of devices if they depend on a device that hasn't been added yet. With this refactor, it'll be very easy to tell what that device is because we now have a reference to the fwnode of the device. - Much easier to add fw_devlink support to ACPI and other firmware types. A refactor to move the common bits from DT specific code to driver core was in my TODO list as a prerequisite to adding ACPI support to fw_devlink. This series gets that done. [1] - https://lore.kernel.org/linux-omap/ea02f57e-871d-cd16-4418-c1da4bbc4696@ti.com/ Signed-off-by: Saravana Kannan Tested-by: Laurent Pinchart Tested-by: Grygorii Strashko --- drivers/base/core.c | 325 ++++++++++++++++++++++++++++++----------- include/linux/device.h | 5 - 2 files changed, 238 insertions(+), 92 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 1873cecb0cc4..9edf9084fc98 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -46,8 +46,6 @@ early_param("sysfs.deprecated", sysfs_deprecated_setup); #endif /* Device links support. */ -static LIST_HEAD(wait_for_suppliers); -static DEFINE_MUTEX(wfs_lock); static LIST_HEAD(deferred_sync); static unsigned int defer_sync_state_count = 1; static DEFINE_MUTEX(fwnode_link_lock); @@ -803,74 +801,6 @@ struct device_link *device_link_add(struct device *consumer, } EXPORT_SYMBOL_GPL(device_link_add); -/** - * device_link_wait_for_supplier - Add device to wait_for_suppliers list - * @consumer: Consumer device - * - * Marks the @consumer device as waiting for suppliers to become available by - * adding it to the wait_for_suppliers list. The consumer device will never be - * probed until it's removed from the wait_for_suppliers list. - * - * The caller is responsible for adding the links to the supplier devices once - * they are available and removing the @consumer device from the - * wait_for_suppliers list once links to all the suppliers have been created. - * - * This function is NOT meant to be called from the probe function of the - * consumer but rather from code that creates/adds the consumer device. - */ -static void device_link_wait_for_supplier(struct device *consumer, - bool need_for_probe) -{ - mutex_lock(&wfs_lock); - list_add_tail(&consumer->links.needs_suppliers, &wait_for_suppliers); - consumer->links.need_for_probe = need_for_probe; - mutex_unlock(&wfs_lock); -} - -static void device_link_wait_for_mandatory_supplier(struct device *consumer) -{ - device_link_wait_for_supplier(consumer, true); -} - -static void device_link_wait_for_optional_supplier(struct device *consumer) -{ - device_link_wait_for_supplier(consumer, false); -} - -/** - * device_link_add_missing_supplier_links - Add links from consumer devices to - * supplier devices, leaving any - * consumer with inactive suppliers on - * the wait_for_suppliers list - * - * Loops through all consumers waiting on suppliers and tries to add all their - * supplier links. If that succeeds, the consumer device is removed from - * wait_for_suppliers list. Otherwise, they are left in the wait_for_suppliers - * list. Devices left on the wait_for_suppliers list will not be probed. - * - * The fwnode add_links callback is expected to return 0 if it has found and - * added all the supplier links for the consumer device. It should return an - * error if it isn't able to do so. - * - * The caller of device_link_wait_for_supplier() is expected to call this once - * it's aware of potential suppliers becoming available. - */ -static void device_link_add_missing_supplier_links(void) -{ - struct device *dev, *tmp; - - mutex_lock(&wfs_lock); - list_for_each_entry_safe(dev, tmp, &wait_for_suppliers, - links.needs_suppliers) { - int ret = fwnode_call_int_op(dev->fwnode, add_links, dev); - if (!ret) - list_del_init(&dev->links.needs_suppliers); - else if (ret != -ENODEV) - dev->links.need_for_probe = false; - } - mutex_unlock(&wfs_lock); -} - #ifdef CONFIG_SRCU static void __device_link_del(struct kref *kref) { @@ -1195,9 +1125,8 @@ void device_links_driver_bound(struct device *dev) * the device links it needs to or make new device links as it needs * them. So, it no longer needs to wait on any suppliers. */ - mutex_lock(&wfs_lock); - list_del_init(&dev->links.needs_suppliers); - mutex_unlock(&wfs_lock); + if (dev->fwnode && dev->fwnode->dev == dev) + fwnode_links_purge_suppliers(dev->fwnode); device_remove_file(dev, &dev_attr_waiting_for_supplier); device_links_write_lock(); @@ -1488,10 +1417,6 @@ static void device_links_purge(struct device *dev) if (dev->class == &devlink_class) return; - mutex_lock(&wfs_lock); - list_del(&dev->links.needs_suppliers); - mutex_unlock(&wfs_lock); - /* * Delete all of the remaining links from this device to any other * devices (either consumers or suppliers). @@ -1561,19 +1486,246 @@ static void fw_devlink_parse_fwtree(struct fwnode_handle *fwnode) fw_devlink_parse_fwtree(child); } -static void fw_devlink_link_device(struct device *dev) +/** + * fw_devlink_create_devlink - Create a device link from a consumer to fwnode + * @con - Consumer device for the device link + * @sup_handle - fwnode handle of supplier + * + * This function will try to create a device link between the consumer device + * @con and the supplier device represented by @sup_handle. + * + * The supplier has to be provided as a fwnode because incorrect cycles in + * fwnode links can sometimes cause the supplier device to never be created. + * This function detects such cases and returns an error if it cannot create a + * device link from the consumer to a missing supplier. + * + * Returns, + * 0 on successfully creating a device link + * -EINVAL if the device link cannot be created as expected + * -EAGAIN if the device link cannot be created right now, but it may be + * possible to do that in the future + */ +static int fw_devlink_create_devlink(struct device *con, + struct fwnode_handle *sup_handle, u32 flags) +{ + struct device *sup_dev; + int ret = 0; + + sup_dev = get_dev_from_fwnode(sup_handle); + if (sup_dev) { + /* + * If this fails, it is due to cycles in device links. Just + * give up on this link and treat it as invalid. + */ + if (!device_link_add(con, sup_dev, flags)) + ret = -EINVAL; + + goto out; + } + + /* + * DL_FLAG_SYNC_STATE_ONLY doesn't block probing and supports + * cycles. So cycle detection isn't necessary and shouldn't be + * done. + */ + if (flags & DL_FLAG_SYNC_STATE_ONLY) + return -EAGAIN; + + /* + * If we can't find the supplier device from its fwnode, it might be + * due to a cyclic dependency between fwnodes. Some of these cycles can + * be broken by applying logic. Check for these types of cycles and + * break them so that devices in the cycle probe properly. + * + * If the supplier's parent is dependent on the consumer, then + * the consumer-supplier dependency is a false dependency. So, + * treat it as an invalid link. + */ + sup_dev = fwnode_get_next_parent_dev(sup_handle); + if (sup_dev && device_is_dependent(con, sup_dev)) { + dev_dbg(con, "Not linking to %pfwP - False link\n", + sup_handle); + ret = -EINVAL; + } else { + /* + * Can't check for cycles or no cycles. So let's try + * again later. + */ + ret = -EAGAIN; + } + +out: + put_device(sup_dev); + return ret; +} + +/** + * __fw_devlink_link_to_consumers - Create device links to consumers of a device + * @dev - Device that needs to be linked to its consumers + * + * This function looks at all the consumer fwnodes of @dev and creates device + * links between the consumer device and @dev (supplier). + * + * If the consumer device has not been added yet, then this function creates a + * SYNC_STATE_ONLY link between @dev (supplier) and the closest ancestor device + * of the consumer fwnode. This is necessary to make sure @dev doesn't get a + * sync_state() callback before the real consumer device gets to be added and + * then probed. + * + * Once device links are created from the real consumer to @dev (supplier), the + * fwnode links are deleted. + */ +static void __fw_devlink_link_to_consumers(struct device *dev) +{ + struct fwnode_handle *fwnode = dev->fwnode; + struct fwnode_link *link, *tmp; + + list_for_each_entry_safe(link, tmp, &fwnode->consumers, s_hook) { + u32 dl_flags = fw_devlink_get_flags(); + struct device *con_dev; + bool own_link = true; + int ret; + + con_dev = get_dev_from_fwnode(link->consumer); + /* + * If consumer device is not available yet, make a "proxy" + * SYNC_STATE_ONLY link from the consumer's parent device to + * the supplier device. This is necessary to make sure the + * supplier doesn't get a sync_state() callback before the real + * consumer can create a device link to the supplier. + * + * This proxy link step is needed to handle the case where the + * consumer's parent device is added before the supplier. + */ + if (!con_dev) { + con_dev = fwnode_get_next_parent_dev(link->consumer); + /* + * However, if the consumer's parent device is also the + * parent of the supplier, don't create a + * consumer-supplier link from the parent to its child + * device. Such a dependency is impossible. + */ + if (con_dev && + fwnode_is_ancestor_of(con_dev->fwnode, fwnode)) { + put_device(con_dev); + con_dev = NULL; + } else { + own_link = false; + dl_flags = DL_FLAG_SYNC_STATE_ONLY; + } + } + + if (!con_dev) + continue; + + ret = fw_devlink_create_devlink(con_dev, fwnode, dl_flags); + put_device(con_dev); + if (!own_link || ret == -EAGAIN) + continue; + + list_del(&link->s_hook); + list_del(&link->c_hook); + kfree(link); + } +} + +/** + * __fw_devlink_link_to_suppliers - Create device links to suppliers of a device + * @dev - The consumer device that needs to be linked to its suppliers + * @fwnode - Root of the fwnode tree that is used to create device links + * + * This function looks at all the supplier fwnodes of fwnode tree rooted at + * @fwnode and creates device links between @dev (consumer) and all the + * supplier devices of the entire fwnode tree at @fwnode. + * + * The function creates normal (non-SYNC_STATE_ONLY) device links between @dev + * and the real suppliers of @dev. Once these device links are created, the + * fwnode links are deleted. When such device links are successfully created, + * this function is called recursively on those supplier devices. This is + * needed to detect and break some invalid cycles in fwnode links. See + * fw_devlink_create_devlink() for more details. + * + * In addition, it also looks at all the suppliers of the entire fwnode tree + * because some of the child devices of @dev that have not been added yet + * (because @dev hasn't probed) might already have their suppliers added to + * driver core. So, this function creates SYNC_STATE_ONLY device links between + * @dev (consumer) and these suppliers to make sure they don't execute their + * sync_state() callbacks before these child devices have a chance to create + * their device links. The fwnode links that correspond to the child devices + * aren't delete because they are needed later to create the device links + * between the real consumer and supplier devices. + */ +static void __fw_devlink_link_to_suppliers(struct device *dev, + struct fwnode_handle *fwnode) { - int fw_ret; + bool own_link = (dev->fwnode == fwnode); + struct fwnode_link *link, *tmp; + struct fwnode_handle *child = NULL; + u32 dl_flags; + + if (own_link) + dl_flags = fw_devlink_get_flags(); + else + dl_flags = DL_FLAG_SYNC_STATE_ONLY; - device_link_add_missing_supplier_links(); + list_for_each_entry_safe(link, tmp, &fwnode->suppliers, c_hook) { + int ret; + struct device *sup_dev; + struct fwnode_handle *sup = link->supplier; + + ret = fw_devlink_create_devlink(dev, sup, dl_flags); + if (!own_link || ret == -EAGAIN) + continue; - if (fw_devlink_flags && fwnode_has_op(dev->fwnode, add_links)) { - fw_ret = fwnode_call_int_op(dev->fwnode, add_links, dev); - if (fw_ret == -ENODEV && !fw_devlink_is_permissive()) - device_link_wait_for_mandatory_supplier(dev); - else if (fw_ret) - device_link_wait_for_optional_supplier(dev); + list_del(&link->s_hook); + list_del(&link->c_hook); + kfree(link); + + /* If no device link was created, nothing more to do. */ + if (ret) + continue; + + /* + * If a device link was successfully created to a supplier, we + * now need to try and link the supplier to all its suppliers. + * + * This is needed to detect and delete false dependencies in + * fwnode links that haven't been converted to a device link + * yet. See comments in fw_devlink_create_devlink() for more + * details on the false dependency. + * + * Without deleting these false dependencies, some devices will + * never probe because they'll keep waiting for their false + * dependency fwnode links to be converted to device links. + */ + sup_dev = get_dev_from_fwnode(sup); + __fw_devlink_link_to_suppliers(sup_dev, sup_dev->fwnode); + put_device(sup_dev); } + + /* + * Make "proxy" SYNC_STATE_ONLY device links to represent the needs of + * all the descendants. This proxy link step is needed to handle the + * case where the supplier is added before the consumer's parent device + * (@dev). + */ + while ((child = fwnode_get_next_available_child_node(fwnode, child))) + __fw_devlink_link_to_suppliers(dev, child); +} + +static void fw_devlink_link_device(struct device *dev) +{ + struct fwnode_handle *fwnode = dev->fwnode; + + if (!fw_devlink_flags) + return; + + fw_devlink_parse_fwtree(fwnode); + + mutex_lock(&fwnode_link_lock); + __fw_devlink_link_to_consumers(dev); + __fw_devlink_link_to_suppliers(dev, fwnode); + mutex_unlock(&fwnode_link_lock); } /* Device links support end. */ @@ -2431,7 +2583,6 @@ void device_initialize(struct device *dev) #endif INIT_LIST_HEAD(&dev->links.consumers); INIT_LIST_HEAD(&dev->links.suppliers); - INIT_LIST_HEAD(&dev->links.needs_suppliers); INIT_LIST_HEAD(&dev->links.defer_sync); dev->links.status = DL_DEV_NO_DRIVER; } diff --git a/include/linux/device.h b/include/linux/device.h index 1e771ea4dca6..89bb8b84173e 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -351,18 +351,13 @@ enum dl_dev_state { * struct dev_links_info - Device data related to device links. * @suppliers: List of links to supplier devices. * @consumers: List of links to consumer devices. - * @needs_suppliers: Hook to global list of devices waiting for suppliers. * @defer_sync: Hook to global list of devices that have deferred sync_state. - * @need_for_probe: If needs_suppliers is on a list, this indicates if the - * suppliers are needed for probe or not. * @status: Driver status information. */ struct dev_links_info { struct list_head suppliers; struct list_head consumers; - struct list_head needs_suppliers; struct list_head defer_sync; - bool need_for_probe; enum dl_dev_state status; }; From patchwork Sat Nov 21 02:02:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 330029 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89273C8300F for ; Sat, 21 Nov 2020 02:03:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 648CB2408E for ; Sat, 21 Nov 2020 02:03:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ELFquWWm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727459AbgKUCDb (ORCPT ); Fri, 20 Nov 2020 21:03:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727435AbgKUCDa (ORCPT ); Fri, 20 Nov 2020 21:03:30 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65790C0613CF for ; Fri, 20 Nov 2020 18:03:29 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id k196so14049974ybf.9 for ; Fri, 20 Nov 2020 18:03:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=/4b98HN7Dg/gsZp1FJDKtTqc5+TRGSRPQQAwQrD06k0=; b=ELFquWWmVQsPKcB73FJvKB8rjQRr79nN6pXIgdOw3TJNpJs/SGo0AHl0FEmMW05BRV Xes5u0tIB4/MDSdfr9mD+s0AnIIyA2+S7MuxmGWUvou6iB0bVgpu3JaR6HLp1AmrlTAS 8Qks1RPu4kiemPkvShsX9exOQZLRvgPL66Ji50TUOVAf2U85Kedz9LW4KGm0ZYqtAKMj DT/hLkTBeTQZ3cne0CCV8Qm4pl7RNzWq59terw7rikrP3Lc37CA345pmIWsjczkJdSBZ 6Oudkw/Dufr8rxRjyRzpznxlFRQ11LjraK0Ty2n7Vvxhjy5DzqyIZ+keKTzIjQ7gWkHu I5Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=/4b98HN7Dg/gsZp1FJDKtTqc5+TRGSRPQQAwQrD06k0=; b=WjhVsgEMM7nDTA6Rd9HTNMTb/OaEr1uGhTTJnIt4PNcrhVMOhjTObI8zUb8xSUkpos NGbElESXfxYZ3HlsNy7EGI7t7QDCbR32MNeLOqi8T2vb6JxbQKQw7sRSiZWc3JmrRnPm DEzXWF80vZH9u+kSTSN+0y6OBUfs3jf1zrOBL8KkBY8HJOpQmsWaT/BnH0k3UzqTC2oL TJdWdhNjkrJcZ2oQhXx6m8PSu8bTyIEkVQKXhU6ibqAA+HrFTfRGA1RO45qBxSB6ZAch kBOEbzgaDAqrwRlTKMYRvriCklFC02enayjKRD3PQfcwGWxt0YGmpNcLUhgtaHcvXot2 3uvQ== X-Gm-Message-State: AOAM531F07tFtvO9PKtza8ep3If4FWkVgllwFlRkrkSysCICONgVY2tP sJkz7JSnXZ7y1JVnhpps7zZ3NPm3HZdq9nY= X-Google-Smtp-Source: ABdhPJxe1QO0yyWkfLZI2Ck3kq+oJXU7180eiST2dap9Bfk+tY8Z9kisuDNZoag/ofp3xkKJ+0iQVTquDNjuK7s= Sender: "saravanak via sendgmr" X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:7220:84ff:fe09:fedc]) (user=saravanak job=sendgmr) by 2002:a25:d18c:: with SMTP id i134mr25682880ybg.448.1605924208599; Fri, 20 Nov 2020 18:03:28 -0800 (PST) Date: Fri, 20 Nov 2020 18:02:32 -0800 In-Reply-To: <20201121020232.908850-1-saravanak@google.com> Message-Id: <20201121020232.908850-18-saravanak@google.com> Mime-Version: 1.0 References: <20201121020232.908850-1-saravanak@google.com> X-Mailer: git-send-email 2.29.2.454.gaff20da3a2-goog Subject: [PATCH v2 17/17] driver core: Delete pointless parameter in fwnode_operations.add_links From: Saravana Kannan To: "Rafael J. Wysocki" , "Rafael J. Wysocki" , Len Brown , Greg Kroah-Hartman , Ard Biesheuvel , Rob Herring , Frank Rowand , Marc Zyngier , Thomas Gleixner Cc: Saravana Kannan , Tomi Valkeinen , Laurent Pinchart , Grygorii Strashko , kernel-team@android.com, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, devicetree@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The struct device input to add_links() is not used for anything. So delete it. Signed-off-by: Saravana Kannan Acked-by: Rob Herring --- drivers/base/core.c | 2 +- drivers/firmware/efi/efi-init.c | 3 +-- drivers/of/property.c | 3 +-- include/linux/fwnode.h | 3 +-- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 9edf9084fc98..63edb8bd9d7d 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1472,7 +1472,7 @@ static void fw_devlink_parse_fwnode(struct fwnode_handle *fwnode) if (fwnode->flags & FWNODE_FLAG_LINKS_ADDED) return; - fwnode_call_int_op(fwnode, add_links, NULL); + fwnode_call_int_op(fwnode, add_links); fwnode->flags |= FWNODE_FLAG_LINKS_ADDED; } diff --git a/drivers/firmware/efi/efi-init.c b/drivers/firmware/efi/efi-init.c index c0c3d4c3837a..a552a08a1741 100644 --- a/drivers/firmware/efi/efi-init.c +++ b/drivers/firmware/efi/efi-init.c @@ -316,8 +316,7 @@ static struct device_node *find_pci_overlap_node(void) * resource reservation conflict on the memory window that the efifb * framebuffer steals from the PCIe host bridge. */ -static int efifb_add_links(struct fwnode_handle *fwnode, - struct device *dev) +static int efifb_add_links(struct fwnode_handle *fwnode) { struct device_node *sup_np; diff --git a/drivers/of/property.c b/drivers/of/property.c index 620d29fdace8..5f9eed79a8aa 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1343,8 +1343,7 @@ static int of_link_property(struct device_node *con_np, const char *prop_name) return ret; } -static int of_fwnode_add_links(struct fwnode_handle *fwnode, - struct device *dev) +static int of_fwnode_add_links(struct fwnode_handle *fwnode) { struct property *p; struct device_node *con_np = to_of_node(fwnode); diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h index ffa9129182a6..fde4ad97564c 100644 --- a/include/linux/fwnode.h +++ b/include/linux/fwnode.h @@ -127,8 +127,7 @@ struct fwnode_operations { (*graph_get_port_parent)(struct fwnode_handle *fwnode); int (*graph_parse_endpoint)(const struct fwnode_handle *fwnode, struct fwnode_endpoint *endpoint); - int (*add_links)(struct fwnode_handle *fwnode, - struct device *dev); + int (*add_links)(struct fwnode_handle *fwnode); }; #define fwnode_has_op(fwnode, op) \