Skip to content

Commit 0f0d2c8

Browse files
minwooimChristoph Hellwig
authored andcommitted
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: Minwoo Im <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 9f16a66 commit 0f0d2c8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

drivers/nvme/host/pci.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,21 @@ static void nvme_dbbuf_init(struct nvme_dev *dev,
292292
nvmeq->dbbuf_cq_ei = &dev->dbbuf_eis[cq_idx(qid, dev->db_stride)];
293293
}
294294

295+
static void nvme_dbbuf_free(struct nvme_queue *nvmeq)
296+
{
297+
if (!nvmeq->qid)
298+
return;
299+
300+
nvmeq->dbbuf_sq_db = NULL;
301+
nvmeq->dbbuf_cq_db = NULL;
302+
nvmeq->dbbuf_sq_ei = NULL;
303+
nvmeq->dbbuf_cq_ei = NULL;
304+
}
305+
295306
static void nvme_dbbuf_set(struct nvme_dev *dev)
296307
{
297308
struct nvme_command c;
309+
unsigned int i;
298310

299311
if (!dev->dbbuf_dbs)
300312
return;
@@ -308,6 +320,9 @@ static void nvme_dbbuf_set(struct nvme_dev *dev)
308320
dev_warn(dev->ctrl.device, "unable to set dbbuf\n");
309321
/* Free memory and continue on */
310322
nvme_dbbuf_dma_free(dev);
323+
324+
for (i = 1; i <= dev->online_queues; i++)
325+
nvme_dbbuf_free(&dev->queues[i]);
311326
}
312327
}
313328

0 commit comments

Comments
 (0)