[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 17/17] xen/arm: Add linux,pci-domain property for hwdom if not available.


  • To: Rahul Singh <Rahul.Singh@xxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Wed, 29 Sep 2021 13:42:35 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=GK6htvme9xg7hSsrL/AXnqo3AzT3yL+ksC2ZRu1U1qg=; b=FtGMC0aBXYDehbEir/MVTetpuX2CDW8PFfdMzOO8e1MZrhjVr+Ps7ifMRD4rbqwYV4c4bv8+Fn+gHFaFoDYg5VIjy6ebc89QwtuFDIeB/yHa+fUSGwZjNocZc8jG2fITy0EJ+kzEb2kq7PYyVT1/DDLNSFYFzsCwCOELhbxbbDQ81RFkPZr/pSbZZnHAbIWla+//L+yJ2Hh+GbWaQd5M+KOzg+0drStgSjDDcpJNm9ThD4WQkkAgqVK7YNp1k1dIZEAPDeeTAurbPxaCCRe1tCP4JgI19qM294wzsnU1Xhc/ItZnFpGh7YlOPjejxBeov4PPj6mqqwWVtd8PWUNOWQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kTo9e3USnb24yQS2GGeRJYqBEAt9FYuw07O+0KcFsuJRYCU2fdNm9dJOWP0a4RKXWPdHoISjiWODkCMYeF9Pep1wc0qIReCLim+wihSS042IcmLht7a+oXwOH1d43cpA83cpltNZf4LhbgW6DECJHPxVdOAIhLljjPG96uO4SmxE0N/Pf8/7UQ0iBVcU/3Ni+ypVcaO1u8jaN8/zquNCbGjP/qsQBZ7JT4OjY2w27vnMgzXe5EfClTKrbn1M6Z2/mX3ySLpdBhE5tqCDnYVejHrMQBK6dvghN3fT0VmspCjujvaxkcOnwV9WyRfZnjUxOvziWBZa063T3L0Dvyw+Qw==
  • Authentication-results-original: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com;
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andre Przywara <Andre.Przywara@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Wed, 29 Sep 2021 13:42:55 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHXtJYkOb3La5Yps0eoFpxXuc4i76u7BooA
  • Thread-topic: [PATCH v3 17/17] xen/arm: Add linux,pci-domain property for hwdom if not available.

Hi Rahul,

> On 28 Sep 2021, at 19:18, Rahul Singh <rahul.singh@xxxxxxx> 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@xxxxxxx>
Reviewed-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>

Cheers
Bertrand

> ---
> Change in v3:
> - Use is_pci_passthrough_enabled()
> 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 1731ae2028..026c9e5c6c 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 ( is_pci_passthrough_enabled() && dt_device_type_is_equal(node, 
> "pci") )
> +    {
> +        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 c5941b10e9..593beeb48c 100644
> --- a/xen/arch/arm/pci/pci-host-common.c
> +++ b/xen/arch/arm/pci/pci-host-common.c
> @@ -255,6 +255,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 5532ce3977..7cb2e2f1ed 100644
> --- a/xen/include/asm-arm/pci.h
> +++ b/xen/include/asm-arm/pci.h
> @@ -90,6 +90,8 @@ int pci_generic_config_write(struct pci_host_bridge 
> *bridge, pci_sbdf_t sbdf,
> void __iomem *pci_ecam_map_bus(struct pci_host_bridge *bridge,
>                                pci_sbdf_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)
> {
> @@ -104,5 +106,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
> 




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.