The alignment of PF's IOV BAR is designed to be the individual size of a VF's BAR size. This works fine for many platforms, but on PowerNV platform it needs some change.
The original alignment works, since at sizing and assigning stage the requirement is from an individual VF's BAR size instead of the PF's IOV BAR. This is the reason for the original code to just retrieve the individual VF BAR size as the alignment. On PowerNV platform, it is required to align the whole PF IOV BAR to a hardware segment. Based on this fact, the alignment of PF's IOV BAR should be calculated seperately. This patch introduces a weak pcibios_iov_resource_alignment() interface, which gives platform a chance to implement specific method to calculate the PF's IOV BAR alignment. Signed-off-by: Wei Yang <weiy...@linux.vnet.ibm.com> --- drivers/pci/iov.c | 11 ++++++++++- include/linux/pci.h | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index 5e8091b..4d1685d 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -501,6 +501,12 @@ int pci_iov_resource_bar(struct pci_dev *dev, int resno, 4 * (resno - PCI_IOV_RESOURCES); } +resource_size_t __weak pcibios_iov_resource_alignment(struct pci_dev *dev, + int resno, resource_size_t align) +{ + return align; +} + /** * pci_sriov_resource_alignment - get resource alignment for VF BAR * @dev: the PCI device @@ -515,13 +521,16 @@ resource_size_t pci_sriov_resource_alignment(struct pci_dev *dev, int resno) { struct resource tmp; enum pci_bar_type type; + resource_size_t align; int reg = pci_iov_resource_bar(dev, resno, &type); if (!reg) return 0; __pci_read_base(dev, type, &tmp, reg); - return resource_alignment(&tmp); + align = resource_alignment(&tmp); + + return pcibios_iov_resource_alignment(dev, resno, align); } /** diff --git a/include/linux/pci.h b/include/linux/pci.h index 3ed7c66..bbf8058 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1159,6 +1159,9 @@ unsigned char pci_bus_max_busnr(struct pci_bus *bus); void pci_setup_bridge(struct pci_bus *bus); resource_size_t pcibios_window_alignment(struct pci_bus *bus, unsigned long type); +resource_size_t pcibios_iov_resource_alignment(struct pci_dev *dev, + int resno, + resource_size_t align); #define PCI_VGA_STATE_CHANGE_BRIDGE (1 << 0) #define PCI_VGA_STATE_CHANGE_DECODES (1 << 1) -- 1.7.9.5 _______________________________________________ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev