···598598}599599600600/**601601+ * pci_sriov_resource_alignment - get resource alignment for VF BAR602602+ * @dev: the PCI device603603+ * @resno: the resource number604604+ *605605+ * Returns the alignment of the VF BAR found in the SR-IOV capability.606606+ * This is not the same as the resource size which is defined as607607+ * the VF BAR size multiplied by the number of VFs. The alignment608608+ * is just the VF BAR size.609609+ */610610+int pci_sriov_resource_alignment(struct pci_dev *dev, int resno)611611+{612612+ struct resource tmp;613613+ enum pci_bar_type type;614614+ int reg = pci_iov_resource_bar(dev, resno, &type);615615+616616+ if (!reg)617617+ return 0;618618+619619+ __pci_read_base(dev, type, &tmp, reg);620620+ return resource_alignment(&tmp);621621+}622622+623623+/**601624 * pci_restore_iov_state - restore the state of the IOV capability602625 * @dev: the PCI device603626 */
+13
drivers/pci/pci.h
···243243extern void pci_iov_release(struct pci_dev *dev);244244extern int pci_iov_resource_bar(struct pci_dev *dev, int resno,245245 enum pci_bar_type *type);246246+extern int pci_sriov_resource_alignment(struct pci_dev *dev, int resno);246247extern void pci_restore_iov_state(struct pci_dev *dev);247248extern int pci_iov_bus_range(struct pci_bus *bus);248249···298297 return 0;299298}300299#endif /* CONFIG_PCI_IOV */300300+301301+static inline int pci_resource_alignment(struct pci_dev *dev,302302+ struct resource *res)303303+{304304+#ifdef CONFIG_PCI_IOV305305+ int resno = res - dev->resource;306306+307307+ if (resno >= PCI_IOV_RESOURCES && resno <= PCI_IOV_RESOURCE_END)308308+ return pci_sriov_resource_alignment(dev, resno);309309+#endif310310+ return resource_alignment(res);311311+}301312302313#endif /* DRIVERS_PCI_H */