All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme-pci: simplify __nvme_submit_cmd
@ 2018-05-26 11:45 Christoph Hellwig
  2018-05-26 12:54 ` Jens Axboe
  2018-05-28 13:12 ` Max Gurtovoy
  0 siblings, 2 replies; 3+ messages in thread
From: Christoph Hellwig @ 2018-05-26 11:45 UTC (permalink / raw)


With recent CQ handling improvements we can now move the locking into
__nvme_submit_cmd.  Also remove the local tail variable to make the code
more obvious, remove the __ prefix in the name, and fix the comments
describing the function.

Signed-off-by: Christoph Hellwig <hch at lst.de>
---
 drivers/nvme/host/pci.c | 37 ++++++++++++++-----------------------
 1 file changed, 14 insertions(+), 23 deletions(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 79b48052ea11..3fe41b2594a1 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -421,28 +421,25 @@ static int nvme_pci_map_queues(struct blk_mq_tag_set *set)
 }
 
 /**
- * __nvme_submit_cmd() - Copy a command into a queue and ring the doorbell
+ * nvme_submit_cmd() - Copy a command into a queue and ring the doorbell
  * @nvmeq: The queue to use
  * @cmd: The command to send
- *
- * Safe to use from interrupt context
  */
-static void __nvme_submit_cmd(struct nvme_queue *nvmeq,
-						struct nvme_command *cmd)
+static void nvme_submit_cmd(struct nvme_queue *nvmeq, struct nvme_command *cmd)
 {
-	u16 tail = nvmeq->sq_tail;
-
+	spin_lock(&nvmeq->sq_lock);
 	if (nvmeq->sq_cmds_io)
-		memcpy_toio(&nvmeq->sq_cmds_io[tail], cmd, sizeof(*cmd));
+		memcpy_toio(&nvmeq->sq_cmds_io[nvmeq->sq_tail], cmd,
+				sizeof(*cmd));
 	else
-		memcpy(&nvmeq->sq_cmds[tail], cmd, sizeof(*cmd));
+		memcpy(&nvmeq->sq_cmds[nvmeq->sq_tail], cmd, sizeof(*cmd));
 
-	if (++tail == nvmeq->q_depth)
-		tail = 0;
-	if (nvme_dbbuf_update_and_check_event(tail, nvmeq->dbbuf_sq_db,
-					      nvmeq->dbbuf_sq_ei))
-		writel(tail, nvmeq->q_db);
-	nvmeq->sq_tail = tail;
+	if (++nvmeq->sq_tail == nvmeq->q_depth)
+		nvmeq->sq_tail = 0;
+	if (nvme_dbbuf_update_and_check_event(nvmeq->sq_tail,
+			nvmeq->dbbuf_sq_db, nvmeq->dbbuf_sq_ei))
+		writel(nvmeq->sq_tail, nvmeq->q_db);
+	spin_unlock(&nvmeq->sq_lock);
 }
 
 static void **nvme_pci_iod_list(struct request *req)
@@ -895,10 +892,7 @@ static blk_status_t nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
 	}
 
 	blk_mq_start_request(req);
-
-	spin_lock(&nvmeq->sq_lock);
-	__nvme_submit_cmd(nvmeq, &cmnd);
-	spin_unlock(&nvmeq->sq_lock);
+	nvme_submit_cmd(nvmeq, &cmnd);
 	return BLK_STS_OK;
 out_cleanup_iod:
 	nvme_free_iod(dev, req);
@@ -1058,10 +1052,7 @@ static void nvme_pci_submit_async_event(struct nvme_ctrl *ctrl)
 	memset(&c, 0, sizeof(c));
 	c.common.opcode = nvme_admin_async_event;
 	c.common.command_id = NVME_AQ_BLK_MQ_DEPTH;
-
-	spin_lock(&nvmeq->sq_lock);
-	__nvme_submit_cmd(nvmeq, &c);
-	spin_unlock(&nvmeq->sq_lock);
+	nvme_submit_cmd(nvmeq, &c);
 }
 
 static int adapter_delete_queue(struct nvme_dev *dev, u8 opcode, u16 id)
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] nvme-pci: simplify __nvme_submit_cmd
  2018-05-26 11:45 [PATCH] nvme-pci: simplify __nvme_submit_cmd Christoph Hellwig
@ 2018-05-26 12:54 ` Jens Axboe
  2018-05-28 13:12 ` Max Gurtovoy
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2018-05-26 12:54 UTC (permalink / raw)


On 5/26/18 5:45 AM, Christoph Hellwig wrote:
> With recent CQ handling improvements we can now move the locking into
> __nvme_submit_cmd.  Also remove the local tail variable to make the code
> more obvious, remove the __ prefix in the name, and fix the comments
> describing the function.

Looks good to me.

Reviewed-by: Jens Axboe <axboe at kernel.dk>

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] nvme-pci: simplify __nvme_submit_cmd
  2018-05-26 11:45 [PATCH] nvme-pci: simplify __nvme_submit_cmd Christoph Hellwig
  2018-05-26 12:54 ` Jens Axboe
@ 2018-05-28 13:12 ` Max Gurtovoy
  1 sibling, 0 replies; 3+ messages in thread
From: Max Gurtovoy @ 2018-05-28 13:12 UTC (permalink / raw)




On 5/26/2018 2:45 PM, Christoph Hellwig wrote:
> With recent CQ handling improvements we can now move the locking into
> __nvme_submit_cmd.  Also remove the local tail variable to make the code
> more obvious, remove the __ prefix in the name, and fix the comments
> describing the function.
> 
> Signed-off-by: Christoph Hellwig <hch at lst.de>
> ---
>   drivers/nvme/host/pci.c | 37 ++++++++++++++-----------------------
>   1 file changed, 14 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> index 79b48052ea11..3fe41b2594a1 100644
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c

Looks good,

Reviewed-by: Max Gurtovoy <maxg at mellanox.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-28 13:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-26 11:45 [PATCH] nvme-pci: simplify __nvme_submit_cmd Christoph Hellwig
2018-05-26 12:54 ` Jens Axboe
2018-05-28 13:12 ` Max Gurtovoy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.