From nobody Fri Nov 29 19:37:01 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 1632853318831588.3355575576051; Tue, 28 Sep 2021 11:21:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.198249.351640 (Exim 4.92) (envelope-from ) id 1mVHje-0002JJ-Cl; Tue, 28 Sep 2021 18:21:46 +0000 Received: by outflank-mailman (output) from mailman id 198249.351640; Tue, 28 Sep 2021 18:21:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVHje-0002JC-9q; Tue, 28 Sep 2021 18:21:46 +0000 Received: by outflank-mailman (input) for mailman id 198249; Tue, 28 Sep 2021 18:21:45 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVHjd-0002Ii-4Q for xen-devel@lists.xenproject.org; Tue, 28 Sep 2021 18:21:45 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 6ae4ebc5-0c61-4d20-af29-907f25ad8507; Tue, 28 Sep 2021 18:21:44 +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 DAB296D; Tue, 28 Sep 2021 11:21:43 -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 014CB3F793; Tue, 28 Sep 2021 11:21:42 -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: 6ae4ebc5-0c61-4d20-af29-907f25ad8507 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 v3 08/17] xen/device-tree: Add dt_get_pci_domain_nr helper Date: Tue, 28 Sep 2021 19:18:17 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: X-ZM-MESSAGEID: 1632853320537100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Based Linux commit 41e5c0f81d3e676d671d96a0a1fafb27abfbd9d7 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 Reviewed-by: Bertrand Marquis Reviewed-by: Stefano Stabellini --- Change in v3: - Modify commit message to include upstream Linux commit-id not stable Linux commit-id - Remove return value as those are not valid for XEN Change in v2: Patch introduced in v2 --- xen/common/device_tree.c | 12 ++++++++++++ xen/include/xen/device_tree.h | 17 +++++++++++++++++ 2 files changed, 29 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 3ffe3eb3d2..2297c59ce6 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -832,6 +832,23 @@ 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. + * + * 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