From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Mykyta Poturai <Mykyta_Poturai@epam.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
Stefano Stabellini <sstabellini@kernel.org>,
Julien Grall <julien@xen.org>,
Bertrand Marquis <bertrand.marquis@arm.com>,
Michal Orzel <michal.orzel@amd.com>,
Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>,
Jan Beulich <jbeulich@suse.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Teddy Astie <teddy.astie@vates.tech>,
Stewart Hildebrand <stewart.hildebrand@amd.com>
Subject: Re: [RFC PATCH 1/2] pci: Allow platforms to modify BAR adresses
Date: Fri, 24 Apr 2026 10:58:21 +0200 [thread overview]
Message-ID: <aeswrXLdbdK1wPMf@macbook.local> (raw)
In-Reply-To: <a0f623792497ab92cfb64c50bd17d28138e10b99.1776756291.git.mykyta_poturai@epam.com>
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@epam.com>
> ---
> 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.
prev parent reply other threads:[~2026-04-24 8:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-21 7:57 [RFC PATCH 0/2] Add region id support for PCI Mykyta Poturai
2026-04-21 7:57 ` [RFC PATCH 2/2] plat/rcar: " Mykyta Poturai
2026-04-21 8:28 ` Jan Beulich
2026-04-21 8:45 ` Mykyta Poturai
2026-04-21 8:36 ` Julien Grall
2026-04-22 13:23 ` Oleksandr Tyshchenko
2026-04-21 7:57 ` [RFC PATCH 1/2] pci: Allow platforms to modify BAR adresses Mykyta Poturai
2026-04-21 8:31 ` Jan Beulich
2026-04-24 8:58 ` Roger Pau Monné [this message]
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=aeswrXLdbdK1wPMf@macbook.local \
--to=roger.pau@citrix.com \
--cc=Mykyta_Poturai@epam.com \
--cc=Volodymyr_Babchuk@epam.com \
--cc=andrew.cooper3@citrix.com \
--cc=bertrand.marquis@arm.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=sstabellini@kernel.org \
--cc=stewart.hildebrand@amd.com \
--cc=teddy.astie@vates.tech \
--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.