[PATCH v3 05/11] xen/arm: Mark device as PCI while creating one

Oleksandr Andrushchenko posted 11 patches 3 years, 2 months ago
There is a newer version of this series
[PATCH v3 05/11] xen/arm: Mark device as PCI while creating one
Posted by Oleksandr Andrushchenko 3 years, 2 months ago
From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>

While adding a PCI device mark it as such, so other frameworks
can distinguish it from DT devices.
For that introduce an architecture defined helper which may perform
additional initialization of the newly created PCI device.

Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
---
Since v2:
 - !! dropped Stefano's r-b because of the changes
 - introduced arch_pci_init_pdev (Jan)
Since v1:
 - moved the assignment from iommu_add_device to alloc_pdev
---
 xen/arch/arm/pci/pci.c        | 5 +++++
 xen/drivers/passthrough/pci.c | 2 ++
 xen/include/asm-arm/pci.h     | 5 +++++
 xen/include/asm-x86/pci.h     | 2 ++
 4 files changed, 14 insertions(+)

diff --git a/xen/arch/arm/pci/pci.c b/xen/arch/arm/pci/pci.c
index 9fc522e566a9..a8d10e869603 100644
--- a/xen/arch/arm/pci/pci.c
+++ b/xen/arch/arm/pci/pci.c
@@ -34,6 +34,11 @@ struct pci_dev *dev_to_pci(struct device *dev)
     return container_of(dev, struct pci_dev, arch.dev);
 }
 
