Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/powernv: Implement pcibios_iov_resource_alignment() on powernv

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>

authored by

Wei Yang and committed by
Benjamin Herrenschmidt
5350ab3f 6e628c7d

+31
+1
arch/powerpc/include/asm/machdep.h
··· 252 252 253 253 #ifdef CONFIG_PCI_IOV 254 254 void (*pcibios_fixup_sriov)(struct pci_dev *pdev); 255 + resource_size_t (*pcibios_iov_resource_alignment)(struct pci_dev *, int resno); 255 256 #endif /* CONFIG_PCI_IOV */ 256 257 257 258 /* Called to shutdown machine specific hardware not already controlled
+10
arch/powerpc/kernel/pci-common.c
··· 130 130 pci_reset_secondary_bus(dev); 131 131 } 132 132 133 + #ifdef CONFIG_PCI_IOV 134 + resource_size_t pcibios_iov_resource_alignment(struct pci_dev *pdev, int resno) 135 + { 136 + if (ppc_md.pcibios_iov_resource_alignment) 137 + return ppc_md.pcibios_iov_resource_alignment(pdev, resno); 138 + 139 + return pci_iov_resource_size(pdev, resno); 140 + } 141 + #endif /* CONFIG_PCI_IOV */ 142 + 133 143 static resource_size_t pcibios_io_size(const struct pci_controller *hose) 134 144 { 135 145 #ifdef CONFIG_PPC64
+20
arch/powerpc/platforms/powernv/pci-ioda.c
··· 1965 1965 return phb->ioda.io_segsize; 1966 1966 } 1967 1967 1968 + #ifdef CONFIG_PCI_IOV 1969 + static resource_size_t pnv_pci_iov_resource_alignment(struct pci_dev *pdev, 1970 + int resno) 1971 + { 1972 + struct pci_dn *pdn = pci_get_pdn(pdev); 1973 + resource_size_t align, iov_align; 1974 + 1975 + iov_align = resource_size(&pdev->resource[resno]); 1976 + if (iov_align) 1977 + return iov_align; 1978 + 1979 + align = pci_iov_resource_size(pdev, resno); 1980 + if (pdn->vfs_expanded) 1981 + return pdn->vfs_expanded * align; 1982 + 1983 + return align; 1984 + } 1985 + #endif /* CONFIG_PCI_IOV */ 1986 + 1968 1987 /* Prevent enabling devices for which we couldn't properly 1969 1988 * assign a PE 1970 1989 */ ··· 2183 2164 ppc_md.pcibios_reset_secondary_bus = pnv_pci_reset_secondary_bus; 2184 2165 #ifdef CONFIG_PCI_IOV 2185 2166 ppc_md.pcibios_fixup_sriov = pnv_pci_ioda_fixup_iov_resources; 2167 + ppc_md.pcibios_iov_resource_alignment = pnv_pci_iov_resource_alignment; 2186 2168 #endif /* CONFIG_PCI_IOV */ 2187 2169 pci_add_flags(PCI_REASSIGN_ALL_RSRC); 2188 2170