Commit 3142d832 authored by Filippo Sironi's avatar Filippo Sironi Committed by Bjorn Helgaas

PCI: Cache the VF device ID in the SR-IOV structure

Cache the VF device ID in the SR-IOV structure and use it instead of
reading it over and over from the PF config space capability.
Signed-off-by: default avatarFilippo Sironi <sironi@amazon.de>
[bhelgaas: rename to "vf_device" to match pci_dev->device]
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent ad581f86
...@@ -134,7 +134,7 @@ int pci_iov_add_virtfn(struct pci_dev *dev, int id) ...@@ -134,7 +134,7 @@ int pci_iov_add_virtfn(struct pci_dev *dev, int id)
virtfn->devfn = pci_iov_virtfn_devfn(dev, id); virtfn->devfn = pci_iov_virtfn_devfn(dev, id);
virtfn->vendor = dev->vendor; virtfn->vendor = dev->vendor;
pci_read_config_word(dev, iov->pos + PCI_SRIOV_VF_DID, &virtfn->device); virtfn->device = iov->vf_device;
rc = pci_setup_device(virtfn); rc = pci_setup_device(virtfn);
if (rc) if (rc)
goto failed0; goto failed0;
...@@ -441,6 +441,7 @@ static int sriov_init(struct pci_dev *dev, int pos) ...@@ -441,6 +441,7 @@ static int sriov_init(struct pci_dev *dev, int pos)
iov->nres = nres; iov->nres = nres;
iov->ctrl = ctrl; iov->ctrl = ctrl;
iov->total_VFs = total; iov->total_VFs = total;
pci_read_config_word(dev, pos + PCI_SRIOV_VF_DID, &iov->vf_device);
iov->pgsz = pgsz; iov->pgsz = pgsz;
iov->self = dev; iov->self = dev;
iov->drivers_autoprobe = true; iov->drivers_autoprobe = true;
...@@ -716,7 +717,7 @@ int pci_vfs_assigned(struct pci_dev *dev) ...@@ -716,7 +717,7 @@ int pci_vfs_assigned(struct pci_dev *dev)
* determine the device ID for the VFs, the vendor ID will be the * determine the device ID for the VFs, the vendor ID will be the
* same as the PF so there is no need to check for that one * same as the PF so there is no need to check for that one
*/ */
pci_read_config_word(dev, dev->sriov->pos + PCI_SRIOV_VF_DID, &dev_id); dev_id = dev->sriov->vf_device;
/* loop through all the VFs to see if we own any that are assigned */ /* loop through all the VFs to see if we own any that are assigned */
vfdev = pci_get_device(dev->vendor, dev_id, NULL); vfdev = pci_get_device(dev->vendor, dev_id, NULL);
......
...@@ -263,6 +263,7 @@ struct pci_sriov { ...@@ -263,6 +263,7 @@ struct pci_sriov {
u16 num_VFs; /* number of VFs available */ u16 num_VFs; /* number of VFs available */
u16 offset; /* first VF Routing ID offset */ u16 offset; /* first VF Routing ID offset */
u16 stride; /* following VF stride */ u16 stride; /* following VF stride */
u16 vf_device; /* VF device ID */
u32 pgsz; /* page size for BAR alignment */ u32 pgsz; /* page size for BAR alignment */
u8 link; /* Function Dependency Link */ u8 link; /* Function Dependency Link */
u8 max_VF_buses; /* max buses consumed by VFs */ u8 max_VF_buses; /* max buses consumed by VFs */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment