|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [RFC PATCH 1/2] pci: Allow platforms to modify BAR adresses
On Tue, Apr 21, 2026 at 07:57:14AM +0000, Mykyta Poturai wrote:
> This patch is a preparatory work for adding Region ID support on Renesas
> R-Car series boards. Add new host bridge op "fixup_bar" that allows
> platforms to modify BAR addresses before they are mapped.
>
> Because x86 don't have support for PCI Host Bridge drivers, add another
> level of indirection in form of platform_pci_fixup_bar() function, that
> will call host bridge op on ARM and do nothing on x86.
>
> Signed-off-by: Mykyta Poturai <mykyta_poturai@xxxxxxxx>
> ---
> xen/arch/arm/include/asm/pci.h | 3 +++
> xen/arch/arm/include/asm/vpci.h | 9 +++++++++
> xen/arch/arm/vpci.c | 12 ++++++++++++
> xen/arch/x86/include/asm/vpci.h | 6 ++++++
> xen/drivers/vpci/header.c | 2 ++
> 5 files changed, 32 insertions(+)
>
> diff --git a/xen/arch/arm/include/asm/pci.h b/xen/arch/arm/include/asm/pci.h
> index 7c3211823f..398a4eb746 100644
> --- a/xen/arch/arm/include/asm/pci.h
> +++ b/xen/arch/arm/include/asm/pci.h
> @@ -80,6 +80,9 @@ struct pci_ops {
> void (*init_bus_range)(struct dt_device_node *dev,
> struct pci_host_bridge *bridge,
> struct pci_config_window *cfg);
> + void (*fixup_bar)(struct pci_host_bridge *bridge,
> + unsigned int bar_num,
> + paddr_t *addr);
> };
>
> /*
> diff --git a/xen/arch/arm/include/asm/vpci.h b/xen/arch/arm/include/asm/vpci.h
> index 0cc6f5a105..f5c817a51c 100644
> --- a/xen/arch/arm/include/asm/vpci.h
> +++ b/xen/arch/arm/include/asm/vpci.h
> @@ -16,6 +16,10 @@ struct vpci_arch_msix_entry {
>
> int domain_vpci_init(struct domain *d);
> unsigned int domain_vpci_get_num_mmio_handlers(struct domain *d);
> +
> +void platform_pci_fixup_bar(const struct pci_dev *pdev, unsigned int bar_num,
> + paddr_t *addr);
> +
> #else
> static inline int domain_vpci_init(struct domain *d)
> {
> @@ -26,6 +30,11 @@ static inline unsigned int
> domain_vpci_get_num_mmio_handlers(struct domain *d)
> {
> return 0;
> }
> +
> +static inline void platform_pci_fixup_bar(const struct pci_dev *pdev,
> + unsigned int bar_num,
> + paddr_t *addr)
> +{}
> #endif /* CONFIG_HAS_VPCI */
>
> #endif /* ARM_VPCI_H */
> diff --git a/xen/arch/arm/vpci.c b/xen/arch/arm/vpci.c
> index d41aa383a8..ec6efec22e 100644
> --- a/xen/arch/arm/vpci.c
> +++ b/xen/arch/arm/vpci.c
> @@ -189,6 +189,18 @@ unsigned int domain_vpci_get_num_mmio_handlers(struct
> domain *d)
> return 1;
> }
>
> +void platform_pci_fixup_bar(const struct pci_dev *pdev,
> + unsigned int bar_num,
> + paddr_t *addr)
> +{
> + struct pci_host_bridge *bridge = pci_find_host_bridge(pdev->sbdf.seg,
> pdev->sbdf.bus);
> +
> + if ( bridge->ops->fixup_bar )
> + {
> + bridge->ops->fixup_bar(bridge, bar_num, addr);
> + }
> +}
> +
> /*
> * Local variables:
> * mode: C
> diff --git a/xen/arch/x86/include/asm/vpci.h b/xen/arch/x86/include/asm/vpci.h
> index c501ff1709..a05b70abbf 100644
> --- a/xen/arch/x86/include/asm/vpci.h
> +++ b/xen/arch/x86/include/asm/vpci.h
> @@ -16,6 +16,12 @@ struct vpci_arch_msix_entry {
> int pirq;
> };
>
> +/* X86 does not require PCI BAR modifications */
> +static inline void platform_pci_fixup_bar(const struct pci_dev *pdev,
> + unsigned int bar_num,
> + paddr_t *addr)
> +{}
> +
> #endif /* X86_VPCI_H */
>
> /*
> diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
> index a760d8c32f..d89e43354c 100644
> --- a/xen/drivers/vpci/header.c
> +++ b/xen/drivers/vpci/header.c
> @@ -882,6 +882,8 @@ int vpci_init_header(struct pci_dev *pdev)
> bars[i].size = size;
> bars[i].prefetchable = val & PCI_BASE_ADDRESS_MEM_PREFETCH;
>
> + platform_pci_fixup_bar(pdev, i, &bars[i].addr);
You do this for vpci_init_header(), but don't you also need to do it
for bar_write(), in case dom0 decides to relocate the BAR?
Also - I would assume that both the firmware and dom0 are aware of
this limitation, and hence wonder why you need this fixup in Xen?
Thanks, Roger.
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |