vmd: add device to dev_list after initialization is complete

That way, we don't have to do TAILQ_REMOVE if vmd_assign_base_addrs()
fails.

Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id7a5df2093e4f9dfc95ee1fe415eb644c61bc971
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14258
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tom Nabarro <tom.nabarro@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Konrad Sztyber 2022-08-29 07:36:38 +02:00 committed by Tomasz Zawadzki
parent 35f8bd2a13
commit 3f4e968dab

View File

@ -890,12 +890,14 @@ vmd_init_end_device(struct vmd_pci_device *dev)
struct vmd_adapter *vmd;
uint8_t bdf[32];
/* Attach the device to the current bus and assign base addresses */
TAILQ_INSERT_TAIL(&bus->dev_list, dev, tailq);
g_end_device_count++;
if (vmd_assign_base_addrs(dev)) {
if (!vmd_assign_base_addrs(dev)) {
SPDK_ERRLOG("Failed to allocate BARs for device: %p\n", dev);
return -1;
}
vmd_setup_msix(dev, &bus->vmd->msix_table[0]);
vmd_dev_init(dev);
if (vmd_is_supported_device(dev)) {
spdk_pci_addr_fmt(bdf, sizeof(bdf), &dev->pci.addr);
SPDK_INFOLOG(vmd, "Initializing NVMe device at %s\n", bdf);
@ -907,13 +909,11 @@ vmd_init_end_device(struct vmd_pci_device *dev)
vmd->nvme_count++;
}
return 0;
} else {
SPDK_INFOLOG(vmd, "Removing failed device:%p\n", dev);
TAILQ_REMOVE(&bus->dev_list, dev, tailq);
/* Attach the device to the current bus and assign base addresses */
TAILQ_INSERT_TAIL(&bus->dev_list, dev, tailq);
g_end_device_count++;
return -1;
}
return 0;
}
/*