Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 36a7e993 authored by Jon Derrick's avatar Jon Derrick Committed by Jens Axboe
Browse files

NVMe: Memory barrier before queue_count is incremented



Protects against reordering and/or preempting which would allow the
kthread to access the queue descriptor before it is set up

Signed-off-by: default avatarJon Derrick <jonathan.derrick@intel.com>
Acked-by: default avatarKeith Busch <keith.busch@intel.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 4cc06521
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -1453,9 +1453,12 @@ static struct nvme_queue *nvme_alloc_queue(struct nvme_dev *dev, int qid,
	nvmeq->q_db = &dev->dbs[qid * 2 * dev->db_stride];
	nvmeq->q_depth = depth;
	nvmeq->qid = qid;
	dev->queue_count++;
	dev->queues[qid] = nvmeq;

	/* make sure queue descriptor is set before queue count, for kthread */
	mb();
	dev->queue_count++;

	return nvmeq;

 free_cqdma: