summaryrefslogtreecommitdiff
path: root/drivers/bus/pci
diff options
context:
space:
mode:
authorQi Zhang <qi.z.zhang@intel.com>2018-10-30 23:27:20 +0800
committerThomas Monjalon <thomas@monjalon.net>2018-10-31 19:43:34 +0100
commit55e411b301c31ec8a0096f0f8d92cb544bd8274b (patch)
treed99101d96d7c5614b47699cafe22eb7ba02e7be2 /drivers/bus/pci
parent04854a39e6f61a376bf3cc93087dfc15ab31e3be (diff)
downloaddpdk-55e411b301c31ec8a0096f0f8d92cb544bd8274b.zip
dpdk-55e411b301c31ec8a0096f0f8d92cb544bd8274b.tar.gz
dpdk-55e411b301c31ec8a0096f0f8d92cb544bd8274b.tar.xz
bus/pci: fix resource mapping override
When scanning an already plugged device, the virtual address of mapped PCI resource in rte_pci_device will be overridden with 0, that may cause driver does not work correctly. The fix is not to update any rte_pci_device's field if the being scanned device's driver is already probed. Bugzilla ID: 85 Fixes: c752998b5e2e ("pci: introduce library and driver") Cc: stable@dpdk.org Reported-by: Geoffrey Lv <geoffrey.lv@gmail.com> Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Diffstat (limited to 'drivers/bus/pci')
-rw-r--r--drivers/bus/pci/linux/pci.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c
index 45c24ef..1783ec7 100644
--- a/drivers/bus/pci/linux/pci.c
+++ b/drivers/bus/pci/linux/pci.c
@@ -349,11 +349,36 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)
if (ret < 0) {
rte_pci_insert_device(dev2, dev);
} else { /* already registered */
- dev2->kdrv = dev->kdrv;
- dev2->max_vfs = dev->max_vfs;
- pci_name_set(dev2);
- memmove(dev2->mem_resource, dev->mem_resource,
- sizeof(dev->mem_resource));
+ if (!rte_dev_is_probed(&dev2->device)) {
+ dev2->kdrv = dev->kdrv;
+ dev2->max_vfs = dev->max_vfs;
+ pci_name_set(dev2);
+ memmove(dev2->mem_resource,
+ dev->mem_resource,
+ sizeof(dev->mem_resource));
+ } else {
+ /**
+ * If device is plugged and driver is
+ * probed already, (This happens when
+ * we call rte_dev_probe which will
+ * scan all device on the bus) we don't
+ * need to do anything here unless...
+ **/
+ if (dev2->kdrv != dev->kdrv ||
+ dev2->max_vfs != dev->max_vfs)
+ /*
+ * This should not happens.
+ * But it is still possible if
+ * we unbind a device from
+ * vfio or uio before hotplug
+ * remove and rebind it with
+ * a different configure.
+ * So we just print out the
+ * error as an alarm.
+ */
+ RTE_LOG(ERR, EAL, "Unexpected device scan at %s!\n",
+ filename);
+ }
free(dev);
}
return 0;