Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2176614ybc; Sun, 17 Nov 2019 15:33:27 -0800 (PST) X-Google-Smtp-Source: APXvYqwJy7A8zgT0Nkj3XRpnj2eXd232ucbwqoyv5x11kNDNbu5as1A4Q5LOBvyZs9f0WkJ5hhB+ X-Received: by 2002:a17:906:1b41:: with SMTP id p1mr21787811ejg.65.1574033607160; Sun, 17 Nov 2019 15:33:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574033607; cv=none; d=google.com; s=arc-20160816; b=PiLy92mzYr7e4LkKtwQLisCpkB17MS9Lt7JPjapj6/44lWI+7HNOmbFlPwXz+BHno0 MC6P5/z7ojwmpNdbZUc5T4XY3YSjJrXfOjd8jZgK3rgE6psO7q+v55g6SWppQ9MSMksi oj+B0vr6a9LKnIIcWLruyUr7WrdfEHXXCjJvue2awC0XOghx5tQGvPQPNf7JqWq2WlhA 2jc9qd3GFS1SIeb3KtSzpoj/1kkRjeb1stYNCccwwhQh3y0PIpM6AQMIB+K7ndby5Wa+ bcG//Ew9+XJOZ/bindVqKiUsXLYRFuHs7U9HXvH0s3tcHAvgMymcPfNCWoO2OsjnCxKv 5SHg== 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=dLrDRkj2zG6C0Hi1gLXOXE5rXliBuMxaQzf1Hg9z/Qg=; b=ta/YM3ase1YGXe2JW3Q9a1TomFmeh4SBIAfhDWDmM2jeb+CLZeFcXJydf3o6auop2/ 1TH1MlsI4T5RNDuAKsiEtGgABjmVCM4/xeWFvg8rksA0mx/8BwBSClSp6BB/Gy7n/J4F vWGdMeF1UaMx4+KvuBOL5KcFm+gfe2SeIO2ptJWBUxL1NYsiNBnAn1MQISRGSEGAn+Vl ygnocY9ioMTfo54F4yuAwEi+FkhQRGEy5aucTDLOvQJZ/0pLAhorzKATnPXSgQ45kAti 58ZzEMp+gXF15ukiGCdppg6SxYOv0X5fhzNPaaxDCRy8Zs2uIX8ComPnesKyTg2sWuLX jhkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kudzu-us.20150623.gappssmtp.com header.s=20150623 header.b=gYh+9VSU; 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 q8si10583415ejt.321.2019.11.17.15.33.02; Sun, 17 Nov 2019 15:33:27 -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=@kudzu-us.20150623.gappssmtp.com header.s=20150623 header.b=gYh+9VSU; 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 S1726703AbfKQX2u (ORCPT + 99 others); Sun, 17 Nov 2019 18:28:50 -0500 Received: from mail-io1-f67.google.com ([209.85.166.67]:36267 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726647AbfKQX2t (ORCPT ); Sun, 17 Nov 2019 18:28:49 -0500 Received: by mail-io1-f67.google.com with SMTP id s3so16662050ioe.3 for ; Sun, 17 Nov 2019 15:28:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kudzu-us.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dLrDRkj2zG6C0Hi1gLXOXE5rXliBuMxaQzf1Hg9z/Qg=; b=gYh+9VSU3l4JVqt7hplEMsElL8VkPwE3YKqeud/6Qamz54Bqa5bUEI2hdqqRj1+0qD mgizE4qAgP4QiuDnYFZY9+LhcvZ9fQHAhELmwhPhT389qflgg6KEQnPvA+vOyssJ2286 pRWjtD1ccCNpG1WdvVtJXVeRAynl5jARO0KnwDv6axkO5RjjIGKkBF/78E7PneIH8Oxy XyH6+MEcDXY/ZPOv9DsUM5ln9kqpUbZ6b0FkU8X3aPuH5V0ykBqIvGxrKSwfugItXmvi xZDVrpCj87Z3ERq3F21ApStSI0d0hxWokdEEjsUlefXLRrFp2gpyuvNLmGCPux38jQF+ 5r3g== 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=dLrDRkj2zG6C0Hi1gLXOXE5rXliBuMxaQzf1Hg9z/Qg=; b=k9MLdjFUxdfjge/8YSsPMtwIJKshD/HmjsqMAp5ujxUF0ueut296ow0dC0v7m54WRg AVzKfmK2XBTErs+k5gxUdPAXY1S2hlt31MXGFc4HyKH7lUe8PKAdOAMlVRrgEB2Fv67Z DzppmLWi1vyhMlTcoVY2A4f6s3tT4PBdBd2xiYn2nqi+DBW05hPXx8cBvNcNuryigyUx M3pDjKL8nveKdN2Jmujp6dyoDobn+5q0HhQ1C8DcpTssjq2/4sGo0LSTHu+1fofOBHYw dqQXHtO6VAbFayRX8RKx0VyaNr/iSoGL0dCYmYDPjSUJGHlerWQT98K4yEeX7Gy73YhQ 3XFg== X-Gm-Message-State: APjAAAV55Tr5gWE7cOMmoX4XokVJNQQVsdzQ8rObxZs2FtC8TELAH/82 25NA5SovD+k+HSxbbs1Et0UlASBDicyJGycZHXDGeg== X-Received: by 2002:a02:a38f:: with SMTP id y15mr10835809jak.101.1574033326865; Sun, 17 Nov 2019 15:28:46 -0800 (PST) MIME-Version: 1.0 References: <20190926112933.8922-1-kishon@ti.com> <20190926112933.8922-6-kishon@ti.com> In-Reply-To: <20190926112933.8922-6-kishon@ti.com> From: Jon Mason Date: Sun, 17 Nov 2019 18:28:36 -0500 Message-ID: Subject: Re: [RFC PATCH 05/21] PCI: endpoint: Add API to get reference to EPC from device-tree To: Kishon Vijay Abraham I Cc: Bjorn Helgaas , Jonathan Corbet , Rob Herring , Dave Jiang , Allen Hubbe , Lorenzo Pieralisi , Mark Rutland , linux-pci@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel , devicetree@vger.kernel.org, linux-ntb 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 On Thu, Sep 26, 2019 at 7:31 AM 'Kishon Vijay Abraham I' via linux-ntb wrote: > > Add of_pci_epc_get() and of_pci_epc_get_by_name() to get reference > to EPC from device-tree. This is added in preparation to define > an endpoint function from device tree. I can't get this patch to apply cleanly to my git tree (for the current or any of the previous kernels I tried). Please rebase this series when you send it out as a patch. Thanks, Jon > Signed-off-by: Kishon Vijay Abraham I > --- > drivers/pci/endpoint/pci-epc-core.c | 61 +++++++++++++++++++++++++++++ > include/linux/pci-epc.h | 4 +- > 2 files changed, 64 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c > index 5bc094093a47..0c2fdd39090c 100644 > --- a/drivers/pci/endpoint/pci-epc-core.c > +++ b/drivers/pci/endpoint/pci-epc-core.c > @@ -83,6 +83,66 @@ struct pci_epc *pci_epc_get(const char *epc_name) > } > EXPORT_SYMBOL_GPL(pci_epc_get); > > +/** > + * of_pci_epc_get() - get PCI endpoint controller from device node and index > + * @node: device node which contains the phandle to endpoint controller > + * @index: index of the endpoint controller in "epcs" property > + * > + * Returns the EPC corresponding to the _index_ entry in "epcs" property > + * present in device node, after getting a refcount to it or -ENODEV if > + * there is no such EPC or -EPROBE_DEFER if there is a phandle to the phy, > + * but the device is not yet loaded. > + */ > +struct pci_epc *of_pci_epc_get(struct device_node *node, int index) > +{ > + struct device_node *epc_node; > + struct class_dev_iter iter; > + struct pci_epc *epc; > + struct device *dev; > + > + epc_node = of_parse_phandle(node, "epcs", index); > + if (!epc_node) > + return ERR_PTR(-ENODEV); > + > + class_dev_iter_init(&iter, pci_epc_class, NULL, NULL); > + while ((dev = class_dev_iter_next(&iter))) { > + epc = to_pci_epc(dev); > + if (epc_node != epc->dev.of_node) > + continue; > + > + of_node_put(epc_node); > + class_dev_iter_exit(&iter); > + get_device(&epc->dev); > + return epc; > + } > + > + of_node_put(node); > + class_dev_iter_exit(&iter); > + return ERR_PTR(-EPROBE_DEFER); > +} > +EXPORT_SYMBOL_GPL(of_pci_epc_get); > + > +/** > + * of_pci_epc_get_by_name() - get PCI endpoint controller from device node > + * and string > + * @node: device node which contains the phandle to endpoint controller > + * @epc_name: name of endpoint controller as present in "epc-names" property > + * > + * Returns the EPC corresponding to the epc_name in "epc-names" property > + * present in device node. > + */ > +struct pci_epc *of_pci_epc_get_by_name(struct device_node *node, > + const char *epc_name) > +{ > + int index = 0; > + > + if (epc_name) > + index = of_property_match_string(node, "epc-names", epc_name); > + > + return of_pci_epc_get(node, index); > +} > +EXPORT_SYMBOL_GPL(of_pci_epc_get_by_name); > + > /** > * pci_epc_get_first_free_bar() - helper to get first unreserved BAR > * @epc_features: pci_epc_features structure that holds the reserved bar bitmap > @@ -661,6 +721,7 @@ __pci_epc_create(struct device *dev, const struct pci_epc_ops *ops, > device_initialize(&epc->dev); > epc->dev.class = pci_epc_class; > epc->dev.parent = dev; > + epc->dev.of_node = dev->of_node; > epc->ops = ops; > > ret = dev_set_name(&epc->dev, "%s", dev_name(dev)); > diff --git a/include/linux/pci-epc.h b/include/linux/pci-epc.h > index 0fff52675a6b..ef6531af6ed2 100644 > --- a/include/linux/pci-epc.h > +++ b/include/linux/pci-epc.h > @@ -202,7 +202,9 @@ unsigned int pci_epc_get_first_free_bar(const struct pci_epc_features > *epc_features); > struct pci_epc *pci_epc_get(const char *epc_name); > void pci_epc_put(struct pci_epc *epc); > - > +struct pci_epc *of_pci_epc_get(struct device_node *node, int index); > +struct pci_epc *of_pci_epc_get_by_name(struct device_node *node, > + const char *epc_name); > int __pci_epc_mem_init(struct pci_epc *epc, phys_addr_t phys_addr, size_t size, > size_t page_size); > void pci_epc_mem_exit(struct pci_epc *epc); > -- > 2.17.1 > > -- > You received this message because you are subscribed to the Google Groups "linux-ntb" group. > To unsubscribe from this group and stop receiving emails from it, send an email to linux-ntb+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/linux-ntb/20190926112933.8922-6-kishon%40ti.com.