From: Edward Pickup <Edward.Pickup@arm.com>
This patch adds a Xen boot arguments that, if enabled, causes a call to
existing code to scan pci devices enumerated by the firmware.
This will be needed ahead of dom0less support for pci passthrough on
arm.
Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
Signed-off-by: Mykyta Poturai <mykyta_poturai@epam.com>
---
(cherry picked from commit bce463e1588a45e1bfdf59fc0d5f88b16604e439 from
the downstream branch poc/pci-passthrough from
https://gitlab.com/xen-project/people/bmarquis/xen-arm-poc.git)
v1->v2:
* remove is_pci_scan_enabled wrapper
* make pci_scan_enabled ro_after_init
* drop debug prints
* drop Edward's SOB
changes since cherry-pick:
* s/always_inline/inline/
* replace additional kconfig option with config DEBUG
Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
---
docs/misc/xen-command-line.pandoc | 7 +++++++
xen/arch/arm/include/asm/pci.h | 3 +++
xen/arch/arm/pci/pci-host-common.c | 1 +
xen/arch/arm/pci/pci.c | 24 ++++++++++++++++++++++--
4 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc
index a75b6c9301..762a1a4f5f 100644
--- a/docs/misc/xen-command-line.pandoc
+++ b/docs/misc/xen-command-line.pandoc
@@ -2059,6 +2059,13 @@ This option can be specified more than once (up to 8 times at present).
Flag to enable or disable support for PCI passthrough
+### pci-scan (arm)
+> `= <boolean>`
+
+> Default: `false`
+
+Flag to enable or disable Xen PCI scan at boot.
+
### pcid (x86)
> `= <boolean> | xpti=<bool>`
diff --git a/xen/arch/arm/include/asm/pci.h b/xen/arch/arm/include/asm/pci.h
index 08ffcd4438..7289f7688b 100644
--- a/xen/arch/arm/include/asm/pci.h
+++ b/xen/arch/arm/include/asm/pci.h
@@ -23,6 +23,7 @@
#define pci_to_dev(pcidev) (&(pcidev)->arch.dev)
extern bool pci_passthrough_enabled;
+extern bool pci_scan_enabled;
struct rangeset;
@@ -155,6 +156,8 @@ bool arch_pci_device_physdevop(void);
#else /*!CONFIG_HAS_PCI*/
+#define pci_scan_enabled false
+
struct pci_dev;
static inline void arch_pci_init_pdev(struct pci_dev *pdev) {}
diff --git a/xen/arch/arm/pci/pci-host-common.c b/xen/arch/arm/pci/pci-host-common.c
index 487c545f3a..d3481b05eb 100644
--- a/xen/arch/arm/pci/pci-host-common.c
+++ b/xen/arch/arm/pci/pci-host-common.c
@@ -284,6 +284,7 @@ pci_host_common_probe(struct dt_device_node *dev,
}
pci_add_host_bridge(bridge);
+ pci_add_segment(bridge->segment);
return bridge;
diff --git a/xen/arch/arm/pci/pci.c b/xen/arch/arm/pci/pci.c
index beb1f971fa..1b34e17517 100644
--- a/xen/arch/arm/pci/pci.c
+++ b/xen/arch/arm/pci/pci.c
@@ -91,8 +91,14 @@ bool arch_pci_device_physdevop(void)
bool __read_mostly pci_passthrough_enabled;
boolean_param("pci-passthrough", pci_passthrough_enabled);
+/* By default pci scan is disabled. */
+bool __ro_after_init pci_scan_enabled;
+boolean_param("pci-scan", pci_scan_enabled);
+
static int __init pci_init(void)
{
+ int ret;
+
/*
* Enable PCI passthrough when has been enabled explicitly
* (pci-passthrough=on).
@@ -104,9 +110,23 @@ static int __init pci_init(void)
panic("Could not initialize PCI segment 0\n");
if ( acpi_disabled )
- return dt_pci_init();
+ ret = dt_pci_init();
else
- return acpi_pci_init();
+ ret = acpi_pci_init();
+
+ if ( ret < 0 )
+ return ret;
+
+ if ( pci_scan_enabled )
+ {
+ ret = scan_pci_devices();
+
+ if ( ret < 0 )
+ return ret;
+
+ }
+
+ return 0;
}
__initcall(pci_init);
--
2.34.1
On Wed, 20 Aug 2025, Mykyta Poturai wrote:
> From: Edward Pickup <Edward.Pickup@arm.com>
>
> This patch adds a Xen boot arguments that, if enabled, causes a call to
> existing code to scan pci devices enumerated by the firmware.
>
> This will be needed ahead of dom0less support for pci passthrough on
> arm.
>
> Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
> Signed-off-by: Mykyta Poturai <mykyta_poturai@epam.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
> ---
> (cherry picked from commit bce463e1588a45e1bfdf59fc0d5f88b16604e439 from
> the downstream branch poc/pci-passthrough from
> https://gitlab.com/xen-project/people/bmarquis/xen-arm-poc.git)
>
> v1->v2:
> * remove is_pci_scan_enabled wrapper
> * make pci_scan_enabled ro_after_init
> * drop debug prints
> * drop Edward's SOB
>
> changes since cherry-pick:
> * s/always_inline/inline/
> * replace additional kconfig option with config DEBUG
>
> Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
> ---
> docs/misc/xen-command-line.pandoc | 7 +++++++
> xen/arch/arm/include/asm/pci.h | 3 +++
> xen/arch/arm/pci/pci-host-common.c | 1 +
> xen/arch/arm/pci/pci.c | 24 ++++++++++++++++++++++--
> 4 files changed, 33 insertions(+), 2 deletions(-)
>
> diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc
> index a75b6c9301..762a1a4f5f 100644
> --- a/docs/misc/xen-command-line.pandoc
> +++ b/docs/misc/xen-command-line.pandoc
> @@ -2059,6 +2059,13 @@ This option can be specified more than once (up to 8 times at present).
>
> Flag to enable or disable support for PCI passthrough
>
> +### pci-scan (arm)
> +> `= <boolean>`
> +
> +> Default: `false`
> +
> +Flag to enable or disable Xen PCI scan at boot.
> +
> ### pcid (x86)
> > `= <boolean> | xpti=<bool>`
>
> diff --git a/xen/arch/arm/include/asm/pci.h b/xen/arch/arm/include/asm/pci.h
> index 08ffcd4438..7289f7688b 100644
> --- a/xen/arch/arm/include/asm/pci.h
> +++ b/xen/arch/arm/include/asm/pci.h
> @@ -23,6 +23,7 @@
> #define pci_to_dev(pcidev) (&(pcidev)->arch.dev)
>
> extern bool pci_passthrough_enabled;
> +extern bool pci_scan_enabled;
>
> struct rangeset;
>
> @@ -155,6 +156,8 @@ bool arch_pci_device_physdevop(void);
>
> #else /*!CONFIG_HAS_PCI*/
>
> +#define pci_scan_enabled false
> +
> struct pci_dev;
>
> static inline void arch_pci_init_pdev(struct pci_dev *pdev) {}
> diff --git a/xen/arch/arm/pci/pci-host-common.c b/xen/arch/arm/pci/pci-host-common.c
> index 487c545f3a..d3481b05eb 100644
> --- a/xen/arch/arm/pci/pci-host-common.c
> +++ b/xen/arch/arm/pci/pci-host-common.c
> @@ -284,6 +284,7 @@ pci_host_common_probe(struct dt_device_node *dev,
> }
>
> pci_add_host_bridge(bridge);
> + pci_add_segment(bridge->segment);
>
> return bridge;
>
> diff --git a/xen/arch/arm/pci/pci.c b/xen/arch/arm/pci/pci.c
> index beb1f971fa..1b34e17517 100644
> --- a/xen/arch/arm/pci/pci.c
> +++ b/xen/arch/arm/pci/pci.c
> @@ -91,8 +91,14 @@ bool arch_pci_device_physdevop(void)
> bool __read_mostly pci_passthrough_enabled;
> boolean_param("pci-passthrough", pci_passthrough_enabled);
>
> +/* By default pci scan is disabled. */
> +bool __ro_after_init pci_scan_enabled;
> +boolean_param("pci-scan", pci_scan_enabled);
> +
> static int __init pci_init(void)
> {
> + int ret;
> +
> /*
> * Enable PCI passthrough when has been enabled explicitly
> * (pci-passthrough=on).
> @@ -104,9 +110,23 @@ static int __init pci_init(void)
> panic("Could not initialize PCI segment 0\n");
>
> if ( acpi_disabled )
> - return dt_pci_init();
> + ret = dt_pci_init();
> else
> - return acpi_pci_init();
> + ret = acpi_pci_init();
> +
> + if ( ret < 0 )
> + return ret;
> +
> + if ( pci_scan_enabled )
> + {
> + ret = scan_pci_devices();
> +
> + if ( ret < 0 )
> + return ret;
> +
> + }
> +
> + return 0;
> }
> __initcall(pci_init);
>
> --
> 2.34.1
>
© 2016 - 2025 Red Hat, Inc.