From: Keith Busch <keith.busch@intel.com>
To: Matias Bjorling <m@bjorling.me>
Cc: willy@linux.intel.com, linux-kernel@vger.kernel.org,
linux-nvme@lists.infradead.org
Subject: Re: [PATCH 1/2] NVMe: Refactor doorbell
Date: Fri, 11 Oct 2013 09:39:42 -0600 (MDT) [thread overview]
Message-ID: <alpine.LRH.2.03.1310110823320.4763@AMR> (raw)
In-Reply-To: <1381481333-23888-2-git-send-email-m@bjorling.me>
On Fri, 11 Oct 2013, Matias Bjorling wrote:
> The doorbell code is repeated various places. Refactor it into its own function
> for clarity.
>
> Signed-off-by: Matias Bjorling <m@bjorling.me>
Looks good to me.
Reviewed-by: Keith Busch <keith.busch@intel.com>
> ---
> drivers/block/nvme-core.c | 29 +++++++++++++----------------
> 1 file changed, 13 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
> index da52092..40998d5 100644
> --- a/drivers/block/nvme-core.c
> +++ b/drivers/block/nvme-core.c
> @@ -242,6 +242,13 @@ void put_nvmeq(struct nvme_queue *nvmeq)
> put_cpu();
> }
>
> +static inline void nvme_ring_doorbell(struct nvme_queue *nvmeq)
> +{
> + if (++nvmeq->sq_tail == nvmeq->q_depth)
> + nvmeq->sq_tail = 0;
> + writel(nvmeq->sq_tail, nvmeq->q_db);
> +}
> +
> /**
> * nvme_submit_cmd() - Copy a command into a queue and ring the doorbell
> * @nvmeq: The queue to use
> @@ -252,14 +259,10 @@ void put_nvmeq(struct nvme_queue *nvmeq)
> static int nvme_submit_cmd(struct nvme_queue *nvmeq, struct nvme_command *cmd)
> {
> unsigned long flags;
> - u16 tail;
> +
> spin_lock_irqsave(&nvmeq->q_lock, flags);
> - tail = nvmeq->sq_tail;
> - memcpy(&nvmeq->sq_cmds[tail], cmd, sizeof(*cmd));
> - if (++tail == nvmeq->q_depth)
> - tail = 0;
> - writel(tail, nvmeq->q_db);
> - nvmeq->sq_tail = tail;
> + memcpy(&nvmeq->sq_cmds[nvmeq->sq_tail], cmd, sizeof(*cmd));
> + nvme_ring_doorbell(nvmeq);
> spin_unlock_irqrestore(&nvmeq->q_lock, flags);
>
> return 0;
> @@ -619,9 +622,7 @@ static int nvme_submit_discard(struct nvme_queue *nvmeq, struct nvme_ns *ns,
> cmnd->dsm.nr = 0;
> cmnd->dsm.attributes = cpu_to_le32(NVME_DSMGMT_AD);
>
> - if (++nvmeq->sq_tail == nvmeq->q_depth)
> - nvmeq->sq_tail = 0;
> - writel(nvmeq->sq_tail, nvmeq->q_db);
> + nvme_ring_doorbell(nvmeq);
>
> return 0;
> }
> @@ -636,9 +637,7 @@ static int nvme_submit_flush(struct nvme_queue *nvmeq, struct nvme_ns *ns,
> cmnd->common.command_id = cmdid;
> cmnd->common.nsid = cpu_to_le32(ns->ns_id);
>
> - if (++nvmeq->sq_tail == nvmeq->q_depth)
> - nvmeq->sq_tail = 0;
> - writel(nvmeq->sq_tail, nvmeq->q_db);
> + nvme_ring_doorbell(nvmeq);
>
> return 0;
> }
> @@ -729,9 +728,7 @@ static int nvme_submit_bio_queue(struct nvme_queue *nvmeq, struct nvme_ns *ns,
> cmnd->rw.dsmgmt = cpu_to_le32(dsmgmt);
>
> nvme_start_io_acct(bio);
> - if (++nvmeq->sq_tail == nvmeq->q_depth)
> - nvmeq->sq_tail = 0;
> - writel(nvmeq->sq_tail, nvmeq->q_db);
> + nvme_ring_doorbell(nvmeq);
>
> return 0;
>
> --
> 1.8.1.2
>
>
> _______________________________________________
> Linux-nvme mailing list
> Linux-nvme@lists.infradead.org
> http://merlin.infradead.org/mailman/listinfo/linux-nvme
>
next prev parent reply other threads:[~2013-10-11 15:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-11 8:48 [PATCH 0/2] NVMe: Refactoring v2 Matias Bjorling
2013-10-11 8:48 ` [PATCH 1/2] NVMe: Refactor doorbell Matias Bjorling
2013-10-11 15:39 ` Keith Busch [this message]
2013-10-11 8:48 ` [PATCH 2/2] NVMe: Extract admin queue size Matias Bjorling
-- strict thread matches above, loose matches on Subject: below --
2013-10-10 18:29 [PATCH 0/2] NVMe: Refactoring Matias Bjorling
2013-10-10 18:29 ` [PATCH 1/2] NVMe: Refactor doorbell Matias Bjorling
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LRH.2.03.1310110823320.4763@AMR \
--to=keith.busch@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=m@bjorling.me \
--cc=willy@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox