[Skiboot] [PATCH RFC 5/6] pci-iov: Set parent of VFs to the bridge's downstream instead of PF
Sergey Miroshnichenko
s.miroshnichenko at yadro.com
Sat Mar 2 01:30:37 AEDT 2019
This make it a bit simpler to handle PCIe re-enumeration.
Signed-off-by: Sergey Miroshnichenko <s.miroshnichenko at yadro.com>
---
core/pci-iov.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/core/pci-iov.c b/core/pci-iov.c
index 3bbb7b86..f2344878 100644
--- a/core/pci-iov.c
+++ b/core/pci-iov.c
@@ -133,8 +133,10 @@ static int64_t pci_iov_change(void *dev __unused,
/* Remove all VFs that have been attached to the parent */
if (!iov->enabled) {
- list_for_each_safe(&pd->children, vf, tmp, link)
- list_del(&vf->link);
+ list_for_each_safe(pd->parent ? &pd->parent->children : &pd->children,
+ vf, tmp, link)
+ if ((vf->bdfn & 0xfff8) == (pd->bdfn & 0xfff8))
+ list_del(&vf->link);
return OPAL_PARTIAL;
}
@@ -142,7 +144,8 @@ static int64_t pci_iov_change(void *dev __unused,
for (changed = false, i = 0; i < iov->num_VFs; i++) {
vf = &iov->VFs[i];
vf->bdfn = pd->bdfn + iov->offset + iov->stride * i;
- list_add_tail(&pd->children, &vf->link);
+ list_add_tail(pd->parent ? &pd->parent->children : &pd->children,
+ &vf->link);
/*
* We don't populate the capabilities again if they have
@@ -183,7 +186,7 @@ static void pci_iov_init_VF(struct pci_device *pd, struct pci_device *vf)
vf->class = pd->class;
vf->dn = NULL;
vf->slot = NULL;
- vf->parent = pd;
+ vf->parent = pd->parent ? pd->parent : pd;
vf->phb = pd->phb;
list_head_init(&vf->pcrf);
list_head_init(&vf->children);
--
2.20.1
More information about the Skiboot
mailing list