Skip to content

Commit 4ba50e7

Browse files
jbeulichjgross1
authored andcommitted
xen-pciback: redo VF placement in the virtual topology
The commit referenced below was incomplete: It merely affected what would get written to the vdev-<N> xenstore node. The guest would still find the function at the original function number as long as __xen_pcibk_get_pci_dev() wouldn't be in sync. The same goes for AER wrt __xen_pcibk_get_pcifront_dev(). Undo overriding the function to zero and instead make sure that VFs at function zero remain alone in their slot. This has the added benefit of improving overall capacity, considering that there's only a total of 32 slots available right now (PCI segment and bus can both only ever be zero at present). Fixes: 8a5248f ("xen PV passthru: assign SR-IOV virtual functions to separate virtual slots") Signed-off-by: Jan Beulich <[email protected]> Cc: [email protected] Reviewed-by: Boris Ostrovsky <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Juergen Gross <[email protected]>
1 parent ae897fd commit 4ba50e7

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/xen/xen-pciback/vpci.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static int __xen_pcibk_add_pci_dev(struct xen_pcibk_device *pdev,
7070
struct pci_dev *dev, int devid,
7171
publish_pci_dev_cb publish_cb)
7272
{
73-
int err = 0, slot, func = -1;
73+
int err = 0, slot, func = PCI_FUNC(dev->devfn);
7474
struct pci_dev_entry *t, *dev_entry;
7575
struct vpci_dev_data *vpci_dev = pdev->pci_dev_data;
7676

@@ -95,22 +95,25 @@ static int __xen_pcibk_add_pci_dev(struct xen_pcibk_device *pdev,
9595

9696
/*
9797
* Keep multi-function devices together on the virtual PCI bus, except
98-
* virtual functions.
98+
* that we want to keep virtual functions at func 0 on their own. They
99+
* aren't multi-function devices and hence their presence at func 0
100+
* may cause guests to not scan the other functions.
99101
*/
100-
if (!dev->is_virtfn) {
102+
if (!dev->is_virtfn || func) {
101103
for (slot = 0; slot < PCI_SLOT_MAX; slot++) {
102104
if (list_empty(&vpci_dev->dev_list[slot]))
103105
continue;
104106

105107
t = list_entry(list_first(&vpci_dev->dev_list[slot]),
106108
struct pci_dev_entry, list);
109+
if (t->dev->is_virtfn && !PCI_FUNC(t->dev->devfn))
110+
continue;
107111

108112
if (match_slot(dev, t->dev)) {
109113
dev_info(&dev->dev, "vpci: assign to virtual slot %d func %d\n",
110-
slot, PCI_FUNC(dev->devfn));
114+
slot, func);
111115
list_add_tail(&dev_entry->list,
112116
&vpci_dev->dev_list[slot]);
113-
func = PCI_FUNC(dev->devfn);
114117
goto unlock;
115118
}
116119
}
@@ -123,7 +126,6 @@ static int __xen_pcibk_add_pci_dev(struct xen_pcibk_device *pdev,
123126
slot);
124127
list_add_tail(&dev_entry->list,
125128
&vpci_dev->dev_list[slot]);
126-
func = dev->is_virtfn ? 0 : PCI_FUNC(dev->devfn);
127129
goto unlock;
128130
}
129131
}

0 commit comments

Comments
 (0)