iov: initialize NumVFs register to 0 at the end of sriov_init()
PATCH 1/1 iov: initialize NumVFs register to 0 at the end of sriov_init()
After commit 4449f079722c ("PCI: Calculate maximum number of buses required for VFs"),the initial value of NumVFs register was set to non-zero after sriov_init() and no VFs was enabled in device driver. this changed the behaviour of kernel exported by lspci and sysfs etc. so this patch initialize the NumVFs register to zero after the calculation of max_VF_buses was done.
Tested on stable 4.1 and passed building on stable 4.2-rc7
--- drivers/pci/iov.c | 1 + 1 file changed, 1 insertion(+)
drivers/pci/iov.c +1 -0
@@ -476,6 +476,7 @@ found: dev->is_physfn =1 ; iov->max_VF_buses =virtfn_max_buses (dev); +pci_iov_set_numvfs (dev,0 );return 0 ; failed:
Signature · 1 line
1.8.3.1
Bjorn Helgaas
maintainerQuoted 20 lines · Ethan Zhao
After commit
4449f079722c("PCI: Calculate maximum number of buses required for VFs"),the initial value of NumVFs register was set to non-zero aftersriov_init()and no VFs was enabled in device driver. this changed the behaviour of kernel exported by lspci and sysfs etc. so this patch initialize the NumVFs register to zero after the calculation ofmax_VF_buseswas done.Tested on stable 4.1 and passed building on stable 4.2-rc7
Signed-off-by Ethan Zhao <[email protected]>Tested-by Sriharsha Yadagudde <[email protected]>--- drivers/pci/iov.c | 1 + 1 file changed, 1 insertion(+)drivers/pci/iov.c +0
-0
drivers/pci/iov.c found: · line 479
Quoted 4 lines
drivers/pci/iov.c +1
-0@@ -476,6 +476,7 @@ found: dev->is_physfn =1 ; iov->max_VF_buses =virtfn_max_buses (dev); +pci_iov_set_numvfs (dev,0 );
I think it would be better to put this in virtfn_max_buses(), where we clobbered numVFs in the first place. I'd also read the original value and restore it, e.g.,
pci_read_config_word(dev, iov->pos + PCI_SRIOV_NUM_VF, &numvfs);
for (nr_virtfn = 1; nr_virtfn <= iov->total_VFs; nr_virtfn++) {
...
}
pci_iov_set_numvfs(dev, numvfs);
return max;I know sriov_init() sets numVFs to zero before it calls virtfn_max_buses(), but why rely on that extra knowledge?
Quoted 6 lines
drivers/pci/iov.c +0
-0return 0 ; failed:Signature · 1 line
1.8.3.1
Quoted 36 lines · Bjorn Helgaas
Quoted 20 lines · Ethan Zhao
After commit
4449f079722c("PCI: Calculate maximum number of buses required for VFs"),the initial value of NumVFs register was set to non-zero aftersriov_init()and no VFs was enabled in device driver. this changed the behaviour of kernel exported by lspci and sysfs etc. so this patch initialize the NumVFs register to zero after the calculation ofmax_VF_buseswas done.Tested on stable 4.1 and passed building on stable 4.2-rc7
Signed-off-by Ethan Zhao <[email protected]>Tested-by Sriharsha Yadagudde <[email protected]>--- drivers/pci/iov.c | 1 + 1 file changed, 1 insertion(+)drivers/pci/iov.c +0
-0drivers/pci/iov.c found: · line 479
Quoted 4 lines
drivers/pci/iov.c +1
-0@@ -476,6 +476,7 @@ found: dev->is_physfn =1 ; iov->max_VF_buses =virtfn_max_buses (dev); +pci_iov_set_numvfs (dev,0 );I think it would be better to put this in
virtfn_max_buses(), where we clobbered numVFs in the first place. I'd also read the original value and restore it, e.g.,pci_read_config_word(dev, iov->pos + PCI_SRIOV_NUM_VF, &numvfs); for (nr_virtfn = 1; nr_virtfn <= iov->total_VFs; nr_virtfn++) { ... } pci_iov_set_numvfs(dev, numvfs); return max;
Quoted 2 lines
I know
sriov_init()sets numVFs to zero before it callsvirtfn_max_buses(), but why rely on that extra knowledge?
Yes, I think also virtfn_max_buses() should restore the register
before it returns.
Will revise it and resend.
Thanks,
Ethan
Quoted 6 lines
Quoted 6 lines
drivers/pci/iov.c +0
-0return 0 ; failed:Signature · 1 line
1.8.3.1