All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Stabellini <sstabellini@kernel.org>
To: Rahul Singh <rahul.singh@arm.com>
Cc: xen-devel@lists.xenproject.org, bertrand.marquis@arm.com,
	 andre.przywara@arm.com,
	Stefano Stabellini <sstabellini@kernel.org>,
	 Julien Grall <julien@xen.org>,
	 Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: Re: [PATCH v2 17/17] xen/arm: Add linux,pci-domain property for hwdom if not available.
Date: Wed, 22 Sep 2021 19:52:41 -0700 (PDT)	[thread overview]
Message-ID: <alpine.DEB.2.21.2109221948300.17979@sstabellini-ThinkPad-T480s> (raw)
In-Reply-To: <e1b8d878709dc8e93a3bb340f921a24976cebb57.1632307952.git.rahul.singh@arm.com>

On Wed, 22 Sep 2021, Rahul Singh wrote:
> If the property is not present in the device tree node for host bridge,
> XEN while creating the dtb for hwdom will create this property and
> assigns the already allocated segment to the host bridge
> so that XEN and linux will have the same segment for the host bridges.
> 
> Signed-off-by: Rahul Singh <rahul.singh@arm.com>
> ---
> Change in v2:
> - Add linux,pci-domain only when pci-passthrough command line option is enabeld
> ---
>  xen/arch/arm/domain_build.c        | 16 ++++++++++++++++
>  xen/arch/arm/pci/pci-host-common.c | 21 +++++++++++++++++++++
>  xen/include/asm-arm/pci.h          |  9 +++++++++
>  3 files changed, 46 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 5eb83b12a1..83ab0d52cc 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -743,6 +743,22 @@ static int __init write_properties(struct domain *d, struct kernel_info *kinfo,
>              return res;
>      }
>  
> +    if ( pci_passthrough_enabled && dt_device_type_is_equal(node, "pci") )

Please use the accessor function is_pci_passthrough_enabled


