diff mbox series

[RFC,5/6] pci-iov: Set parent of VFs to the bridge's downstream instead of PF

Message ID 20190301143038.23325-6-s.miroshnichenko@yadro.com
State Superseded
Headers show
Series core/pci: Sync VFs and the changes of bdfns between the firmware and the OS | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success master/apply_patch Successfully applied
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot fail Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present

Commit Message

Sergei Miroshnichenko March 1, 2019, 2:30 p.m. UTC
This make it a bit simpler to handle PCIe re-enumeration.

Signed-off-by: Sergey Miroshnichenko <s.miroshnichenko@yadro.com>
---
 core/pci-iov.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
diff mbox series

Patch

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);