[PATCH 5/7] PCI, ACPI: Don't glue ACPI dev with pci VFs

From: Yinghai Lu
Date: Mon May 13 2013 - 22:29:58 EST


When sriov is enabled, VF could just start after PF in pci tree.
like c1:00.0 will be PF, and c1:00.1 and after will be VF.

acpi do have dev with same ADR. that will make them get glued
wrongly.

Skip that if it is virtfn.

Also need to set is_virtfn before pci_device_add(), as
gluing is triggered by device_add().

Signed-off-by: Yinghai Lu <yinghai@xxxxxxxxxx>

---
drivers/pci/iov.c | 6 +++---
drivers/pci/pci-acpi.c | 4 ++++
2 files changed, 7 insertions(+), 3 deletions(-)

Index: linux-2.6/drivers/pci/iov.c
===================================================================
--- linux-2.6.orig/drivers/pci/iov.c
+++ linux-2.6/drivers/pci/iov.c
@@ -110,12 +110,12 @@ static int virtfn_add(struct pci_dev *de
if (reset)
__pci_reset_function(virtfn);

- pci_device_add(virtfn, virtfn->bus);
- mutex_unlock(&iov->dev->sriov->lock);
-
virtfn->physfn = pci_dev_get(dev);
virtfn->is_virtfn = 1;

+ pci_device_add(virtfn, virtfn->bus);
+ mutex_unlock(&iov->dev->sriov->lock);
+
rc = pci_bus_add_device(virtfn);
sprintf(buf, "virtfn%u", id);
rc = sysfs_create_link(&dev->dev.kobj, &virtfn->dev.kobj, buf);
Index: linux-2.6/drivers/pci/pci-acpi.c
===================================================================
--- linux-2.6.orig/drivers/pci/pci-acpi.c
+++ linux-2.6/drivers/pci/pci-acpi.c
@@ -321,6 +321,10 @@ static int acpi_pci_find_device(struct d
u64 addr;

pci_dev = to_pci_dev(dev);
+ /* don't mix vf with real pci device */
+ if (pci_dev->is_virtfn)
+ return -ENODEV;
+
/* Please ref to ACPI spec for the syntax of _ADR */
addr = (PCI_SLOT(pci_dev->devfn) << 16) | PCI_FUNC(pci_dev->devfn);
*handle = acpi_get_child(DEVICE_ACPI_HANDLE(dev->parent), addr);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/