From: keith.busch@intel.com (Keith Busch)
Subject: [PATCHv3 8/9] nvme-pci: Queue creation error handling
Date: Thu, 24 May 2018 14:34:59 -0600 [thread overview]
Message-ID: <20180524203500.14081-9-keith.busch@intel.com> (raw)
In-Reply-To: <20180524203500.14081-1-keith.busch@intel.com>
This patch sets the nvmeq's cq_vector only after the cq was successfully
created. This way a device reset doesn't mistakenly believe that the
vector is allocated. In case a reset does occur during queue creation,
this patch will return status immediately instead of trying to unwind
the created queues since the device won't be able to delete queues anyway.
This patch will also handle device reported failures correctly. These
errors are reported as positive nvme status codes, which were previously
not handled at all.
Based-on-patch-by: Jianchao Wang <jianchao.w.wang at oracle.com>
Signed-off-by: Keith Busch <keith.busch at intel.com>
---
drivers/nvme/host/pci.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 7c8076411dbc..e12b4ee91254 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1079,7 +1079,7 @@ static int adapter_delete_queue(struct nvme_dev *dev, u8 opcode, u16 id)
}
static int adapter_alloc_cq(struct nvme_dev *dev, u16 qid,
- struct nvme_queue *nvmeq)
+ struct nvme_queue *nvmeq, u16 vector)
{
struct nvme_command c;
int flags = NVME_QUEUE_PHYS_CONTIG | NVME_CQ_IRQ_ENABLED;
@@ -1094,7 +1094,7 @@ static int adapter_alloc_cq(struct nvme_dev *dev, u16 qid,
c.create_cq.cqid = cpu_to_le16(qid);
c.create_cq.qsize = cpu_to_le16(nvmeq->q_depth - 1);
c.create_cq.cq_flags = cpu_to_le16(flags);
- c.create_cq.irq_vector = cpu_to_le16(nvmeq->cq_vector);
+ c.create_cq.irq_vector = cpu_to_le16(vector);
return nvme_submit_sync_cmd(dev->ctrl.admin_q, &c, NULL, 0);
}
@@ -1477,6 +1477,7 @@ static int nvme_create_queue(struct nvme_queue *nvmeq, int qid)
{
struct nvme_dev *dev = nvmeq->dev;
int result;
+ u16 vector;
if (dev->cmb && use_cmb_sqes && (dev->cmbsz & NVME_CMBSZ_SQS)) {
unsigned offset = (qid - 1) * roundup(SQ_SIZE(nvmeq->q_depth),
@@ -1489,16 +1490,20 @@ static int nvme_create_queue(struct nvme_queue *nvmeq, int qid)
* A queue's vector matches the queue identifier unless the controller
* has only one vector available.
*/
- nvmeq->cq_vector = dev->num_vecs == 1 ? 0 : qid;
- result = adapter_alloc_cq(dev, qid, nvmeq);
- if (result < 0)
- goto release_vector;
+ vector = dev->num_vecs == 1 ? 0 : qid;
+ result = adapter_alloc_cq(dev, qid, nvmeq, vector);
+ if (result)
+ return result;
result = adapter_alloc_sq(dev, qid, nvmeq);
if (result < 0)
+ return result;
+ else if (result)
goto release_cq;
nvme_init_queue(nvmeq, qid);
+
+ nvmeq->cq_vector = vector;
result = queue_request_irq(nvmeq);
if (result < 0)
goto release_sq;
@@ -1506,12 +1511,11 @@ static int nvme_create_queue(struct nvme_queue *nvmeq, int qid)
return result;
release_sq:
+ nvmeq->cq_vector = -1;
dev->online_queues--;
adapter_delete_sq(dev, qid);
release_cq:
adapter_delete_cq(dev, qid);
- release_vector:
- nvmeq->cq_vector = -1;
return result;
}
--
2.14.3
next prev parent reply other threads:[~2018-05-24 20:34 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-24 20:34 [PATCHv3 0/9] nvme timeout fixes, v3 Keith Busch
2018-05-24 20:34 ` [PATCHv3 1/9] nvme: Sync request queues on reset Keith Busch
2018-05-25 12:42 ` Christoph Hellwig
2018-05-25 14:22 ` Keith Busch
2018-05-25 14:32 ` Christoph Hellwig
2018-05-25 14:45 ` Keith Busch
2018-05-25 15:56 ` James Smart
2018-05-25 16:24 ` Keith Busch
2018-05-25 18:04 ` James Smart
2018-05-25 18:30 ` Keith Busch
2018-05-30 23:25 ` Sagi Grimberg
2018-06-05 16:25 ` Keith Busch
2018-05-30 23:24 ` Sagi Grimberg
2018-05-24 20:34 ` [PATCHv3 2/9] nvme-pci: Fix queue freeze criteria " Keith Busch
2018-05-25 12:43 ` Christoph Hellwig
2018-05-30 23:36 ` Sagi Grimberg
2018-05-24 20:34 ` [PATCHv3 3/9] nvme: Move all IO out of controller reset Keith Busch
2018-05-25 13:00 ` Christoph Hellwig
2018-05-25 14:41 ` Keith Busch
2018-05-24 20:34 ` [PATCHv3 4/9] nvme-pci: Rate limit the nvme timeout warnings Keith Busch
2018-05-25 13:01 ` Christoph Hellwig
2018-05-30 6:06 ` Christoph Hellwig
2018-05-24 20:34 ` [PATCHv3 5/9] nvme-pci: End IO requests in CONNECTING state Keith Busch
2018-05-24 20:47 ` Christoph Hellwig
2018-05-24 21:03 ` Keith Busch
2018-05-25 12:31 ` Christoph Hellwig
2018-05-24 20:34 ` [PATCHv3 6/9] nvme-pci: Unquiesce dead controller queues Keith Busch
2018-05-25 13:03 ` Christoph Hellwig
2018-05-24 20:34 ` [PATCHv3 7/9] nvme-pci: Attempt reset retry for IO failures Keith Busch
2018-05-25 13:04 ` Christoph Hellwig
2018-05-25 14:25 ` Keith Busch
2018-05-30 23:40 ` Sagi Grimberg
2018-06-04 22:46 ` Keith Busch
2018-05-24 20:34 ` Keith Busch [this message]
2018-05-25 12:35 ` [PATCHv3 8/9] nvme-pci: Queue creation error handling Christoph Hellwig
2018-06-05 16:28 ` Keith Busch
2018-05-30 23:37 ` Sagi Grimberg
2018-05-24 20:35 ` [PATCHv3 9/9] nvme-pci: Don't wait for HMB completion on shutdown Keith Busch
2018-05-24 20:45 ` Christoph Hellwig
2018-05-24 21:15 ` Keith Busch
2018-05-25 3:10 ` jianchao.wang
2018-05-25 15:09 ` Keith Busch
2018-05-25 12:36 ` Christoph Hellwig
2018-07-13 0:48 ` [PATCHv3 0/9] nvme timeout fixes, v3 Ming Lei
2018-07-13 20:54 ` Keith Busch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180524203500.14081-9-keith.busch@intel.com \
--to=keith.busch@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).