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: 159256 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp3907007jad; Tue, 26 Feb 2019 18:18:48 -0800 (PST) X-Google-Smtp-Source: AHgI3IYXhd4GZyM5nsG3lB8TeFS4olLxtsZWyO8BCLyFrzeFnI8U5iXbOl67NW6QM8uOcmM3kmAt X-Received: by 2002:a17:902:7d89:: with SMTP id a9mr29015956plm.33.1551233928485; Tue, 26 Feb 2019 18:18:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551233928; cv=none; d=google.com; s=arc-20160816; b=cMZ4CumMUijUTG28i1DfthWTwICF2wSbIwKT0J4ofiqTOflbVKJ/wlr3iI10UbW4hJ Uf+y+VkCGPs8mKVG6z1PF2CWvuj0Ic4wLk9CGyxgcLAdE0rfouQh1izzmYV8MUm5XHWA 2jEz3kKquE1jN81VXM+joywWlhA9s8N8mhLbGSkEoj7vASnlWLa3b2Df0MEdnIkOCNtb p9UVhJSk3/RI4QejqAmQAl5GuyfzZEb7GW9YVgeKvoH+wp7vwE+O4aen3xYFuhb9BK4P 8nCdLyfpS+4NJXuTaFb6pVNs+H7LwtZVFUCgjds2JuvJvoSxe8zhlOYVFyhBFJPHWL7c TO2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=wOBWNY374y/QfUc2jFMuBhBhbthjm2i0nq7yZ/ojO1I=; b=E6LcMjnZ1hFqu4jqTOKwUzG3tqREO4i9Io4OVVnSrApDG1QfdaQQSoTciEKo5mjJjJ L6MP97osY/+LRn1RVR4XwQlXqWPedXci/ABeLrCh8VyMY7zE3ZxsfMNlC8XhsnlHOFEh gQtchoxaj6LruvWOAyUUNB29E9fq7aqDNUSrtTm3BSm4V8RBN7sZyTIv9kXuOeyR8kwq vQaojlP3lyC3ZSiA8E/+ivrWUt/gpyDFx/+OG0ckrLWHh+TqZeHh+RL9fVUQ1MLnBDit aBiIz3mYzqFM7lYwyFkT2av0yirtWTLoqXu8arq//JPLrZ4CBiIFXYF5v5g4Y+ayzV9B 8h3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WaUX8Xwq; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w5si10123866pgr.93.2019.02.26.18.18.47; Tue, 26 Feb 2019 18:18:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WaUX8Xwq; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729595AbfB0CSr (ORCPT + 11 others); 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-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 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);