+void arch_pci_init_pdev(struct pci_dev *pdev)
+{
+    pci_to_dev(pdev)->type = DEV_PCI;
+}
+
 static int __init dt_pci_init(void)
 {
     struct dt_device_node *np;
diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
index 38eb451448a3..9f804a50e780 100644
--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -329,6 +329,8 @@ static struct pci_dev *alloc_pdev(struct pci_seg *pseg, u8 bus, u8 devfn)
     *((u8*) &pdev->devfn) = devfn;
     pdev->domain = NULL;
 
+    arch_pci_init_pdev(pdev);
+
     rc = pdev_msi_init(pdev);
     if ( rc )
     {
diff --git a/xen/include/asm-arm/pci.h b/xen/include/asm-arm/pci.h
index e6d4000e2ac8..566a9436a18e 100644
--- a/xen/include/asm-arm/pci.h
+++ b/xen/include/asm-arm/pci.h
@@ -105,6 +105,9 @@ static always_inline bool is_pci_passthrough_enabled(void)
 {
     return pci_passthrough_enabled;
 }
+
+void arch_pci_init_pdev(struct pci_dev *pdev);
+
 #else   /*!CONFIG_HAS_PCI*/
 
 struct arch_pci_dev { };
@@ -121,5 +124,7 @@ static inline int pci_get_host_bridge_segment(const struct dt_device_node *node,
     return -EINVAL;
 }
 
+static inline void arch_pci_init_pdev(struct pci_dev *pdev) {}
+
 #endif  /*!CONFIG_HAS_PCI*/
 #endif /* __ARM_PCI_H__ */
diff --git a/xen/include/asm-x86/pci.h b/xen/include/asm-x86/pci.h
index 61b940c91d4a..e7f10beb4eb8 100644
--- a/xen/include/asm-x86/pci.h
+++ b/xen/include/asm-x86/pci.h
@@ -38,4 +38,6 @@ static always_inline bool is_pci_passthrough_enabled(void)
     return true;
 }
 
+static inline void arch_pci_init_pdev(struct pci_dev *pdev) {}
+
 #endif /* __X86_PCI_H__ */
-- 
2.25.1


Re: [PATCH v3 05/11] xen/arm: Mark device as PCI while creating one
Posted by Jan Beulich 3 years, 2 months ago
On 30.09.2021 09:13, Oleksandr Andrushchenko wrote:
> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
> 
> While adding a PCI device mark it as such, so other frameworks
> can distinguish it from DT devices.
> For that introduce an architecture defined helper which may perform
> additional initialization of the newly created PCI device.
> 
> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>

Applicable parts
Acked-by: Jan Beulich <jbeulich@suse.com>

Jan


Re: [PATCH v3 05/11] xen/arm: Mark device as PCI while creating one
Posted by Stefano Stabellini 3 years, 2 months ago
On Thu, 30 Sep 2021, Oleksandr Andrushchenko wrote:
> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
> 
> While adding a PCI device mark it as such, so other frameworks
> can distinguish it from DT devices.
> For that introduce an architecture defined helper which may perform
> additional initialization of the newly created PCI device.
> 
> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>

I get a build failure without CONFIG_PCI on ARM64:

In file included from /local/repos/xen-upstream/xen/include/xen/pci.h:66:0,
                 from /local/repos/xen-upstream/xen/include/xen/iommu.h:25,
                 from /local/repos/xen-upstream/xen/include/xen/sched.h:12,
                 from arch/arm/arm64/asm-offsets.c:9:
/local/repos/xen-upstream/xen/include/asm/pci.h:127:46: error: ‘struct pci_dev’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
 static inline void arch_pci_init_pdev(struct pci_dev *pdev) {}
                                              ^~~~~~~
cc1: all warnings being treated as errors


> ---
> Since v2:
>  - !! dropped Stefano's r-b because of the changes
>  - introduced arch_pci_init_pdev (Jan)
> Since v1:
>  - moved the assignment from iommu_add_device to alloc_pdev
> ---
>  xen/arch/arm/pci/pci.c        | 5 +++++
>  xen/drivers/passthrough/pci.c | 2 ++
>  xen/include/asm-arm/pci.h     | 5 +++++
>  xen/include/asm-x86/pci.h     | 2 ++
>  4 files changed, 14 insertions(+)
> 
> diff --git a/xen/arch/arm/pci/pci.c b/xen/arch/arm/pci/pci.c
> index 9fc522e566a9..a8d10e869603 100644
> --- a/xen/arch/arm/pci/pci.c
> +++ b/xen/arch/arm/pci/pci.c
> @@ -34,6 +34,11 @@ struct pci_dev *dev_to_pci(struct device *dev)
>      return container_of(dev, struct pci_dev, arch.dev);
>  }
>  
> +void arch_pci_init_pdev(struct pci_dev *pdev)
> +{
> +    pci_to_dev(pdev)->type = DEV_PCI;
> +}
> +
>  static int __init dt_pci_init(void)
>  {
>      struct dt_device_node *np;
> diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
> index 38eb451448a3..9f804a50e780 100644
> --- a/xen/drivers/passthrough/pci.c
> +++ b/xen/drivers/passthrough/pci.c
> @@ -329,6 +329,8 @@ static struct pci_dev *alloc_pdev(struct pci_seg *pseg, u8 bus, u8 devfn)
>      *((u8*) &pdev->devfn) = devfn;
>      pdev->domain = NULL;
>  
> +    arch_pci_init_pdev(pdev);
> +
>      rc = pdev_msi_init(pdev);
>      if ( rc )
>      {
> diff --git a/xen/include/asm-arm/pci.h b/xen/include/asm-arm/pci.h
> index e6d4000e2ac8..566a9436a18e 100644
> --- a/xen/include/asm-arm/pci.h
> +++ b/xen/include/asm-arm/pci.h
> @@ -105,6 +105,9 @@ static always_inline bool is_pci_passthrough_enabled(void)
>  {
>      return pci_passthrough_enabled;
>  }
> +
> +void arch_pci_init_pdev(struct pci_dev *pdev);
> +
>  #else   /*!CONFIG_HAS_PCI*/
>  
>  struct arch_pci_dev { };
> @@ -121,5 +124,7 @@ static inline int pci_get_host_bridge_segment(const struct dt_device_node *node,
>      return -EINVAL;
>  }
>  
> +static inline void arch_pci_init_pdev(struct pci_dev *pdev) {}
> +
>  #endif  /*!CONFIG_HAS_PCI*/
>  #endif /* __ARM_PCI_H__ */
> diff --git a/xen/include/asm-x86/pci.h b/xen/include/asm-x86/pci.h
> index 61b940c91d4a..e7f10beb4eb8 100644
> --- a/xen/include/asm-x86/pci.h
> +++ b/xen/include/asm-x86/pci.h
> @@ -38,4 +38,6 @@ static always_inline bool is_pci_passthrough_enabled(void)
>      return true;
>  }
>  
> +static inline void arch_pci_init_pdev(struct pci_dev *pdev) {}
> +
>  #endif /* __X86_PCI_H__ */
> -- 
> 2.25.1
> 
Re: [PATCH v3 05/11] xen/arm: Mark device as PCI while creating one
Posted by Oleksandr Andrushchenko 3 years, 2 months ago

On 01.10.21 03:34, Stefano Stabellini wrote:
> On Thu, 30 Sep 2021, Oleksandr Andrushchenko wrote:
>> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
>>
>> While adding a PCI device mark it as such, so other frameworks
>> can distinguish it from DT devices.
>> For that introduce an architecture defined helper which may perform
>> additional initialization of the newly created PCI device.
>>
>> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
> I get a build failure without CONFIG_PCI on ARM64:
>
> In file included from /local/repos/xen-upstream/xen/include/xen/pci.h:66:0,
>                   from /local/repos/xen-upstream/xen/include/xen/iommu.h:25,
>                   from /local/repos/xen-upstream/xen/include/xen/sched.h:12,
>                   from arch/arm/arm64/asm-offsets.c:9:
> /local/repos/xen-upstream/xen/include/asm/pci.h:127:46: error: ‘struct pci_dev’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
>   static inline void arch_pci_init_pdev(struct pci_dev *pdev) {}
>                                                ^~~~~~~
> cc1: all warnings being treated as errors
Ah, this then needs to be
struct pci_dev;

static inline void arch_pci_init_pdev(struct pci_dev *pdev) {}

Jan, as this is going to be Arm change, so can I keep your Ack please?

Thank you,
Oleksandr
Re: [PATCH v3 05/11] xen/arm: Mark device as PCI while creating one
Posted by Jan Beulich 3 years, 2 months ago
On 01.10.2021 09:11, Oleksandr Andrushchenko wrote:
> On 01.10.21 03:34, Stefano Stabellini wrote:
>> On Thu, 30 Sep 2021, Oleksandr Andrushchenko wrote:
>>> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
>>>
>>> While adding a PCI device mark it as such, so other frameworks
>>> can distinguish it from DT devices.
>>> For that introduce an architecture defined helper which may perform
>>> additional initialization of the newly created PCI device.
>>>
>>> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
>> I get a build failure without CONFIG_PCI on ARM64:
>>
>> In file included from /local/repos/xen-upstream/xen/include/xen/pci.h:66:0,
>>                   from /local/repos/xen-upstream/xen/include/xen/iommu.h:25,
>>                   from /local/repos/xen-upstream/xen/include/xen/sched.h:12,
>>                   from arch/arm/arm64/asm-offsets.c:9:
>> /local/repos/xen-upstream/xen/include/asm/pci.h:127:46: error: ‘struct pci_dev’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
>>   static inline void arch_pci_init_pdev(struct pci_dev *pdev) {}
>>                                                ^~~~~~~
>> cc1: all warnings being treated as errors
> Ah, this then needs to be
> struct pci_dev;
> 
> static inline void arch_pci_init_pdev(struct pci_dev *pdev) {}
> 
> Jan, as this is going to be Arm change, so can I keep your Ack please?

Of course you can, and me having said anyway "Applicable parts" makes
me wonder why you ask. The ack clearly doesn't extend to Arm code; I
can't give (valid) acks for code I'm not a maintainer of. This would
be different for R-b, though.

Jan