> +    {
> +        if ( !dt_find_property(node, "linux,pci-domain", NULL) )
> +        {
> +            uint16_t segment;
> +
> +            res = pci_get_host_bridge_segment(node, &segment);
> +            if ( res < 0 )
> +                return res;
> +
> +            res = fdt_property_cell(kinfo->fdt, "linux,pci-domain", segment);
> +            if ( res )
> +                return res;
> +        }
> +    }
> +
>      /*
>       * Override the property "status" to disable the device when it's
>       * marked for passthrough.
> diff --git a/xen/arch/arm/pci/pci-host-common.c b/xen/arch/arm/pci/pci-host-common.c
> index 3bdc336268..a88f20175e 100644
> --- a/xen/arch/arm/pci/pci-host-common.c
> +++ b/xen/arch/arm/pci/pci-host-common.c
> @@ -262,6 +262,27 @@ struct pci_host_bridge *pci_find_host_bridge(uint16_t segment, uint8_t bus)
>  
>      return NULL;
>  }
> +
> +/*
> + * This function will lookup an hostbridge based on config space address.
> + */
> +int pci_get_host_bridge_segment(const struct dt_device_node *node,
> +                                uint16_t *segment)
> +{
> +    struct pci_host_bridge *bridge;
> +
> +    list_for_each_entry( bridge, &pci_host_bridges, node )
> +    {
> +        if ( bridge->dt_node != node )
> +            continue;
> +
> +        *segment = bridge->segment;
> +        return 0;
> +    }
> +
> +    return -EINVAL;
> +}
> +
>  /*
>   * Local variables:
>   * mode: C
> diff --git a/xen/include/asm-arm/pci.h b/xen/include/asm-arm/pci.h
> index 9327b7488e..9edc6bc5ae 100644
> --- a/xen/include/asm-arm/pci.h
> +++ b/xen/include/asm-arm/pci.h
> @@ -94,6 +94,8 @@ int pci_generic_config_write(struct pci_host_bridge *bridge, uint32_t sbdf,
>  void __iomem *pci_ecam_map_bus(struct pci_host_bridge *bridge,
>                                 uint32_t sbdf, uint32_t where);
>  struct pci_host_bridge *pci_find_host_bridge(uint16_t segment, uint8_t bus);
> +int pci_get_host_bridge_segment(const struct dt_device_node *node,
> +                                uint16_t *segment);
>  
>  static always_inline bool is_pci_passthrough_enabled(void)
>  {
> @@ -110,5 +112,12 @@ static always_inline bool is_pci_passthrough_enabled(void)
>      return false;
>  }
>  
> +static inline int pci_get_host_bridge_segment(const struct dt_device_node *node,
> +                                              uint16_t *segment)
> +{
> +    ASSERT_UNREACHABLE();
> +    return -EINVAL;
> +}
> +
>  #endif  /*!CONFIG_HAS_PCI*/
>  #endif /* __ARM_PCI_H__ */
> -- 
> 2.17.1
> 


  reply	other threads:[~2021-09-23  2:52 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-22 11:34 [PATCH v2 00/17] PCI devices passthrough on Arm Rahul Singh
2021-09-22 11:34 ` [PATCH v2 01/17] xen/pci: Refactor MSI code that implements MSI functionality within XEN Rahul Singh
2021-09-22 11:34 ` [PATCH v2 02/17] xen/pci: solve compilation error on ARM with HAS_PCI enabled Rahul Singh
2021-09-22 22:04   ` Stefano Stabellini
2021-09-23  2:07   ` Julien Grall
2021-09-23 11:14     ` Rahul Singh
2021-09-22 11:34 ` [PATCH v2 03/17] xen/arm: solve compilation error on ARM with ACPI && HAS_PCI Rahul Singh
2021-09-22 22:08   ` Stefano Stabellini
2021-09-22 11:34 ` [PATCH v2 04/17] xen/arm: xc_domain_ioport_permission(..) not supported on ARM Rahul Singh
2021-09-22 22:13   ` Stefano Stabellini
2021-09-22 11:34 ` [PATCH v2 05/17] xen/arm: Add PHYSDEVOP_pci_device_* support for ARM Rahul Singh
2021-09-22 22:37   ` Stefano Stabellini
2021-09-23 11:19     ` Rahul Singh
2021-09-22 11:34 ` [PATCH v2 06/17] xen/device-tree: Add dt_property_read_variable_u32_array helper Rahul Singh
2021-09-22 23:06   ` Stefano Stabellini
2021-09-23 11:21     ` Rahul Singh
2021-09-22 11:34 ` [PATCH v2 07/17] xen/device-tree: Add dt_property_read_u32_array helper Rahul Singh
2021-09-22 23:44   ` Stefano Stabellini
2021-09-22 11:34 ` [PATCH v2 08/17] xen/device-tree: Add dt_get_pci_domain_nr helper Rahul Singh
2021-09-22 23:50   ` Stefano Stabellini
2021-09-23 11:52     ` Rahul Singh
2021-09-22 11:34 ` [PATCH v2 09/17] xen/arm: Add support for PCI init to initialize the PCI driver Rahul Singh
2021-09-23  0:03   ` Stefano Stabellini
2021-09-23 14:53     ` Rahul Singh
2021-09-22 11:34 ` [PATCH v2 10/17] xen/arm: Add cmdline boot option "pci-passthrough = <boolean>" Rahul Singh
2021-09-23  0:14   ` Stefano Stabellini
2021-09-23 15:03     ` Rahul Singh
2021-09-22 11:34 ` [PATCH v2 11/17] xen/arm: PCI host bridge discovery within XEN on ARM Rahul Singh
2021-09-23  2:09   ` Stefano Stabellini
2021-09-23 13:03     ` Oleksandr Andrushchenko
2021-09-23 15:36       ` Stefano Stabellini
2021-09-23 17:08     ` Rahul Singh
2021-09-23 19:12       ` Stefano Stabellini
2021-09-24 12:54         ` Rahul Singh
2021-09-24 21:42           ` Stefano Stabellini
2021-09-24 23:26             ` Stefano Stabellini
2021-09-27 16:20               ` Rahul Singh
2021-09-27 16:59             ` Julien Grall
2021-09-22 11:34 ` [PATCH v2 12/17] xen/arm: Add support for Xilinx ZynqMP PCI host controller Rahul Singh
2021-09-23  2:11   ` Stefano Stabellini
2021-09-23 15:08     ` Rahul Singh
2021-09-22 11:34 ` [PATCH v2 13/17] xen:arm: Implement pci access functions Rahul Singh
2021-09-23  2:23   ` Stefano Stabellini
2021-09-23  8:52     ` Julien Grall
2021-09-23 15:17       ` Rahul Singh
2021-09-23  9:02     ` Julien Grall
2021-09-23 15:19       ` Rahul Singh
2021-09-23 15:15     ` Rahul Singh
2021-09-22 11:35 ` [PATCH v2 14/17] xen/arm: Enable the existing x86 virtual PCI support for ARM Rahul Singh
2021-09-23  2:41   ` Stefano Stabellini
2021-09-23 15:34     ` Rahul Singh
2021-09-24  7:21       ` Oleksandr Andrushchenko
2021-09-24  7:37     ` Jan Beulich
2021-09-24  7:44   ` Jan Beulich
2021-09-28 16:32     ` Rahul Singh
2021-09-22 11:35 ` [PATCH v2 15/17] xen/arm: Transitional change to build HAS_VPCI on ARM Rahul Singh
2021-09-22 11:35 ` [PATCH v2 16/17] arm/libxl: Emulated PCI device tree node in libxl Rahul Singh
2021-09-23 20:41   ` Stefano Stabellini
2021-09-22 11:35 ` [PATCH v2 17/17] xen/arm: Add linux,pci-domain property for hwdom if not available Rahul Singh
2021-09-23  2:52   ` Stefano Stabellini [this message]
2021-09-23 15:21     ` Rahul Singh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.21.2109221948300.17979@sstabellini-ThinkPad-T480s \
    --to=sstabellini@kernel.org \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=andre.przywara@arm.com \
    --cc=bertrand.marquis@arm.com \
    --cc=julien@xen.org \
    --cc=rahul.singh@arm.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.