[PATCH v11 4/7] powerpc/powernv: Override pcibios_default_alignment() to force PCI devices to be page aligned
Bjorn Helgaas
bhelgaas at google.com
Tue Apr 18 23:53:47 AEST 2017
On Mon, Apr 17, 2017 at 4:36 PM, Bjorn Helgaas <bhelgaas at google.com> wrote:
> From: Yongji Xie <elohimes at gmail.com>
>
> This overrides pcibios_default_alignment() to set default alignment
> to PAGE_SIZE for all PCI devices on PowerNV platform. Thus sub-page
> BARs would not share a page and could be mapped into guest when VFIO
> passthrough them.
>
> Signed-off-by: Yongji Xie <elohimes at gmail.com>
> Signed-off-by: Bjorn Helgaas <bhelgaas at google.com>
> ---
> arch/powerpc/include/asm/machdep.h | 2 ++
> arch/powerpc/kernel/pci-common.c | 8 ++++++++
> arch/powerpc/platforms/powernv/pci-ioda.c | 7 +++++++
> 3 files changed, 17 insertions(+)
> +resource_size_t pcibios_default_alignment(struct pci_dev *pdev)
> +{
> + if (ppc_md.pcibios_default_alignment)
> + return ppc_md.pcibios_default_alignment(pdev);
> +
> + return 0;
> +}
> +
> #ifdef CONFIG_PCI_IOV
> resource_size_t pcibios_iov_resource_alignment(struct pci_dev *pdev, int resno)
> {
> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
> index 6901a06da2f9..b724487cbd0f 100644
> --- a/arch/powerpc/platforms/powernv/pci-ioda.c
> +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
> @@ -3287,6 +3287,11 @@ static void pnv_pci_setup_bridge(struct pci_bus *bus, unsigned long type)
> }
> }
>
> +static resource_size_t pnv_pci_default_alignment(struct pci_dev *pdev)
> +{
> + return PAGE_SIZE;
> +}
Is it necessary that pcibios_default_alignment() take a pci_dev
pointer? I'd like this better if it were:
resource_size_t pcibios_default_alignment(void) { ... }
because the last patch relies on the assumption that all resources of
*all* devices will be realigned to the same alignment.
Bjorn
More information about the Linuxppc-dev
mailing list