From 2f9d2b811c406547ccc8c1a55f6a241795848363 Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Thu, 29 Aug 2019 02:28:36 -0400 Subject: [PATCH] nvme: move nvme_ctrlr_construct() before the PCI initialization This will be consistent with TCP and RDMA transport, and we will use ctrlr->flags in nvme_ctrlr_init_cap() in next patch, the flags will be cleared to 0 for now. Change-Id: Ic360cd0c00d60c77452d19cdc1e7a32a5fc34df0 Signed-off-by: Changpeng Liu Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466678 Reviewed-by: Shuhei Matsumoto Reviewed-by: Jim Harris Tested-by: SPDK CI Jenkins --- lib/nvme/nvme_pcie.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/nvme/nvme_pcie.c b/lib/nvme/nvme_pcie.c index 604936f6c..f844198cc 100644 --- a/lib/nvme/nvme_pcie.c +++ b/lib/nvme/nvme_pcie.c @@ -839,6 +839,13 @@ struct spdk_nvme_ctrlr *nvme_pcie_ctrlr_construct(const struct spdk_nvme_transpo pctrlr->claim_fd = claim_fd; memcpy(&pctrlr->ctrlr.trid, trid, sizeof(pctrlr->ctrlr.trid)); + rc = nvme_ctrlr_construct(&pctrlr->ctrlr); + if (rc != 0) { + close(claim_fd); + spdk_free(pctrlr); + return NULL; + } + rc = nvme_pcie_ctrlr_allocate_bars(pctrlr); if (rc != 0) { close(claim_fd); @@ -871,12 +878,6 @@ struct spdk_nvme_ctrlr *nvme_pcie_ctrlr_construct(const struct spdk_nvme_transpo * but we want multiples of 4, so drop the + 2 */ pctrlr->doorbell_stride_u32 = 1 << cap.bits.dstrd; - rc = nvme_ctrlr_construct(&pctrlr->ctrlr); - if (rc != 0) { - nvme_ctrlr_destruct(&pctrlr->ctrlr); - return NULL; - } - pci_id = spdk_pci_device_get_id(pci_dev); pctrlr->ctrlr.quirks = nvme_get_quirks(&pci_id);