Commit 0f0d2c87 authored by Minwoo Im's avatar Minwoo Im Committed by Christoph Hellwig

nvme: free sq/cq dbbuf pointers when dbbuf set fails

If Doorbell Buffer Config command fails even 'dev->dbbuf_dbs != NULL'
which means OACS indicates that NVME_CTRL_OACS_DBBUF_SUPP is set,
nvme_dbbuf_update_and_check_event() will check event even it's not been
successfully set.

This patch fixes mismatch among dbbuf for sq/cqs in case that dbbuf
command fails.
Signed-off-by: default avatarMinwoo Im <minwoo.im.dev@gmail.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 9f16a667
...@@ -292,9 +292,21 @@ static void nvme_dbbuf_init(struct nvme_dev *dev, ...@@ -292,9 +292,21 @@ static void nvme_dbbuf_init(struct nvme_dev *dev,
nvmeq->dbbuf_cq_ei = &dev->dbbuf_eis[cq_idx(qid, dev->db_stride)]; nvmeq->dbbuf_cq_ei = &dev->dbbuf_eis[cq_idx(qid, dev->db_stride)];
} }
static void nvme_dbbuf_free(struct nvme_queue *nvmeq)
{
if (!nvmeq->qid)
return;
nvmeq->dbbuf_sq_db = NULL;
nvmeq->dbbuf_cq_db = NULL;
nvmeq->dbbuf_sq_ei = NULL;
nvmeq->dbbuf_cq_ei = NULL;
}
static void nvme_dbbuf_set(struct nvme_dev *dev) static void nvme_dbbuf_set(struct nvme_dev *dev)
{ {
struct nvme_command c; struct nvme_command c;
unsigned int i;
if (!dev->dbbuf_dbs) if (!dev->dbbuf_dbs)
return; return;
...@@ -308,6 +320,9 @@ static void nvme_dbbuf_set(struct nvme_dev *dev) ...@@ -308,6 +320,9 @@ static void nvme_dbbuf_set(struct nvme_dev *dev)
dev_warn(dev->ctrl.device, "unable to set dbbuf\n"); dev_warn(dev->ctrl.device, "unable to set dbbuf\n");
/* Free memory and continue on */ /* Free memory and continue on */
nvme_dbbuf_dma_free(dev); nvme_dbbuf_dma_free(dev);
for (i = 1; i <= dev->online_queues; i++)
nvme_dbbuf_free(&dev->queues[i]);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment