diff mbox

[V9,14/18] powerpc/powernv: Implement pcibios_iov_resource_size() on powernv

Message ID 1414942894-17034-15-git-send-email-weiyang@linux.vnet.ibm.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Wei Yang Nov. 2, 2014, 3:41 p.m. UTC
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(+)
diff mbox

Patch

diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index 15a13e6..d971874 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -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
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 581e67b..a2a96d3 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -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)
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 880d76d..f7abba3 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -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);