Skip to content

Commit 3827463

Browse files
YongjiXiebjorn-helgaas
authored andcommitted
powerpc/powernv: Override pcibios_default_alignment() to force PCI devices to be page aligned
Override 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 <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent 0a701aa commit 3827463

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

arch/powerpc/include/asm/machdep.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ struct machdep_calls {
173173
/* Called after scan and before resource survey */
174174
void (*pcibios_fixup_phb)(struct pci_controller *hose);
175175

176+
resource_size_t (*pcibios_default_alignment)(void);
177+
176178
#ifdef CONFIG_PCI_IOV
177179
void (*pcibios_fixup_sriov)(struct pci_dev *pdev);
178180
resource_size_t (*pcibios_iov_resource_alignment)(struct pci_dev *, int resno);

arch/powerpc/kernel/pci-common.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,14 @@ void pcibios_reset_secondary_bus(struct pci_dev *dev)
233233
pci_reset_secondary_bus(dev);
234234
}
235235

236+
resource_size_t pcibios_default_alignment(void)
237+
{
238+
if (ppc_md.pcibios_default_alignment)
239+
return ppc_md.pcibios_default_alignment();
240+
241+
return 0;
242+
}
243+
236244
#ifdef CONFIG_PCI_IOV
237245
resource_size_t pcibios_iov_resource_alignment(struct pci_dev *pdev, int resno)
238246
{

arch/powerpc/platforms/powernv/pci-ioda.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3287,6 +3287,11 @@ static void pnv_pci_setup_bridge(struct pci_bus *bus, unsigned long type)
32873287
}
32883288
}
32893289

3290+
static resource_size_t pnv_pci_default_alignment(void)
3291+
{
3292+
return PAGE_SIZE;
3293+
}
3294+
32903295
#ifdef CONFIG_PCI_IOV
32913296
static resource_size_t pnv_pci_iov_resource_alignment(struct pci_dev *pdev,
32923297
int resno)
@@ -3820,6 +3825,8 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np,
38203825
hose->controller_ops = pnv_pci_ioda_controller_ops;
38213826
}
38223827

3828+
ppc_md.pcibios_default_alignment = pnv_pci_default_alignment;
3829+
38233830
#ifdef CONFIG_PCI_IOV
38243831
ppc_md.pcibios_fixup_sriov = pnv_pci_ioda_fixup_iov_resources;
38253832
ppc_md.pcibios_iov_resource_alignment = pnv_pci_iov_resource_alignment;

0 commit comments

Comments
 (0)