Skip to contentSkip to conversation

PCI/IOV: Fix VF0 cached config space size for other VFs

PATCH In review Hao Zheng 2 participants 3 messages May 20, 2019 – Jun 14, 2019 PCI

lore
Share & tools
lore

Hao Zheng

author
#0 lore raw

PATCH 1/1 PCI/IOV: Fix VF0 cached config space size for other VFs

Set the pcie_cap field before getting the config space size for other VFs. Otherwise, the config space size of other VFs are error set to 256, while the size of VF0 is 4096.

---
 drivers/pci/iov.c | 1 +
 1 file changed, 1 insertion(+)
drivers/pci/iov.c +1 -0
index 3aa115e..239fad1 100644
@@ -133,6 +133,7 @@ static void pci_read_vf_config_common(struct pci_dev *virtfn)
 	pci_read_config_word(virtfn, PCI_SUBSYSTEM_ID,
 			     &physfn->sriov->subsystem_device);
 
+	set_pcie_port_type(virtfn);
 	physfn->sriov->cfg_size = pci_cfg_space_size(virtfn);
 }
 
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 15 lines · On Mon, 20 May 2019 21:17:24 +0800 Hao Zheng <[email protected]> wrote:

Set the pcie_cap field before getting the config space size for other VFs. Otherwise, the config space size of other VFs are error set to 256, while the size of VF0 is 4096.

---
 drivers/pci/iov.c | 1 +
 1 file changed, 1 insertion(+)
drivers/pci/iov.c +0 -0
index 3aa115e..239fad1 100644

drivers/pci/iov.c static void pci_read_vf_config_common(struct pci_dev *virtfn) · line 139

Quoted 7 lines
drivers/pci/iov.c +1 -0
@@ -133,6 +133,7 @@ static void pci_read_vf_config_common(struct pci_dev *virtfn)
 	pci_read_config_word(virtfn, PCI_SUBSYSTEM_ID,
 			     &physfn->sriov->subsystem_device);
 
+	set_pcie_port_type(virtfn);
 	physfn->sriov->cfg_size = pci_cfg_space_size(virtfn);
 }
 

This results in set_pci_port_type() being called multiple times on VF0. Why not simply delay calling pci_read_vf_config_common() until after pci_setup_device()? Here's the alternate approach:

https://lore.kernel.org/linux-pci/[email protected]/

Thanks,
Alex

author
#2 lore raw
Quoted 31 lines · Alex Williamson <[email protected]> 于2019年6月5日周三 上午1:29写道:
Quoted 15 lines · On Mon, 20 May 2019 21:17:24 +0800 Hao Zheng <[email protected]> wrote:

Set the pcie_cap field before getting the config space size for other VFs. Otherwise, the config space size of other VFs are error set to 256, while the size of VF0 is 4096.

---
 drivers/pci/iov.c | 1 +
 1 file changed, 1 insertion(+)
drivers/pci/iov.c +0 -0
index 3aa115e..239fad1 100644

drivers/pci/iov.c static void pci_read_vf_config_common(struct pci_dev *virtfn) · line 139

Quoted 7 lines
drivers/pci/iov.c +1 -0
@@ -133,6 +133,7 @@ static void pci_read_vf_config_common(struct pci_dev *virtfn)
      pci_read_config_word(virtfn, PCI_SUBSYSTEM_ID,
                           &physfn->sriov->subsystem_device);
 
+     set_pcie_port_type(virtfn);
      physfn->sriov->cfg_size = pci_cfg_space_size(virtfn);
 }
 

This results in set_pci_port_type() being called multiple times on VF0. Why not simply delay calling pci_read_vf_config_common() until after pci_setup_device()? Here's the alternate approach:

Quoted 1 line

https://lore.kernel.org/linux-pci/[email protected]/

I get it. This is a better approach. Thank you for your advice!

Quoted 3 lines

Thanks,
Alex

Signature · 1 line
Best Regards!