From: Jon Derrick Date: Wed, 27 May 2015 18:26:23 +0000 (-0600) Subject: NVMe: Memory barrier before queue_count is incremented X-Git-Tag: v4.14-rc1~5190^2~17 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=36a7e993eedb2c3f11de3b686b351f75e1edbbb5;p=platform%2Fkernel%2Flinux-rpi.git 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: Jon Derrick Acked-by: Keith Busch Signed-off-by: Jens Axboe --- diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c index 9682e29..cae7cac 100644 --- a/drivers/block/nvme-core.c +++ b/drivers/block/nvme-core.c @@ -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: