From patchwork Wed Feb 27 02:18:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Cassel X-Patchwork-Id: 10831005 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 22C3B17E9 for ; Wed, 27 Feb 2019 02:18:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBDF52DC0A for ; Wed, 27 Feb 2019 02:18:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E984B2DBC0; Wed, 27 Feb 2019 02:18:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED9112DC00 for ; Wed, 27 Feb 2019 02:18:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729595AbfB0CSr (ORCPT ); Tue, 26 Feb 2019 21:18:47 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:34455 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729464AbfB0CSq (ORCPT ); Tue, 26 Feb 2019 21:18:46 -0500 Received: by mail-lj1-f194.google.com with SMTP id l5so12606052lje.1 for ; Tue, 26 Feb 2019 18:18:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=wOBWNY374y/QfUc2jFMuBhBhbthjm2i0nq7yZ/ojO1I=; b=WaUX8Xwqg5HRRfL9G5j88gqwRF/sj3rDzWdnRHiS0K8nr7UDTL1BXAT3BiI0jDZYbF Q/qkwG0t1ZMkzR1Q6xJhV6VF1ZXXk63YWDpodzOC4ouGIXEObNNfZBXECoLuzCe5RYhI aXmYWTHO4ZN0kivPtVtp2lLhsFuflOqL1Bu7KkWeb5w3REz2v9RNxKERo89cV2NqLs+R sUxvCrB2pTWijTNIwOcfdEgSiqijKYeYseX5U1uJxthZVSktVphFC/qZh1k1lYy6/Pe7 VZiOO9iS+W96MRN1u+dk3xktfX3kB5aFO7m7U/gRe5BomEY8oYFnsLkPEwA5gNVGTQsj kYHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=wOBWNY374y/QfUc2jFMuBhBhbthjm2i0nq7yZ/ojO1I=; b=uRkCUaR9IgztAg0IOAIGCl5HssAj0TNhbsUiqZdu7iKYF29Xs/gF1Kb2gQZLvMxQMj ZoZWlPa7Wx70AYLeAv0LvAdT9h0Z5W+OQ2kRUsRghXd2WxdweuLwq2nWWLzTHt9x/S/n W1OGmO+JGOf86U7hdXf3/HlZlT2sE+5rFbV5ZckFPhTgbVTQ7fYZ1QxHE8DeT3zGMQId paKUtka/NUiHjo+Bl3aBb8KUze1+YH5DMNLWzW+Lr1wtCLGbyNjd3OGGAh5TSDHaPzIB EF55PTx3vUFydKmuJ1jaPQRUiBmlLivRdJu6UzjhN/YPcoNIXvIXO/iVhCSfdxVg78GK lMTw== X-Gm-Message-State: AHQUAuY1qEBP3NA1cvZVWtOaokAGsBtFYLW3IfzSzo+cTh7LQty2+gWN AkvT+XJHAJ4HSGXxYSUT2pW6KQ== X-Google-Smtp-Source: AHgI3IaCk0QmoYK2sWM7bpPG2odhZcYzUoJ4/lYoQ0V484Rf9OA0BwKh7BlBYNL9jiLAzg8n60PIKA== X-Received: by 2002:a2e:9001:: with SMTP id h1mr15291072ljg.5.1551233924543; Tue, 26 Feb 2019 18:18:44 -0800 (PST) Received: from centauri.lan (h-229-118.A785.priv.bahnhof.se. [5.150.229.118]) by smtp.gmail.com with ESMTPSA id o14sm3402917lfl.41.2019.02.26.18.18.43 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 26 Feb 2019 18:18:43 -0800 (PST) Date: Wed, 27 Feb 2019 03:18:41 +0100 From: Niklas Cassel To: robh@kernel.org Cc: agraf@suse.de, gregkh@linuxfoundation.org, ulf.hansson@linaro.org, rjw@rjwysocki.net, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: broken probe deferred for power-domains Message-ID: <20190227021841.GA26337@centauri.lan> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hello Rob, Your patch e01afc325025 ("PM / Domains: Stop deferring probe at the end of initcall") breaks deferred probe for power domains. The patch looks like this: +++ b/drivers/base/power/domain.c @@ -2253,7 +2253,7 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device_node *np, mutex_unlock(&gpd_list_lock); dev_dbg(dev, "%s() failed to find PM domain: %ld\n", __func__, PTR_ERR(pd)); - return -EPROBE_DEFER; + return driver_deferred_probe_check_state(dev); } Having two drivers (both using module_platform_driver), one being a PD provider and one being a PD consumer. Before your patch: The PD consumer driver calls dev_pm_domain_attach(), and gets EPROBE_DEFER until the PD provider driver has been probed successfully. (The PD provider driver needs some regulators, so it is only successfully probed after the regulator driver has been probed successfully.) Anyway, dev_pm_domain_attach() returned success after the some deferred probes. After your patch: dev_pm_domain_attach() return ENODEV, which comes from driver_deferred_probe_check_state(). Since it returns ENODEV rather than EPROBE_DEFER, the PD consumer driver fails to probe. The problem is related to your other patch 25b4e70dcce9 ("driver core: allow stopping deferred probe after init"). driver_deferred_probe_check_state() returns ENODEV if initcalls_done == true. initcalls_done is set from late_initcall(deferred_probe_initcall), in drivers/base/dd.c: driver_deferred_probe_trigger(); flush_work(&deferred_probe_work); initcalls_done = true; This does not seem very robust, since #1 It does not handle the case where two drivers have been deferred (put in the deferred probe pending list), where additionally one of the drivers has to be probed before the other. (We would need to call driver_deferred_probe_trigger() + flush_work() at least twice to handle this.) #2 Since this code is run from late_initcall(), initcalls_done might get set before other drivers using late_initcall() have even had a chance to run. I can imagine that a driver using late_initcall() + EPROBE_DEFER will absolutely not work with this code. This patch fixes #1, but not #2. However, I assume that even this change would not work if we have 3 drivers, where each driver a > b > c has to be probed, in that order. (and all of them were placed in the deferred probe pending list). Suggestions and patches are welcome. Kind regards, Niklas diff --git a/drivers/base/dd.c b/drivers/base/dd.c index a823f469e53f..3443cb78be9b 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -288,7 +288,6 @@ static int deferred_probe_initcall(void) driver_deferred_probe_trigger(); /* Sort as many dependencies as possible before exiting initcalls */ flush_work(&deferred_probe_work); - initcalls_done = true; /* * Trigger deferred probe again, this time we won't defer anything @@ -297,6 +296,8 @@ static int deferred_probe_initcall(void) driver_deferred_probe_trigger(); flush_work(&deferred_probe_work); + initcalls_done = true; + if (deferred_probe_timeout > 0) { schedule_delayed_work(&deferred_probe_timeout_work, deferred_probe_timeout * HZ);