Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1345468ybx; Tue, 5 Nov 2019 14:37:20 -0800 (PST) X-Google-Smtp-Source: APXvYqzwYlsmN+eB5oHT9dd/nAOF2NPB+afDt5IyS0BYLEZMrBZLGj4qDYL9FT4+jzMuhXajQ+Q7 X-Received: by 2002:a05:6402:502:: with SMTP id m2mr11251477edv.65.1572993440036; Tue, 05 Nov 2019 14:37:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572993440; cv=none; d=google.com; s=arc-20160816; b=IsEK7QCa71EYq+1iW1Ow/swCoLvafYIOyd28hDWSnQlfAp+tKEr3piktWKN2nGCWxD UFn2HgmRReSbDS/3iU6kpWCLNW5PeYqWEdIiD2YWULK5EAk8Gl35vJ9zNH1jQmhgR9PZ bxMwHzPjSvcZs5ek5WV5o4AVkXQvIzDkTctuYe2Q7okdtZQIlzW5HBj7dz4cUxE+iXfv UE16AWADhBXgXmgQoEfyZyscuWu+XZ+O+DxSDN08hCTm55dkvSMc7H5UhPtiofHd6dNa SpPbJ8jKot1ohIlxYbnuNUz71vffhR6APixKAqo2lp7gG+MTrqDva6TYun6lRnzk1t9M 9+9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=sI67ya690BTFzgQFAyEbbbi8Nt1gAKdEUwsmNFmIXdc=; b=HItwoAk9iL1ifM5tw18dMCsWqSvjcezskFVDU7khAHVXVC/pP8iSdy97P+RJlZEgAl didubXTccGtr8RIMhAvpKECdQJ2R882v45kEuVnG1l+P4Hohp8bEu5rNmriQxzbRbjMp o0U2SV4qNxKFr6rSPmQXq3sC/0lGpx2Vz1QkRjWd6k34U72xD05EahLHQ+fh32W3XSgR WGILH+llnNyVkorYWEQxGT15eaOjk5nwAkmY2znFTXQoyoIurp0Q2jG6Wb7eWej0bQdz 0Ksaf93zUhBSMEjGlJvUcUJge/PJrQC4eT6p3dR0pNIta1xpeXUQuyyxo0ZewF0pk57H ayVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ZODWxeoM; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e4si12787457edc.146.2019.11.05.14.36.56; Tue, 05 Nov 2019 14:37:20 -0800 (PST) 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; dkim=pass header.i=@google.com header.s=20161025 header.b=ZODWxeoM; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730363AbfKEWgG (ORCPT + 99 others); Tue, 5 Nov 2019 17:36:06 -0500 Received: from mail-ot1-f66.google.com ([209.85.210.66]:46289 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730192AbfKEWgG (ORCPT ); Tue, 5 Nov 2019 17:36:06 -0500 Received: by mail-ot1-f66.google.com with SMTP id n23so8867164otr.13 for ; Tue, 05 Nov 2019 14:36:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sI67ya690BTFzgQFAyEbbbi8Nt1gAKdEUwsmNFmIXdc=; b=ZODWxeoMRTwEvAD65PgEfzPAUnDmSFK4brlri5jweoy7Vi+WgtjrshGTfCoZLdLlmE OxudRyI4pmvp87d3vuAk/pMDHJzZl5Al1b36eh9f9DSrvm60ek6rspFnti0c8O4Ev4uk z1qhp+xiMln01gOwVNShh2+KNYFk2Y/pLgcF5FTn5/Xtf2qFyCSb0FoRY8l7WfkpepGF oAy/GlU+tNs3vQHqFKsJxibWdE6Rt5t2LmGpQq1hzGlAT9GojrTabUQw4Jw0xefov4Tw iYlDOldEuXej4F2xabetKwN2uUdatrbgmhOfgs1QE4zlqslyTvdW0roW/t8G01FlgEoF Q3Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sI67ya690BTFzgQFAyEbbbi8Nt1gAKdEUwsmNFmIXdc=; b=sX5Prj6H1D48EGTHLEw4JRJkQHhwuEzkUN342P26pUJ0kFEV6jVjFOGWvmgFHWwiof BU06TbbhULpoDBt94/KM7MX0x6K4ETk6soD5e9ko2p1zynVFA/h5Ap6wuoq3It+ggHgl r98N/HCtkKs/90UFtOfKoptu5fWYAdT5xSrWACOCZQW05bap+P0YVwfzeTOV7Vs0HrUK EyyqIZ2ZoG3+YxTMjBBKbzSVMTgcjUDGfm4mSOtgM+CGznkn6kcPLa/HRmn22AlUmyZl qy2pw2GkaKdvoZWQjLMkedSxMWsWtM4lYKsZtpFmN7O9DJxzkSussIJE6OK1A5WCDi1m 3MWQ== X-Gm-Message-State: APjAAAWLtLy5aocPyKwlVNwzCYubpgybWW+50FsJ6tp1AipBlxM7Txmx DFrI3Lwpy2nOCBx4vNEY5BgfvaqxRpO8DHV/F5JyTg== X-Received: by 2002:a9d:648f:: with SMTP id g15mr7370526otl.195.1572993364486; Tue, 05 Nov 2019 14:36:04 -0800 (PST) MIME-Version: 1.0 References: <20191028220027.251605-1-saravanak@google.com> <20191028220027.251605-3-saravanak@google.com> <1593797.btdyhENphq@kreacher> In-Reply-To: <1593797.btdyhENphq@kreacher> From: Saravana Kannan Date: Tue, 5 Nov 2019 14:35:28 -0800 Message-ID: Subject: Re: [PATCH v1 2/5] driver core: Allow a device to wait on optional suppliers To: "Rafael J. Wysocki" Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Frank Rowand , Len Brown , Android Kernel Team , LKML , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , linux-acpi@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Looks like I squashed/rebased a bit incorrectly. It's fixed in the next patch in the series. -Saravana On Tue, Nov 5, 2019 at 2:29 PM Rafael J. Wysocki wrote: > > On Monday, October 28, 2019 11:00:23 PM CET Saravana Kannan wrote: > > Before this change, if a device is waiting on suppliers, it's assumed > > that all those suppliers are needed for the device to probe > > successfully. This change allows marking a devices as waiting only on > > optional suppliers. This allows a device to wait on suppliers (and link > > to them as soon as they are available) without preventing the device > > from being probed. > > > > Signed-off-by: Saravana Kannan > > --- > > drivers/base/core.c | 28 +++++++++++++++++++++++++--- > > include/linux/device.h | 3 +++ > > 2 files changed, 28 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/base/core.c b/drivers/base/core.c > > index 17ed054c4132..48cd43a91ce6 100644 > > --- a/drivers/base/core.c > > +++ b/drivers/base/core.c > > @@ -480,13 +480,25 @@ EXPORT_SYMBOL_GPL(device_link_add); > > * 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) > > +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 > > @@ -656,7 +668,8 @@ int device_links_check_suppliers(struct device *dev) > > * probe. > > */ > > mutex_lock(&wfs_lock); > > - if (!list_empty(&dev->links.needs_suppliers)) { > > + if (!list_empty(&dev->links.needs_suppliers) && > > + dev->links.need_for_probe) { > > mutex_unlock(&wfs_lock); > > return -EPROBE_DEFER; > > } > > @@ -760,6 +773,15 @@ void device_links_driver_bound(struct device *dev) > > { > > struct device_link *link; > > > > + /* > > + * If a device probes successfully, it's expected to have created all > > + * 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); > > + > > device_links_write_lock(); > > > > list_for_each_entry(link, &dev->links.consumers, s_node) { > > @@ -2393,7 +2415,7 @@ int device_add(struct device *dev) > > > > if (fwnode_has_op(dev->fwnode, add_links) > > && fwnode_call_int_op(dev->fwnode, add_links, dev)) > > - device_link_wait_for_supplier(dev); > > + device_link_wait_for_mandatory_supplier(dev, true); > > Does this compile even? > > The function takes one argument according to the definition above ... > > > bus_probe_device(dev); > > if (parent) > > diff --git a/include/linux/device.h b/include/linux/device.h > > index f1f2aa0b19da..4fd33da9a848 100644 > > --- a/include/linux/device.h > > +++ b/include/linux/device.h > > @@ -1156,6 +1156,8 @@ enum dl_dev_state { > > * @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 { > > @@ -1163,6 +1165,7 @@ struct dev_links_info { > > struct list_head consumers; > > struct list_head needs_suppliers; > > struct list_head defer_sync; > > + bool need_for_probe; > > enum dl_dev_state status; > > }; > > > > > > > >