From patchwork Sat Nov 21 02:02:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 330137 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 0D330C6379F 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 CB8872408E 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="oVICUpmk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727104AbgKUCCv (ORCPT ); Fri, 20 Nov 2020 21:02:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727100AbgKUCCv (ORCPT ); Fri, 20 Nov 2020 21:02:51 -0500 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16620C061A04 for ; Fri, 20 Nov 2020 18:02:50 -0800 (PST) Received: by mail-pf1-x449.google.com with SMTP id c24so114442pfd.13 for ; Fri, 20 Nov 2020 18:02:50 -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=C0bHKb1/iWiLgdtF9sSmjqtEvvSI0v807amqNyJzdNU=; b=oVICUpmkGZYeD7GCm7OHZePNr0D7oNE9MGHDeA14TlrhsrfYTroblrGIZDXkuUvKJy 1xmlgXXXtOvWXNsWsBLt4bjiHDWfOXdlI7nWqGRa/D++ATibv0GyA81LGS2AyZV2uvhZ x1VfPlF7j5GZQUE6NdUdZj40qx2f51YwrtoiBrZdlrx7qx0MrmlCwAe5UWli6SN7FtbP bLbzo5MqzQ4xydQHAZfNdgDtBArIgPU44e6eGAm5wOsWzo6Xx/5rTfinOOyVkJkMiID9 bH+2ZhrIwEgzDXXX/v946bSvkc4YQrqI7kbnnhnitJIohJMixgsYDLl0FdY66/cdy6V9 cocg== 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=C0bHKb1/iWiLgdtF9sSmjqtEvvSI0v807amqNyJzdNU=; b=Nsubxjt6h5+qVOxDAoKMiTkbU26Fx6J/McUSCZjjGnT7ZIo3OM5hTWW3uASaGrwunt SsZ1wGn6TFhI6VihASCufmcP3+gJtgmg7YecuCcHwsh8Sxw9IZVN/uClv3zQjy9/yhkG wrgBBYsE1E4CqJdD/LwDgmkFEhpIj1QkGxLtwJdKX5mCqiiWxUa0AUUk1btlnWKUXFDr +I9e1/7WJRF+1bEsO7haPremxD5Jz2eVUNDxj8rogmJkxtDgcDYfPOSyiN9NqOfUpg4K YyU7ARt3fcgIBZpbWSshUotcQOpaSe5BLhmxgsrghH29/dK1nRiGUdZPqzuJii6ayPis BQpg== X-Gm-Message-State: AOAM531Q9MXBFcrDE+lG8a0Kd6moabFPBj6yg3TtjB19uzkj1yXrxPVV JUU0c5cLfbGYDRRPAinsT2bJiFH+l+VspNs= X-Google-Smtp-Source: ABdhPJwkoh7gsKp85NKgP+D91F1jQ8SL7LKV9shZgwbKa77TXviiL3HDVdSCd11fSTpospmRJjxFmFG2oPfHfGM= 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:aa7:8552:0:b029:18e:f030:e514 with SMTP id y18-20020aa785520000b029018ef030e514mr15787534pfn.2.1605924169466; Fri, 20 Nov 2020 18:02:49 -0800 (PST) Date: Fri, 20 Nov 2020 18:02:17 -0800 In-Reply-To: <20201121020232.908850-1-saravanak@google.com> Message-Id: <20201121020232.908850-3-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 02/17] Revert "driver core: Rename dev_links_info.defer_sync to defer_hook" 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-efi@vger.kernel.org This reverts commit ec7bd78498f29680f536451fbdf9464e851273ed. This field rename was done to reuse defer_syc list head for multiple lists. That's not needed anymore and this list head will only be used for defer sync. So revert this patch to avoid conflicts with the other reverts coming after this. Signed-off-by: Saravana Kannan --- drivers/base/core.c | 22 +++++++++++----------- include/linux/device.h | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index b202fe54f46a..c91ff2546247 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -959,11 +959,11 @@ static void __device_links_queue_sync_state(struct device *dev, */ dev->state_synced = true; - if (WARN_ON(!list_empty(&dev->links.defer_hook))) + if (WARN_ON(!list_empty(&dev->links.defer_sync))) return; get_device(dev); - list_add_tail(&dev->links.defer_hook, list); + list_add_tail(&dev->links.defer_sync, list); } /** @@ -981,8 +981,8 @@ static void device_links_flush_sync_list(struct list_head *list, { struct device *dev, *tmp; - list_for_each_entry_safe(dev, tmp, list, links.defer_hook) { - list_del_init(&dev->links.defer_hook); + list_for_each_entry_safe(dev, tmp, list, links.defer_sync) { + list_del_init(&dev->links.defer_sync); if (dev != dont_lock_dev) device_lock(dev); @@ -1020,12 +1020,12 @@ void device_links_supplier_sync_state_resume(void) if (defer_sync_state_count) goto out; - list_for_each_entry_safe(dev, tmp, &deferred_sync, links.defer_hook) { + list_for_each_entry_safe(dev, tmp, &deferred_sync, links.defer_sync) { /* * Delete from deferred_sync list before queuing it to - * sync_list because defer_hook is used for both lists. + * sync_list because defer_sync is used for both lists. */ - list_del_init(&dev->links.defer_hook); + list_del_init(&dev->links.defer_sync); __device_links_queue_sync_state(dev, &sync_list); } out: @@ -1043,8 +1043,8 @@ late_initcall(sync_state_resume_initcall); static void __device_links_supplier_defer_sync(struct device *sup) { - if (list_empty(&sup->links.defer_hook) && dev_has_sync_state(sup)) - list_add_tail(&sup->links.defer_hook, &deferred_sync); + if (list_empty(&sup->links.defer_sync) && dev_has_sync_state(sup)) + list_add_tail(&sup->links.defer_sync, &deferred_sync); } static void device_link_drop_managed(struct device_link *link) @@ -1274,7 +1274,7 @@ void device_links_driver_cleanup(struct device *dev) WRITE_ONCE(link->status, DL_STATE_DORMANT); } - list_del_init(&dev->links.defer_hook); + list_del_init(&dev->links.defer_sync); __device_links_no_driver(dev); device_links_write_unlock(); @@ -2407,7 +2407,7 @@ void device_initialize(struct device *dev) 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_hook); + INIT_LIST_HEAD(&dev->links.defer_sync); dev->links.status = DL_DEV_NO_DRIVER; } EXPORT_SYMBOL_GPL(device_initialize); diff --git a/include/linux/device.h b/include/linux/device.h index da00f8e449bb..1e771ea4dca6 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -352,7 +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. + * @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. @@ -361,7 +361,7 @@ struct dev_links_info { struct list_head suppliers; struct list_head consumers; struct list_head needs_suppliers; - struct list_head defer_hook; + struct list_head defer_sync; bool need_for_probe; enum dl_dev_state status; }; From patchwork Sat Nov 21 02:02:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 330130 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 718EDC8301F for ; Sat, 21 Nov 2020 02:04:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 387F924124 for ; Sat, 21 Nov 2020 02:04:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="fsbK5xxw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726431AbgKUCD6 (ORCPT ); Fri, 20 Nov 2020 21:03:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727133AbgKUCC5 (ORCPT ); Fri, 20 Nov 2020 21:02:57 -0500 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7381C061A48 for ; Fri, 20 Nov 2020 18:02:57 -0800 (PST) Received: by mail-pl1-x64a.google.com with SMTP id ba3so7176461plb.9 for ; Fri, 20 Nov 2020 18:02:57 -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=u8gSY0xV7Hxd2w8NGW6IzppBe4J1ijRyucJg3LQF0Gk=; b=fsbK5xxw4z7i23FSKugbrasJEIXN13Q4zN4isokluNuL4HjEO/jGHpCycjM7g9sfqR +kbOqa7qcSGga0Lm/F27nYxTNhPX4fRgh4Mf9+oYz6aUhraA4s7J5QNNMCxQsLKJfiu6 hO9xCcF+bjceWP/4mkj62eK+d2GhPUnH8ipvjoF5lXH5cwi6X4Wyh+5rcJdkI2Y7Mg6U iT6tK3+H9NRURvDqYLmMIA70OMrl2Yj+fQCQc8tKeIPW+uVGa3W2KjLifbeHcVbYlj5y Q04w/t2ewdvVIWyUrX6OqLnatW7MndjTFeg7RNiUGjOroBN0Dv6izRyJdeVw3DlHXFza a27g== 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=u8gSY0xV7Hxd2w8NGW6IzppBe4J1ijRyucJg3LQF0Gk=; b=OIW/VaTzofoyoQjOZSsdqiaR0sh771ZqUfyEwC+DLTuLHXxc4eg7xWdLxe4Y7VhUgO pkSX1jR0X6hCcyOZsC0q+wWFcU6a2wTxsN8ir77iAm5K2RS0dEI1tp8Htt7vwBJLNkm/ KqN2dGZacDZdrOksbaga4GYFHPmG/9x+wPbQIInErK2CaLICx30pjFbLvrEf/glxIDh0 9GIhfD3muTTFNyPSpncVOvUKLNNpPmrZZNZVV1kU+imDmyaEvqIVGF7Xg4UZWeIQNb4u zfGSHrm7T5xaWzcU2pk5y/62QpeBi42RdobZGaQv4Jr07vDs6ezs3yGPGn4AKOQj7uq8 sj4Q== X-Gm-Message-State: AOAM530pi96XIDn2RglxU4+Dee3DWH3lU8/4yesfyngx9T0/1qiOd2NI SyX9E85MoN8Qye2PcrPLxbiguoF4Sj7AnDI= X-Google-Smtp-Source: ABdhPJzP83DwhORfMb+bJuQz5UmJs3XebCnI6uLqfDOyEgb2ymxIPPeS7NMxGqPYiMO5s4yUrfepUAr2i5NMiTs= 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:a17:90a:f28e:: with SMTP id fs14mr6235679pjb.91.1605924177080; Fri, 20 Nov 2020 18:02:57 -0800 (PST) Date: Fri, 20 Nov 2020 18:02:20 -0800 In-Reply-To: <20201121020232.908850-1-saravanak@google.com> Message-Id: <20201121020232.908850-6-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 05/17] Revert "of: platform: Batch fwnode parsing when adding all top level devices" 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-efi@vger.kernel.org This reverts commit 93d2e4322aa74c1ad1e8c2160608eb9a960d69ff. The fw_devlink_pause/resume() optimization attempt is getting replaced with a much more robust optimization by the end of this series. So, stop using those APIs. Signed-off-by: Saravana Kannan Acked-by: Rob Herring --- drivers/of/platform.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index b557a0fcd4ba..79bd5f5a1bf1 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -538,9 +538,7 @@ static int __init of_platform_default_populate_init(void) } /* Populate everything else. */ - fw_devlink_pause(); of_platform_default_populate(NULL, NULL, NULL); - fw_devlink_resume(); return 0; } From patchwork Sat Nov 21 02:02:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 330136 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 F0FECC71156 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 B16AE246A5 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="gSBeYkC3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727221AbgKUCDE (ORCPT ); Fri, 20 Nov 2020 21:03:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727214AbgKUCDE (ORCPT ); Fri, 20 Nov 2020 21:03:04 -0500 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB98DC061A04 for ; Fri, 20 Nov 2020 18:03:03 -0800 (PST) Received: by mail-qv1-xf4a.google.com with SMTP id b9so1241375qvj.6 for ; Fri, 20 Nov 2020 18:03:03 -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=BEFBYjf850Ydzo63+5rwraIHDR8Cqu0fdfzu8DbL0fA=; b=gSBeYkC3hQ7wzIslfgvOpCfXurXfCRj9ddCikE8lToem57W+ZgEmKV4/7kwvRk4nkU B+Yq0fCMAX+BTSVg+KpXb7dCkTyHmv0Vs8YcqMGzKEnJxEoD6zAITT29pEfe50aT5Vw5 lqaeRb+2fFZDseJzctWDDDyxolv/P8Xoyt31sKR6LtFF7bu+GwPw9Wr1UAuqljOC5xmX Pq3XphLdk4mVFlHUIhUGDCGBx0u3KJ7wFlsV6X/tkJO3bTCgKm7ylfq7fLqqRNeXjayQ noIKMKbcbZ+xGLAnX7Dy7ijL7bpPlFFfcTjukDUZE84H2VUZflsZWWwYjXH4dawoQS7f Pcsw== 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=BEFBYjf850Ydzo63+5rwraIHDR8Cqu0fdfzu8DbL0fA=; b=peJT6pUwB9pgDJj9SqtOeCkniEsOPx0nrC0a39S8JiuMwpgFnubt40DwA5cyXvqOqX dG3cuCHDTGqXaNYmkrGqSuukzxYZiN/uUMpNVqI1kNLOHMfjiHohlQqajxgMydZK3ly2 sGk5Kh0e3p6MzWoTjuwoDMHbKbseNXqjEmpc9uXiozAb+CV1hLE6Xk4z3to4IJcWNCSU TWdMOo8Jtt1qWfvjbcB2mNNgln/A0jS1jkt+9ZwZ0vqFP+fv+FiEoOFiWMGEDXjxylLu wGiCQwlvQ6XrY91dBS5/F6YABVthH9yosOmQjEAuVPAkVsFBQXXYLMj5g1KvbAOr2dHI LTFA== X-Gm-Message-State: AOAM531OBZz2R+HJTizr7vdlQ/9x+vrhd9Fdc9SrJ6H6BP0oT63UmUfP E1B66V8jvpvNpGXh66FcnbPL5lfrkkPQpWQ= X-Google-Smtp-Source: ABdhPJztIuCkrLcn+gUs8LJYiOxV3Oj6qHuVK25FKWOhywIwi1DvpSREzSMr8PjNIvYy5JgUGDysjhQxV+JLf+M= 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:a0c:9121:: with SMTP id q30mr2362792qvq.17.1605924182604; Fri, 20 Nov 2020 18:03:02 -0800 (PST) Date: Fri, 20 Nov 2020 18:02:22 -0800 In-Reply-To: <20201121020232.908850-1-saravanak@google.com> Message-Id: <20201121020232.908850-8-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 07/17] driver core: Add fwnode_init() 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-efi@vger.kernel.org There are multiple locations in the kernel where a struct fwnode_handle is initialized. Add fwnode_init() so that we have one way of initializing a fwnode_handle. Signed-off-by: Saravana Kannan Acked-by: Rob Herring --- drivers/acpi/property.c | 2 +- drivers/acpi/scan.c | 2 +- drivers/base/swnode.c | 2 +- drivers/firmware/efi/efi-init.c | 8 ++++---- include/linux/fwnode.h | 6 ++++++ include/linux/of.h | 2 +- kernel/irq/irqdomain.c | 2 +- 7 files changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index d04de10a63e4..24e87b630573 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -76,7 +76,7 @@ static bool acpi_nondev_subnode_extract(const union acpi_object *desc, return false; dn->name = link->package.elements[0].string.pointer; - dn->fwnode.ops = &acpi_data_fwnode_ops; + fwnode_init(&dn->fwnode, &acpi_data_fwnode_ops); dn->parent = parent; INIT_LIST_HEAD(&dn->data.properties); INIT_LIST_HEAD(&dn->data.subnodes); diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index bc6a79e33220..519963bcc047 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1589,7 +1589,7 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, device->device_type = type; device->handle = handle; device->parent = acpi_bus_get_parent(handle); - device->fwnode.ops = &acpi_device_fwnode_ops; + fwnode_init(&device->fwnode, &acpi_device_fwnode_ops); acpi_set_device_status(device, sta); acpi_device_get_busid(device); acpi_set_pnp_ids(handle, &device->pnp, type); diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c index 010828fc785b..4a4b2008fbc2 100644 --- a/drivers/base/swnode.c +++ b/drivers/base/swnode.c @@ -653,7 +653,7 @@ swnode_register(const struct software_node *node, struct swnode *parent, swnode->parent = parent; swnode->allocated = allocated; swnode->kobj.kset = swnode_kset; - swnode->fwnode.ops = &software_node_ops; + fwnode_init(&swnode->fwnode, &software_node_ops); ida_init(&swnode->child_ids); INIT_LIST_HEAD(&swnode->entry); diff --git a/drivers/firmware/efi/efi-init.c b/drivers/firmware/efi/efi-init.c index f55a92ff12c0..b148f1459fb3 100644 --- a/drivers/firmware/efi/efi-init.c +++ b/drivers/firmware/efi/efi-init.c @@ -359,9 +359,7 @@ static const struct fwnode_operations efifb_fwnode_ops = { .add_links = efifb_add_links, }; -static struct fwnode_handle efifb_fwnode = { - .ops = &efifb_fwnode_ops, -}; +static struct fwnode_handle efifb_fwnode; static int __init register_gop_device(void) { @@ -375,8 +373,10 @@ static int __init register_gop_device(void) if (!pd) return -ENOMEM; - if (IS_ENABLED(CONFIG_PCI)) + if (IS_ENABLED(CONFIG_PCI)) { + fwnode_init(&efifb_fwnode, &efifb_fwnode_ops); pd->dev.fwnode = &efifb_fwnode; + } err = platform_device_add_data(pd, &screen_info, sizeof(screen_info)); if (err) diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h index e0abafbb17f8..5589799708b5 100644 --- a/include/linux/fwnode.h +++ b/include/linux/fwnode.h @@ -170,6 +170,12 @@ struct fwnode_operations { } while (false) #define get_dev_from_fwnode(fwnode) get_device((fwnode)->dev) +static inline void fwnode_init(struct fwnode_handle *fwnode, + const struct fwnode_operations *ops) +{ + fwnode->ops = ops; +} + extern u32 fw_devlink_get_flags(void); #endif diff --git a/include/linux/of.h b/include/linux/of.h index 5d51891cbf1a..27fba2472eee 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -108,7 +108,7 @@ static inline void of_node_init(struct device_node *node) #if defined(CONFIG_OF_KOBJ) kobject_init(&node->kobj, &of_node_ktype); #endif - node->fwnode.ops = &of_fwnode_ops; + fwnode_init(&node->fwnode, &of_fwnode_ops); } #if defined(CONFIG_OF_KOBJ) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index cf8b374b892d..06fce7e39033 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -91,7 +91,7 @@ struct fwnode_handle *__irq_domain_alloc_fwnode(unsigned int type, int id, fwid->type = type; fwid->name = n; fwid->pa = pa; - fwid->fwnode.ops = &irqchip_fwnode_ops; + fwnode_init(&fwid->fwnode, &irqchip_fwnode_ops); return &fwid->fwnode; } EXPORT_SYMBOL_GPL(__irq_domain_alloc_fwnode); From patchwork Sat Nov 21 02:02:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 330135 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 1BD27C83010 for ; Sat, 21 Nov 2020 02:03:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D352E22202 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="XxQGXE/c" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727267AbgKUCDK (ORCPT ); Fri, 20 Nov 2020 21:03:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727229AbgKUCDJ (ORCPT ); Fri, 20 Nov 2020 21:03:09 -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 98DE3C061A49 for ; Fri, 20 Nov 2020 18:03:08 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id 4so89868ybv.11 for ; Fri, 20 Nov 2020 18:03:08 -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=b0YvDCLNXxObE7vEHCWq6i2O13x5pj7Sk5izCVC1W1s=; b=XxQGXE/c0CApYTMKGirkC/NzMW9PtuZKAP0Rij3rLCyz7ACe2iRldS3XiSAccUTDuw VexRPSGAp19xMnrTHsfrtF5BtMzF2MZP/DburWgf71GZwW5Ml9VtBSJJoaK8B8kB98JM LTiTyCSzkEAb3y96o6VkCwOeqiGY+E0TeBcGhxdVHz5xYkR8krpv6j9DfBcaZSO0HmQl FEbM1Bmew/lG+Q9/jFkWXlzWb5h4aJ92qoVUZ5HtmlWCWprdCkzLRZTSK1CfTFcfNnXl ooAeFNVOj3t7IovBKQRkijeoUTKtE2F8itFINpJOY5jVFiNDziby4r2/KpPmiYobuZR1 QVgA== 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=b0YvDCLNXxObE7vEHCWq6i2O13x5pj7Sk5izCVC1W1s=; b=a3HLiEoMOiPDXe0k7YKAQhi+YaX0jbtdAUusewSIX/f2ApHcOL58DdL3LNdGErn6Uz H5yiYmzWXYq2TtyAqnQCBhCitmXlQlDZV93nFKjXeGnC4ymHrSomO1+4VfvDQJpV74+s Ic5jcyMn4x66OQP5zIaYc93M9zk9xmUjf9+OGdo27x1hvvCiArrpiOh4AxAqYxOE5odb v9WLfBnoMZZE9tg5blo2zkcDP4mXZ49a/Kqau2emAuOte4yzI9VBnhl0H3P5RTNVDdyf lUrL40yt1qr+0fRSEOQRSowm6cH+ULBe8YM9nRcya6qfV5W5kPKknaKAFZjB0IL93KD7 kC6A== X-Gm-Message-State: AOAM533pC4iMFh1OHrCHa+UfNbRRNSjKOIo2hnCuraHm9E57dEr54nRH pi+Kb65WVLPQfuY6ldRhf12UwIrrp/o52io= X-Google-Smtp-Source: ABdhPJw7hTX1ig2DBMzM7Cg89jHEaXXOfJNgJV7mzTh9QzeRlAT0xMYvrW67/KGE2pLPBd6hd9qCI67qknxhIss= 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:a5b:3cd:: with SMTP id t13mr31630414ybp.144.1605924187829; Fri, 20 Nov 2020 18:03:07 -0800 (PST) Date: Fri, 20 Nov 2020 18:02:24 -0800 In-Reply-To: <20201121020232.908850-1-saravanak@google.com> Message-Id: <20201121020232.908850-10-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 09/17] driver core: Allow only unprobed consumers for SYNC_STATE_ONLY device 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-efi@vger.kernel.org SYNC_STATE_ONLY device links only affect the behavior of sync_state() callbacks. Specifically, they prevent sync_state() only callbacks from being called on a device if one or more of its consumers haven't probed. So, creating a SYNC_STATE_ONLY device link from an already probed consumer is useless. So, don't allow creating such device links. Signed-off-by: Saravana Kannan --- drivers/base/core.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/base/core.c b/drivers/base/core.c index e2b246a44d1a..215ce9e72790 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -649,6 +649,17 @@ struct device_link *device_link_add(struct device *consumer, goto out; } + /* + * SYNC_STATE_ONLY links are useless once a consumer device has probed. + * So, only create it if the consumer hasn't probed yet. + */ + if (flags & DL_FLAG_SYNC_STATE_ONLY && + consumer->links.status != DL_DEV_NO_DRIVER && + consumer->links.status != DL_DEV_PROBING) { + link = NULL; + goto out; + } + /* * DL_FLAG_AUTOREMOVE_SUPPLIER indicates that the link will be needed * longer than for DL_FLAG_AUTOREMOVE_CONSUMER and setting them both From patchwork Sat Nov 21 02:02:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 330134 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 354B7C64E69 for ; Sat, 21 Nov 2020 02:03:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F050F22202 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="C0huOxQf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727358AbgKUCDT (ORCPT ); Fri, 20 Nov 2020 21:03:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727309AbgKUCDS (ORCPT ); Fri, 20 Nov 2020 21:03:18 -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 57358C061A47 for ; Fri, 20 Nov 2020 18:03:16 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id w8so14386485ybq.4 for ; Fri, 20 Nov 2020 18:03:16 -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=kkvUYmRSkidNjkTq5GwniBTGKUzDD8tYACZuHPPCtMw=; b=C0huOxQfOFIYkmZ5+j5wBG0r+aPmC4/UZ/pyjY13Gqsre385QtU5zpSWQqtLiSK4EC DJG49WcUPSMz92mQT8T6Zxckt93Reu6GEAXQO+yNjstfjcXyxQjhricoR5vmJydKCcqT W4clRYgmd/+H2PBfwwmEL54kIktmgWsA2vP0leAI328J0tvhKucVE1oyV3otEuzsze0Q VxogMphFyQZJGHwXst43+T9wmNbXvyaJUnMaHAlVZFg7Dlf369VoYCx4YlanCeqOPXku rlUsaqd6kIfaZWYKUJgQQ6H994f73Sx5bSOOmMPSW62bBO/93wbtorcE7/iH0aY3VEOj CZdg== 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=kkvUYmRSkidNjkTq5GwniBTGKUzDD8tYACZuHPPCtMw=; b=Sv91sTw4SLTQwex09kjY3GKFVkPLNM5vNesSW+CzbyX3AEBbzB5vODMUgUdIe/FyI1 PqLZcD4L+BP1LHgzSnazDr7Y6dhf1dAHMv4F617mI0rkqkk12RfIDc6qzGZm8ZwIsty2 YxGNcjHZc4iSNtIPAsjOqddT2bfhq59edASL3f/gxa+8XzcmmM+O/J4t+SW71E/XGFMZ 0UfXmzrvtHgWB8DY2mRb6cc/yvz3Cl0Z/xdGQte3wH9sFsrBRW/bFouSzRFxyiEAV0Rc oxrxbG4l6Ama2BW5KwaDq81DMeZXacop8JoFk2RT6/RlDl5SqSS59M8sTjUG0dChOzvZ zKOA== X-Gm-Message-State: AOAM532XJGv9hfMkivjpVJiCP1r7i88vy4uv5fs1ChVLkUE04hgZIP8p HrVkH07r1HpJVFQUBxxs7P/2H9N8XGD+xhk= X-Google-Smtp-Source: ABdhPJyV9Uoir3KqyP3MamhCm8qYOnpgbNbEd6xLZ5JjffYqgi0HKnViyZWiFepF+7Lo7+787hyZ2uVL7R2L6mw= 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:2a4b:: with SMTP id q72mr34851917ybq.385.1605924195519; Fri, 20 Nov 2020 18:03:15 -0800 (PST) Date: Fri, 20 Nov 2020 18:02:27 -0800 In-Reply-To: <20201121020232.908850-1-saravanak@google.com> Message-Id: <20201121020232.908850-13-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 12/17] driver core: Add fw_devlink_parse_fwtree() 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-efi@vger.kernel.org This function is a wrapper around fwnode_operations.add_links(). This function parses each node in a fwnode tree and create fwnode links for each of those nodes. The information for creating the fwnode links (the supplier and consumer fwnode) is obtained by parsing the properties in each of the fwnodes. This function also ensures that no fwnode is parsed more than once by marking the fwnodes as parsed. Signed-off-by: Saravana Kannan --- drivers/base/core.c | 19 +++++++++++++++++++ include/linux/fwnode.h | 8 ++++++++ 2 files changed, 27 insertions(+) diff --git a/drivers/base/core.c b/drivers/base/core.c index 215ce9e72790..395dece1c83a 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1544,6 +1544,25 @@ static bool fw_devlink_is_permissive(void) return fw_devlink_flags == DL_FLAG_SYNC_STATE_ONLY; } +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->flags |= FWNODE_FLAG_LINKS_ADDED; +} + +static void fw_devlink_parse_fwtree(struct fwnode_handle *fwnode) +{ + struct fwnode_handle *child = NULL; + + fw_devlink_parse_fwnode(fwnode); + + while ((child = fwnode_get_next_available_child_node(fwnode, child))) + fw_devlink_parse_fwtree(child); +} + static void fw_devlink_link_device(struct device *dev) { int fw_ret; diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h index 942a6bb18201..ffa9129182a6 100644 --- a/include/linux/fwnode.h +++ b/include/linux/fwnode.h @@ -15,12 +15,20 @@ struct fwnode_operations; struct device; +/* + * fwnode link flags + * + * LINKS_ADDED: The fwnode has already be parsed to add fwnode links. + */ +#define FWNODE_FLAG_LINKS_ADDED BIT(0) + struct fwnode_handle { struct fwnode_handle *secondary; const struct fwnode_operations *ops; struct device *dev; struct list_head suppliers; struct list_head consumers; + u8 flags; }; struct fwnode_link { From patchwork Sat Nov 21 02:02:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 330133 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 9AC50C64E75 for ; Sat, 21 Nov 2020 02:03:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6E36822403 for ; Sat, 21 Nov 2020 02:03:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="CRhGb2ss" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727356AbgKUCDV (ORCPT ); Fri, 20 Nov 2020 21:03:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727353AbgKUCDT (ORCPT ); Fri, 20 Nov 2020 21:03:19 -0500 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C265CC061A04 for ; Fri, 20 Nov 2020 18:03:18 -0800 (PST) Received: by mail-qk1-x749.google.com with SMTP id 143so9516521qkg.20 for ; Fri, 20 Nov 2020 18:03:18 -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=TDH6sKF+25uJe3sYo1DkxQ2WsvdJDRIVI/Vx11qvHv0=; b=CRhGb2ssFoN8jV9EKkRfvLzAyT6vs0pAPoP3mlKKlfYL8xfFLIGkhUDuQS7xxtgbym N6/C1nnKo2saz/AAZpqUmzqximqL94cyCamjx8A6LvmQqYh6DhIkSveqAFRFwJhaNGIS dAwX7NRQd4MzarcH1nQ4zLVN4NpiWj8VTe/Qn2ArYNnLkwvnNreUGNmU52gEbt2c3Hu/ Qq2sWaXZr7nBByFFHlUjRhb/fRmMFeImX9ez71sBAiQlULSGW/3fDUGcuWdeZruFXPYX KEEJZ/5S3aZInGZtCBB58vZV4/osfC7OrwljZ1WSEyfLr3lEOPzjEFOY/nYMX0Lk4cz2 eTkw== 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=TDH6sKF+25uJe3sYo1DkxQ2WsvdJDRIVI/Vx11qvHv0=; b=uL4d8tdMfbJxZ6ziI0BZJW4qu1lTVZ1P1HD+N9JWpXwsa7dC2IFyP4mf57rCT9s1bW TN7kSFRgbeIXlFomXG07KRun2eSdtVvdceLwCBq19ZmoN73Hv7Zw/Y5BZVE06PEosvwF 5FRZCCjxokShqKoj5IURDPDdjQfHudm072OVOQl4vnHAx33X4qLkHs00LVNUjbxIZt9p O7ILr/q/LaoZf7Tezr7rZyPr0C+6tAqXf9aUfi2JG6Kpkssw3DwCHjp+opEse3jrqA+b 0bsl3lj92+AxXhEjTSQ5w/02S1lzFMF8ltAN36j5GVQy1G7DTbXO1pmNz6Tp+/DYvnqz qRTg== X-Gm-Message-State: AOAM531tcu7HesbzuX8rgN9M66UwII5VysdmruFmoD4sjoznWegeGYe7 0yajaQbffB41pNpjiERb96mG++qwFzXov3A= X-Google-Smtp-Source: ABdhPJx51C0SU2lAydPfKuJ16S1v5AwFANmnRet4R5tmtjmVrjb7V9OqzMmQprV4NxbyZQlfBM442vd1HdoXKYE= 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:a0c:c78e:: with SMTP id k14mr19214638qvj.5.1605924197961; Fri, 20 Nov 2020 18:03:17 -0800 (PST) Date: Fri, 20 Nov 2020 18:02:28 -0800 In-Reply-To: <20201121020232.908850-1-saravanak@google.com> Message-Id: <20201121020232.908850-14-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 13/17] driver core: Use device's fwnode to check if it is waiting for suppliers 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-efi@vger.kernel.org To check if a device is still waiting for its supplier devices to be added, we used to check if the devices is in a global waiting_for_suppliers list. Since the global list will be deleted in subsequent patches, this patch stops using this check. Instead, this patch uses a more device specific check. It checks if the device's fwnode has any fwnode links that haven't been converted to device links yet. Signed-off-by: Saravana Kannan --- drivers/base/core.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 395dece1c83a..1873cecb0cc4 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -51,6 +51,7 @@ static DEFINE_MUTEX(wfs_lock); static LIST_HEAD(deferred_sync); static unsigned int defer_sync_state_count = 1; static DEFINE_MUTEX(fwnode_link_lock); +static bool fw_devlink_is_permissive(void); /** * fwnode_link_add - Create a link between two fwnode_handles. @@ -995,13 +996,13 @@ int device_links_check_suppliers(struct device *dev) * Device waiting for supplier to become available is not allowed to * probe. */ - mutex_lock(&wfs_lock); - if (!list_empty(&dev->links.needs_suppliers) && - dev->links.need_for_probe) { - mutex_unlock(&wfs_lock); + mutex_lock(&fwnode_link_lock); + if (dev->fwnode && !list_empty(&dev->fwnode->suppliers) && + !fw_devlink_is_permissive()) { + mutex_unlock(&fwnode_link_lock); return -EPROBE_DEFER; } - mutex_unlock(&wfs_lock); + mutex_unlock(&fwnode_link_lock); device_links_write_lock(); @@ -1167,10 +1168,7 @@ static ssize_t waiting_for_supplier_show(struct device *dev, bool val; device_lock(dev); - mutex_lock(&wfs_lock); - val = !list_empty(&dev->links.needs_suppliers) - && dev->links.need_for_probe; - mutex_unlock(&wfs_lock); + val = !list_empty(&dev->fwnode->suppliers); device_unlock(dev); return sysfs_emit(buf, "%u\n", val); } @@ -2202,7 +2200,7 @@ static int device_add_attrs(struct device *dev) goto err_remove_dev_groups; } - if (fw_devlink_flags && !fw_devlink_is_permissive()) { + if (fw_devlink_flags && !fw_devlink_is_permissive() && dev->fwnode) { error = device_create_file(dev, &dev_attr_waiting_for_supplier); if (error) goto err_remove_dev_online; 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: 330132 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=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 0031DC8300B 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 D071B24137 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="EOisX5uj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727430AbgKUCD2 (ORCPT ); Fri, 20 Nov 2020 21:03:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727429AbgKUCD0 (ORCPT ); Fri, 20 Nov 2020 21:03:26 -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 788A8C0613CF for ; Fri, 20 Nov 2020 18:03:26 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id c9so14118124ybs.8 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=bJMnoKzFYJbgUVmcUqjOWUbu2KJ/EhxPjt9eGA2DmY3qVnL5xxGxr2GKnrdzPUDoXE 9MZgxHysmeEetg71Cz/s1ZTcFseDKNGzCiP4iAVyavobS4XejLeIakQHAU4dSrKuSyMY k4eKOVP5/0z8mlyHqgDiF9DlwTmT+PN4smHFV2CjwUCLhRQ3QqOsstBI2SyBnmFFsomC TUpC7swc02RLgBb23Ss3q1RPYfBhZqCP3KZIJfSz44Ch+3jxhKANjnsUttREAc3VUCBL k6aid2DHYP5RoEzg5pATvj65ZpqDIOpe16eXICiK3BMGUVGVyShjj8RX8DkgrYjPItVV ANpA== X-Gm-Message-State: AOAM533NjDANEl3fy+guQ3PRUNdhjnI12TORPfTojL0LdcKYTCLSb52d EAaVSlvm0pNRXdAwBAi8z5Y4NOSwE9GMycU= 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-efi@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: 330131 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 196F7C83011 for ; Sat, 21 Nov 2020 02:03:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D55182415B 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 S1727449AbgKUCDc (ORCPT ); Fri, 20 Nov 2020 21:03:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727444AbgKUCD3 (ORCPT ); Fri, 20 Nov 2020 21:03:29 -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 6725DC061A47 for ; Fri, 20 Nov 2020 18:03:29 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id m186so14133732ybm.22 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=YGgIRfqmYk9Gf5uIEwIfw64UPzvsXmcDuSg8ZbG/kyK1sGK16keNuH0W0PIS5aKDNY eRywdaW2S6ANAF6yJKqBRnq2COQyC6dX/AO8EhHoYNNySbenX6GBqY53pZ7kzL4hJ32U IGyo2snuXgrGeMSB2YL16EvLzJMG14r0xcla9eExX2s7tuxVmFlIKjkAqKEu4QDug/hH rcOLnlOK+Rq1+SY1eiUhwXd2q5nDsLFuwn6g0rOe80pmPumNGE3qY4MY/2GTWO/yJzkr VoKw+LV0Ea2IL+ZZr4oClMUFtyM6J0y7PWuiEVmXsaruVxoG+R/Vd1Lo7urQHwRzUBJj Sj1w== X-Gm-Message-State: AOAM530b2EDzQs+mw+rUMjYPMtvD2J9UZ7nnGNDibG1mOOIPFD648HWr WNCVQVTuhWxIadAwNyX4FE8gUJ5AnfJ3Brg= 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-efi@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) \