From nobody Fri Nov 29 18:34:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1632310711365415.08135274116023; Wed, 22 Sep 2021 04:38:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.192573.343081 (Exim 4.92) (envelope-from ) id 1mT0Zv-0000QO-SX; Wed, 22 Sep 2021 11:38:19 +0000 Received: by outflank-mailman (output) from mailman id 192573.343081; Wed, 22 Sep 2021 11:38:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mT0Zv-0000QC-PO; Wed, 22 Sep 2021 11:38:19 +0000 Received: by outflank-mailman (input) for mailman id 192573; Wed, 22 Sep 2021 11:38:18 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mT0Zu-0008Gc-Az for xen-devel@lists.xenproject.org; Wed, 22 Sep 2021 11:38:18 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 4de2483e-8f72-40e6-8d6c-4f95e8c0774b; Wed, 22 Sep 2021 11:38:12 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6D72C11B3; Wed, 22 Sep 2021 04:38:12 -0700 (PDT) Received: from e109506.cambridge.arm.com (e109506.cambridge.arm.com [10.1.199.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 881CE3F719; Wed, 22 Sep 2021 04:38:11 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4de2483e-8f72-40e6-8d6c-4f95e8c0774b From: Rahul Singh To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, rahul.singh@arm.com, andre.przywara@arm.com, Stefano Stabellini , Julien Grall Subject: [PATCH v2 08/17] xen/device-tree: Add dt_get_pci_domain_nr helper Date: Wed, 22 Sep 2021 12:34:54 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: X-ZM-MESSAGEID: 1632310713444100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Based on tag Linux v5.14.2 commit bbdd3de144fc142f2f4b9834c9241cc4e7f3d3fc Import the Linux helper of_get_pci_domain_nr. This function will try to obtain the host bridge domain number by finding a property called "linux,pci-domain" of the given device node. Signed-off-by: Rahul Singh --- Change in v2: Patch introduced in v2 --- xen/common/device_tree.c | 12 ++++++++++++ xen/include/xen/device_tree.h | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index 53160d61f8..ea93da1725 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -2183,6 +2183,18 @@ void __init dt_unflatten_host_device_tree(void) dt_alias_scan(); } =20 +int dt_get_pci_domain_nr(struct dt_device_node *node) +{ + u32 domain; + int error; + + error =3D dt_property_read_u32(node, "linux,pci-domain", &domain); + if ( !error ) + return -EINVAL; + + return (u16)domain; +} + /* * Local variables: * mode: C diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 497144b8a7..9069040ef7 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -831,6 +831,25 @@ int dt_count_phandle_with_args(const struct dt_device_= node *np, const char *list_name, const char *cells_name); =20 +/** + * dt_get_pci_domain_nr - Find the host bridge domain number + * of the given device node. + * @node: Device tree node with the domain information. + * + * This function will try to obtain the host bridge domain number by findi= ng + * a property called "linux,pci-domain" of the given device node. + * + * Return: + * * > 0 - On success, an associated domain number. + * * -EINVAL - The property "linux,pci-domain" does not exist. + * * -ENODATA - The linux,pci-domain" property does not have value. + * * -EOVERFLOW - Invalid "linux,pci-domain" property value. + * + * Returns the associated domain number from DT in the range [0-0xffff], or + * a negative value if the required property is not found. + */ +int dt_get_pci_domain_nr(struct dt_device_node *node); + #ifdef CONFIG_DEVICE_TREE_DEBUG #define dt_dprintk(fmt, args...) \ printk(XENLOG_DEBUG fmt, ## args) --=20 2.17.1