@@ -259,6 +259,7 @@ struct machdep_calls {
resource_size_t (*pcibios_iov_resource_alignment)(struct pci_dev *,
int resno,
resource_size_t align);
+ resource_size_t (*pcibios_iov_resource_size)(struct pci_dev *, int resno);
#endif /* CONFIG_PCI_IOV */
/* Called to shutdown machine specific hardware not already controlled
@@ -143,6 +143,14 @@ resource_size_t pcibios_iov_resource_alignment(struct pci_dev *pdev,
return 0;
}
+
+resource_size_t pcibios_iov_resource_size(struct pci_dev *pdev, int resno)
+{
+ if (ppc_md.pcibios_iov_resource_size)
+ return ppc_md.pcibios_iov_resource_size(pdev, resno);
+
+ return 0;
+}
#endif /* CONFIG_PCI_IOV */
static resource_size_t pcibios_io_size(const struct pci_controller *hose)
@@ -1847,6 +1847,20 @@ static resource_size_t pnv_pci_iov_resource_alignment(struct pci_dev *pdev,
return align;
}
+
+static resource_size_t pnv_pci_iov_resource_size(struct pci_dev *pdev, int resno)
+{
+ struct pci_dn *pdn = pci_get_pdn(pdev);
+ resource_size_t size = 0;
+
+ if (!pdn->max_vfs)
+ return size;
+
+ size = resource_size(pdev->resource + resno);
+ do_div(size, pdn->max_vfs);
+
+ return size;
+}
#endif /* CONFIG_PCI_IOV */
/* Prevent enabling devices for which we couldn't properly
@@ -2058,6 +2072,7 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np,
#ifdef CONFIG_PCI_IOV
ppc_md.pcibios_fixup_sriov = pnv_pci_ioda_fixup_sriov;
ppc_md.pcibios_iov_resource_alignment = pnv_pci_iov_resource_alignment;
+ ppc_md.pcibios_iov_resource_size = pnv_pci_iov_resource_size;
#endif /* CONFIG_PCI_IOV */
pci_add_flags(PCI_REASSIGN_ALL_RSRC);
On PowerNV platform, the PF's IOV BAR size would be expanded, which is different from the normal case. This patch retrieves the VF BAR size by total size dividing the expanded number of VFs. Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com> --- arch/powerpc/include/asm/machdep.h | 1 + arch/powerpc/kernel/pci-common.c | 8 ++++++++ arch/powerpc/platforms/powernv/pci-ioda.c | 15 +++++++++++++++ 3 files changed, 24 insertions(+)