···598}599600/**00000000000000000000000601 * pci_restore_iov_state - restore the state of the IOV capability602 * @dev: the PCI device603 */
···598}599600/**601+ * pci_sriov_resource_alignment - get resource alignment for VF BAR602+ * @dev: the PCI device603+ * @resno: the resource number604+ *605+ * Returns the alignment of the VF BAR found in the SR-IOV capability.606+ * This is not the same as the resource size which is defined as607+ * the VF BAR size multiplied by the number of VFs. The alignment608+ * is just the VF BAR size.609+ */610+int pci_sriov_resource_alignment(struct pci_dev *dev, int resno)611+{612+ struct resource tmp;613+ enum pci_bar_type type;614+ int reg = pci_iov_resource_bar(dev, resno, &type);615+616+ if (!reg)617+ return 0;618+619+ __pci_read_base(dev, type, &tmp, reg);620+ return resource_alignment(&tmp);621+}622+623+/**624 * pci_restore_iov_state - restore the state of the IOV capability625 * @dev: the PCI device626 */
+13
drivers/pci/pci.h
···243extern void pci_iov_release(struct pci_dev *dev);244extern int pci_iov_resource_bar(struct pci_dev *dev, int resno,245 enum pci_bar_type *type);0246extern void pci_restore_iov_state(struct pci_dev *dev);247extern int pci_iov_bus_range(struct pci_bus *bus);248···298 return 0;299}300#endif /* CONFIG_PCI_IOV */000000000000301302#endif /* DRIVERS_PCI_H */
···243extern void pci_iov_release(struct pci_dev *dev);244extern int pci_iov_resource_bar(struct pci_dev *dev, int resno,245 enum pci_bar_type *type);246+extern int pci_sriov_resource_alignment(struct pci_dev *dev, int resno);247extern void pci_restore_iov_state(struct pci_dev *dev);248extern int pci_iov_bus_range(struct pci_bus *bus);249···297 return 0;298}299#endif /* CONFIG_PCI_IOV */300+301+static inline int pci_resource_alignment(struct pci_dev *dev,302+ struct resource *res)303+{304+#ifdef CONFIG_PCI_IOV305+ int resno = res - dev->resource;306+307+ if (resno >= PCI_IOV_RESOURCES && resno <= PCI_IOV_RESOURCE_END)308+ return pci_sriov_resource_alignment(dev, resno);309+#endif310+ return resource_alignment(res);311+}312313#endif /* DRIVERS_PCI_H */
+2-2
drivers/pci/setup-bus.c
···25#include <linux/ioport.h>26#include <linux/cache.h>27#include <linux/slab.h>28-2930static void pbus_assign_resources_sorted(const struct pci_bus *bus)31{···384 continue;385 r_size = resource_size(r);386 /* For bridges size != alignment */387- align = resource_alignment(r);388 order = __ffs(align) - 20;389 if (order > 11) {390 dev_warn(&dev->dev, "BAR %d bad alignment %llx: "