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:
parent
35f8bd2a13
commit
3f4e968dab
@ -890,30 +890,30 @@ vmd_init_end_device(struct vmd_pci_device *dev)
|
|||||||
struct vmd_adapter *vmd;
|
struct vmd_adapter *vmd;
|
||||||
uint8_t bdf[32];
|
uint8_t bdf[32];
|
||||||
|
|
||||||
|
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);
|
||||||
|
dev->pci.parent = dev->bus->vmd->pci;
|
||||||
|
spdk_pci_hook_device(spdk_pci_nvme_get_driver(), &dev->pci);
|
||||||
|
|
||||||
|
vmd = bus->vmd;
|
||||||
|
vmd->target[vmd->nvme_count] = dev;
|
||||||
|
vmd->nvme_count++;
|
||||||
|
}
|
||||||
|
|
||||||
/* Attach the device to the current bus and assign base addresses */
|
/* Attach the device to the current bus and assign base addresses */
|
||||||
TAILQ_INSERT_TAIL(&bus->dev_list, dev, tailq);
|
TAILQ_INSERT_TAIL(&bus->dev_list, dev, tailq);
|
||||||
g_end_device_count++;
|
g_end_device_count++;
|
||||||
if (vmd_assign_base_addrs(dev)) {
|
|
||||||
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);
|
|
||||||
dev->pci.parent = dev->bus->vmd->pci;
|
|
||||||
spdk_pci_hook_device(spdk_pci_nvme_get_driver(), &dev->pci);
|
|
||||||
|
|
||||||
vmd = bus->vmd;
|
return 0;
|
||||||
vmd->target[vmd->nvme_count] = dev;
|
|
||||||
vmd->nvme_count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
SPDK_INFOLOG(vmd, "Removing failed device:%p\n", dev);
|
|
||||||
TAILQ_REMOVE(&bus->dev_list, dev, tailq);
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user