Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1339289ybx; Tue, 5 Nov 2019 14:30:38 -0800 (PST) X-Google-Smtp-Source: APXvYqxq32dKCSzasUV6NvOfBhZ/G7weCjF3h5EpkPaOUx88Yh5hdLLPVAEr15R2qc8Yfuuue+6L X-Received: by 2002:a17:906:4dda:: with SMTP id f26mr9326751ejw.89.1572993038781; Tue, 05 Nov 2019 14:30:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572993038; cv=none; d=google.com; s=arc-20160816; b=fcTBMVsBu2mcZaVB7SSiV8p9S4TQ2yCBJSCdrMfA6MMYvssq8Et5KXBdU7sw0soa+4 /P8WnBA0yX5LwnQ9inFNDIBCN7dwEKohDjJQzASOebLpsRmAX5KZd7RIrlz8ztfexMB2 GOqYFV1urXtuE0ZcB8nrr4PPc45vRflLoaDwccri7rjxyn1tGW14txCOEGPseJ1Mhrs/ PIBfDXiLObG5HAxhuQt8UvZKTCSW8SbfxVpARkZ58q1WS0yoMl9SMboStS7EE/y/DMEI FPgNZFeGN61x/EL2+e3e1l4y4wN62tcgpRw8ArfFiOXojzsBd38GG9T4ikoT/O8eh2G5 LurA== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=bSdnKZyCOsQ6V0NMECjeU3DrRlqbTIhvKPmzzfWGLCE=; b=rbihlaF5P3wglsZFFI8vj957PM9CPXB/nfSTWvlK5/p+IVSz4zWddZ22NiwcODCOzI mDZ9iRvE/W0OGeF2eXUhp+fsmjIkTwJ3BCqiYu/FPnS+HFTbh5yb/2hIB+S39DzoeZuG SE/mOxL0HFLAQ1p48dTrlQResK/1dTmUtM/ed4NnVf/GQvKmn0LH375EA0dXa/t33o0Y dxcSW4Du8tyTULm1tmxQLMuORJVLkQBRi3IvyYevRvQJOwqCvD144hSuLrvsZk1cLHt6 z6jGUxTrDV0S4n6q6ZL+f8Xg7dzNvhujYHkqGSJofIO7H8JqP+FRx7x66Tvq1+HRE6TW zGtA== 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 k51si9980272edb.411.2019.11.05.14.30.15; Tue, 05 Nov 2019 14:30:38 -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; 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 S2387501AbfKEW3k (ORCPT + 99 others); Tue, 5 Nov 2019 17:29:40 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:57531 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729895AbfKEW3k (ORCPT ); Tue, 5 Nov 2019 17:29:40 -0500 Received: from 79.184.254.83.ipv4.supernova.orange.pl (79.184.254.83) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.292) id c295a5493549a351; Tue, 5 Nov 2019 23:29:36 +0100 From: "Rafael J. Wysocki" To: Saravana Kannan Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Frank Rowand , Len Brown , kernel-team@android.com, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-acpi@vger.kernel.org Subject: Re: [PATCH v1 2/5] driver core: Allow a device to wait on optional suppliers Date: Tue, 05 Nov 2019 23:29:36 +0100 Message-ID: <1593797.btdyhENphq@kreacher> In-Reply-To: <20191028220027.251605-3-saravanak@google.com> References: <20191028220027.251605-1-saravanak@google.com> <20191028220027.251605-3-saravanak@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; > }; > >