]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
powerpc/powernv: Implement pcibios_iov_resource_alignment() on powernv
authorWei Yang <weiyang@linux.vnet.ibm.com>
Wed, 25 Mar 2015 08:23:56 +0000 (16:23 +0800)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Tue, 31 Mar 2015 02:02:37 +0000 (13:02 +1100)
Implement pcibios_iov_resource_alignment() on powernv platform.

On PowerNV platform, there are 3 cases for the IOV BAR:
1. initial state, the IOV BAR size is multiple times of VF BAR size
2. after expanded, the IOV BAR size is expanded to meet the M64 segment size
3. sizing stage, the IOV BAR is truncated to 0

pnv_pci_iov_resource_alignment() handle these three cases respectively.

[bhelgaas: adjust to drop "align" parameter, return pci_iov_resource_size()
if no ppc_md machdep_call version]
Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/include/asm/machdep.h
arch/powerpc/kernel/pci-common.c
arch/powerpc/platforms/powernv/pci-ioda.c

index b303833fa3fbe64a1ab2f305b99e015f8f6a97f2..1b268044f29003b6f522bc6a98cbd11f0fd5b9a5 100644 (file)
@@ -252,6 +252,7 @@ struct machdep_calls {
 
 #ifdef CONFIG_PCI_IOV
        void (*pcibios_fixup_sriov)(struct pci_dev *pdev);
+       resource_size_t (*pcibios_iov_resource_alignment)(struct pci_dev *, int resno);
 #endif /* CONFIG_PCI_IOV */
 
        /* Called to shutdown machine specific hardware not already controlled
index 375bf70999128285a83eaa90b0f18c1db1ab28cf..9a306ff304ae1ebc3653575f4da977ea6fc8877a 100644 (file)
@@ -130,6 +130,16 @@ void pcibios_reset_secondary_bus(struct pci_dev *dev)
        pci_reset_secondary_bus(dev);
 }
 
+#ifdef CONFIG_PCI_IOV
+resource_size_t pcibios_iov_resource_alignment(struct pci_dev *pdev, int resno)
+{
+       if (ppc_md.pcibios_iov_resource_alignment)
+               return ppc_md.pcibios_iov_resource_alignment(pdev, resno);
+
+       return pci_iov_resource_size(pdev, resno);
+}
+#endif /* CONFIG_PCI_IOV */
+
 static resource_size_t pcibios_io_size(const struct pci_controller *hose)
 {
 #ifdef CONFIG_PPC64
index 1da45aa76a03bf7b6fb5646aea036ed05d32ba2b..217eaad23cdef8f865265b3be4ac09bb923186e3 100644 (file)
@@ -1965,6 +1965,25 @@ static resource_size_t pnv_pci_window_alignment(struct pci_bus *bus,
        return phb->ioda.io_segsize;
 }
 
+#ifdef CONFIG_PCI_IOV
+static resource_size_t pnv_pci_iov_resource_alignment(struct pci_dev *pdev,
+                                                     int resno)
+{
+       struct pci_dn *pdn = pci_get_pdn(pdev);
+       resource_size_t align, iov_align;
+
+       iov_align = resource_size(&pdev->resource[resno]);
+       if (iov_align)
+               return iov_align;
+
+       align = pci_iov_resource_size(pdev, resno);
+       if (pdn->vfs_expanded)
+               return pdn->vfs_expanded * align;
+
+       return align;
+}
+#endif /* CONFIG_PCI_IOV */
+
 /* Prevent enabling devices for which we couldn't properly
  * assign a PE
  */
@@ -2164,6 +2183,7 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np,
        ppc_md.pcibios_reset_secondary_bus = pnv_pci_reset_secondary_bus;
 #ifdef CONFIG_PCI_IOV
        ppc_md.pcibios_fixup_sriov = pnv_pci_ioda_fixup_iov_resources;
+       ppc_md.pcibios_iov_resource_alignment = pnv_pci_iov_resource_alignment;
 #endif /* CONFIG_PCI_IOV */
        pci_add_flags(PCI_REASSIGN_ALL_RSRC);