Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3410031imm; Fri, 25 May 2018 05:21:33 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrnIUBIL5BSXtuaYa9cXTi8lShrcCuyhDp9GUa037WsH+tpFxgIiKJC7evOb7LN+2MtC+KL X-Received: by 2002:a17:902:3c5:: with SMTP id d63-v6mr2355497pld.163.1527250893865; Fri, 25 May 2018 05:21:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527250893; cv=none; d=google.com; s=arc-20160816; b=MBI3y3zc909SyrPV52uIuCCM8T8VFt9+NJOuplI1M1Ge/x01HHswDjffqjh1UWjszu GPuW7YGYh6os0kqjnSGNF7ANPc7zc7g/X4KKN7sLvumoV9ZWetczz3HmlF0JRSTa11Gh Fdq9USFI7OPcKcZ27ocBdhstqKLNzE0CY+keAIKBJa7rwy5W4UnV5LfeqPfivgYMJYHN 5ns7TOQB2R6ARumyPfzD/CvsmvWC0UrmWlLnX+tvbTzc5LadvlFXWAQ77Mg4oUHOf8L7 oTKyVSbDAfl5WFnLncEp61NavNkvVlBz3ujYBILrHkQFoRKyYMyNWC97EwqhHwVka3Gv TQsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=zwt25tVxhEPsFZ9vmYcFdMKHNk7aKgGbooaDcnImgfA=; b=0pwlHTEQ2u20yFXqlonS7tO4aV3/kDxB1YSF3Y4QED1LQ6vWK1tnZDGaywvNzuXA6v XJldnO0thfDQuAfAkyybPuJuL2PgPViSQMsQrQxybXrvEOVOFr4OIJPG2YTvLUztGrzQ uNG01K7x3evbMBUCd2RrIfFNeIeMwqAGIb1H7mBs8ClaVnS84O36fi88oSbALFMeIdQF OLsTu6vrxnGh5Mtqj7ZPjTdkuxsBz2MZL9uHT8iN5+3lbOBsL2fDbUDo8P97N9taFjLg 6D6pzK0p/eX34TJRBESMzCwjfy9LON/1inmkINAvTQwUMOAN+7F1nAI6zfgFpKrNAMl5 QbRg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 y17-v6si7027246plp.485.2018.05.25.05.21.18; Fri, 25 May 2018 05:21:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966637AbeEYMU0 (ORCPT + 99 others); Fri, 25 May 2018 08:20:26 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:60988 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966464AbeEYMUY (ORCPT ); Fri, 25 May 2018 08:20:24 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 586241529; Fri, 25 May 2018 05:20:24 -0700 (PDT) Received: from [10.1.210.88] (e110467-lin.cambridge.arm.com [10.1.210.88]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DA2433F24A; Fri, 25 May 2018 05:20:21 -0700 (PDT) Subject: Re: [PATCH v2 1/8] driver core: make deferring probe after init optional To: Rob Herring , Greg Kroah-Hartman Cc: Linus Walleij , Alexander Graf , Bjorn Andersson , "Rafael J. Wysocki" , Kevin Hilman , Ulf Hansson , Joerg Roedel , Mark Brown , Frank Rowand , "linux-kernel@vger.kernel.org" , devicetree@vger.kernel.org, Architecture Mailman List , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" References: <20180524175024.19874-1-robh@kernel.org> <20180524175024.19874-2-robh@kernel.org> <20180524190031.GB31019@kroah.com> From: Robin Murphy Message-ID: <92e3be10-e65a-99e9-6ef7-f11ded6a35f9@arm.com> Date: Fri, 25 May 2018 13:20:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24/05/18 21:57, Rob Herring wrote: > On Thu, May 24, 2018 at 2:00 PM, Greg Kroah-Hartman > wrote: >> On Thu, May 24, 2018 at 12:50:17PM -0500, Rob Herring wrote: >>> Deferred probe will currently wait forever on dependent devices to probe, >>> but sometimes a driver will never exist. It's also not always critical for >>> a driver to exist. Platforms can rely on default configuration from the >>> bootloader or reset defaults for things such as pinctrl and power domains. >>> This is often the case with initial platform support until various drivers >>> get enabled. There's at least 2 scenarios where deferred probe can render >>> a platform broken. Both involve using a DT which has more devices and >>> dependencies than the kernel supports. The 1st case is a driver may be >>> disabled in the kernel config. The 2nd case is the kernel version may >>> simply not have the dependent driver. This can happen if using a newer DT >>> (provided by firmware perhaps) with a stable kernel version. >>> >>> Subsystems or drivers may opt-in to this behavior by calling >>> driver_deferred_probe_check_init_done() instead of just returning >>> -EPROBE_DEFER. They may use additional information from DT or kernel's >>> config to decide whether to continue to defer probe or not. >>> >>> Cc: Alexander Graf >>> Signed-off-by: Rob Herring >>> --- >>> drivers/base/dd.c | 17 +++++++++++++++++ >>> include/linux/device.h | 2 ++ >>> 2 files changed, 19 insertions(+) >>> >>> diff --git a/drivers/base/dd.c b/drivers/base/dd.c >>> index c9f54089429b..d6034718da6f 100644 >>> --- a/drivers/base/dd.c >>> +++ b/drivers/base/dd.c >>> @@ -226,6 +226,16 @@ void device_unblock_probing(void) >>> driver_deferred_probe_trigger(); >>> } >>> >>> +int driver_deferred_probe_check_init_done(struct device *dev, bool optional) >>> +{ >>> + if (optional && initcalls_done) { >> >> Wait, what's the "optional" mess here? > > My intent was that subsystems just always call this function and never > return EPROBE_DEFER themselves. Then the driver core can make > decisions as to what to do (such as the timeout added in the next > patch). Or it can print common error/debug messages. So optional is a > hint to allow subsystems per device control. Maybe just driver_defer_probe() might be a more descriptive name? To me, calling "foo_check_x()" with a parameter that says "I don't actually care about x" is the really unintuitive bit. >> >> The caller knows this value, so why do you need to even pass it in here? > > Because regardless of the value, we always stop deferring when/if we > hit the timeout and the caller doesn't know about the timeout. If we > get rid of it, we'd need functions for both init done and for deferred > timeout. > >> And bool values that are not obvious are horrid. I had to go look this >> up when reading the later patches that just passed "true" in this >> variable as I had no idea what that meant. > > Perhaps inverting it and calling it "keep_deferring" would be better. > However, the flag is ignored if we have timed out. Perhaps an enum (or bitmask of named flags) then? That would allow the most readability at callsites, plus it seems quite likely that we may want intermediate degrees of "deferral strictness" eventually. Robin. >> >> So as-is, no, this isn't ok, sorry. >> >> And at the least, this needs some kerneldoc to explain it :) > > That part is easy enough to fix. > > Rob >